diff --git a/Util/__init__.py b/Util/__init__.py index 2e2d8ee..a91cac6 100644 --- a/Util/__init__.py +++ b/Util/__init__.py @@ -4,8 +4,8 @@ @Description:__init__.py @Date :2022/07/29 23:20:56 @Author :JohnserfSeed -@version :1.3.0.90 -@License :(C)Copyright 2019-2022, Liugroup-NLPR-CASIA +@version :1.4.0.0 +@License :MIT License @Github :https://github.com/johnserf-seed @Mail :johnserfseed@gmail.com ------------------------------------------------- @@ -16,25 +16,37 @@ ------------------------------------------------- ''' +# 标准库 import re +import io import os +import sys import json import time -import rich +import math import signal import random import asyncio import logging -import requests import platform import argparse -import configparser +import base64 +from urllib import parse +from urllib.request import urlopen +from functools import partial +from typing import Union, Optional +from concurrent.futures import ThreadPoolExecutor +from pathlib import Path + +# 第三方库 +import aiohttp +import requests +from PIL import Image from lxml import etree -from TikTokUpdata import Updata -from functools import partial -from threading import Event -from urllib.request import urlopen +import rich +import qrcode +from configobj import ConfigObj from rich.progress import ( BarColumn, DownloadColumn, @@ -44,54 +56,25 @@ TimeRemainingColumn, TransferSpeedColumn, ) -from concurrent.futures import ThreadPoolExecutor +from rich.console import Console +from rich.table import Table +from rich.panel import Panel +# 自定义模块 +from TikTokUpdata import Updata from .XB import XBogus from .Log import Log from .Urls import Urls from .Lives import Lives -from .Check import CheckInfo +from .Login import * +from .Check import Check from .Config import Config -from .Images import Images from .Command import Command from .Cookies import Cookies from .Profile import Profile from .Download import Download - - -progress = Progress( - TextColumn("{task.description}[bold blue]{task.fields[filename]}", justify="left"), - BarColumn(bar_width=20), - "[progress.percentage]{task.percentage:>3.1f}%", - "•", - DownloadColumn(), - "•", - TransferSpeedColumn(), - "•", - TimeRemainingColumn(), -) - -done_event = Event() - - -def handle_sigint(signum, frame): - done_event.set() - - -signal.signal(signal.SIGINT, handle_sigint) - - -def copy_url(task_id: TaskID, url: str, name: str, path: str) -> None: - response = urlopen(url) - progress.update(task_id, total=int( - response.info()["Content-length"])) - with open(path, "wb") as dest_file: - progress.start_task(task_id) - for data in iter(partial(response.read, 32768), b""): - dest_file.write(data) - progress.update(task_id, advance=len(data)) - if done_event.is_set(): - return +from .NickMapper import NickMapper +from . import __version__ # 日志记录 @@ -120,15 +103,6 @@ def replaceT(obj): return new -def Status_Code(code: int): - if code == 200: - return - else: - log.info('[ 提示 ]:该视频%i,暂时无法解析!' % code) - print('[ 提示 ]:该视频%i,暂时无法解析!' % code) - return - - def reFind(strurl): """ 匹配分享的url地址 @@ -145,50 +119,31 @@ def reFind(strurl): return result -print(''' - ████████╗██╗██╗ ██╗████████╗ ██████╗ ██╗ ██╗██████╗ ██████╗ ██╗ ██╗███╗ ██╗██╗ ██████╗ █████╗ ██████╗ - ╚══██╔══╝██║██║ ██╔╝╚══██╔══╝██╔═══██╗██║ ██╔╝██╔══██╗██╔═══██╗██║ ██║████╗ ██║██║ ██╔═══██╗██╔══██╗██╔══██╗ - ██║ ██║█████╔╝ ██║ ██║ ██║█████╔╝ ██║ ██║██║ ██║██║ █╗ ██║██╔██╗ ██║██║ ██║ ██║███████║██║ ██║ - ██║ ██║██╔═██╗ ██║ ██║ ██║██╔═██╗ ██║ ██║██║ ██║██║███╗██║██║╚██╗██║██║ ██║ ██║██╔══██║██║ ██║ - ██║ ██║██║ ██╗ ██║ ╚██████╔╝██║ ██╗██████╔╝╚██████╔╝╚███╔███╔╝██║ ╚████║███████╗╚██████╔╝██║ ██║██████╔╝ - ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ ╚═════╝ ╚══╝╚══╝ ╚═╝ ╚═══╝╚══════╝ ╚═════╝ ╚═╝ ╚═╝╚═════╝ - ''') +table = Table.grid(padding=1, pad_edge=True) +table.add_column(no_wrap=True, justify="left") +table.add_row(__version__.__help__) + + +console = Console(width=150) # 显示字符宽度 +console = rich.console.Console(color_system="truecolor") # 真彩 +console.print(f"{__version__.__logo__}", justify="center") +console.print(f"\n:rocket: [bold]TikTokDownload [bright_yellow]{__version__.__version__}[/bright_yellow] :rocket:", justify="center") +console.print(f":zap: [i]{__version__.__description_cn__} :zap:", justify="center") +console.print(f":fire: [i]{__version__.__description_en__} :fire:", justify="center") +console.print(f":computer: [i]Repo {__version__.__repourl__} :computer:\n", justify="center") +console.print(Panel(table, border_style="bold", title="使用说明")) -print("#" * 120) -print( - """ - TikTokTool V1.3.0.90 - 使用说明: - 1、本程序目前支持命令行调用和配置文件操作,GUI预览版本已经发布 - 2、命令行操作方法:1)将本程序路径添加到环境变量 - 2)控制台输入 TikTokTool -u https://v.douyin.com/jqwLHjF/ - - 3、配置文件操作方法:1)运行软件前先打开目录下 conf.ini 文件配置用户主页和音乐下载模式 - 2)按照控制台输出信息操作 - - 4、如有您有任何bug或者意见反馈请在 https://github.com/Johnserf-Seed/TikTokDownload/issues 发起 - 5、GUI预览版本现已发布,操作更简单 https://github.com/Johnserf-Seed/TikTokDownload/tags 下载 - 6、TikTokLive 输入抖音直播间web端链接,例如 https://live.douyin.com/176819813905 - 7、新版工具fastdl正在开发中 ----> https://github.com/Johnserf-Seed/fastdl - - 注意: 目前已经支持app内分享短链和web端长链识别。 - """ -) -print("#" * 120) -print('\r') if (platform.system() == 'Windows'): - sprit = '\\' # 💻 - print('[ 💻 ]:Windows平台') + console.print('[ 💻 ]:Windows平台') elif (platform.system() == 'Linux'): - sprit = '/' # 🐧 - print('[ 🐧 ]:Linux平台') + console.print('[ 🐧 ]:Linux平台') else: - sprit = '/' # 🍎 - print('[ 🍎 ]:MacOS平台') + console.print('[ 🍎 ]:MacOS平台') + -# 检查版本 -Updata().get_Updata() +# 输出操作系统版本 +log.info(platform.system())