📝 去除多余代码

This commit is contained in:
xtaodada 2021-02-14 14:27:49 +08:00
parent 23ad62b495
commit 632b932ea7
No known key found for this signature in database
GPG Key ID: EE4DC37B55E24736

View File

@ -8,7 +8,6 @@ from pagermaid import bot, log
from pagermaid.listener import listener from pagermaid.listener import listener
from telethon.tl.types import DocumentAttributeVideo from telethon.tl.types import DocumentAttributeVideo
from time import sleep from time import sleep
from re import search
@listener(outgoing=True, command="vdl", @listener(outgoing=True, command="vdl",
@ -33,7 +32,9 @@ async def vdl(context):
try: try:
from pytube import YouTube from pytube import YouTube
except ImportError: except ImportError:
await context.edit('`pytube`支持库未安装YouTube视频无法下载\n请使用 `-sh pip3 install --user git+https://github.com/nficano/pytube` 安装或自行ssh安装\n\n已安装过 `pytube3` 的用户请使用 `-sh pip3 uninstall pytube3 -y` 进行卸载') await context.edit('`pytube`支持库未安装YouTube视频无法下载\n请使用 `-sh pip3 install --user '
'git+https://github.com/nficano/pytube` 安装或自行ssh安装\n\n已安装过 `pytube3` 的用户请使用 `-sh pip3 '
'uninstall pytube3 -y` 进行卸载')
return return
url = url.replace('www.youtube.com/watch?v=', 'youtu.be/') url = url.replace('www.youtube.com/watch?v=', 'youtu.be/')
if not await youtube_dl(url, context, reply_id): if not await youtube_dl(url, context, reply_id):
@ -68,7 +69,8 @@ async def youtube_dl(url, context, reply_id):
async def bilibili_dl(url, context, reply_id): async def bilibili_dl(url, context, reply_id):
url = 'https://tenapi.cn/bilivideo/?url=' + url url = 'https://tenapi.cn/bilivideo/?url=' + url
headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063', "X-Real-IP": "223.252.199.66"} headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/52.0.2743.116 Safari/537.36 Edge/15.15063', "X-Real-IP": "223.252.199.66"}
for _ in range(20): # 最多尝试20次 for _ in range(20): # 最多尝试20次
status = False status = False
try: try:
@ -101,7 +103,8 @@ async def upload(as_file, filename, context, reply_id, caption, duration=0):
if not exists("plugins/VideoDLExtra"): if not exists("plugins/VideoDLExtra"):
mkdir("plugins/VideoDLExtra") mkdir("plugins/VideoDLExtra")
faster = requests.request( faster = requests.request(
"GET", "https://gist.githubusercontent.com/TNTcraftHIM/ca2e6066ed5892f67947eb2289dd6439/raw/86244b02c7824a3ca32ce01b2649f5d9badd2e49/FastTelethon.py") "GET", "https://gist.githubusercontent.com/TNTcraftHIM/ca2e6066ed5892f67947eb2289dd6439/raw"
"/86244b02c7824a3ca32ce01b2649f5d9badd2e49/FastTelethon.py")
for _ in range(6): # 最多尝试6次 for _ in range(6): # 最多尝试6次
if faster.status_code == 200: if faster.status_code == 200:
with open("plugins/VideoDLExtra/FastTelethon.py", "wb") as f: with open("plugins/VideoDLExtra/FastTelethon.py", "wb") as f: