-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Lyrics: Refactor Genius, Google backends, and consolidate common functionality #5474
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
snejus
force-pushed
the
lyrics-general-improvements
branch
5 times, most recently
from
October 20, 2024 17:05
13b52ec
to
fed32d9
Compare
snejus
force-pushed
the
fix-lrclib-lyrics
branch
from
October 23, 2024 04:01
e914d59
to
73e4a5a
Compare
snejus
force-pushed
the
lyrics-general-improvements
branch
5 times, most recently
from
October 26, 2024 16:32
1497893
to
cb559f0
Compare
snejus
force-pushed
the
fix-lrclib-lyrics
branch
from
October 30, 2024 19:23
8d6762f
to
16188fa
Compare
snejus
force-pushed
the
lyrics-general-improvements
branch
from
October 30, 2024 19:24
cb559f0
to
95c954a
Compare
3 tasks
snejus
force-pushed
the
fix-lrclib-lyrics
branch
from
November 22, 2024 07:34
16188fa
to
79b2af5
Compare
snejus
force-pushed
the
lyrics-general-improvements
branch
from
November 22, 2024 07:45
95c954a
to
ebf136f
Compare
snejus
force-pushed
the
fix-lrclib-lyrics
branch
from
December 7, 2024 16:57
79b2af5
to
b879e9c
Compare
snejus
force-pushed
the
lyrics-general-improvements
branch
from
December 7, 2024 16:59
ebf136f
to
09c0b9f
Compare
snejus
force-pushed
the
fix-lrclib-lyrics
branch
from
January 12, 2025 22:39
b879e9c
to
645c12e
Compare
snejus
force-pushed
the
lyrics-general-improvements
branch
from
January 12, 2025 22:39
09c0b9f
to
83c125c
Compare
snejus
force-pushed
the
fix-lrclib-lyrics
branch
from
January 12, 2025 23:12
645c12e
to
121ae5f
Compare
snejus
force-pushed
the
lyrics-general-improvements
branch
from
January 12, 2025 23:12
83c125c
to
4531297
Compare
snejus
force-pushed
the
fix-lrclib-lyrics
branch
from
January 13, 2025 22:55
121ae5f
to
788a1d7
Compare
Having removed it I fuond that only the Genius lyrics changed: it had en extra new line. Thus I defined a function 'collapse_newlines' which now gets called for the Genius lyrics.
Tidy up 'Google.is_page_candidate' method and remove 'Google.sluggify' method which was a duplicate of 'slug'. Since 'GeniusFetchTest' only tested whether the artist name is cleaned up (the rest of the functionality is patched), remove it and move its test cases to the 'test_slug' test.
snejus
force-pushed
the
lyrics-general-improvements
branch
4 times, most recently
from
January 27, 2025 10:40
7f51480
to
50ac6ca
Compare
3 tasks
* Type the response data that Google Custom Search API return. * Exclude some 'letras.mus.br' pages that do not contain lyric. * Exclude results from Musixmatch as we cannot access their pages. * Improve parsing of the URL title: - Handle long URL titles that get truncated (end with ellipsis) for long searches - Remove domains starting with 'www' - Parse the title AND the artist. Previously this would only parse the title, and fetch lyrics even when the artist did not match. * Remove now redundant credits cleanup and checks for valid lyrics.
Additionally, improve HTML pre-processing: * Ensure a new line between blocks of lyrics text from letras.mus.br. * Parse a missing last block of lyrics text from lacocinelle.net. * Parse a missing last block of lyrics text from paroles.net. * Fix encoding issues with AZLyrics by setting response encoding to None, allowing `requests` to handle it.
If we get caught by Cloudfare, it forwards our request somewhere else and returns some validation text response. To make sure that this text does not get assumed for lyrics, we can disable redirects for the Google backend, check the response code and raise if there's a redirect attempt. This source will then be skipped and the backend continues with the next one.
I think we can make our life easier by removing these checks assuming that users follow the instructions in the docs.
It was my mistake to remove search earlier - I found that in many cases it works fine.
snejus
force-pushed
the
lyrics-general-improvements
branch
from
January 27, 2025 10:57
50ac6ca
to
dab9a0d
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
I've made several updates to the lyrics plugin to enhance its functionality and address a few bugs. Here's a quick overview of what has changed:
Bug Fixes
Plugin Enhancements
TimeoutSession
to enable connection pooling and maintain consistent configuration across requests.RequestsHandler
class, which includes methods for retrieving either HTML text or JSON data.Configuration Changes
dist_thresh
field to the configuration, allowing users to control the maximum tolerable mismatch between the artist and title of the lyrics search result and their item. Interestingly, this field was previously available (though undocumented) and used in theTekstowo
backend. Now, this threshold has also been applied to Genius and Google search logic.Backend Updates
dist_thresh
.Genius
Google
dist_thresh
value are discarded. The previous functionality simply selected the first result containing the track's title in its URL, which often led to returning lyrics for the wrong artist, particularly for short track titles.HTML Cleanup
Html
class.letras.mus.br
andmusica.com
.paroles.net
andlacoccinelle.net
. See the diff intest/plugins/lyrics_page.py
.To Do
docs/
to describe it.docs/changelog.rst
at the bottom of one of the lists near the top of the document.Note: If you find this PR too large to manage, I am happy to split it up!