This commit is contained in:
lars 2022-11-13 23:56:43 +01:00
parent fbbcd499c5
commit 5be0b3be64
4 changed files with 19 additions and 7 deletions

View File

@ -107,4 +107,4 @@ def cli(start_at: int = 0, only_lyrics: bool = False):
if __name__ == "__main__": if __name__ == "__main__":
cli(start_at=0, only_lyrics=True) cli(start_at=3, only_lyrics=False)

View File

@ -33,7 +33,10 @@ class MetadataDownloader:
self.musicbrainz_artistid = musicbrainz_artistid self.musicbrainz_artistid = musicbrainz_artistid
try:
result = musicbrainzngs.get_artist_by_id(self.musicbrainz_artistid, includes=["release-groups", "releases"]) result = musicbrainzngs.get_artist_by_id(self.musicbrainz_artistid, includes=["release-groups", "releases"])
except musicbrainzngs.musicbrainz.NetworkError:
return
artist_data = get_elem_from_obj(result, ['artist'], return_if_none={}) artist_data = get_elem_from_obj(result, ['artist'], return_if_none={})
self.artist = get_elem_from_obj(artist_data, ['name']) self.artist = get_elem_from_obj(artist_data, ['name'])
@ -85,8 +88,11 @@ class MetadataDownloader:
self.artists = artists self.artists = artists
self.releases = [] self.releases = []
try:
result = musicbrainzngs.get_release_group_by_id(musicbrainz_releasegroupid, result = musicbrainzngs.get_release_group_by_id(musicbrainz_releasegroupid,
includes=["artist-credits", "releases"]) includes=["artist-credits", "releases"])
except musicbrainzngs.musicbrainz.NetworkError:
return
release_group_data = get_elem_from_obj(result, ['release-group'], return_if_none={}) release_group_data = get_elem_from_obj(result, ['release-group'], return_if_none={})
artist_datas = get_elem_from_obj(release_group_data, ['artist-credit'], return_if_none={}) artist_datas = get_elem_from_obj(release_group_data, ['artist-credit'], return_if_none={})
release_datas = get_elem_from_obj(release_group_data, ['release-list'], return_if_none={}) release_datas = get_elem_from_obj(release_group_data, ['release-list'], return_if_none={})
@ -179,8 +185,11 @@ class MetadataDownloader:
self.release_group = release_group self.release_group = release_group
self.tracklist = [] self.tracklist = []
try:
result = musicbrainzngs.get_release_by_id(self.musicbrainz_albumid, result = musicbrainzngs.get_release_by_id(self.musicbrainz_albumid,
includes=["recordings", "labels", "release-groups"]) includes=["recordings", "labels", "release-groups"])
except musicbrainzngs.musicbrainz.NetworkError:
return
release_data = get_elem_from_obj(result, ['release'], return_if_none={}) release_data = get_elem_from_obj(result, ['release'], return_if_none={})
label_data = get_elem_from_obj(release_data, ['label-info-list'], return_if_none={}) label_data = get_elem_from_obj(release_data, ['label-info-list'], return_if_none={})
recording_datas = get_elem_from_obj(release_data, ['medium-list', 0, 'track-list'], return_if_none=[]) recording_datas = get_elem_from_obj(release_data, ['medium-list', 0, 'track-list'], return_if_none=[])
@ -251,9 +260,12 @@ class MetadataDownloader:
self.track_number = track_number self.track_number = track_number
try:
result = musicbrainzngs.get_recording_by_id(self.musicbrainz_releasetrackid, result = musicbrainzngs.get_recording_by_id(self.musicbrainz_releasetrackid,
includes=["artists", "releases", "recording-rels", "isrcs", includes=["artists", "releases", "recording-rels", "isrcs",
"work-level-rels"]) "work-level-rels"])
except musicbrainzngs.musicbrainz.NetworkError:
return
recording_data = result['recording'] recording_data = result['recording']
release_data = get_elem_from_obj(recording_data, ['release-list', -1]) release_data = get_elem_from_obj(recording_data, ['release-list', -1])
if self.release is None: if self.release is None:

View File

@ -53,7 +53,7 @@ def download_from_musify(file, url):
logging.info(f"downloading: '{url}'") logging.info(f"downloading: '{url}'")
try: try:
r = session.get(url, timeout=15) r = session.get(url, timeout=15)
except requests.exceptions.ConnectionError: except requests.exceptions.ConnectionError or requests.exceptions.ReadTimeout:
return -1 return -1
if r.status_code != 200: if r.status_code != 200:
if r.status_code == 404: if r.status_code == 404:

View File

@ -34,7 +34,7 @@ database = Database(os.path.join(temp_dir, DATABASE_FILE),
os.path.join(temp_dir, DATABASE_STRUCTURE_FILE), os.path.join(temp_dir, DATABASE_STRUCTURE_FILE),
DATABASE_STRUCTURE_FALLBACK, DATABASE_STRUCTURE_FALLBACK,
DATABASE_LOGGER, DATABASE_LOGGER,
reset_anyways=True) reset_anyways=False)
TOR = False TOR = False