diff --git a/Cricket_info.py b/Cricket_info.py index 660cbbe..77ec2bc 100644 --- a/Cricket_info.py +++ b/Cricket_info.py @@ -28,9 +28,7 @@ async def _(client, message): page = await resp.text() soup = BeautifulSoup(page, "html.parser") result = soup.find_all("description") - Sed = "" - for match in result: - Sed += match.get_text() + "\n\n" + Sed = "".join(match.get_text() + "\n\n" for match in result) await edit_or_reply( message, f"Match information Gathered Successfully\n\n\n{Sed}", diff --git a/any_dl.py b/any_dl.py index 696989b..1f5153e 100644 --- a/any_dl.py +++ b/any_dl.py @@ -28,12 +28,12 @@ async def download_file(message, url, file_name): async with aiohttp.ClientSession() as session: async with session.get(url) as r: total_length = r.headers.get('content-length') or r.headers.get("Content-Length") - dl = 0 if total_length is None: f.write(await r.read()) else: total_length = int(total_length) - async for chunk in r.content.iter_chunked(max(int(total_length/500), (1024*1024)*2)): + dl = 0 + async for chunk in r.content.iter_chunked(max(total_length // 500, (1024*1024)*2)): dl += len(chunk) e_ = time.time() diff = e_ - c_ @@ -44,9 +44,23 @@ async def download_file(message, url, file_name): estimated_total_time = elapsed_time + time_to_completion f.write(chunk) progress_str = "{0}{1} {2}%\n".format( - "".join(["▰" for i in range(math.floor(percentage / 10))]), - "".join(["▱" for i in range(10 - math.floor(percentage / 10))]), - round(percentage, 2)) + "".join( + [ + "▰" + for _ in range(math.floor(percentage / 10)) + ] + ), + "".join( + [ + "▱" + for _ in range( + 10 - math.floor(percentage / 10) + ) + ] + ), + round(percentage, 2), + ) + r_ = f"Downloading This File \nFile : {file_name} \nFile Size : {humanbytes(total_length)} \nDownloaded : {humanbytes(dl)} \n{progress_str} \n\nSpeed : {humanbytes(round(speed))}/ps \nETA : {time_formatter(estimated_total_time)}" try: await message.edit(r_) @@ -85,9 +99,7 @@ async def upload_file(client, reply_message, message, file_path, caption): async def send_file(client, r_msg, file, capt, e_msg): c_time = time.time() file_name = os.path.basename(file) - send_as_thumb = False - if os.path.exists("./main_startup/Cache/thumb.jpg"): - send_as_thumb = True + send_as_thumb = bool(os.path.exists("./main_startup/Cache/thumb.jpg")) if file.endswith(image_ext): await r_msg.reply_video( file, @@ -157,24 +169,23 @@ async def send_file(client, r_msg, file, capt, e_msg): progress=progress, progress_args=(e_msg, c_time, f"`Uploading {file_name}!`", file_name), ) + elif send_as_thumb: + await r_msg.reply_document( + file, + quote=True, + thumb="./main_startup/Cache/thumb.jpg", + caption=capt, + progress=progress, + progress_args=(e_msg, c_time, f"`Uploading {file_name}!`", file_name), + ) else: - if send_as_thumb: - await r_msg.reply_document( - file, - quote=True, - thumb="./main_startup/Cache/thumb.jpg", - caption=capt, - progress=progress, - progress_args=(e_msg, c_time, f"`Uploading {file_name}!`", file_name), - ) - else: - await r_msg.reply_document( - file, - quote=True, - caption=capt, - progress=progress, - progress_args=(e_msg, c_time, f"`Uploading {file_name}!`", file_name), - ) + await r_msg.reply_document( + file, + quote=True, + caption=capt, + progress=progress, + progress_args=(e_msg, c_time, f"`Uploading {file_name}!`", file_name), + ) def file_list(path, lisT): pathlib.Path(path) @@ -203,8 +214,8 @@ async def download_(client, message): file_url, file_name = await dl_client.gdrive(url) except BaseException as e: return await s.edit(f"**Failed To GET Direct Link ::** `{e}`") - if file_url == None: - return await s.edit(f"**Failed To GET Direct Link**") + if file_url is None: + return await s.edit("**Failed To GET Direct Link**") file = await download_file(s, file_url, file_name) caption = f"File Downloaded & Uploaded \nFile Name : {file_name}" await upload_file(client, msg, s, file, caption) @@ -218,8 +229,8 @@ async def download_(client, message): file_url, file_name, file_size, file_upload_date, caption_, scan_result = await dl_client.media_fire_dl(url) except BaseException as e: return await s.edit(f"**Failed To GET Direct Link ::** `{e}`") - if file_url == None: - return await s.edit(f"**Failed To GET Direct Link**") + if file_url is None: + return await s.edit("**Failed To GET Direct Link**") file = await download_file(s, file_url, file_name) caption = f"File Downloaded & Uploaded \nFile Name : {file_name} \nFile Size : {file_size} \nFile Upload Date : {file_upload_date} \nFile Scan Result : {scan_result} \n{caption_}" await upload_file(client, msg, s, file, caption) @@ -235,8 +246,8 @@ async def download_(client, message): file_url, file_name, file_size = await dl_client.mega_dl(link) except BaseException as e: return await s.edit(f"**Failed To GET Direct Link ::** `{e}`") - if file_url == None: - return await s.edit(f"**Failed To GET Direct Link**") + if file_url is None: + return await s.edit("**Failed To GET Direct Link**") file = await download_file(s, file_url, file_name) file_size = humanbytes(file_size) caption = f"File Downloaded & Uploaded \nFile Name : {file_name} \nFile Size : {file_size}" @@ -251,12 +262,9 @@ async def download_(client, message): file_url, file_size, file_name = await dl_client.anon_files_dl(link) except BaseException as e: return await s.edit(f"**Failed To GET Direct Link ::** `{e}`") - if file_url == None: - return await s.edit(f"**Failed To GET Direct Link**") + if file_url is None: + return await s.edit("**Failed To GET Direct Link**") file = await download_file(s, file_url, file_name) - caption = f"File Downloaded & Uploaded \nFile Name : {file_name} \nFile Size : {file_size}" - await upload_file(client, msg, s, file, caption) - return os.remove(file) else: url_ = url.split('|') if len(url_) != 2: @@ -268,7 +276,8 @@ async def download_(client, message): except BaseException as e: return await s.edit(f"**Failed To Download ::** `{e}`") file_size = humanbytes(os.stat(file).st_size) - caption = f"File Downloaded & Uploaded \nFile Name : {file_name} \nFile Size : {file_size}" - await upload_file(client, msg, s, file, caption) - return os.remove(file) + + caption = f"File Downloaded & Uploaded \nFile Name : {file_name} \nFile Size : {file_size}" + await upload_file(client, msg, s, file, caption) + return os.remove(file) diff --git a/carbon.py b/carbon.py index 728e40a..be7e93e 100644 --- a/carbon.py +++ b/carbon.py @@ -35,10 +35,10 @@ def make_carbon(code, driver, lang="auto"): type_ = '//*[@id="__next"]/main/div[2]/div[2]/div[1]/div[1]/div/span[2]' em = "export-menu" png_xpath = '//*[@id="export-png"]' - four_x_path = '//*[@id="__next"]/main/div[2]/div[2]/div[1]/div[3]/div[4]/div[3]/div[2]/div[3]/div/button[3]' + four_x_path = '//*[@id="__next"]/main/div[2]/div[2]/div[1]/div[3]/div[4]/div[3]/div[2]/div[3]/div/button[3]' color_used_xpath = '/html/body/div[1]/main/div[2]/div[2]/div[1]/div[1]/div/span[2]/input' random_int = random.randint(1, 29) - value_ = "downshift-0-item-" + str(random_int) + value_ = f"downshift-0-item-{str(random_int)}" wait = WebDriverWait(driver, 20) wait.until(EC.visibility_of_element_located((By.XPATH, type_))).click() wait.until(EC.visibility_of_element_located((By.ID, value_))).click() diff --git a/cc_tools.py b/cc_tools.py index b6b7774..c6c9745 100644 --- a/cc_tools.py +++ b/cc_tools.py @@ -53,7 +53,7 @@ def namso_gen(bin, no_of_result=15): button_xpath = '/html/body/div/div/div/main/div/div/div[3]/div[1]/form/div[5]/button' w.until(EC.visibility_of_element_located((By.XPATH, bin_xpath))).send_keys(bin) elem3 = w.until(EC.visibility_of_element_located((By.XPATH, no_of_r_xpath))) - for i in range(2): + for _ in range(2): elem3.send_keys(Keys.BACKSPACE) elem3 = w.until(EC.visibility_of_element_located((By.XPATH, no_of_r_xpath))) elem3.send_keys(no_of_result) @@ -97,9 +97,13 @@ async def ns_gen(client, message): await msg.edit(t, parse_mode="md") def stark_finder(to_find, from_find): - if re.search(r"( |^|[^\w])" + re.escape(to_find) + r"( |$|[^\w])", from_find, flags=re.IGNORECASE): - return True - return False + return bool( + re.search( + f"( |^|[^\\w]){re.escape(to_find)}( |$|[^\\w])", + from_find, + flags=re.IGNORECASE, + ) + ) my_code = { 400: "『! Invalid Key !』", diff --git a/collage.py b/collage.py index a9411e7..9ef620b 100644 --- a/collage.py +++ b/collage.py @@ -21,7 +21,7 @@ async def create_s_collage(file_path, filename, width, stark_h): """Create Image Collage""" - img_stark = [filepath for filepath in pathlib.Path(file_path).glob("**/*")] + img_stark = list(pathlib.Path(file_path).glob("**/*")) margin_size = 2 while True: img_stark_list = list(img_stark) @@ -45,10 +45,12 @@ async def create_s_collage(file_path, filename, width, stark_h): stark_h -= 10 else: break - out_lol_h = 0 - for meisnub, sedlife in ujwal_liness: - if sedlife: - out_lol_h += int(stark_h / meisnub) + margin_size + out_lol_h = sum( + int(stark_h / meisnub) + margin_size + for meisnub, sedlife in ujwal_liness + if sedlife + ) + if not out_lol_h: return None final_image = Image.new('RGB', (width, int(out_lol_h)), (35, 35, 35)) diff --git a/fban.py b/fban.py index b136537..5ffbc48 100644 --- a/fban.py +++ b/fban.py @@ -179,32 +179,32 @@ async def fetch_all_fed(client, message): pass await asyncio.sleep(7) sed = (await client.get_history("@MissRose_bot", 1))[0] - if sed.media: - fed_file = await sed.download() - file = open(fed_file, "r") - lines = file.readlines() - for line in lines: - try: - fed_list.append(line[:36]) - except BaseException: - pass - os.remove(fed_file) - else: + if not sed.media: return None + fed_file = await sed.download() + file = open(fed_file, "r") + lines = file.readlines() + for line in lines: + try: + fed_list.append(line[:36]) + except BaseException: + pass + os.remove(fed_file) else: X = ok.text lol = X.splitlines() if "you are the owner" in X.lower(): for lo in lol: - if "you are the owner" not in lo.lower(): - if "you are admin" not in lo.lower(): - if lo[:36] != "": - if not lo.startswith("-"): - fed_list.append(lo[:36]) - else: - fed_list.append(lo[2:38]) + if ( + "you are the owner" not in lo.lower() + and "you are admin" not in lo.lower() + and lo[:36] != "" + ): + if not lo.startswith("-"): + fed_list.append(lo[:36]) + else: + fed_list.append(lo[2:38]) else: Y = X[44:].splitlines() - for lol in Y: - fed_list.append(lol[2:38]) + fed_list.extend(lol[2:38] for lol in Y) return fed_list diff --git a/github_search.py b/github_search.py index 0e3fc95..2cc4953 100644 --- a/github_search.py +++ b/github_search.py @@ -54,5 +54,5 @@ async def git(client, message): if qw.get("created_at"): txt += f'Created At : {qw.get("created_at")}' if qw.get("archived") == True: - txt += f"This Project is Archived" + txt += "This Project is Archived" await pablo.edit(txt, disable_web_page_preview=True) diff --git a/harem.py b/harem.py index 27eda17..c7c574d 100644 --- a/harem.py +++ b/harem.py @@ -87,10 +87,7 @@ async def remove_nsfw(client, message): async def is_harem_enabled(f, client, message): if Config.ENABLE_WAIFU_FOR_ALL_CHATS: return bool(True) - if await is_chat_in_db(int(message.chat.id)): - return bool(True) - else: - return bool(False) + return bool(True) if await is_chat_in_db(int(message.chat.id)) else bool(False) async def harem_event(f, client, message): if not message: @@ -117,11 +114,11 @@ def get_data(img): harem_event = filters.create(func=harem_event, name="harem_event") is_harem_enabled = filters.create(func=is_harem_enabled, name="is_harem_enabled") -@listen(filters.user([int(792028928)]) & ~filters.edited & is_harem_enabled & harem_event & filters.group) +@listen(filters.user([792028928]) & ~filters.edited & is_harem_enabled & harem_event & filters.group) async def harem_catcher(client, message): img = await message.download() fetchUrl = await get_data(img) - match = await ParseSauce(fetchUrl + "&preferences?hl=en&fg=1#languages") + match = await ParseSauce(f'{fetchUrl}&preferences?hl=en&fg=1#languages') guessp = match["best_guess"] if not guessp: return logging.info("(Waifu Catch Failed.) \nERROR : 404: Waifu Not Found.") diff --git a/helper_files/dl_.py b/helper_files/dl_.py index 7d89148..75c3276 100644 --- a/helper_files/dl_.py +++ b/helper_files/dl_.py @@ -33,9 +33,7 @@ def gdrive(self, url): url = f'{drive}/uc?export=download&id={file_id}' download = requests.get(url, stream=True, allow_redirects=False) cookies = download.cookies - dl_url = None - if download.headers: - dl_url = download.headers.get("location") + dl_url = download.headers.get("location") if download.headers else None if not dl_url: page = BeautifulSoup(download.content, 'lxml') export = drive + page.find('a', {'id': 'uc-download-url'}).get('href') @@ -48,7 +46,7 @@ def gdrive(self, url): async def mega_dl(self, url): path = parse_url(url).split('!') - if path == None: + if path is None: return None, None, None file_handle = path[0] file_key = path[1] diff --git a/helper_files/dl_helpers.py b/helper_files/dl_helpers.py index afe248d..d7ffc99 100644 --- a/helper_files/dl_helpers.py +++ b/helper_files/dl_helpers.py @@ -44,47 +44,46 @@ def base64_to_a32(s): return str_to_a32(base64_url_decode(s)) def parse_url(url): - if '/file/' in url: - url = url.replace(' ', '') - file_id = re.findall(r'\W\w\w\w\w\w\w\w\w\W', url)[0][1:-1] - id_index = re.search(file_id, url).end() - key = url[id_index + 1:] - return f'{file_id}!{key}' - elif '!' in url: - match = re.findall(r'/#!(.*)', url) - path = match[0] - return path - else: - return None + if '/file/' in url: + url = url.replace(' ', '') + file_id = re.findall(r'\W\w\w\w\w\w\w\w\w\W', url)[0][1:-1] + id_index = re.search(file_id, url).end() + key = url[id_index + 1:] + return f'{file_id}!{key}' + elif '!' in url: + match = re.findall(r'/#!(.*)', url) + return match[0] + else: + return None async def download_file(url): - path = parse_url(url).split('!') - if path == None: - return None, None, None - file_handle = path[0] - file_key = path[1] - file_key = base64_to_a32(file_key) - file_data = await api_request({ - 'a': 'g', - 'g': 1, - 'p': file_handle - }) - k = (file_key[0] ^ file_key[4], file_key[1] ^ file_key[5], - file_key[2] ^ file_key[6], file_key[3] ^ file_key[7]) - if 'g' not in file_data: - return None, None, None - file_url = file_data['g'] - file_size = file_data['s'] - attribs = base64_url_decode(file_data['at']) - attribs = decrypt_attr(attribs, k) - file_name = attribs['n'] - return file_name,file_size, file_url + path = parse_url(url).split('!') + if path is None: + return None, None, None + file_handle = path[0] + file_key = path[1] + file_key = base64_to_a32(file_key) + file_data = await api_request({ + 'a': 'g', + 'g': 1, + 'p': file_handle + }) + k = (file_key[0] ^ file_key[4], file_key[1] ^ file_key[5], + file_key[2] ^ file_key[6], file_key[3] ^ file_key[7]) + if 'g' not in file_data: + return None, None, None + file_url = file_data['g'] + file_size = file_data['s'] + attribs = base64_url_decode(file_data['at']) + attribs = decrypt_attr(attribs, k) + file_name = attribs['n'] + return file_name,file_size, file_url async def api_request(data): sequence_num = random.randint(0, 0xFFFFFFFF) if not isinstance(data, list): data = [data] - url = f'https://g.api.mega.co.nz/cs' + url = 'https://g.api.mega.co.nz/cs' params = {'id': sequence_num} async with aiohttp.ClientSession() as session: response = await session.post(url, data=json.dumps(data), params=params) diff --git a/imdb.py b/imdb.py index a651a02..49af634 100644 --- a/imdb.py +++ b/imdb.py @@ -25,7 +25,6 @@ async def get_content(url): "example": "{ch}imdb joker", } ) - async def _(client,message): query = get_text(message) msg = await edit_or_reply(message, "`Searching For Movie..`") @@ -33,7 +32,7 @@ async def _(client,message): if not query: await msg.edit("`Please Give Me An Input.`") return - url = "https://www.imdb.com/find?ref_=nv_sr_fn&q=" + query + "&s=all" + url = f"https://www.imdb.com/find?ref_=nv_sr_fn&q={query}&s=all" r = await get_content(url) soup = BeautifulSoup(r, "lxml") o_ = soup.find("td", {"class": "result_text"}) @@ -47,21 +46,17 @@ async def _(client,message): if r_json.get("@type"): res_str += f"\nType : {r_json['@type']} \n" if r_json.get("name"): - res_str += f"Name : {r_json['name']} \n" + res_str += f"Name : {r_json['name']} \n" if r_json.get("contentRating"): res_str += f"Content Rating : {r_json['contentRating']} \n" if r_json.get("genre"): all_genre = r_json['genre'] - genre = "" - for i in all_genre: - genre += f"{i}, " + genre = "".join(f"{i}, " for i in all_genre) genre = genre[:-2] res_str += f"Genre : {genre} \n" if r_json.get("actor"): all_actors = r_json['actor'] - actors = "" - for i in all_actors: - actors += f"{i['name']}, " + actors = "".join(f"{i['name']}, " for i in all_actors) actors = actors[:-2] res_str += f"Actors : {actors} \n" if r_json.get("trailer"): @@ -81,9 +76,8 @@ async def _(client,message): res_str += f"Date Published : {r_json['datePublished']} \n" if r_json.get("aggregateRating"): res_str += f"Rating Count : {r_json['aggregateRating']['ratingCount']} \nRating Value : {r_json['aggregateRating']['ratingValue']} \n" - res_str += f"URL : {url}" - thumb = r_json.get('image') - if thumb: + res_str += f"URL : {url}" + if thumb := r_json.get('image'): await msg.delete() return await reply.reply_photo(thumb, caption=res_str) await msg.edit(res_str) diff --git a/music_player.py b/music_player.py index e932aa9..46d24f0 100644 --- a/music_player.py +++ b/music_player.py @@ -48,7 +48,6 @@ async def pl(client, message): group_call = GPC.get((message.chat.id, client.me.id)) play = await edit_or_reply(message, "`Please Wait!`") song = f"**PlayList in {message.chat.title}** \n" - sno = 0 s = s_dict.get((message.chat.id, client.me.id)) if not group_call: return await play.edit("`Voice Chat Not Connected. So How Am i Supposed To Give You Playlist?`") @@ -59,9 +58,8 @@ async def pl(client, message): return await play.edit("`Voice Chat Not Connected. So How Am i Supposed To Give You Playlist?`") if group_call.is_connected: song += f"**Currently Playing :** `{group_call.song_name}` \n\n" - for i in s: - sno += 1 - song += f"**{sno} ▶** [{i['song_name']}]({i['url']}) `| {i['singer']} | {i['dur']}` \n\n" + for sno, i in enumerate(s, start=1): + song += f"**{sno} ▶** [{i['song_name']}]({i['url']}) `| {i['singer']} | {i['dur']}` \n\n" await play.edit(song) async def get_chat_(client, chat_): @@ -71,7 +69,7 @@ async def get_chat_(client, chat_): return (await client.get_chat(int(chat_))).id except ValueError: chat_ = chat_.split("-100")[1] - chat_ = '-' + str(chat_) + chat_ = f'-{str(chat_)}' return int(chat_) async def playout_ended_handler(group_call, filename): @@ -113,10 +111,10 @@ async def ski_p(client, message): s = s_dict.get((message.chat.id, client.me.id)) if not group_call: await m_.edit("`Is Group Call Even Connected?`") - return + return if not group_call.is_connected: await m_.edit("`Is Group Call Even Connected?`") - return + return if not no_t_s: return await m_.edit("`Give Me Valid List Key Len.`") if no_t_s == "current": @@ -127,14 +125,14 @@ async def ski_p(client, message): name = str(s[0]['song_name']) prev = group_call.song_name group_call.input_filename = next_s - return await m_.edit(f"`Skipped {prev}. Now Playing {name}!`") + return await m_.edit(f"`Skipped {prev}. Now Playing {name}!`") else: if not s: return await m_.edit("`There is No Playlist!`") if not no_t_s.isdigit(): return await m_.edit("`Input Should Be In Digits.`") no_t_s = int(no_t_s) - if int(no_t_s) == 0: + if no_t_s == 0: return await m_.edit("`0? What?`") no_t_s = int(no_t_s - 1) try: @@ -153,39 +151,45 @@ async def ski_p(client, message): async def play_m(client, message): group_call = GPC.get((message.chat.id, client.me.id)) u_s = await edit_or_reply(message, "`Processing..`") - input_str = get_text(message) - if not input_str: - if not message.reply_to_message: - return await u_s.edit_text("`Reply To A File To PLay It.`") - if message.reply_to_message.audio: - await u_s.edit_text("`Please Wait, Let Me Download This File!`") - audio = message.reply_to_message.audio - audio_original = await message.reply_to_message.download() - vid_title = audio.title or audio.file_name - uploade_r = message.reply_to_message.audio.performer or "Unknown Artist." - dura_ = message.reply_to_message.audio.duration - dur = datetime.timedelta(seconds=dura_) - raw_file_name = ''.join([random.choice(string.ascii_lowercase) for i in range(5)]) + ".raw" - url = message.reply_to_message.link - else: - return await u_s.edit("`Reply To A File To PLay It.`") + if input_str := get_text(message): + search = SearchVideos(str(input_str), offset=1, mode="dict", max_results=1) + rt = search.result() + result_s = rt.get("search_result") + if not result_s: + return await u_s.edit(f"`No Song Found Matching With Query - {input_str}, Please Try Giving Some Other Name.`") + url = result_s[0]["link"] + dur = result_s[0]["duration"] + vid_title = result_s[0]["title"] + yt_id = result_s[0]["id"] + uploade_r = result_s[0]["channel"] + start = time.time() + try: + audio_original = await yt_dl(url, client, message, start) + except BaseException as e: + return await u_s.edit(f"**Failed To Download** \n**Error :** `{str(e)}`") + raw_file_name = ( + ''.join([random.choice(string.ascii_lowercase) for _ in range(5)]) + + ".raw" + ) + else: - search = SearchVideos(str(input_str), offset=1, mode="dict", max_results=1) - rt = search.result() - result_s = rt.get("search_result") - if not result_s: - return await u_s.edit(f"`No Song Found Matching With Query - {input_str}, Please Try Giving Some Other Name.`") - url = result_s[0]["link"] - dur = result_s[0]["duration"] - vid_title = result_s[0]["title"] - yt_id = result_s[0]["id"] - uploade_r = result_s[0]["channel"] - start = time.time() - try: - audio_original = await yt_dl(url, client, message, start) - except BaseException as e: - return await u_s.edit(f"**Failed To Download** \n**Error :** `{str(e)}`") - raw_file_name = ''.join([random.choice(string.ascii_lowercase) for i in range(5)]) + ".raw" + if not message.reply_to_message: + return await u_s.edit_text("`Reply To A File To PLay It.`") + if not message.reply_to_message.audio: + return await u_s.edit("`Reply To A File To PLay It.`") + await u_s.edit_text("`Please Wait, Let Me Download This File!`") + audio = message.reply_to_message.audio + audio_original = await message.reply_to_message.download() + vid_title = audio.title or audio.file_name + uploade_r = message.reply_to_message.audio.performer or "Unknown Artist." + dura_ = message.reply_to_message.audio.duration + dur = datetime.timedelta(seconds=dura_) + raw_file_name = ( + ''.join([random.choice(string.ascii_lowercase) for _ in range(5)]) + + ".raw" + ) + + url = message.reply_to_message.link try: raw_file_name = await convert_to_raw(audio_original, raw_file_name) except BaseException as e: @@ -273,8 +277,7 @@ def yt_dl(url, client, message, start): } with YoutubeDL(opts) as ytdl: ytdl_data = ytdl.extract_info(url, download=True) - file_name = str(ytdl_data['id']) + ".mp3" - return file_name + return str(ytdl_data['id']) + ".mp3" RD_ = {} FFMPEG_PROCESSES = {} @@ -286,12 +289,11 @@ def yt_dl(url, client, message, start): cmd_help={"help": "Play Radio.", "example": "{ch}pradio (radio url)"}, ) async def radio_s(client, message): - g_s_ = GPC.get((message.chat.id, client.me.id)) - if g_s_: + if g_s_ := GPC.get((message.chat.id, client.me.id)): if g_s_.is_connected: await g_s_.stop() del GPC[(message.chat.id, client.me.id)] - s = await edit_or_reply(message, "`Please Wait.`") + s = await edit_or_reply(message, "`Please Wait.`") input_filename = f"radio_{message.chat.id}.raw" radio_url = get_text(message) if not radio_url: @@ -322,12 +324,10 @@ async def radio_s(client, message): ) async def stop_radio(client, message): msg = await edit_or_reply(message, "`Please Wait.`") - group_call = RD_.get((message.chat.id, client.me.id)) - if group_call: - if group_call.is_connected: - await group_call.stop() - else: - return await msg.edit("`Is Vc is Connected?`") + if not (group_call := RD_.get((message.chat.id, client.me.id))): + return await msg.edit("`Is Vc is Connected?`") + if group_call.is_connected: + await group_call.stop() else: return await msg.edit("`Is Vc is Connected?`") process = FFMPEG_PROCESSES.get((message.chat.id, client.me.id)) @@ -362,12 +362,12 @@ async def wow_dont_stop_songs(client, message): group_call = GPC.get((message.chat.id, client.me.id)) if not group_call: await edit_or_reply(message, "`Is Group Call Even Connected?`") - return + return if not group_call.is_connected: await edit_or_reply(message, "`Is Group Call Even Connected?`") - return + return group_call.resume_playout() - await edit_or_reply(message, f"`▶️ Resumed.`") + await edit_or_reply(message, "`▶️ Resumed.`") @friday_on_cmd( @@ -421,7 +421,7 @@ async def rejoinvcpls(client, message): await edit_or_reply(message, "`Is Group Call Even Connected?`") return await group_call.reconnect() - await edit_or_reply(message, f"`Rejoined! - Vc`") + await edit_or_reply(message, "`Rejoined! - Vc`") @friday_on_cmd( diff --git a/rom_search.py b/rom_search.py index dd6e1e7..7a6adfc 100644 --- a/rom_search.py +++ b/rom_search.py @@ -115,7 +115,7 @@ async def m_(client, message): if not query: return await e_.edit("`Please Give Me An Query.`") href = await get_url(query) - if href == None: + if href is None: return await e_.edit("`No Results Matching You Query.`") url, device_name, version, size, rs_date, type_, package_name = await fetch_data(href) final_ = f"MIUI Search \nModel : {device_name} \nVersion : {version} \nSize : {size} \nRelease Date : {rs_date} \nType : {type_} \nPackage Name : {package_name} \nDownload : {ch_}udl {url}" @@ -134,7 +134,7 @@ async def rm_s(client, message): if not query: return await e_.edit("`Please Give Me An Query.`") file_url, r_date, size, system, device = await realme_rom_search(query) - if file_url == None: + if file_url is None: return await e_.edit("`No Results Matching You Query.`") final_ = f"RealMeRom Search \nDevice : {device} \nSystem : {system} \nSize : {size} \nRelease Date : {r_date} \nDownload : {ch_}udl {file_url}" await message.edit(final_) diff --git a/shazam.py b/shazam.py index ecc9769..1f5a1f3 100644 --- a/shazam.py +++ b/shazam.py @@ -66,7 +66,7 @@ async def shazam_(client, message): size_ = humanbytes(os.stat(music_file).st_size) dur = datetime.timedelta(seconds=dur) thumb, by, title = await shazam(music_file) - if title == None: + if title is None: return await msg.edit("`No Results Found.`") etime = time.time() t_k = round(etime - stime)