-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.py
More file actions
38 lines (32 loc) · 1.03 KB
/
utils.py
File metadata and controls
38 lines (32 loc) · 1.03 KB
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
from pytube import Playlist
from discord import (
Interaction
)
from config import DOMAINS
def take_playlist_by_url(url:str):
playlist = Playlist(url)
index = 0
if 'index=' in url:
for section in url.split('&'):
if 'index=' in section:
index = int(section.split('index=')[1])
video_urls = list(playlist.video_urls)
return video_urls[index - 1 :]
def check_play_condition(interaction:Interaction,url:str):
data_check = {}
if not check_yt_url(url):
data_check['message'] = 'Url no valida'
data_check['is_valid'] = False
return data_check
if interaction.user.voice is None:
data_check['message'] = 'Debes estar en un canal de voz para usar este comando.'
data_check['is_valid'] = False
return data_check
data_check['is_valid'] = True
return data_check
def check_yt_url(url:str):
url_in_domain = False
for domain in DOMAINS:
if domain in url:
url_in_domain = True
return url_in_domain