Skip to content

Commit 2f246a1

Browse files
authored
update lyrics library (#92)
* update lyrics library. went from - lyricwikia (not supported) to - lyriq (supported) * update README, requirements and removed comment from spotifycli.py
1 parent b076446 commit 2f246a1

File tree

3 files changed

+15
-13
lines changed

3 files changed

+15
-13
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ if you don't use any parameters, you'll enter the shell mode, where you'll be ab
7777
solving problems
7878
----------------
7979

80-
### lyricwikia
80+
### lyriq
8181

82-
When, you're missing `lyricwikia` dependency, run the following command:
82+
When, you're missing `lyriq` dependency, run the following command:
8383

8484
```
85-
pip install lyricwikia
85+
pip install lyriq
8686
```
8787

8888
usage with tmux

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
autopep8
22
jeepney
3-
lyricwikia
3+
lyriq
44
pycodestyle
55
pylint
66
setuptools

spotifycli/spotifycli.py

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
import textwrap
99
import datetime
1010
from subprocess import Popen, PIPE
11+
import logging
12+
import lyriq
1113

12-
import lyricwikia
14+
logging.getLogger("lyriq.lyriq").setLevel(logging.CRITICAL)
1315

1416
from jeepney import DBusAddress, new_method_call
1517
from jeepney.io.blocking import open_dbus_connection
@@ -229,14 +231,14 @@ def show_song_short():
229231

230232
def show_lyrics():
231233
artist, title = get_song()
232-
try:
233-
lyrics = lyricwikia.get_all_lyrics(artist, title)
234-
except lyricwikia.LyricsNotFound:
235-
raise SpotifyCLIException(
236-
'Lyrics not found or could not connect'
237-
) from None
238-
lyrics = ''.join(lyrics[0])
239-
print(lyrics)
234+
lyrics = lyriq.get_lyrics(title, artist)
235+
236+
if lyrics is None:
237+
print(f"Lyrics for '{title}' by {artist} were not found.")
238+
print("This could happen if the track is missing from the lyrics database or is unsupported.")
239+
return
240+
241+
print(lyrics.plain_lyrics)
240242

241243

242244
def show_artist():

0 commit comments

Comments
 (0)