[Jsign-commits] CVS: pyweb cddb.py,NONE,1.1 news.py,1.2,1.3
Brought to you by:
borillo
|
From: Ricardo B. D. <bo...@us...> - 2001-09-10 11:51:28
|
Update of /cvsroot/jsign/pyweb
In directory usw-pr-cvs1:/tmp/cvs-serv28690
Modified Files:
news.py
Added Files:
cddb.py
Log Message:
Soporte para CDDB en lugar de FREEDB !!
--- NEW FILE: cddb.py ---
import urllib, re, sys, string
class cddb:
def __init__(self):
self.URL="http://www.cddb.com/"
def querygroup(self,grupo):
url = self.URL + "php/search1.php3?f=artist&q=" + grupo
while url<>"":
urllib.urlretrieve(url,"querygroup.tmp")
page = open('querygroup.tmp').read()
# Buscamos todos los enlaces a los discos
discos = re.findall("\<A HREF=\"\/xm\/cd\/[^\>]*\>[^\<]*\<\/A\>",page)
if len(discos) == 0:
print "No se ha encontrado ningún resultado."
return
for disco in discos:
disc_url=re.search("xm\/cd\/[^\"\>\/]*/[^\"\>]*", disco).group()
self.querydisc(disc_url)
next = re.findall("A HREF=[^\>]*>[^;]*;NEXT",page)
if len(next) >0:
url = str(re.findall("xm[^\"]*\"",str(next)))
url = self.URL + url[2:-3]
else:
url = ""
def querydisc(self, disc_url):
urllib.urlretrieve(self.URL+disc_url,"querydisc.tmp")
page = open("querydisc.tmp").readlines()
track_n = 1
for line in page:
if re.search("f=artist", line):
artist=str(re.findall("f=artist[^\<]*\<", line))[12:-3]
artist=trans_car(artist)
disc=str(re.findall("f=disc[^\<]*\<", line))[10:-3]
disc = trans_car(disc)
track_n = 1
print "\n[" + urllib.unquote(artist) + " / " + disc +"]"
elif re.search("f=track", line):
track = str(re.findall("f=track[^\<]*\<", line))[11:-3]
track = trans_car(track)
print "\t" + string.zfill(str(track_n),2) + " - "+ track
track_n = track_n + 1
def trans_car(cad):
cad = string.replace(cad,"&","&")
cad = string.replace(cad,"'","'")
cad = string.replace(cad,""","\"")
cad = string.replace(cad,"#","#")
return cad
if __name__ == "__main__":
consulta = cddb()
group=""
if len(sys.argv) == 1:
print "Modo de uso:",sys.argv[0],"<nombre del grupo>"
for i in sys.argv[1:]:
group=group+i+"+"
consulta.querygroup(group[0:-1])
Index: news.py
===================================================================
RCS file: /cvsroot/jsign/pyweb/news.py,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** news.py 2001/08/31 07:10:58 1.2
--- news.py 2001/09/10 11:51:22 1.3
***************
*** 81,85 ****
if __name__ == "__main__":
! url = 'http://barrapunto.com/barrapunto.rdf'
np = NewsParser()
parse(urllib.urlopen(url), np)
--- 81,85 ----
if __name__ == "__main__":
! url = 'barrapunto.rdf'
np = NewsParser()
parse(urllib.urlopen(url), np)
|