当前位置:   article > 正文

39. 实战:基于api接口实现视频解析播放(32接口,窗口化操作,可导出exe,附源码)_视频解析接口

视频解析接口

目录

前言

目的

思路

代码实现

需要导入的模块

1. 导入解析网站列表,实现解析过程

2. 设计UI界面

3. 设置窗口居中和循环执行

4. 注意事项

完整源码

运行效果

总结


前言

本节将类似34. 实战:基于某api实现歌曲检索与下载(附完整源代码),也将基于api实现视频解析播放的功能,并且还实现了用户UI界面,随后大家也可以用py2exe等库导出exe来永久保存可执行文件。

本例具有32个接口供大家解析,一般前面的就能够顺利解析出来了,看大家喜好~


目的

实现输入任意视频链接,在用户UI窗口选择解析接口,点击解析按钮自动跳转到系统默认浏览器进行播放。


思路

1. 导入解析网站列表,实现解析过程

2. 设计UI界面

3. 设置窗口居中和循环执行

4. 注意事项


代码实现

需要导入的模块

  1. from urllib import parse
  2. import tkinter.messagebox as msgbox
  3. import tkinter as tk
  4. import webbrowser
  5. import re

1. 导入解析网站列表,实现解析过程

  1. """
  2. 函数说明:视频播放
  3. """
  4. def video_play(self):
  5. # 视频解析网站地址
  6. # port_1 = 'https://jx.618g.com/?url='
  7. port_1 = 'https://im1907.top/?jx='
  8. port_2 = 'https://jx.jsonplayer.com/player/?url='
  9. port_3 = 'https://jx.aidouer.net/?url='
  10. port_4 = 'https://jx.xmflv.com/?url='
  11. port_5 = 'https://okjx.cc/?url='
  12. port_6 = 'https://www.nxflv.com/?url='
  13. port_7 = 'https://www.yemu.xyz/?url='
  14. port_8 = 'https://jx.m3u8.tv/jiexi/?url='
  15. port_9 = 'https://jx.blbo.cc:4433/?url='
  16. port_10 = 'https://api.qianqi.net/vip/?url='
  17. port_11 = 'https://jx.nnxv.cn/tv.php?url='
  18. port_12 = 'https://bd.jx.cn/?url='
  19. port_13 = 'https://123.1dior.cn/?url='
  20. port_14 = 'https://www.ckplayer.vip/jiexi/?url='
  21. port_15 = 'https://www.ckmov.vip/api.php?url='
  22. port_16 = 'https://jx.playerjy.com/?url='
  23. port_17 = 'https://ckmov.ccyjjd.com/ckmov/?url='
  24. port_18 = 'https://www.ckmov.com/?url='
  25. port_19 = 'https://www.h8jx.com/jiexi.php?url='
  26. port_20 = 'https://svip.bljiex.cc/?v='
  27. port_21 = 'https://api.jiexi.la/?url='
  28. port_22 = 'https://jiexi.janan.net/jiexi/?url='
  29. port_23 = 'https://www.mtosz.com/erzi.php?url='
  30. port_24 = 'https://www.administratorw.com/video.php?url='
  31. port_25 = 'https://www.pangujiexi.cc/jiexi.php?url='
  32. port_26 = 'https://www.gai4.com/?url='
  33. port_27 = 'https://go.yh0523.cn/y.cy?url='
  34. port_28 = 'https://www.1717yun.com/jx/ty.php?url='
  35. port_29 = 'https://jx.4kdv.com/?url='
  36. port_30 = 'https://www.8090g.cn/?url='
  37. port_31 = 'https://jx.dj6u.com/?url='
  38. port_32 = 'https://jx.000180.top/jx/?url='
  39. # 正则表达是判定是否为合法链接
  40. if re.match(r'^https?:/{2}\w.+$', self.url.get()):
  41. port_num = self.v.get()
  42. port_url_referer = locals()[f'port_{port_num}']
  43. # 视频链接获取
  44. ip = self.url.get()
  45. # 视频链接加密
  46. ip = parse.quote_plus(ip)
  47. # 浏览器打开
  48. webbrowser.open(port_url_referer + self.url.get())
  49. else:
  50. msgbox.showerror(title='错误', message='视频链接地址无效,请重新输入!')

