Compare commits
6 commits
Author | SHA1 | Date | |
---|---|---|---|
6bce98ea9e | |||
c639414ec3 | |||
4ffd817961 | |||
4bf541ae87 | |||
b4b43aa936 | |||
6d87523bbf |
3 changed files with 21 additions and 15 deletions
|
@ -1,7 +1,7 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="900">
|
||||
<meta http-equiv="refresh" content="420">
|
||||
<title>Erik's Playlist</title>
|
||||
<style type="text/css">
|
||||
body, th, td {font-family:verdana, sans-serif; font-size:70%; line-height:150%}
|
||||
|
|
|
@ -1 +1 @@
|
|||
*/15 * * * * ${HOME}/bin/xmmslist.sh
|
||||
*/7 * * * * ${HOME}/bin/xmmslist.sh
|
||||
|
|
30
xmmslist.py
30
xmmslist.py
|
@ -46,14 +46,17 @@ playlist=os.path.expanduser('~/bin/playlist.txt')
|
|||
# The maximum number of songs to keep in the playlist
|
||||
maxsongs=20
|
||||
|
||||
# The song search URL
|
||||
# The song search tooltip and URL
|
||||
songtip='Search for the lyrics of this song.'
|
||||
songsearch='http://www.lyricsstation.com/search.asp?R1=V1&txtSearch='
|
||||
|
||||
# The artist search URL
|
||||
# The artist search tooltip and URL
|
||||
bandtip='Search for this artist on Google.'
|
||||
bandsearch='"http://www.google.com/search?cat=gwd%2FTop%2FArts%2FMusic&q='
|
||||
|
||||
# The album search URL
|
||||
albumsearch='http://www.cduniverse.com/sresult.asp?HT_Search=TITLE&HT_Search_Info='
|
||||
# The album search tooltip and URL
|
||||
albumtip='Search for this album on freedb.'
|
||||
albumsearch='http://www.freedb.org/freedb_search.php?allfields=NO&fields=artist&fields=title&allcats=YES&grouping=cats&words='
|
||||
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
|
@ -63,17 +66,19 @@ if len(sys.argv) > 1:
|
|||
if m:
|
||||
|
||||
try:
|
||||
if (os.path.getsize(playlist) == 0):
|
||||
time.sleep(1)
|
||||
f = open(playlist, 'r')
|
||||
lines = f.readlines()
|
||||
f.close()
|
||||
except IOError:
|
||||
lines = ''
|
||||
|
||||
song = ''
|
||||
song = '<tr valign="top">'
|
||||
|
||||
# Song
|
||||
if len(m.group(2)) >= 1:
|
||||
song += '<tr valign="top"><td><a href="' + songsearch + urllib.quote_plus(m.group(2)) + '" target="_blank">' + cgi.escape(m.group(2)) + '</a></td>'
|
||||
song += '<td><a title="' + songtip + '" href="' + songsearch + urllib.quote_plus(m.group(2)) + '" target="_blank">' + cgi.escape(m.group(2)) + '</a></td>'
|
||||
else:
|
||||
song += '<td><font color="gray">n/a</font></td>'
|
||||
|
||||
|
@ -81,7 +86,7 @@ if len(sys.argv) > 1:
|
|||
|
||||
# Artist
|
||||
if len(m.group(1)) >= 1:
|
||||
song += '<td><a href=' + bandsearch + urllib.quote_plus('"' + m.group(1) + '"') + '" target="_blank">' + cgi.escape(m.group(1)) + '</a></td>'
|
||||
song += '<td><a title="' + bandtip + '" href=' + bandsearch + urllib.quote_plus('"' + m.group(1) + '"') + '" target="_blank">' + cgi.escape(m.group(1)) + '</a></td>'
|
||||
else:
|
||||
song += '<td><font color="gray">n/a</font></td>'
|
||||
|
||||
|
@ -89,26 +94,27 @@ if len(sys.argv) > 1:
|
|||
|
||||
# Album
|
||||
if len(m.group(3)) >= 1:
|
||||
song += '<td><a href="' + albumsearch + urllib.quote_plus(m.group(3)) + '" target="_blank">' + cgi.escape(m.group(3)) + '</a></td>'
|
||||
song += '<td><a title="'+ albumtip + '" href="' + albumsearch + urllib.quote_plus((m.group(1) + ' ' + m.group(3)).replace('(', '').replace(')', '').replace('.', '')) + '" target="_blank">' + cgi.escape(m.group(3)) + '</a></td>'
|
||||
else:
|
||||
song += '<td><font color="gray">n/a</font></td>'
|
||||
|
||||
song += '</tr>\n'
|
||||
|
||||
f = open(playlist, 'w')
|
||||
f.write(song)
|
||||
plist = song
|
||||
|
||||
stop = len(lines) - 1
|
||||
if stop > 0:
|
||||
i = 1
|
||||
for line in lines:
|
||||
if song != line:
|
||||
f.write(line)
|
||||
plist += line
|
||||
i += 1
|
||||
if i >= maxsongs or i > stop:
|
||||
break
|
||||
|
||||
# Last Update
|
||||
f.write('<tr><td colspan="3" valign="bottom" align="left"><br><br><small>' + time.strftime('Updated on %B %d, %Y at %H:%M %Z') + '</small></td><td colspan="2" valign="bottom" align="right"><small><a href="http://www.thauvin.net/blog/stories.jsp?id=5#xmmslist" class="small" target="_blank">' + os.path.basename(sys.argv[0]) + '</a> ' + version + '</small></td></tr>\n')
|
||||
plist += ('<tr><td colspan="3" valign="bottom" align="left"><br><br><small>' + time.strftime('Updated on %B %d, %Y at %H:%M %Z') + '</small></td><td colspan="2" valign="bottom" align="right"><small><a href="http://www.thauvin.net/blog/stories.jsp?id=5#xmmslist" class="small" target="_blank">' + os.path.basename(sys.argv[0]) + '</a> ' + version + '</small></td></tr>\n')
|
||||
|
||||
f = open(playlist, 'w')
|
||||
f.write(plist)
|
||||
f.close()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue