fix: genius fallback
	
		
			
	
		
	
	
		
	
		
			All checks were successful
		
		
	
	
		
			
				
	
				ci/woodpecker/push/woodpecker Pipeline was successful
				
			
		
		
	
	
				
					
				
			
		
			All checks were successful
		
		
	
	ci/woodpecker/push/woodpecker Pipeline was successful
				
			This commit is contained in:
		@@ -79,6 +79,8 @@ class Genius(Page):
 | 
				
			|||||||
            artwork.append(url=url)
 | 
					            artwork.append(url=url)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def parse_api_object(self, data: dict) -> Optional[DatabaseObject]:
 | 
					    def parse_api_object(self, data: dict) -> Optional[DatabaseObject]:
 | 
				
			||||||
 | 
					        if data is None:
 | 
				
			||||||
 | 
					            return None
 | 
				
			||||||
        object_type = data.get("_type")
 | 
					        object_type = data.get("_type")
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        artwork = Artwork()
 | 
					        artwork = Artwork()
 | 
				
			||||||
@@ -93,7 +95,7 @@ class Genius(Page):
 | 
				
			|||||||
        })
 | 
					        })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        notes = FormattedText()
 | 
					        notes = FormattedText()
 | 
				
			||||||
        description = data.get("description", {})
 | 
					        description = data.get("description") or {}
 | 
				
			||||||
        if "html" in description:
 | 
					        if "html" in description:
 | 
				
			||||||
            notes.html = description["html"]
 | 
					            notes.html = description["html"]
 | 
				
			||||||
        elif "markdown" in description:
 | 
					        elif "markdown" in description:
 | 
				
			||||||
@@ -113,7 +115,7 @@ class Genius(Page):
 | 
				
			|||||||
                additional_sources.append(Source(ALL_SOURCE_TYPES.TWITTER, f"https://x.com/{data['twitter_name']}/"))
 | 
					                additional_sources.append(Source(ALL_SOURCE_TYPES.TWITTER, f"https://x.com/{data['twitter_name']}/"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            return Artist(
 | 
					            return Artist(
 | 
				
			||||||
                name=data.get("name").strip(),
 | 
					                name=data["name"].strip() if data.get("name") is not None else None,
 | 
				
			||||||
                source_list=[source],
 | 
					                source_list=[source],
 | 
				
			||||||
                artwork=artwork,
 | 
					                artwork=artwork,
 | 
				
			||||||
                notes=notes,
 | 
					                notes=notes,
 | 
				
			||||||
@@ -147,7 +149,7 @@ class Genius(Page):
 | 
				
			|||||||
            if primary_artist is not None:
 | 
					            if primary_artist is not None:
 | 
				
			||||||
                _artist_name = primary_artist.name
 | 
					                _artist_name = primary_artist.name
 | 
				
			||||||
                main_artist_list.append(primary_artist)
 | 
					                main_artist_list.append(primary_artist)
 | 
				
			||||||
            for feature_artist in (*data.get("featured_artists", []), *data.get("producer_artists", []), *data.get("writer_artists", [])):
 | 
					            for feature_artist in (*(data.get("featured_artists") or []), *(data.get("producer_artists") or []), *(data.get("writer_artists") or [])):
 | 
				
			||||||
                artist = self.parse_api_object(feature_artist)
 | 
					                artist = self.parse_api_object(feature_artist)
 | 
				
			||||||
                if artist is not None:
 | 
					                if artist is not None:
 | 
				
			||||||
                    featured_artist_list.append(artist)
 | 
					                    featured_artist_list.append(artist)
 | 
				
			||||||
@@ -201,16 +203,16 @@ class Genius(Page):
 | 
				
			|||||||
            dump_to_file("genius_itemprop_artist.json", content, is_json=True, exit_after_dump=False)
 | 
					            dump_to_file("genius_itemprop_artist.json", content, is_json=True, exit_after_dump=False)
 | 
				
			||||||
            data = json.loads(content)
 | 
					            data = json.loads(content)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            artist = self.parse_api_object(data.get("artist", {}))
 | 
					            artist = self.parse_api_object(data.get("artist"))
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            for e in data.get("artist_albums", []):
 | 
					            for e in (data.get("artist_albums") or []):
 | 
				
			||||||
                r = self.parse_api_object(e)
 | 
					                r = self.parse_api_object(e)
 | 
				
			||||||
                if not isinstance(r, Album):
 | 
					                if not isinstance(r, Album):
 | 
				
			||||||
                    continue
 | 
					                    continue
 | 
				
			||||||
 | 
					
 | 
				
			||||||
                artist.album_collection.append(r)
 | 
					                artist.album_collection.append(r)
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            for e in data.get("artist_songs", []):
 | 
					            for e in (data.get("artist_songs") or []):
 | 
				
			||||||
                r = self.parse_api_object(e)
 | 
					                r = self.parse_api_object(e)
 | 
				
			||||||
                if not isinstance(r, Song):
 | 
					                if not isinstance(r, Song):
 | 
				
			||||||
                    continue
 | 
					                    continue
 | 
				
			||||||
@@ -243,7 +245,7 @@ class Genius(Page):
 | 
				
			|||||||
            dump_to_file("genius_itemprop_album.json", content, is_json=True, exit_after_dump=False)
 | 
					            dump_to_file("genius_itemprop_album.json", content, is_json=True, exit_after_dump=False)
 | 
				
			||||||
            data = json.loads(content)
 | 
					            data = json.loads(content)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            album = self.parse_api_object(data.get("album", {}))
 | 
					            album = self.parse_api_object(data.get("album"))
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            for e in data.get("album_appearances", []):
 | 
					            for e in data.get("album_appearances", []):
 | 
				
			||||||
                r = self.parse_api_object(e.get("song"))
 | 
					                r = self.parse_api_object(e.get("song"))
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user