-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathjitwin.py
97 lines (84 loc) · 3.08 KB
/
jitwin.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
import re
import os
import time
import threading #多进程库
from pathlib import Path #路径库
import platform#获取系统信息
import requests
import pywebio as io
out = io.output
ioin = io.input
pin = io.pin
import core #导入python核心接口
#声明下载列表
set_info = core.load_json()
#获取当前平台
system_type = platform.system()#系统名称
system_bit = platform.machine()#操作系统位数
#启动时间
local_time = time.strftime("%Y_%m_%d_%H_%M_%S", time.localtime())
#解析输入的链接类型
def get_url_type(url:str) -> list:
if '/read/' in url:
if '/cv' in url:#匹配cv
return_data = re.search('/cv([0-9]*)',url).group()
return ['cv',return_data]
elif '/readlist/' in url:#匹配rl
return_data = re.search('/rl([0-9]*)',url).group()
return ['rl',return_data]
return
elif 'space.bilibili.com' in url:#up主类
return_data = re.search('space.bilibili.com/([0-9]*)',url).group()
return ['up',return_data]
#校验输入是否正确
def check_input_url(url:str):
if '/read/' in url:#cv rl类
return
elif 'space.bilibili.com' in url:#up主类
return
return '输入链接错误'
#获取信息
def get_info(url_type:str,id:str) -> dict:
if url_type == 'cv':
return_data = core.bili_cv(id)
return return_data
elif url_type == 'rl':
return_data = core.bili_rl(id)
return return_data
elif url_type == 'up':
return_data = core.bili_up_cv(id)
return return_data
#显示信息
def print_info(info):
"""
创建专栏信息显示页
"""
#解析输入的url
def start_url():
url = pin.pin['url_input']#获取输入
check_return = check_input_url(url)
if check_return != None:
out.toast(check_return,duration=3,color='error')#显示错误信息
return
#解析url
out_url = get_url_type(url)
info = get_info(out_url[0],out_url[1])
#主函数
def main():
with out.use_scope('main'):#创建并进入main域
out.scroll_to('main','top')
#创建横向标签栏
scope_url = out.put_scope('url')#创建url域
scope_set = out.put_scope('set')#创建set域
scope_down = out.put_scope('down')#创建down域
out.put_tabs([{'title':'链接解析','content':scope_url},{'title':'下载列表','content':scope_down},{'title':'设置','content':scope_set}])#创建
#创建url输入框
with out.use_scope('url'):#进入域
pin.put_input('url_input',label='请输入链接',type='text')#限制类型为url,使用check_input_url检查内容
out.put_button(label='解析链接',onclick=start_url).style('width: 100%')#创建按键
out.put_scope('video_info')
#创建下载列表
with out.use_scope('down'):
scope_down_work = out.put_scope('down_work')
scope_down_fin = out.put_scope('down_fin')
out.put_tabs([{'title':'下载中','content':scope_down_work},{'title':'下载完成','content':scope_down_fin}])#创建横向标签栏