From c6832dfebeac98fe2d5ca5c0546d0c18d7e64466 Mon Sep 17 00:00:00 2001 From: "Erik C. Thauvin" Date: Wed, 13 Aug 2003 02:40:14 +0000 Subject: [PATCH] First import. --- index.shtml | 39 +++++++++++++++++ xmmslist.cron | 1 + xmmslist.py | 114 ++++++++++++++++++++++++++++++++++++++++++++++++++ xmmslist.sh | 30 +++++++++++++ 4 files changed, 184 insertions(+) create mode 100644 index.shtml create mode 100644 xmmslist.cron create mode 100755 xmmslist.py create mode 100755 xmmslist.sh diff --git a/index.shtml b/index.shtml new file mode 100644 index 0000000..e177773 --- /dev/null +++ b/index.shtml @@ -0,0 +1,39 @@ + + + + +Erik's Playlist + + + +Erik's Playlist +
+
+ + + + + + + + + + + +
Song Title Artist Album

+
+
+ + diff --git a/xmmslist.cron b/xmmslist.cron new file mode 100644 index 0000000..ba4b9d6 --- /dev/null +++ b/xmmslist.cron @@ -0,0 +1 @@ +*/15 * * * * ${HOME}/bin/xmmslist.sh diff --git a/xmmslist.py b/xmmslist.py new file mode 100755 index 0000000..f0dd76e --- /dev/null +++ b/xmmslist.py @@ -0,0 +1,114 @@ +#!/usr/bin/python + +# +# File: xmmslist.py +# +# Function: Shell-command for XMMS Song Change plugin. +# +# Author(s): Erik C. Thauvin (erik@thauvin.net) +# +# Copyright: Copyright (C) 2003 Erik C. Thauvin +# All Rights Reserved. +# +# Source: Started anew. +# +# Notes: See the README file for more information. +# +# History: +# +# 2003-08-11 ECT Initial coding. +# +# +# Disclaimer: +# +# This software is provided "as is" without express or implied warranties. +# Permission is granted to use, copy, modify and distribute this software, +# provided this disclaimer and copyright are preserved on all copies. This +# software may not, however, be sold or distributed for profit, or included +# with other software which is sold or distributed for profit, without the +# permission of the author. +# +# $Id$ + +import sys +import re +import cgi +import urllib +import time +import os.path + +# The script version number +version='0.1' + +# The output file +playlist=os.path.expanduser('~/bin/playlist.txt') + +# The maximum number of songs to keep in the playlist +maxsongs=20 + +# The song search URL +songsearch='http://www.lyricsstation.com/search.asp?R1=V1&txtSearch=' + +# The artist search URL +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=' + + +if len(sys.argv) > 1: + # XMMS title format should be set to: %p -- %t -- %a + # e.g.: The Artist -- The Song -- The Album + m = re.search('(.*) -- (.*) -- (.*)', sys.argv[1]) + if m: + + try: + f = open(playlist, 'r') + lines = f.readlines() + f.close() + except IOError: + lines = '' + + song = '' + + # Song + if len(m.group(2)) >= 1: + song += '' + cgi.escape(m.group(2)) + '' + else: + song += 'n/a' + + song += ' ' + + # Artist + if len(m.group(1)) >= 1: + song += '' + cgi.escape(m.group(1)) + '' + else: + song += 'n/a' + + song += ' ' + + # Album + if len(m.group(3)) >= 1: + song += '' + cgi.escape(m.group(3)) + '' + else: + song += 'n/a' + + song += '\n' + + f = open(playlist, 'w') + f.write(song) + + stop = len(lines) - 1 + if stop > 0: + i = 1 + for line in lines: + if song != line: + f.write(line) + i += 1 + if i >= maxsongs or i > stop: + break + + # Last Update + f.write('

' + time.strftime('Updated on %B %d, %Y at %H:%M %Z') + '' + os.path.basename(sys.argv[0]) + ' ' + version + '\n') + + f.close() diff --git a/xmmslist.sh b/xmmslist.sh new file mode 100755 index 0000000..30a86f3 --- /dev/null +++ b/xmmslist.sh @@ -0,0 +1,30 @@ +#!/bin/sh + +# +# xmmslist.sh +# +# Transfers the xmmslist playlist to a Web server. See the README file for +# more information. +# +# Copyright (C) 2003 Erik C. Thauvin. All rights reserved. +# +# This software is provided "as is" without express or implied warranties. +# +# Permission is granted to use, copy, modify and distribute this software, +# provided this disclaimer and copyright are preserved on all copies. This +# software may not, however, be sold or distributed for profit, or included +# with other software which is sold or distributed for profit, without the +# permission of the author. +# +# $Id$ + +# The receiving host name +RHOST="nix.thauvin.net" + +# The receiving host location +RLOC="/var/www/html/erik/tunez/" + +if test -n "`ps -cx|grep xmms$`"; then + # ncftpput -u user -p password ${RHOST} ${RLOC} ${HOME}/bin/playlist.txt + scp -q ${HOME}/bin/playlist.txt ${RHOST}:${RLOC} +fi