35async def download_video(v_url):
36 """ For .ytdl command, download media from YouTube and many other sites. """
37 url = v_url.pattern_match.group(2)
38 type = v_url.pattern_match.group(1).lower() 39 await v_url.edit("`Preparing to download...`")
40 out_folder = Config.TMP_DOWNLOAD_DIRECTORY + "youtubedl/"
41 thumb_image_path = Config.TMP_DOWNLOAD_DIRECTORY + "/thumb_image.jpg"
94async def download_video(v_url): # sourcery skip: avoid-builtin-shadow
95 """ For .ytdl command, download media from YouTube and many other sites. """
96 url = v_url.pattern_match.group(2)
97 type = v_url.pattern_match.group(1).lower() 98 out_folder = Config.TMP_DOWNLOAD_DIRECTORY + "youtubedl/"
99
100 if not os.path.isdir(out_folder):
1import asyncio
2from asyncio import TimeoutError, sleep 3
4from telethon import events
5from telethon.errors.rpcerrorlist import YouBlockedUserError
104 for item in subitems:
105 totallength += len(item)
106 if (totallength <= maxlinelength):
107 str = "".join(item + " " for item in subitems)108 # wrap concatenated content in a new list
109 subitems = [str.strip()]
110 else:
75 def __enter__(self):
76 return self.open_files()
77
78 def __exit__(self, type, value, traceback): 79 self.close_files()
80
81 def open_files(self):
Defining a local variable or function with the same name as a built-in object makes the built-in object unusable within the current scope and makes the code prone to bugs.
dict = {} # dict is a Python builtin!
for idx, student in enumerate(students):
dict[student] = idx
roll_number = {}
for idx, student in enumerate(students):
roll_number[student] = idx