Spaces:
Paused
Paused
File size: 2,280 Bytes
2f67506 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
#
# 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)
|