这里用locals函数实现基于变量名称的字符串检索变量对应值的操作,还是值得一学的。如果是全局变量就要使用globals,用法是一样的。 

2. 设计UI界面

就常规设计一下,大同小异的,博主审美能力有限,就做的很粗糙了:

  1. def __init__(self, width=1280, height=720):
  2. self.w = width
  3. self.h = height
  4. self.title = 'Vector的VIP解析助手'
  5. self.root = tk.Tk(className=self.title)
  6. # 定义button控件上的文字
  7. self.url = tk.StringVar()
  8. # 定义选择哪个播放源
  9. self.v = tk.IntVar()
  10. # 默认为1
  11. self.v.set(1)
  12. # Frame空间
  13. frame_1 = tk.Frame(self.root)
  14. frame_2 = tk.Frame(self.root)
  15. frame_3 = tk.Frame(self.root)
  16. # Menu菜单
  17. menu = tk.Menu(self.root)
  18. self.root.config(menu=menu)
  19. moviemenu = tk.Menu(menu, tearoff=0)
  20. menu.add_cascade(label='友情链接', menu=moviemenu)
  21. # 各大视频网站
  22. moviemenu.add_command(label='腾讯视频', command=lambda: webbrowser.open('http://v.qq.com/'))
  23. moviemenu.add_command(label='搜狐视频', command=lambda: webbrowser.open('http://tv.sohu.com/'))
  24. moviemenu.add_command(label='芒果TV', command=lambda: webbrowser.open('http://www.mgtv.com/'))
  25. moviemenu.add_command(label='爱奇艺', command=lambda: webbrowser.open('http://www.iqiyi.com/'))
  26. moviemenu.add_command(label='PPTV', command=lambda: webbrowser.open('http://www.bilibili.com/'))
  27. moviemenu.add_command(label='优酷', command=lambda: webbrowser.open('http://www.youku.com/'))
  28. moviemenu.add_command(label='乐视', command=lambda: webbrowser.open('http://www.le.com/'))
  29. moviemenu.add_command(label='土豆', command=lambda: webbrowser.open('http://www.tudou.com/'))
  30. moviemenu.add_command(label='A站', command=lambda: webbrowser.open('http://www.acfun.tv/'))
  31. moviemenu.add_command(label='B站', command=lambda: webbrowser.open('http://www.bilibili.com/'))
  32. # 控件内容设置
  33. group = tk.Label(frame_1, text='请选择一个视频解析方式:', padx=10, pady=10)
  34. tb1 = tk.Radiobutton(frame_1, text='纯净/B站', variable=self.v, value=1, width=10, height=3)
  35. tb2 = tk.Radiobutton(frame_1, text='综合/B站', variable=self.v, value=2, width=10, height=3)
  36. tb3 = tk.Radiobutton(frame_1, text='爱豆', variable=self.v, value=3, width=10, height=3)
  37. tb4 = tk.Radiobutton(frame_1, text='虾米', variable=self.v, value=4, width=10, height=3)
  38. tb5 = tk.Radiobutton(frame_1, text='OK解析', variable=self.v, value=5, width=10, height=3)
  39. tb6 = tk.Radiobutton(frame_1, text='诺讯', variable=self.v, value=6, width=10, height=3)
  40. tb7 = tk.Radiobutton(frame_1, text='夜幕', variable=self.v, value=7, width=10, height=3)
  41. tb8 = tk.Radiobutton(frame_1, text='M3U8.TV', variable=self.v, value=8, width=10, height=3)
  42. tb9 = tk.Radiobutton(frame_1, text='人人迷', variable=self.v, value=9, width=10, height=3)
  43. tb10 = tk.Radiobutton(frame_1, text='全民', variable=self.v, value=10, width=10, height=3)
  44. tb11 = tk.Radiobutton(frame_1, text='七哥', variable=self.v, value=11, width=10, height=3)
  45. tb12 = tk.Radiobutton(frame_1, text='冰豆', variable=self.v, value=12, width=10, height=3)
  46. tb13 = tk.Radiobutton(frame_1, text='迪奥', variable=self.v, value=13, width=10, height=3)
  47. tb14 = tk.Radiobutton(frame_1, text='CK', variable=self.v, value=14, width=10, height=3)
  48. tb15 = tk.Radiobutton(frame_1, text='ckmov', variable=self.v, value=15, width=10, height=3)
  49. tb16 = tk.Radiobutton(frame_1, text='playerjy/B站', variable=self.v, value=16, width=10, height=3)
  50. tb17 = tk.Radiobutton(frame_1, text='ccyjjd', variable=self.v, value=17, width=10, height=3)
  51. tb18 = tk.Radiobutton(frame_1, text='诺诺', variable=self.v, value=18, width=10, height=3)
  52. tb19 = tk.Radiobutton(frame_1, text='H8', variable=self.v, value=19, width=10, height=3)
  53. tb20 = tk.Radiobutton(frame_1, text='BL', variable=self.v, value=20, width=10, height=3)
  54. tb21 = tk.Radiobutton(frame_1, text='解析la', variable=self.v, value=21, width=10, height=3)
  55. tb22 = tk.Radiobutton(frame_1, text='MUTV', variable=self.v, value=22, width=10, height=3)
  56. tb23 = tk.Radiobutton(frame_1, text='MAO', variable=self.v, value=23, width=10, height=3)
  57. tb24 = tk.Radiobutton(frame_1, text='无名', variable=self.v, value=24, width=10, height=3)
  58. tb25 = tk.Radiobutton(frame_1, text='盘古', variable=self.v, value=25, width=10, height=3)
  59. tb26 = tk.Radiobutton(frame_1, text='盖世', variable=self.v, value=26, width=10, height=3)
  60. tb27 = tk.Radiobutton(frame_1, text='0523', variable=self.v, value=27, width=10, height=3)
  61. tb28 = tk.Radiobutton(frame_1, text='17云', variable=self.v, value=28, width=10, height=3)
  62. tb29 = tk.Radiobutton(frame_1, text='4K', variable=self.v, value=29, width=10, height=3)
  63. tb30 = tk.Radiobutton(frame_1, text='8090', variable=self.v, value=30, width=10, height=3)
  64. tb31 = tk.Radiobutton(frame_1, text='听乐', variable=self.v, value=31, width=10, height=3)
  65. tb32 = tk.Radiobutton(frame_1, text='180', variable=self.v, value=32, width=10, height=3)
  66. label1 = tk.Label(frame_2, text="请输入视频链接:")
  67. entry = tk.Entry(frame_2, textvariable=self.url, highlightcolor='Fuchsia', highlightthickness=1, width=35)
  68. label2 = tk.Label(frame_2, text=" ")
  69. play = tk.Button(frame_2, text="播放", font=('楷体', 12), fg='Purple', width=2, height=1, command=self.video_play)
  70. label3 = tk.Label(frame_2, text=" ")
  71. label_explain = tk.Label(frame_3, fg='red', font=('楷体', 18), text='\n注意:\nCSDN博主Vec_Kun版权所有\n此工具仅用于交流学习\n请勿用于任何商业用途!')
  72. label_warning = tk.Label(frame_3, fg='black', font=('楷体', 16), text='\n\n')
  73. # 控件布局
  74. frame_1.pack()
  75. frame_2.pack()
  76. frame_3.pack()
  77. group.grid(row=0, column=0)
  78. tb1.grid(row=0, column=1)
  79. tb2.grid(row=0, column=2)
  80. tb3.grid(row=0, column=3)
  81. tb4.grid(row=0, column=4)
  82. tb5.grid(row=1, column=1)
  83. tb6.grid(row=1, column=2)
  84. tb7.grid(row=1, column=3)
  85. tb8.grid(row=1, column=4)
  86. tb9.grid(row=2, column=1)
  87. tb10.grid(row=2, column=2)
  88. tb11.grid(row=2, column=3)
  89. tb12.grid(row=2, column=4)
  90. tb13.grid(row=3, column=1)
  91. tb14.grid(row=3, column=2)
  92. tb15.grid(row=3, column=3)
  93. tb16.grid(row=3, column=4)
  94. tb17.grid(row=4, column=1)
  95. tb18.grid(row=4, column=2)
  96. tb19.grid(row=4, column=3)
  97. tb20.grid(row=4, column=4)
  98. tb21.grid(row=5, column=1)
  99. tb22.grid(row=5, column=2)
  100. tb23.grid(row=5, column=3)
  101. tb24.grid(row=5, column=4)
  102. tb25.grid(row=6, column=1)
  103. tb26.grid(row=6, column=2)
  104. tb27.grid(row=6, column=3)
  105. tb28.grid(row=6, column=4)
  106. tb29.grid(row=7, column=1)
  107. tb30.grid(row=7, column=2)
  108. tb31.grid(row=7, column=3)
  109. tb32.grid(row=7, column=4)
  110. label1.grid(row=0, column=0)
  111. entry.grid(row=0, column=1)
  112. label2.grid(row=0, column=2)
  113. play.grid(row=0, column=3, ipadx=10, ipady=10)
  114. label3.grid(row=0, column=4)
  115. label_explain.grid(row=1, column=0)
  116. label_warning.grid(row=2, column=0)

