mirror of
https://github.com/RafaelSolVargas/Vulkan.git
synced 2025-10-29 16:57:23 +00:00
Fixing error 34
This commit is contained in:
@@ -56,8 +56,8 @@ class Downloader:
|
||||
song.finish_down(song_info)
|
||||
return song
|
||||
# Convert yt_dlp error to my own error
|
||||
except DownloadError:
|
||||
raise DownloadingError()
|
||||
except DownloadError as e:
|
||||
raise DownloadingError(e.msg)
|
||||
|
||||
@run_async
|
||||
def extract_info(self, url: str) -> List[dict]:
|
||||
|
||||
@@ -106,6 +106,10 @@ class Playlist:
|
||||
self.__queue.append(song)
|
||||
return song
|
||||
|
||||
def add_song_start(self, song: Song) -> Song:
|
||||
self.__queue.insert(0, song)
|
||||
return song
|
||||
|
||||
def shuffle(self) -> None:
|
||||
random.shuffle(self.__queue)
|
||||
|
||||
|
||||
@@ -1,15 +1,20 @@
|
||||
from time import time
|
||||
|
||||
|
||||
class Song:
|
||||
def __init__(self, identifier: str, playlist, requester: str) -> None:
|
||||
self.__identifier = identifier
|
||||
self.__info = {'requester': requester}
|
||||
self.__problematic = False
|
||||
self.__playlist = playlist
|
||||
self.__downloadTime: int = time()
|
||||
|
||||
def finish_down(self, info: dict) -> None:
|
||||
if info is None or info == {}:
|
||||
self.destroy()
|
||||
return None
|
||||
|
||||
self.__downloadTime = time()
|
||||
self.__useful_keys = ['duration',
|
||||
'title', 'webpage_url',
|
||||
'channel', 'id', 'uploader',
|
||||
@@ -35,6 +40,10 @@ class Song:
|
||||
self.__info['title'] = ''.join(char if char.isalnum() or char ==
|
||||
' ' else ' ' for char in self.__info['title'])
|
||||
|
||||
@property
|
||||
def downloadTime(self) -> int:
|
||||
return self.__downloadTime
|
||||
|
||||
@property
|
||||
def source(self) -> str:
|
||||
if 'url' in self.__info.keys():
|
||||
@@ -42,6 +51,10 @@ class Song:
|
||||
else:
|
||||
return None
|
||||
|
||||
@source.setter
|
||||
def source(self, value) -> None:
|
||||
self.__info['url'] = value
|
||||
|
||||
@property
|
||||
def title(self) -> str:
|
||||
if 'title' in self.__info.keys():
|
||||
@@ -53,13 +66,17 @@ class Song:
|
||||
def duration(self) -> str:
|
||||
if 'duration' in self.__info.keys():
|
||||
return self.__info['duration']
|
||||
else:
|
||||
return 0.0
|
||||
else: # Default minimum duration
|
||||
return 5.0
|
||||
|
||||
@property
|
||||
def identifier(self) -> str:
|
||||
return self.__identifier
|
||||
|
||||
@identifier.setter
|
||||
def identifier(self, value) -> None:
|
||||
self.__identifier = value
|
||||
|
||||
@property
|
||||
def problematic(self) -> bool:
|
||||
return self.__problematic
|
||||
|
||||
Reference in New Issue
Block a user