You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

165 lines
5.8 KiB

# coding = utf-8
import yaml
import os
from tkinter import *
from tkinter.ttk import *
from tkinter import messagebox
import Vqq.vqq as gm
import mv163.get_163mv_data as mv163
import weibomv.get_weibomv_data as weibomv
'''全局变量的定义'''
# 顶层窗口
root = None
# 控件绑定的值
choose = None
entry_links = None
text_remark = None
def redis():
createUI2()
def redis_baocun():
yaml_dict = {
"host": entry_host.get(),
"port": entry_port.get(),
"password": entry_password.get(),
"db": entry_db.get()
}
yaml_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), 'redis.yml')
with open(yaml_dir, 'w', encoding='utf-8', ) as f:
yaml.dump(yaml_dict, f, encoding='utf-8', allow_unicode=True)
f.close()
messagebox.showinfo(title='Redis设置', message='保存成功,请重新启动软件!')
# def close():
# '''
# 关闭窗口
# :return:
# '''
# print("close is called......")
# global root
# root.quit()
def createUI():
'''
创建窗口和控件
:return:
'''
global root, choose, text_remark, entry_links
root = Tk()
root.title("解析工具")
# frame_head其父窗口为root
frame_head = Frame(root)
frame_head.pack(side=TOP, fill=BOTH, expand=YES)
# frame_account其父窗口为frame_head
frame_account = Frame(frame_head)
frame_account.grid(row=0, column=0)
label_links = Label(frame_account, text='地址:', width=10)
label_links.grid(row=0, column=0, padx=10, pady=5)
entry_links = Entry(frame_account, foreground='blue', width=42)
# entry_links.insert(0, '1')
# entry_links.delete(3, END)
entry_links.grid(row=0, column=1, padx=10, pady=5)
# frame_info其父窗口为root
frame_info = Frame(root)
frame_info.pack(side=TOP, fill=BOTH, expand=YES)
label_choose = Label(frame_info, text='解析项目:', width=10)
label_choose.grid(row=1, column=0, padx=10, pady=5)
choose = StringVar()
comb_choose = Combobox(frame_info, textvariable=choose, width=40)
comb_choose.grid(row=1, column=1, padx=10, pady=5)
comb_choose['value'] = ['腾讯视频(链接)', '网易云MVid', '微博视频uid,cursor,hd', '待添加']
comb_choose.current(0)
# frame_remark其父窗口是root
frame_remark = Frame(root)
frame_remark.pack(side=TOP, fill=BOTH, expand=YES)
text_remark = Text(frame_remark, width=55,
height=5, foreground='green')
text_remark.insert(1.0, 'hello world')
text_remark.grid(row=0, column=0, padx=10, pady=5)
# frame_btn其父窗口为root
frame_btn = Frame(root, width=40)
frame_btn.pack(side=BOTTOM, fill=BOTH, expand=YES)
btn_submit = Button(frame_btn, text='开始解析', command=main_progarm)
btn_submit.grid(row=0, column=0, padx=65, pady=10)
btn_redis = Button(frame_btn, text='Redis设置', command=redis)
btn_redis.grid(row=0, column=1, padx=40, pady=10)
# btn_quit = Button(frame_btn, text='关闭窗口', command=close)
# btn_quit.grid(row=0, column=2, padx=20, pady=10)
root.mainloop()
def createUI2():
'''
创建窗口和控件
:return:
'''
global entry_host, entry_port, entry_password, entry_db
root = Tk()
root.title("Redis设置")
# frame_head其父窗口为root
frame_head = Frame(root)
frame_head.pack(side=TOP, fill=BOTH, expand=YES)
# frame_account其父窗口为frame_head
frame_account = Frame(frame_head)
frame_account.grid(row=0, column=0)
label_host = Label(frame_account, text='host', width=10)
label_host.grid(row=0, column=0, padx=10, pady=5)
entry_host = Entry(frame_account, foreground='blue', width=42)
entry_host.grid(row=0, column=1, padx=10, pady=5)
entry_host.insert(0, '127.0.0.1')
label_port = Label(frame_account, text='port', width=10)
label_port.grid(row=1, column=0, padx=10, pady=5)
entry_port = Entry(frame_account, foreground='blue', width=42)
entry_port.grid(row=1, column=1, padx=10, pady=5)
entry_port.insert(0, '6379')
label_password = Label(frame_account, text='password', width=10)
label_password.grid(row=2, column=0, padx=10, pady=5)
entry_password = Entry(frame_account, foreground='blue', width=42)
entry_password.grid(row=2, column=1, padx=10, pady=5)
label_db = Label(frame_account, text='db', width=10)
label_db.grid(row=3, column=0, padx=10, pady=5)
entry_db = Entry(frame_account, foreground='blue', width=42)
entry_db.grid(row=3, column=1, padx=10, pady=5)
entry_db.insert(0, '0')
# frame_btn其父窗口为root
frame_btn = Frame(root, width=40)
frame_btn.pack(side=BOTTOM, fill=BOTH, expand=YES)
btn_submit = Button(frame_btn, text='保存设置', command=redis_baocun)
btn_submit.grid(row=0, column=0, padx=200, pady=10)
root.mainloop()
def main_progarm():
global entry_links, choose, text_remark
# print(entry_links.get())
if entry_links.get() == '':
messagebox.showinfo('提示', '请输入地址!')
if choose.get() == '腾讯视频(链接)':
links = gm.run_js(entry_links.get())
text_remark.delete(1.0, END)
text_remark.insert(1.0, links)
if choose.get() == '网易云MVid':
links = mv163.get_video_link(entry_links.get())
text_remark.delete(1.0, END)
text_remark.insert(1.0, links)
if choose.get() == '微博视频uid,cursor,hd':
uid, cursor, hd = map(int, entry_links.get().split(","))
links = weibomv.get_weibomv_url(uid, cursor, hd)
text_remark.delete(1.0, END)
text_remark.insert(1.0, links)
if __name__ == '__main__':
createUI()