3. 设置窗口居中和循环执行

  1. """
  2. 函数说明:tkinter窗口居中
  3. """
  4. def center(self):
  5. ws = self.root.winfo_screenwidth()
  6. hs = self.root.winfo_screenheight()
  7. x = int((ws / 2) - (self.w / 2))
  8. y = int((hs / 2) - (self.h / 2))
  9. self.root.geometry('{}x{}+{}+{}'.format(self.w, self.h, x, y))
  1. """
  2. 函数说明:loop等待用户事件
  3. """
  4. def loop(self):
  5. # 禁止修改窗口大小
  6. self.root.resizable(False, False)
  7. # 窗口居中
  8. self.center()
  9. self.root.mainloop()

最后在主函数运行就好了

  1. if __name__ == '__main__':
  2. app = APP() # 实例化APP对象
  3. app.loop() # loop等待用户事件

4. 注意事项

此工具仅用于交流学习,请勿用于任何商业用途!!!

此工具仅用于交流学习,请勿用于任何商业用途!!!

此工具仅用于交流学习,请勿用于任何商业用途!!!


完整源码

  1. # Created at UESTC
  2. # Author: Vector Kun
  3. # Time: 2023/1/30 11:26
  4. # url解析
  5. from urllib import parse
  6. import tkinter.messagebox as msgbox
  7. import tkinter as tk
  8. import webbrowser
  9. import re
  10. class APP:
  11. def __init__(self, width=1280, height=720):
  12. self.w = width
  13. self.h = height
  14. self.title = 'Vector的VIP解析助手'
  15. self.root = tk.Tk(className=self.title)
  16. # 定义button控件上的文字
  17. self.url = tk.StringVar()
  18. # 定义选择哪个播放源
  19. self.v = tk.IntVar()
  20. # 默认为1
  21. self.v.set(1)
  22. # Frame空间
  23. frame_1 = tk.Frame(self.root)
  24. frame_2 = tk.Frame(self.root)
  25. frame_3 = tk.Frame(self.root)
  26. # Menu菜单
  27. menu = tk.Menu(self.root)
  28. self.root.config(menu=menu)
  29. moviemenu = tk.Menu(menu, tearoff=0)
  30. menu.add_cascade(label='友情链接', menu=moviemenu)
  31. # 各大视频网站
  32. moviemenu.add_command(label='腾讯视频', command=lambda: webbrowser.open('http://v.qq.com/'))
  33. moviemenu.add_command(label='搜狐视频', command=lambda: webbrowser.open('http://tv.sohu.com/'))
  34. moviemenu.add_command(label='芒果TV', command=lambda: webbrowser.open('http://www.mgtv.com/'))
  35. moviemenu.add_command(label='爱奇艺', command=lambda: webbrowser.open('http://www.iqiyi.com/'))
  36. moviemenu.add_command(label='PPTV', command=lambda: webbrowser.open('http://www.bilibili.com/'))
  37. moviemenu.add_command(label='优酷', command=lambda: webbrowser.open('http://www.youku.com/'))
  38. moviemenu.add_command(label='乐视', command=lambda: webbrowser.open('http://www.le.com/'))
  39. moviemenu.add_command(label='土豆', command=lambda: webbrowser.open('http://www.tudou.com/'))
  40. moviemenu.add_command(label='A站', command=lambda: webbrowser.open('http://www.acfun.tv/'))
  41. moviemenu.add_command(label='B站', command=lambda: webbrowser.open('http://www.bilibili.com/'))
  42. # 控件内容设置
  43. group = tk.Label(frame_1, text='请选择一个视频解析方式:', padx=10, pady=10)
  44. tb1 = tk.Radiobutton(frame_1, text='纯净/B站', variable=self.v, value=1, width=10, height=3)
  45. tb2 = tk.Radiobutton(frame_1, text='综合/B站', variable=self.v, value=2, width=10, height=3)
  46. tb3 = tk.Radiobutton(frame_1, text='爱豆', variable=self.v, value=3, width=10, height=3)
  47. tb4 = tk.Radiobutton(frame_1, text='虾米', variable=self.v, value=4, width=10, height=3)
  48. tb5 = tk.Radiobutton(frame_1, text='OK解析', variable=self.v, value=5, width=10, height=3)
  49. tb6 = tk.Radiobutton(frame_1, text='诺讯', variable=self.v, value=6, width=10, height=3)
  50. tb7 = tk.Radiobutton(frame_1, text='夜幕', variable=self.v, value=7, width=10, height=3)
  51. tb8 = tk.Radiobutton(frame_1, text='M3U8.TV', variable=self.v, value=8, width=10, height=3)
  52. tb9 = tk.Radiobutton(frame_1, text='人人迷', variable=self.v, value=9, width=10, height=3)
  53. tb10 = tk.Radiobutton(frame_1, text='全民', variable=self.v, value=10, width=10, height=3)
  54. tb11 = tk.Radiobutton(frame_1, text='七哥', variable=self.v, value=11, width=10, height=3)
  55. tb12 = tk.Radiobutton(frame_1, text='冰豆', variable=self.v, value=12, width=10, height=3)
  56. tb13 = tk.Radiobutton(frame_1, text='迪奥', variable=self.v, value=13, width=10, height=3)
  57. tb14 = tk.Radiobutton(frame_1, text='CK', variable=self.v, value=14, width=10, height=3)
  58. tb15 = tk.Radiobutton(frame_1, text='ckmov', variable=self.v, value=15, width=10, height=3)
  59. tb16 = tk.Radiobutton(frame_1, text='playerjy/B站', variable=self.v, value=16, width=10, height=3)
  60. tb17 = tk.Radiobutton(frame_1, text='ccyjjd', variable=self.v, value=17, width=10, height=3)
  61. tb18 = tk.Radiobutton(frame_1, text='诺诺', variable=self.v, value=18, width=10, height=3)
  62. tb19 = tk.Radiobutton(frame_1, text='H8', variable=self.v, value=19, width=10, height=3)
  63. tb20 = tk.Radiobutton(frame_1, text='BL', variable=self.v, value=20, width=10, height=3)
  64. tb21 = tk.Radiobutton(frame_1, text='解析la', variable=self.v, value=21, width=10, height=3)
  65. tb22 = tk.Radiobutton(frame_1, text='MUTV', variable=self.v, value=22, width=10, height=3)
  66. tb23 = tk.Radiobutton(frame_1, text='MAO', variable=self.v, value=23, width=10, height=3)
  67. tb24 = tk.Radiobutton(frame_1, text='无名', variable=self.v, value=24, width=10, height=3)
  68. tb25 = tk.Radiobutton(frame_1, text='盘古', variable=self.v, value=25, width=10, height=3)
  69. tb26 = tk.Radiobutton(frame_1, text='盖世', variable=self.v, value=26, width=10, height=3)
  70. tb27 = tk.Radiobutton(frame_1, text='0523', variable=self.v, value=27, width=10, height=3)
  71. tb28 = tk.Radiobutton(frame_1, text='17云', variable=self.v, value=28, width=10, height=3)
  72. tb29 = tk.Radiobutton(frame_1, text='4K', variable=self.v, value=29, width=10, height=3)
  73. tb30 = tk.Radiobutton(frame_1, text='8090', variable=self.v, value=30, width=10, height=3)
  74. tb31 = tk.Radiobutton(frame_1, text='听乐', variable=self.v, value=31, width=10, height=3)
  75. tb32 = tk.Radiobutton(frame_1, text='180', variable=self.v, value=32, width=10, height=3)
  76. label1 = tk.Label(frame_2, text="请输入视频链接:")
  77. entry = tk.Entry(frame_2, textvariable=self.url, highlightcolor='Fuchsia', highlightthickness=1, width=35)
  78. label2 = tk.Label(frame_2, text=" ")
  79. play = tk.Button(frame_2, text="播放", font=('楷体', 12), fg='Purple', width=2, height=1, command=self.video_play)
  80. label3 = tk.Label(frame_2, text=" ")
  81. label_explain = tk.Label(frame_3, fg='red', font=('楷体', 18), text='\n注意:\nCSDN博主Vec_Kun版权所有\n此工具仅用于交流学习\n请勿用于任何商业用途!')
  82. label_warning = tk.Label(frame_3, fg='black', font=('楷体', 16), text='\n\n')
  83. # 控件布局
  84. frame_1.pack()
  85. frame_2.pack()
  86. frame_3.pack()
  87. group.grid(row=0, column=0)
  88. tb1.grid(row=0, column=1)
  89. tb2.grid(row=0, column=2)
  90. tb3.grid(row=0, column=3)
  91. tb4.grid(row=0, column=4)
  92. tb5.grid(row=1, column=1)
  93. tb6.grid(row=1, column=2)
  94. tb7.grid(row=1, column=3)
  95. tb8.grid(row=1, column=4)
  96. tb9.grid(row=2, column=1)
  97. tb10.grid(row=2, column=2)
  98. tb11.grid(row=2, column=3)
  99. tb12.grid(row=2, column=4)
  100. tb13.grid(row=3, column=1)
  101. tb14.grid(row=3, column=2)
  102. tb15.grid(row=3, column=3)
  103. tb16.grid(row=3, column=4)
  104. tb17.grid(row=4, column=1)
  105. tb18.grid(row=4, column=2)
  106. tb19.grid(row=4, column=3)
  107. tb20.grid(row=4, column=4)
  108. tb21.grid(row=5, column=1)
  109. tb22.grid(row=5, column=2)
  110. tb23.grid(row=5, column=3)
  111. tb24.grid(row=5, column=4)
  112. tb25.grid(row=6, column=1)
  113. tb26.grid(row=6, column=2)
  114. tb27.grid(row=6, column=3)
  115. tb28.grid(row=6, column=4)
  116. tb29.grid(row=7, column=1)
  117. tb30.grid(row=7, column=2)
  118. tb31.grid(row=7, column=3)
  119. tb32.grid(row=7, column=4)
  120. label1.grid(row=0, column=0)
  121. entry.grid(row=0, column=1)
  122. label2.grid(row=0, column=2)
  123. play.grid(row=0, column=3, ipadx=10, ipady=10)
  124. label3.grid(row=0, column=4)
  125. label_explain.grid(row=1, column=0)
  126. label_warning.grid(row=2, column=0)
  127. """
  128. 函数说明:视频播放
  129. """
  130. def video_play(self):
  131. # 视频解析网站地址
  132. # port_1 = 'https://jx.618g.com/?url='
  133. port_1 = 'https://im1907.top/?jx='
  134. port_2 = 'https://jx.jsonplayer.com/player/?url='
  135. port_3 = 'https://jx.aidouer.net/?url='
  136. port_4 = 'https://jx.xmflv.com/?url='
  137. port_5 = 'https://okjx.cc/?url='
  138. port_6 = 'https://www.nxflv.com/?url='
  139. port_7 = 'https://www.yemu.xyz/?url='
  140. port_8 = 'https://jx.m3u8.tv/jiexi/?url='
  141. port_9 = 'https://jx.blbo.cc:4433/?url='
  142. port_10 = 'https://api.qianqi.net/vip/?url='
  143. port_11 = 'https://jx.nnxv.cn/tv.php?url='
  144. port_12 = 'https://bd.jx.cn/?url='
  145. port_13 = 'https://123.1dior.cn/?url='
  146. port_14 = 'https://www.ckplayer.vip/jiexi/?url='
  147. port_15 = 'https://www.ckmov.vip/api.php?url='
  148. port_16 = 'https://jx.playerjy.com/?url='
  149. port_17 = 'https://ckmov.ccyjjd.com/ckmov/?url='
  150. port_18 = 'https://www.ckmov.com/?url='
  151. port_19 = 'https://www.h8jx.com/jiexi.php?url='
  152. port_20 = 'https://svip.bljiex.cc/?v='
  153. port_21 = 'https://api.jiexi.la/?url='
  154. port_22 = 'https://jiexi.janan.net/jiexi/?url='
  155. port_23 = 'https://www.mtosz.com/erzi.php?url='
  156. port_24 = 'https://www.administratorw.com/video.php?url='
  157. port_25 = 'https://www.pangujiexi.cc/jiexi.php?url='
  158. port_26 = 'https://www.gai4.com/?url='
  159. port_27 = 'https://go.yh0523.cn/y.cy?url='
  160. port_28 = 'https://www.1717yun.com/jx/ty.php?url='
  161. port_29 = 'https://jx.4kdv.com/?url='
  162. port_30 = 'https://www.8090g.cn/?url='
  163. port_31 = 'https://jx.dj6u.com/?url='
  164. port_32 = 'https://jx.000180.top/jx/?url='
  165. # 正则表达是判定是否为合法链接
  166. if re.match(r'^https?:/{2}\w.+$', self.url.get()):
  167. port_num = self.v.get()
  168. port_url_referer = locals()[f'port_{port_num}']
  169. # 视频链接获取
  170. ip = self.url.get()
  171. # 视频链接加密
  172. ip = parse.quote_plus(ip)
  173. # 浏览器打开
  174. webbrowser.open(port_url_referer + self.url.get())
  175. else:
  176. msgbox.showerror(title='错误', message='视频链接地址无效,请重新输入!')
  177. """
  178. 函数说明:tkinter窗口居中
  179. """
  180. def center(self):
  181. ws = self.root.winfo_screenwidth()
  182. hs = self.root.winfo_screenheight()
  183. x = int((ws / 2) - (self.w / 2))
  184. y = int((hs / 2) - (self.h / 2))
  185. self.root.geometry('{}x{}+{}+{}'.format(self.w, self.h, x, y))
  186. """
  187. 函数说明:loop等待用户事件
  188. """
  189. def loop(self):
  190. # 禁止修改窗口大小
  191. self.root.resizable(False, False)
  192. # 窗口居中
  193. self.center()
  194. self.root.mainloop()
  195. if __name__ == '__main__':
  196. app = APP() # 实例化APP对象
  197. app.loop() # loop等待用户事件

运行效果


总结

本节实现了输入任意视频链接,在用户UI窗口选择解析接口,点击解析按钮自动跳转到系统默认浏览器进行播放的功能,切记不要用于商业活动!本教程仅用于个人学习交流用途!

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/156403
推荐阅读
相关标签
  

闽ICP备14008679号