Spaces:
Paused
Paused
| # | |
| # Copyright (C) 2021-2022 by TeamYukki@Github, < https://github.com/TeamYukki >. | |
| # | |
| # This file is part of < https://github.com/TeamYukki/YukkiMusicBot > project, | |
| # and is released under the "GNU v3.0 License Agreement". | |
| # Please see < https://github.com/TeamYukki/YukkiMusicBot/blob/master/LICENSE > | |
| # | |
| # All rights reserved. | |
| from typing import Union | |
| from config import autoclean, chatstats, userstats | |
| from config.config import time_to_seconds | |
| from YukkiMusic.misc import db | |
| async def put_queue( | |
| chat_id, | |
| original_chat_id, | |
| file, | |
| title, | |
| duration, | |
| user, | |
| vidid, | |
| user_id, | |
| stream, | |
| forceplay: Union[bool, str] = None, | |
| ): | |
| title = title.title() | |
| try: | |
| duration_in_seconds = time_to_seconds(duration) - 3 | |
| except: | |
| duration_in_seconds = 0 | |
| put = { | |
| "title": title, | |
| "dur": duration, | |
| "streamtype": stream, | |
| "by": user, | |
| "chat_id": original_chat_id, | |
| "file": file, | |
| "vidid": vidid, | |
| "seconds": duration_in_seconds, | |
| "played": 0, | |
| } | |
| if forceplay: | |
| check = db.get(chat_id) | |
| if check: | |
| check.insert(0, put) | |
| else: | |
| db[chat_id] = [] | |
| db[chat_id].append(put) | |
| else: | |
| db[chat_id].append(put) | |
| autoclean.append(file) | |
| vidid = "telegram" if vidid == "soundcloud" else vidid | |
| to_append = {"vidid": vidid, "title": title} | |
| if chat_id not in chatstats: | |
| chatstats[chat_id] = [] | |
| chatstats[chat_id].append(to_append) | |
| if user_id not in userstats: | |
| userstats[user_id] = [] | |
| userstats[user_id].append(to_append) | |
| return | |
| async def put_queue_index( | |
| chat_id, | |
| original_chat_id, | |
| file, | |
| title, | |
| duration, | |
| user, | |
| vidid, | |
| stream, | |
| forceplay: Union[bool, str] = None, | |
| ): | |
| put = { | |
| "title": title, | |
| "dur": duration, | |
| "streamtype": stream, | |
| "by": user, | |
| "chat_id": original_chat_id, | |
| "file": file, | |
| "vidid": vidid, | |
| "seconds": 0, | |
| "played": 0, | |
| } | |
| if forceplay: | |
| check = db.get(chat_id) | |
| if check: | |
| check.insert(0, put) | |
| else: | |
| db[chat_id] = [] | |
| db[chat_id].append(put) | |
| else: | |
| db[chat_id].append(put) | |