Minor fix youtube

This commit is contained in:
BarsTiger
2023-10-24 18:12:07 +03:00
parent b5e4f55de3
commit 495202d949
2 changed files with 9 additions and 8 deletions

View File

@@ -27,13 +27,6 @@ class YouTubeBytestream:
duration=int(duration),
)
@property
def dict(self):
return {
"file": self.file,
"filename": self.filename
}
@define
class Downloader:

View File

@@ -31,7 +31,7 @@ class SongItem:
return f"{self.all_artists} - {self.name}"
def __str__(self):
return f"{', '.join(self.artists)} - {self.name}"
return self.full_name
def to_bytestream(self) -> Awaitable[YouTubeBytestream]:
return Downloader.from_id(self.id).to_bytestream()
@@ -51,3 +51,11 @@ class Songs(object):
def search_one(self, query: str) -> SongItem | None:
return (self.search(query, limit=1) or [None])[0]
def from_id(self, song_id: str) -> SongItem | None:
r = self.ytm.get_song(song_id)
if r is None:
return None
return SongItem.from_youtube(r)