refactor(youtubedl): add __repr__ and __str__ implementations
This commit is contained in:
parent
286df89085
commit
1359c1c96d
19
youtubedl.py
19
youtubedl.py
@ -5,7 +5,6 @@ import disnake
|
|||||||
import yt_dlp
|
import yt_dlp
|
||||||
|
|
||||||
import constants
|
import constants
|
||||||
import utils
|
|
||||||
|
|
||||||
ytdl = yt_dlp.YoutubeDL(constants.YTDL_OPTIONS)
|
ytdl = yt_dlp.YoutubeDL(constants.YTDL_OPTIONS)
|
||||||
|
|
||||||
@ -43,6 +42,12 @@ class YTDLSource(disnake.PCMVolumeTransformer):
|
|||||||
data=data,
|
data=data,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"<YTDLSource title={self.title} original_url=<{self.original_url}> duration={self.duration}>"
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.__repr__()
|
||||||
|
|
||||||
|
|
||||||
class QueuedPlayer:
|
class QueuedPlayer:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -61,6 +66,12 @@ class QueuedPlayer:
|
|||||||
def queue_add_front(self, item):
|
def queue_add_front(self, item):
|
||||||
self.queue.insert(0, item)
|
self.queue.insert(0, item)
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"<QueuedPlayer current={self.current} queue={self.queue}>"
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.__repr__()
|
||||||
|
|
||||||
|
|
||||||
class QueuedSong:
|
class QueuedSong:
|
||||||
def __init__(self, player, queuer):
|
def __init__(self, player, queuer):
|
||||||
@ -81,6 +92,12 @@ class QueuedSong:
|
|||||||
del segments[0]
|
del segments[0]
|
||||||
return f"{':'.join(f'{s:0>2}' for s in segments)}"
|
return f"{':'.join(f'{s:0>2}' for s in segments)}"
|
||||||
|
|
||||||
|
def __repr__(self):
|
||||||
|
return f"<QueuedSong player={self.player} queuer={self.queuer}>"
|
||||||
|
|
||||||
|
def __str__(self):
|
||||||
|
return self.__repr__()
|
||||||
|
|
||||||
|
|
||||||
def __reload_module__():
|
def __reload_module__():
|
||||||
global ytdl
|
global ytdl
|
||||||
|
Loading…
x
Reference in New Issue
Block a user