[Python] 纯文本查看 复制代码
import tkinter as tk
import tkinter.messagebox #用于弹框
import requests
import re
import pyperclip #用于复制
headers={'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0'}
def get_seasons_episodes_addresses(idnum):
global addresses
global season_episode
global seasons_episodes
s_ename=value_3[-4:-1]
r_sources=requests.get('http://pc.zmzapi.com/index.php?g=api/pv3&m=index&client=5&accesskey=519f9cab85c8059d17544947k361a827&a=resource&id='+str(idnum)+'&uid=undefined&token=undefined',headers=headers)
addresses=re.findall(r'ss":"([^"]+)',r_sources.text)
r_seasons_episodes_raw=re.compile(r'(%s).([^.]+)' %s_ename ) #正则表达式加入变量
seasons_episodes_raw=r_seasons_episodes_raw.findall(r_sources.text)
season_episode=[] #储存季集 数字 例如1023
seasons_episodes=[] #储存季集 例如s10e23
seasons=[] #储存季
episodes=[] #储存集
for i in range(len(seasons_episodes_raw)-4): #遍历列表 季和集 例如 s10s24
if ''.join(seasons_episodes_raw[i][1])[1:3].isdigit():
seasons_episodes.append(seasons_episodes_raw[i][1])
if len(seasons_episodes)>4:
ufirst_element=re.findall(r'\d+',seasons_episodes[-1])
usecond_element=re.findall(r'\d+',seasons_episodes[-2])
season_episode.append(''.join(ufirst_element))
if ufirst_element!=usecond_element: #由于每集都多三个 所以我们选择去掉最后三个
del seasons_episodes[-2]
del seasons_episodes[-3]
del seasons_episodes[-4]
season_episode=list(set(season_episode))
season_episode.sort(reverse=True)
for i in season_episode:
if len(i)==4 or len(i)==6:
seasons.append(i[0:2])
episodes.append(i[2:4])
else:
season_episode.remove(i)
seasons=list(set(seasons))
seasons.sort(reverse=True)
return seasons,episodes,addresses
def print_selection_1():
s_episodes=[]
global lb_2
global value_1
try:
value_1 = lb_1.get(lb_1.curselection()) # 获取当前选中的文本
except:
tkinter.messagebox.showinfo('提示','请先选择“季”!')
else:
season=''.join(re.findall(r'\d+',value_1))
for i in season_episode:
if season ==i[0:2]:
s_episodes.append(i[2:])
lb_2 = tk.Listbox(window,width=13,height=len(s_episodes))
lb_2.place(x=200,y=300)
for k in s_episodes:
lb_2.insert('end', '第'+str(k)+'集')# 从最后一个位置开始加入值
var_1.set(value_1) # 为labe_1设置值
def print_selection_2():
s_season_episode=[]
global lb_3
try:
value_2 = lb_2.get(lb_2.curselection()) # 获取当前选中的文本
except:
tkinter.messagebox.showinfo('提示','请先选择“集”!')
else:
episode=''.join(re.findall(r'\d+',value_1))+''.join(re.findall(r'\d+',value_2))
lb_3 = tk.Listbox(window,width=50,height=10)
lb_3.place(x=400,y=300)
for n in range(len(seasons_episodes)-1):
if episode==''.join(re.findall(r'\d+',seasons_episodes[n])):
s_season_episode.append(addresses[n])
for m in s_season_episode:
m=m.replace('\/', '/')
lb_3.insert('end', str(m))
var_2.set(value_2) # 为labe_2设置值
def print_selection_3():
try:
value_3 = lb_3.get(lb_3.curselection()) # 获取当前选中的文本
except:
tkinter.messagebox.showinfo('提示','请先选择一个地址再点复制哦!')
else:
pyperclip.copy(value_3)
tkinter.messagebox.showinfo('提示','复制成功!')
def print_selection_4():
global var_cname
global seasons
global episodes
global lb_4
global idnums
global cnames
global cname
global enames
global ename
var_cname=entry_explore.get()
if var_cname=='':
tkinter.messagebox.showinfo('提示','不能搜索空东西哦!')
else:
r_id=requests.get('http://pc.zmzapi.com/index.php?g=api/pv3&m=index&client=5&accesskey=519f9cab85c8059d17544947k361a827&a=search&uid=&token=&page=1&limit=30&k='+var_cname,headers=headers)
idnums=re.findall(r'id":"([^"]+)',r_id.text)
cnames=re.findall(r'cnname":"([^"]+)',r_id.text)
enames=re.findall(r'enname":"([^"]+)',r_id.text)
lb_4 = tk.Listbox(window,width=40, height=6)
if len(idnums)!=1:
for cname in cnames:
ename= enames[cnames.index(cname)]
lb_4.insert('end',str(eval("u'"+cname+"'"))+' ('+ename+')')
else:
cname=cnames[0]
ename=enames[0]
lb_4.insert('end',str(eval("u'"+cname+"'"))+' ('+ename+')')
lb_4.place(x=100,y=140)
def print_selection_5():
global value_3
global lb_1
global lb_3
global idnum
try:
value_3 = lb_4.get(lb_4.curselection())
except:
tkinter.messagebox.showinfo('提示','请先选择一个哦!')
else:
var_3.set(value_3)
for i in idnums:
#print(i)
k=idnums.index(i)
if str(eval("u'"+cnames[k]+"'"))+' ('+enames[k]+')'== value_3:
idnum=i
seasons,episodes,addresses=get_seasons_episodes_addresses(idnum)
if len(seasons)!=0:
lb_1 = tk.Listbox(window,width=13,height=len(seasons))
for item in seasons:
lb_1.insert('end', '第'+str(item)+'季')
lb_1.place(x=10,y=300)
else:
r_moves=requests.get('http://pc.zmzapi.com/index.php?g=api/pv3&m=index&client=5&accesskey=519f9cab85c8059d17544947k361a827&a=resource&id='+idnum+'&uid=undefined&token=undefined',headers=headers)
addresses_moves=re.findall(r'ss":"([^"]+)',r_moves.text)
lb_3 = tk.Listbox(window,width=50,height=10)
#lb_3.grid(column=5,row=3)
lb_3.place(x=400,y=300)
for i in addresses_moves:
i=i.replace('\/', '/')
lb_3.insert('end', str(i))
tkinter.messagebox.showinfo('提示','您选择的资源可能没有!如果有,地址已经显示在下方!')
if __name__=="__main__":
window = tk.Tk()
window.title('人人影视资源链接解析')
window.geometry('800x760')
var_1 = tk.StringVar() # 创建变量,用var1用来接收鼠标点击具体选项的内容
var_2 = tk.StringVar()
var_3=tk.StringVar()
var_name = tk.StringVar()
var_name.set('老友记')
entry_explore = tk.Entry(window,textvariable=var_name,font=('Arial', 12),width=16)
entry_explore.place(x=150,y=110)
bu_4= tk.Button(window, text='搜索',font=('Arial',12), width=8,height=1,command=print_selection_4)
bu_4.place(x=310,y=107) #定位
bu_5= tk.Button(window, text='确定',font=('Arial',12), width=8,height=1,command=print_selection_5)
bu_5.place(x=700,y=107) #定位
l_3 = tk.Label(window, text='请在此处搜索:',bg='green', fg='white',font=('Arial', 12), width=14, height=1)
l_3.place(x=10,y=110)
l_5 = tk.Label(window, text='''
使用方法:在搜索框输入你想搜索的资源名字,下方会出现搜索到的结果,选择一个,然后点击确定。如果为
电视剧,则会出现相应的季和集(由于api内资源混乱和本人技术有限可能出现错位现象,例如生活大爆炸等。
如果是电影,资源地址则会出现在下方。如果是空白那就代表还没有资源,比如变形金刚5。''',bg='green', fg='white',font=('Arial', 12), width=89, height=5)
l_5.place(x=0,y=0)
l_6 = tk.Label(window, text='''
资源说明:ed2k-->电驴(也可以用迅雷下载)
禁止使用网挣网盘,禁止使用网挣网盘-->诚通网盘
miwifi.com-->小米路由
http://url.cn/-->微云
百度网盘,微云和搜狐视频的大多失效....''',bg='green', fg='white',font=('Arial', 12), width=43, height=6)
l_6.place(x=400,y=140)
l_1 = tk.Label(window, textvariable=var_1, bg='green', fg='white', font=('Arial', 12), width=10, height=1)
#l_1.grid(column=1,row=2)
l_1.place(x=10,y=270)
l_2 = tk.Label(window, textvariable=var_2, bg='green', fg='white', font=('Arial', 12), width=10, height=1)
#l_2.grid(column=3,row=2)
l_2.place(x=200,y=270)
l_4 = tk.Label(window, textvariable=var_3, bg='green', fg='white', font=('Arial', 12), width=30, height=1)
l_4.place(x=400,y=110)
bu_1= tk.Button(window, text='选择季', font=('Arial', 12), width=8,height=1,command=print_selection_1)
#bu_1.grid(column=2,row=2) #第n列 第m行
bu_1.place(x=110,y=268) #定位
bu_2= tk.Button(window, text='选择集', font=('Arial', 12), width=8,height=1,command=print_selection_2)
#bu_2.grid(column=4,row=2) #第n列 第m行
bu_2.place(x=300,y=268)
bu_3= tk.Button(window, text='复制该地址', font=('Arial', 12), width=10,height=1,command=print_selection_3)
bu_3.place(x=600,y=268)#定位
window.mainloop()