mirror of https://github.com/captn3m0/Scripts.git
Updating the music display in statusbar
This commit is contained in:
parent
757fdac685
commit
7eca894f8c
|
@ -1,3 +1,12 @@
|
|||
current_song="$HOME/.cmus/now-playing.txt"
|
||||
# curl -s http://www.last.fm/user/captn3m0 > /tmp/lastfm.html
|
||||
|
||||
cat $current_song
|
||||
current_song=""
|
||||
if [[ LASTFM_SONG="$(python get_current_track.py)" ]]; then
|
||||
current_song="$HOME/.cmus/lastfm.txt"
|
||||
echo $(/usr/bin/python get_current_track.py) > $current_song 2>&1
|
||||
# echo $(which python) > $current_song
|
||||
else
|
||||
current_song="$HOME/.cmus/now-playing.txt"
|
||||
fi
|
||||
cat $current_song
|
||||
exit 0
|
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from bs4 import BeautifulSoup
|
||||
try:
|
||||
with open('/tmp/lastfm.html', 'r') as myfile:
|
||||
data = myfile.read()
|
||||
soup = BeautifulSoup(data, 'html.parser')
|
||||
chartlist = soup.find(class_="chartlist-now-scrobbling").parent.parent.find(class_='chartlist-name').get_text().strip().replace('\n', '')
|
||||
print(chartlist)
|
||||
except Exception as e:
|
||||
print("FAILED")
|
||||
exit(1)
|
Loading…
Reference in New Issue