Have nothing to do at home on National Day? Teach everyone to use Python to make a software that can watch any video, of course, only watch serious

No, the National Day holiday is over. Although the students who are still studying have only three days off, but we have a lot of holidays for work, haha~

Back then, when I was a freshman, the National Day holiday was 15 days. It was really cool~

Alright, well, having said that, after taking such a long vacation, three days are also vacations. This is not because I am afraid that everyone will not be able to travel, go home or have nothing to do in the dormitory. It is too boring, so I specially show you how to use Python to develop a project. This video does not require VIP software~

If you want to send it to friends, we are packaging it into exe executable software, so that small partners can use it together~

Show results

Let's see the effect first

This is the interface to be written this time

You, Teng, and Ai are all available. I didn't try the others. I just copied and pasted the video address into the playback address, and clicked the online analysis to watch it~

Some friends want to ask, won't it be Teacher Ma's ancient picture quality?

Of course not, it has to be super clear!

The playback effect, I will not demonstrate it~

Let's try it yourself

Code display

module

import tkinter as tk
import webbrowser

create a window

root = tk.Tk()

Set software title

root.title('在线观影软件')

Set size 800<width>x300<height> 200+200 Distance from screen margin

root.geometry('800x300+200+200')

read image

img = tk.PhotoImage(file='img\\封面.png')

Custom function button trigger event

def show():

    # 获取输入框的内容
    word = input_va.get()
    # 获取选择的是那个接口
    num = num_int_va.get()
    # 判断选择的第一个接口
    if num == 1:
        # 视频解析播放地址
        link = 'https://jx.qqwtt.com/?url=' + word
        # 打开视频网站进行播放
        webbrowser.open(link)
    elif num == 2:
        link = 'https://okjx.cc/?url=' + word
        webbrowser.open(link)
    elif num == 3:
        link = 'https://svip.bljiex.cc/?url=' + word
        webbrowser.open(link)

The pack() layout method defaults to the top-centered Label label component <part>

set image tags

tk.Label(root, image=img).pack()

set label box

choose_frame = tk.LabelFrame(root)

fill='both' fill pady=10 Y-axis spacing, upper and lower spacing.

choose_frame.pack(fill='both', pady=10)

set text labels

tk.Label(choose_frame, text='选择接口:', font=('黑体', 20)).pack(side=tk.LEFT)

Set variable variables -> determine which one you click

num_int_va = tk.IntVar()

The default setting selects the first

num_int_va.set(1)

Set the radio button side=tk.LEFT to the left, left aligned.

tk.Radiobutton(choose_frame, text='①号通用vip引擎系统【稳定通用】',variable=num_int_va, value=1).pack(side=tk.LEFT, padx=5)
tk.Radiobutton(choose_frame, text='②号通用vip引擎系统【稳定通用】', variable=num_int_va, value=2).pack(side=tk.LEFT, padx=5)
tk.Radiobutton(choose_frame, text='③号通用vip引擎系统【稳定通用】', variable=num_int_va, value=3).pack(side=tk.LEFT)

Create a second label box

input_frame = tk.LabelFrame(root)
input_frame.pack(fill='both', pady=10)

Set play address text label

tk.Label(input_frame, text='播放地址:', font=('黑体', 20)).pack(side=tk.LEFT)

set variable

input_va = tk.StringVar()

set input box width set width relief input box style set flat smooth

tk.Entry(input_frame, width=100, relief='flat', textvariable=input_va).pack(side=tk.LEFT, fill='both')

Settings button

tk.Button(root, text='Go点击在线解析播放', font=('黑体', 20), bg='#449d44', relief='flat', command=show).pack(fill='both')

Packaged as exe executable file

Py file packaging is generally used Pyinstaller, everyone install this module.

The packaging process is too long, so I won't write it in detail. You can read my previous article: Ultimate Python package exe file and modify the icon

This is what I just packed~

at last

If you have the complete code and materials, you can pick up the business card at the end of the article~

Everyone has interesting ideas, and you can change them yourself.

If you want to learn on National Day, I recommend a set of Python tutorials, covering most of the common cases: Always forget the code after learning it? 100 crawler combat projects! Let you indulge in learning丨Apply what you learn丨The next Python god is you!

Finally, I wish everyone a happy National Day, play well, eat well, study well, and feel good!

Guess you like

Origin blog.csdn.net/fei347795790/article/details/127124623