refactored and added for possibility for multiple sources per track

This commit is contained in:
Lars Noack
2022-11-21 14:27:18 +01:00
parent 0f25833da0
commit 58626a7d99
7 changed files with 22 additions and 17 deletions

View File

@@ -156,10 +156,9 @@ class Musify(AudioSource):
return True
@classmethod
def fetch_audio(cls, row: dict):
super().fetch_audio(row)
def fetch_audio(cls, url: str, row: dict):
super().fetch_audio(url, row)
url = row['url']
file_ = row['file']
return cls.download_from_musify(file_, url)

View File

@@ -16,5 +16,5 @@ class AudioSource:
logger.info(f"try getting source {row['title']} from {cls.__name__}")
@classmethod
def fetch_audio(cls, row: dict):
def fetch_audio(cls, url: str,row: dict):
logger.info(f"downloading audio from {row['url']} from {cls.__name__} to {row['file']}")

View File

@@ -59,10 +59,9 @@ class Youtube(AudioSource):
return final_result['url']
@classmethod
def fetch_audio(cls, row: dict, trie: int=0):
super().fetch_audio(row)
def fetch_audio(cls, url: str, row: dict, trie: int=0):
super().fetch_audio(url, row)
url = row['url']
file_ = row['file']
options = {
'format': 'bestaudio/best',
@@ -79,7 +78,7 @@ class Youtube(AudioSource):
logger.warning("too many tries, returning")
logger.warning(f"retrying in {WAIT_BETWEEN_BLOCK} seconds again")
time.sleep(WAIT_BETWEEN_BLOCK)
return cls.fetch_audio(row, trie=trie + 1)
return cls.fetch_audio(url, row, trie=trie + 1)
"""
def get_youtube_from_isrc(isrc: str) -> List[dict]: