最新公告
  • 欢迎您光临小酒资源吧,本站秉承服务宗旨 履行“站长”责任,销售只是起点 服务永无止境!立即加入我们
  • [Python] tk & json 做的GUI 人人影视下载资源解析

    [Python] tk & json 做的GUI 人人影视下载资源解析 最后编辑:2020-09-10
    增值服务: 自动发货 使用说明 安装指导 环境配置二次开发BUG修复

    这几天在学tkinter,看到论坛里的这个帖子 https://www.52pojie.cn/thread-1003791-1-1.html,学习了一下觉得有可以改进的地方,于是自己动手写了一个,其中的api还是借鉴原帖
    好了,不多说了,直接上code,大家发现有什么不足请指出来,一起提高

    11.19 : 今天翻出刚学 tkinter 时写的这个程序,觉得好幼稚,于是重新改写了一遍。

    [Python] 纯文本查看 复制代码#!/usr/bin/env python3
    # -*- coding: utf-8 -*-

    \’人人影视下载资源解析\’

    from tkinter import *
    import tkinter.messagebox as messagebox
    import requests
    import json
    import pyperclip

    class YYets:

    def __init__(self, master):
    self.master = master
    self.headers = {\’User-Agent\’: \’Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:60.0) Gecko/20100101 Firefox/60.0\’}
    self.api_search = \’http://pc.zmzapi.com/index.php?g=api/pv3&m=index&client=5&accesskey=519f9cab85c8059d17544947k361a827&a=search&uid=&token=&page=1&limit=30&k=\’
    self.api_get = \’http://pc.zmzapi.com/index.php?g=api/pv3&m=index&client=5&accesskey=519f9cab85c8059d17544947k361a827&a=resource&uid=undefined&token=undefined&id=\’
    self.listboxes = {}
    self.initWidgets()

    def initWidgets(self):
    #影剧搜索框、影剧搜索结果提示
    frame = Frame(self.master)
    frame.pack(expand=True, fill=BOTH, padx=10, pady=10, side=TOP)
    self.entry = Entry(frame, width=30, font=(\’simkai\’, 12), foreground=\’red\’)
    self.entry.pack(expand=True, fill=X, padx=0, pady=0, side=LEFT)
    self.entry.bind(\'<Return>\’, self.searchDrama)
    self.entry.insert(0, \’关键词\’)
    self.entry.selection_range(0, END)
    self.entry.focus_set()
    self.sr = StringVar()
    Label(frame, textvariable=self.sr, background=\’green\’, foreground=\’white\’, font=(\’simkai\’, 12), width=16, justify=CENTER).pack(expand=True, fill=X, padx=30, pady=0, side=LEFT)
    #影剧搜索详细结果
    frame = Frame(self.master)
    frame.pack(expand=True, fill=BOTH, padx=10, pady=0, side=TOP)
    self.srlist = StringVar()
    listbox = Listbox(frame, listvariable=self.srlist, background=\’lightgreen\’, font=(\’simkai\’, 12), exportselection=False)
    listbox.pack(expand=True, fill=BOTH, padx=0, pady=0, side=LEFT)
    listbox.bind(\'<Double-Button-1>\’, self.chooseDrama)
    listbox.bind(\'<Return>\’, self.chooseDrama)
    scrollbar = Scrollbar(frame)
    scrollbar.pack(fill=Y, padx=0, pady=0, side=RIGHT)
    listbox.config(yscrollcommand=scrollbar.set)
    scrollbar.config(command=listbox.yview)
    self.listboxes[\’drama\’] = listbox
    #影剧季集title
    self.videotitle = StringVar()
    Label(self.master, textvariable=self.videotitle, background=\’green\’, foreground=\’white\’, font=(\’simkai\’, 12), justify=CENTER).pack(expand=True, fill=X, padx=10, pady=10, side=TOP)
    #季、集、资源选择
    topframe = Frame(self.master)
    topframe.pack(expand=True, fill=BOTH, padx=10, pady=0, side=TOP)
    #季
    frame = Frame(topframe)
    frame.pack(expand=True, fill=BOTH, padx=0, pady=0, side=LEFT)
    self.seasonlist = StringVar()
    listbox = Listbox(frame, listvariable=self.seasonlist, background=\’lightgreen\’, font=(\’simkai\’, 10), width=10, exportselection=False)
    listbox.pack(expand=True, fill=BOTH, padx=0, pady=0, side=LEFT)
    listbox.bind(\'<Double-Button-1>\’, self.chooseSeason)
    listbox.bind(\'<Return>\’, self.chooseSeason)
    scrollbar = Scrollbar(frame)
    scrollbar.pack(fill=Y, padx=0, pady=0, side=RIGHT)
    listbox.config(yscrollcommand=scrollbar.set)
    scrollbar.config(command=listbox.yview)
    self.listboxes[\’season\’] = listbox
    #集
    frame = Frame(topframe)
    frame.pack(expand=True, fill=BOTH, padx=10, pady=0, side=LEFT)
    self.episodelist = StringVar()
    listbox = Listbox(frame, listvariable=self.episodelist, background=\’lightgreen\’, font=(\’simkai\’, 10), width=10, exportselection=False)
    listbox.pack(expand=True, fill=BOTH, padx=0, pady=0, side=LEFT)
    listbox.bind(\'<Double-Button-1>\’, self.chooseEpisode)
    listbox.bind(\'<Return>\’, self.chooseEpisode)
    scrollbar = Scrollbar(frame)
    scrollbar.pack(fill=Y, padx=0, pady=0, side=RIGHT)
    listbox.config(yscrollcommand=scrollbar.set)
    scrollbar.config(command=listbox.yview)
    self.listboxes[\’episode\’] = listbox
    #资源
    frame = Frame(topframe)
    frame.pack(expand=True, fill=BOTH, padx=0, pady=0, side=LEFT)
    self.srclist = StringVar()
    listbox = Listbox(frame, listvariable=self.srclist, background=\’lightgreen\’, font=(\’simkai\’, 10), width=50, height=14, exportselection=False)
    listbox.bind(\'<Double-Button-1>\’, self.copySrc)
    listbox.bind(\'<Return>\’, self.copySrc)
    scrollbar = Scrollbar(frame)
    scrollbar.pack(fill=Y, padx=0, pady=0, side=RIGHT)
    listbox.config(yscrollcommand=scrollbar.set)
    scrollbar.config(command=listbox.yview)
    scrollbar = Scrollbar(frame, orient=HORIZONTAL)
    scrollbar.pack(fill=X, padx=0, pady=0, side=BOTTOM)
    listbox.config(xscrollcommand=scrollbar.set)
    scrollbar.config(command=listbox.xview)
    listbox.pack(expand=True, fill=BOTH, padx=0, pady=0, side=LEFT)
    self.listboxes[\’src\’] = listbox
    #空白
    frame = Frame(self.master)
    frame.pack(expand=True, fill=BOTH, padx=10, pady=5, side=BOTTOM)

    def searchDrama(self, event):
    if self.entry.get() == \’\’:
    messagebox.showwarning(sys._getframe().f_code.co_name, \’关键词缺失\’)
    else:
    self.sr.set(\’\’)
    self.srlist.set(\’\’)
    self.videotitle.set(\’\’)
    self.seasonlist.set(\’\’)
    self.episodelist.set(\’\’)
    self.srclist.set(\’\’)
    try:
    response = requests.get(self.api_search+self.entry.get(), headers=self.headers)
    if response.status_code != 200:
    response.raise_for_status()
    except Exception as e:
    messagebox.showwarning(\’影视\’, e)
    else:
    result = json.loads(response.text)
    self.ids = list(map(lambda i: result[\’data\’][i][\’id\’], range(len(result[\’data\’]))))
    self.sr.set(\’查询结果:%d项\’ % len(result[\’data\’]))
    self.srlist.set(list(map(lambda i: \’%d.[%s].%s (%s)\’ % (i, result[\’data\’][i][\’channel_cn\’], result[\’data\’][i][\’cnname\’], result[\’data\’][i][\’enname\’]), range(len(result[\’data\’])))))
    #如果列表中只有一项,则自动选中
    if self.listboxes[\’drama\’].size() == 1:
    self.listboxes[\’drama\’].selection_set(0)
    self.chooseDrama()

    def chooseDrama(self, event=\'<Double-Button-1>\’):
    try:
    drama_chosen = self.listboxes[\’drama\’].get(ACTIVE)
    except:
    messagebox.showwarning(sys._getframe().f_code.co_name, \’未选择影剧\’)
    else:
    self.seasonlist.set(\’\’)
    self.episodelist.set(\’\’)
    self.srclist.set(\’\’)
    drama_id = self.ids[int(drama_chosen[:drama_chosen.index(\’.\’)])]
    self.drama = drama_chosen[drama_chosen.index(\’.\’)+1:]
    self.videotitle.set(self.drama)
    try:
    response_drama = requests.get(self.api_get+str(drama_id), headers=self.headers)
    if response_drama.status_code != 200:
    response_drama.raise_for_status()
    except Exception as e:
    messagebox.showwarning(sys._getframe().f_code.co_name, e)
    else:
    self.parseDrama(response_drama)

    def parseDrama(self, response_drama):
    result_drama = json.loads(response_drama.text)
    if result_drama[\’info\’] in [\’暂无资源\’, \’资源关闭\’]:
    messagebox.showwarning(sys._getframe().f_code.co_name, result_drama[\’info\’])
    return
    season_names = []
    episode_names = []
    self.season_episodes = {}
    self.src = {}
    try:
    for list in result_drama[\’data\’][\’list\’]:
    episodes = list[\’episodes\’]
    if episodes:
    #正常情况,episodes是一个列表
    #特殊情况,"episodes": null,则跳过
    season_name = list[\’season_name\’]
    season_names.append(season_name)
    for j in range(len(episodes)):
    episode_name = episodes[j][\’episode_name\’]
    episode_names.append(episode_name)
    self.src[season_name+episode_name] = []
    files = episodes[j][\’files\’]
    for fileformat in files:
    if fileformat == \’yyets\’:
    src_address = files[fileformat][\’name\’]
    self.src[season_name+episode_name].append(src_address)
    else:
    for filesrc in files[fileformat]:
    src_address = filesrc[\’address\’]
    src_passwd = filesrc[\’passwd\’]
    if src_passwd:
    self.src[season_name+episode_name].append(src_address + \’ pw: \’ + src_passwd)
    else:
    self.src[season_name+episode_name].append(src_address)
    self.season_episodes[season_name] = episode_names
    self.seasonlist.set(season_names)
    #如果列表中只有一项,则自动选中
    if self.listboxes[\’season\’].size() == 1:
    self.listboxes[\’season\’].selection_set(0)
    self.chooseSeason()
    except Exception as e:
    messagebox.showwarning(sys._getframe().f_code.co_name, e)

    def chooseSeason(self, event=\'<Double-Button-1>\’):
    try:
    self.season_chosen = self.listboxes[\’season\’].get(ACTIVE)
    except:
    messagebox.showwarning(sys._getframe().f_code.co_name, \’未选择“季”\’)
    else:
    self.episodelist.set(\’\’)
    self.srclist.set(\’\’)
    self.videotitle.set(self.drama + \’.\’ + self.season_chosen)
    self.episodelist.set(self.season_episodes[self.season_chosen])
    #如果列表中只有一项,则自动选中
    if self.listboxes[\’episode\’].size() == 1:
    self.listboxes[\’episode\’].selection_set(0)
    self.chooseEpisode()

    def chooseEpisode(self, event=\'<Double-Button-1>\’):
    try:
    episode_chosen = self.listboxes[\’episode\’].get(ACTIVE)
    except:
    messagebox.showwarning(sys._getframe().f_code.co_name, \’未选择“集”\’)
    else:
    self.srclist.set(\’\’)
    self.videotitle.set(self.drama + \’.\’ + self.season_chosen + \’.\’ + episode_chosen)
    if self.src[self.season_chosen+episode_chosen]:
    self.srclist.set(self.src[self.season_chosen+episode_chosen])
    else:
    self.srclist.set(\’not found\’)

    def copySrc(self, event=\'<Double-Button-1>\’):
    try:
    src_chosen = self.listboxes[\’src\’].get(ACTIVE)
    except:
    messagebox.showwarning(sys._getframe().f_code.co_name, \’未选择资源\’)
    else:
    pyperclip.copy(src_chosen)
    messagebox.showinfo(sys._getframe().f_code.co_name, \’%s\\n\\n已复制至剪贴板\’ % src_chosen)

    if __name__ == \’__main__\’:
    root = Tk()
    root.resizable(width=False, height=False)
    root.title(\’人人影视下载资源解析\’)
    YYets(root)
    root.update_idletasks()
    width, height = (root.winfo_width(), root.winfo_height())
    screenwidth, screenheight = (root.winfo_screenwidth(), root.winfo_screenheight())
    size_loc = \’%dx%d+%d+%d\’ % (width, height, (screenwidth-width)/2, (screenheight-height)/2-30)
    root.geometry(size_loc)
    root.mainloop()

    yyets.jpg

    gui_yyets.rar

    (2.72 KB, 下载次数: 140)

    2019-11-19 13:05 上传

    源码

    猜你在找

    1. 本站所有资源来源于用户上传和网络,因此不包含技术服务请大家谅解!如有侵权请邮件联系客服!603313839@qq.com
    2. 本站不保证所提供下载的资源的准确性、安全性和完整性,资源仅供下载学习之用!如有链接无法下载、失效或广告,请联系客服处理,有奖励!
    3. 您必须在下载后的24个小时之内,从您的电脑中彻底删除上述内容资源!如用于商业或者非法用途,与本站无关,一切后果请用户自负!
    4. 如果您也有好的资源或教程,您可以投稿发布,成功分享后有站币奖励和额外收入!

    小酒资源吧 » [Python] tk & json 做的GUI 人人影视下载资源解析

    常见问题FAQ

    免费下载或者VIP会员专享资源能否直接商用?
    本站所有资源版权均属于原作者所有,这里所提供资源均只能用于参考学习用,请勿直接商用。若由于商用引起版权纠纷,一切责任均由使用者承担。更多说明请参考 VIP介绍。
    提示下载完但解压或打开不了?
    最常见的情况是下载不完整: 可对比下载完压缩包的与网盘上的容量,若小于网盘提示的容量则是这个原因。这是浏览器下载的bug,建议用百度网盘软件或迅雷下载。若排除这种情况,可在对应资源底部留言,或 联络我们.。
    找不到素材资源介绍文章里的示例图片?
    对于PPT,KEY,Mockups,APP,网页模版等类型的素材,文章内用于介绍的图片通常并不包含在对应可供下载素材包内。这些相关商业图片需另外购买,且本站不负责(也没有办法)找到出处。 同样地一些字体文件也是这种情况,但部分素材会在素材包内有一份字体下载链接清单。
    小酒资源吧
    一个高级程序员模板开发平台
    • 2020-09-10Hi,初次和大家见面了,请多关照!

    Hi, 如果你对这款模板有疑问,可以跟我联系哦!

    联系客服
    • 2261会员总数(位)
    • 4394资源总数(个)
    • 3本周发布(个)
    • 0 今日发布(个)
    • 338稳定运行(天)

    提供最优质的资源集合

    立即查看 了解详情
  • 2020 XiaoJiu8.cn - & WordPress Theme. All rights reserved 黔ICP备17003460号-5

  • XML地图 | 站长导航
         
    升级SVIP尊享更多特权立即升级