吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 13972|回复: 19
收起左侧

[Python 原创] [python]tk做人人影视资源搜集

  [复制链接]
liuhu1210 发表于 2019-8-6 14:53
本帖最后由 wushaominkk 于 2019-8-7 08:30 编辑

之前发错地方了,违规被删除了....
我想再试试,如果违规请管理及时删除。谢谢!
我分享出来是想和大家一起学习,一起讨论,没有其他任何目的!
暑假闲来无事,看美剧,突然有个想法,嘿嘿!
先用fiddler 对PC端rrsy抓包 得到了内置api
搜索:http://pc.zmzapi.com/index.php?g=api/pv3&m=index&client=5&accesskey=519f9cab85c8059d17544947k361a827&a=search&uid=&token=&page=1&limit=30&k+要搜索的名字
选择:http://pc.zmzapi.com/index.php?g=api/pv3&m=index&client=5&accesskey=519f9cab85c8059d17544947k361a827&a=resource&id=+搜索得到的结果中的你选择的资源的对应的id+&uid=undefined&token=undefined
然后用了最笨的办法,因为我本来懂得就不多.....
经过几天的奋战....
掉了好多头发......
最终.....

想要下载的  下方有源码下载链接
本人比较笨所以没有用什么简洁的方式和算法 如果有什么不足请说出来 互相学习
当然也有好多bug  不过我实在是改不了了 希望大家一起努力 一起学习


[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()


源码:[url=]rrys.rar[/url]
TIM截图20190806143702.jpg

rrys.rar

2.98 KB, 下载次数: 153, 下载积分: 吾爱币 -1 CB

免费评分

参与人数 3吾爱币 +5 热心值 +2 收起 理由
小六先生 + 1 + 1 <font style="vertical-align: inherit;"><font style=
苏紫方璇 + 3 + 1 欢迎分析讨论交流,吾爱破解论坛有你更精彩!
zjf6311 + 1 热心回复!

查看全部评分

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

 楼主| liuhu1210 发表于 2019-8-6 15:34
Huauan 发表于 2019-8-6 15:33
单单人人的资源而已吗?不能搜一个资源全网搜索资源吗

好 等我没事了研究一下 谢谢你的建议
bluerabbit 发表于 2019-8-10 16:07
谢谢分享,这几天正在学tkinter,研究了一下楼主的程序,个人觉得有些地方可以改进,于是自己也写了一个 (https://www.52pojie.cn/thread-1006124-1-1.html),其中解析用了json而非re,因为这个api返回的response.text其实是一个json字符串。一起学习,一起提高
saomu007 发表于 2019-8-6 15:01
1847123212 发表于 2019-8-6 15:07
这个和直接去网页搜索的区别是?看起来方便一点?
liujieaipojie 发表于 2019-8-6 15:09
1847123212 发表于 2019-8-6 15:07
这个和直接去网页搜索的区别是?看起来方便一点?

差不多就是这样,省去了你打开浏览器这一步
 楼主| liuhu1210 发表于 2019-8-6 15:25
1847123212 发表于 2019-8-6 15:07
这个和直接去网页搜索的区别是?看起来方便一点?

主要是学习进步    还不是很方便呢
Huauan 发表于 2019-8-6 15:33
单单人人的资源而已吗?不能搜一个资源全网搜索资源吗
阳光JARAY 发表于 2019-8-7 09:52
持续关注楼主的分享
whjp 发表于 2019-8-7 23:05
感谢分享
aa2727 发表于 2019-8-8 07:44
很好,感谢无私分享。
心情不好,研究一下。
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-4-28 04:12

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表