More progress re: #34
- Change of direction, LRCLib searches from /lyric/search now use internal cache - which is a PGSQL import of the LRCLib SQLite database. Change to PGSQL was made for performance.
This commit is contained in:
@@ -45,11 +45,11 @@ class Genius:
|
||||
Optional[LyricsResult]: The result, if found - None otherwise.
|
||||
"""
|
||||
try:
|
||||
artist = artist.strip().lower()
|
||||
song = song.strip().lower()
|
||||
artist_name = artist.strip().lower()
|
||||
song_name = song.strip().lower()
|
||||
time_start: float = time.time()
|
||||
logging.info("Searching %s - %s on %s", artist, song, self.label)
|
||||
search_term: str = f"{artist}%20{song}"
|
||||
logging.info("Searching %s - %s on %s", artist_name, song_name, self.label)
|
||||
search_term: str = f"{artist_name}%20{song_name}"
|
||||
returned_lyrics: str = ""
|
||||
async with ClientSession() as client:
|
||||
async with client.get(
|
||||
@@ -100,10 +100,13 @@ class Genius:
|
||||
)
|
||||
for returned in possible_matches
|
||||
]
|
||||
searched: str = f"{artist} - {song}"
|
||||
best_match: tuple = self.matcher.find_best_match(
|
||||
searched: str = f"{artist_name} - {song_name}"
|
||||
best_match: Optional[tuple] = self.matcher.find_best_match(
|
||||
input_track=searched, candidate_tracks=to_scrape
|
||||
)
|
||||
if not best_match:
|
||||
raise InvalidGeniusResponseException("No matching result")
|
||||
|
||||
logging.info("To scrape: %s", to_scrape)
|
||||
((scrape_stub, track), confidence) = best_match
|
||||
scrape_url: str = f"{self.genius_url}{scrape_stub[1:]}"
|
||||
@@ -157,8 +160,8 @@ class Genius:
|
||||
returned_lyrics: str = self.datautils.scrub_lyrics(
|
||||
returned_lyrics
|
||||
)
|
||||
artist: str = track.split(" - ", maxsplit=1)[0]
|
||||
song: str = track.split(" - ", maxsplit=1)[1]
|
||||
artist = track.split(" - ", maxsplit=1)[0]
|
||||
song = track.split(" - ", maxsplit=1)[1]
|
||||
logging.info("Result found on %s", self.label)
|
||||
time_end: float = time.time()
|
||||
time_diff: float = time_end - time_start
|
||||
|
||||
Reference in New Issue
Block a user