Skip to content
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

Fix falso positive lyric pages for Tekstowo #3905

Merged
merged 3 commits into from
Apr 12, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions beetsplug/lyrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,16 @@ class Tekstowo(Backend):

def fetch(self, artist, title):
url = self.build_url(title, artist)
print(url)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like stray debugging lines.

search_results = self.fetch_url(url)
song_page_url = self.parse_search_results(search_results)

if not song_page_url:
return None

print('--------------------')
print(song_page_url)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto.

song_page_html = self.fetch_url(song_page_url)
return self.extract_lyrics(song_page_html)

Expand All @@ -437,8 +441,14 @@ def parse_search_results(self, html):
except HTMLParseError:
return None

song_row = html.find("div", class_="content"). \
find_all("div", class_="box-przeboje")[0]
song_rows = html.find("div", class_="content"). \
find("div", class_="card"). \
find_all("div", class_="box-przeboje")

if len(song_rows) < 1:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not song_rows should be equivalent.

return None

song_row = song_rows[0]

if not song_row:
return None
Expand Down
2 changes: 2 additions & 0 deletions docs/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -353,6 +353,8 @@ Fixes:
:bug:`3870`
* Allow equals within ``--set`` value when importing.
:bug:`2984`
* :doc:`/plugins/lyrics`: Fix crashes for Tekstowo false positives
:bug:`3904`

For plugin developers:

Expand Down