Fix youtube downloading wrong track, saving exceptions, attempt to fix deezer

This commit is contained in:
BarsTiger
2023-10-30 23:39:54 +02:00
parent 2ae18aacae
commit 8cd956388e
13 changed files with 272 additions and 39 deletions

View File

@@ -38,16 +38,26 @@ class SongItem(BaseSongItem):
class Songs(object):
ytm: ytmusicapi.YTMusic
def search(self, query: str, limit: int = 10) -> list[SongItem] | None:
r = self.ytm.search(query, limit=limit, filter='songs')
def search(
self,
query: str,
limit: int = 10,
exact_match: bool = False
) -> list[SongItem] | None:
r = self.ytm.search(
query,
limit=limit,
filter='songs',
ignore_spelling=exact_match
)
if r is None:
return None
return [SongItem.from_youtube(song_item) for song_item in r]
def search_one(self, query: str) -> SongItem | None:
return (self.search(query, limit=1) or [None])[0]
def search_one(self, query: str, exact_match: bool = False) -> SongItem | None:
return (self.search(query, limit=1, exact_match=exact_match) or [None])[0]
def from_id(self, song_id: str) -> SongItem | None:
r = self.ytm.get_song(song_id)