need to fix another fcking thing fck refactoring
This commit is contained in:
@@ -21,59 +21,58 @@ class Download:
|
||||
def __init__(self) -> None:
|
||||
self.urls = []
|
||||
|
||||
for row in temp_database.get_tracks_without_src():
|
||||
row['artists'] = [artist['name'] for artist in row['artists']]
|
||||
for song in temp_database.get_tracks_without_src():
|
||||
|
||||
id_ = row['id']
|
||||
if os.path.exists(os.path.join(MUSIC_DIR, row['file'])):
|
||||
logger.info(f"skipping the fetching of the download links, cuz {row['file']} already exists.")
|
||||
id_ = song['id']
|
||||
if os.path.exists(song.target.file):
|
||||
logger.info(f"skipping the fetching of the download links, cuz {song['file']} already exists.")
|
||||
continue
|
||||
|
||||
"""
|
||||
not implemented yet, will in one point crashe everything
|
||||
# check File System
|
||||
file_path = file_system.get_path(row)
|
||||
file_path = file_system.get_path(song)
|
||||
if file_path is not None:
|
||||
self.add_url(file_path, 'file', id_)
|
||||
continue
|
||||
"""
|
||||
"""
|
||||
# check YouTube
|
||||
youtube_url = youtube.Youtube.fetch_source(row)
|
||||
youtube_url = youtube.Youtube.fetch_source(song)
|
||||
if youtube_url is not None:
|
||||
self.add_url(youtube_url, 'youtube', id_)
|
||||
continue
|
||||
|
||||
# check musify
|
||||
musify_url = musify.Musify.fetch_source(row)
|
||||
musify_url = musify.Musify.fetch_source(song)
|
||||
if musify_url is not None:
|
||||
self.add_url(musify_url, 'musify', id_)
|
||||
continue
|
||||
|
||||
# check musify again, but with a different methode that takes longer
|
||||
musify_url = musify.get_musify_url_slow(row)
|
||||
musify_url = musify.get_musify_url_slow(song)
|
||||
if musify_url is not None:
|
||||
self.add_url(musify_url, 'musify', id_)
|
||||
continue
|
||||
"""
|
||||
for src in AUDIO_SOURCES:
|
||||
res = Download.fetch_from_src(row, src)
|
||||
res = Download.fetch_from_src(song, src)
|
||||
if res is not None:
|
||||
Download.add_url(res, src, id_)
|
||||
|
||||
logger.warning(f"Didn't find any sources for {row['title']}")
|
||||
logger.warning(f"Didn't find any sources for {song}")
|
||||
|
||||
@staticmethod
|
||||
def fetch_from_src(row: dict, src: str):
|
||||
def fetch_from_src(song, src):
|
||||
if src not in sources:
|
||||
raise ValueError(f"source {src} seems to not exist")
|
||||
|
||||
source_subclass = sources[src]
|
||||
return source_subclass.fetch_source(row)
|
||||
return source_subclass.fetch_source(song)
|
||||
|
||||
@staticmethod
|
||||
def add_url(url: str, src: str, id_: str):
|
||||
database.set_download_data(id_, url, src)
|
||||
temp_database.set_download_data(id_, url, src)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
@@ -47,7 +47,7 @@ class Youtube(AudioSource):
|
||||
final_result = None
|
||||
results = cls.get_youtube_from_isrc(song.isrc)
|
||||
for result in results:
|
||||
video_title = result.title.lower()
|
||||
video_title = result['title'].lower()
|
||||
match, distance = phonetic_compares.match_titles(video_title, real_title)
|
||||
|
||||
if match:
|
||||
|
||||
Reference in New Issue
Block a user