[Jsign-commits] CVS: pyweb AudioGalaxy.py,1.1,1.2
Brought to you by:
borillo
|
From: Ricardo B. D. <bo...@us...> - 2001-11-22 14:08:35
|
Update of /cvsroot/jsign/pyweb
In directory usw-pr-cvs1:/tmp/cvs-serv663
Modified Files:
AudioGalaxy.py
Log Message:
Nova actualització de Miguel :)
Index: AudioGalaxy.py
===================================================================
RCS file: /cvsroot/jsign/pyweb/AudioGalaxy.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** AudioGalaxy.py 2001/11/16 09:39:31 1.1
--- AudioGalaxy.py 2001/11/22 14:08:33 1.2
***************
*** 9,15 ****
self.song = self.URL + "/list/song.php?"
self.chooseversion = self.URL + "/list/chooseVersion.php?"
! #la informacion del usuario debe ser leida de las cookies o
! #pedida al usuario
! self.username, self.password = self.readCookie()
tmp=tempfile.mktemp()
urllib.urlretrieve(self.home,tmp)
--- 9,25 ----
self.song = self.URL + "/list/song.php?"
self.chooseversion = self.URL + "/list/chooseVersion.php?"
!
! #la informacion del usuario es leida de las cookies
!
! self.SID, self.username, self.password = self.readCookie()
!
! if self.SID == "" or self.username == "" or self.password=="":
! self.SID = getSID()
! system.stdout.write("Username:")
! self.username=sys.stdin.readline()[:-1]
! system.stdout.write("Password:")
! self.password=sys.stdin.readline()[:-1]
!
! def getSID(self):
tmp=tempfile.mktemp()
urllib.urlretrieve(self.home,tmp)
***************
*** 18,28 ****
a = re.findall("\<input type=\"hidden\" name=\"SID\" value=\"[0-9a-zA-Z]*\"\>",page)[0]
b = string.split(a,"value=\"")[1]
! self.SID=str(b[:-2])
def readCookie(self):
! lc=os.listdir('c:\windows\cookies')
for i in lc:
if string.find(i,"audiogalaxy") != -1:
! f=open("c:\\windows\\cookies\\"+i)
c=f.read()
f.close()
--- 28,44 ----
a = re.findall("\<input type=\"hidden\" name=\"SID\" value=\"[0-9a-zA-Z]*\"\>",page)[0]
b = string.split(a,"value=\"")[1]
! return str(b[:-2])
!
!
def readCookie(self):
! a=os.environ
! cookie_path=a["WINDIR"]+"\\cookies"
!
!
! lc=os.listdir(cookie_path)
for i in lc:
if string.find(i,"audiogalaxy") != -1:
! f=open(cookie_path+"\\"+i)
c=f.read()
f.close()
***************
*** 30,35 ****
username=re.findall("cookieUsername\n[^\n]+\n",c)[0]
password=re.findall("cookiePassword\n[^\n]+\n",c)[0]
! return string.replace(username,"cookieUsername\n","")[:-1], string.replace(password,"cookiePassword\n","")[:-1]
--- 46,52 ----
username=re.findall("cookieUsername\n[^\n]+\n",c)[0]
password=re.findall("cookiePassword\n[^\n]+\n",c)[0]
+ sid=re.findall("SID\n[^\n]+\n",c)[0]
! return string.replace(sid,"SID\n","")[:-1], string.replace(username,"cookieUsername\n","")[:-1], string.replace(password,"cookiePassword\n","")[:-1]
***************
*** 44,48 ****
--- 61,94 ----
return urllib.urlencode(a)
+
+ def match_bitrate(self,match,bitrate):
+ if string.upper(match) == "ANY":
+ return 1
+
+ if match[0] == ">":
+ if match[1] == "=":
+ b=int(match[2:])
+ return int(bitrate) >= b
+ else:
+ b=int(match[1:])
+ return int(bitrate) > b
+ elif match[0] == "<":
+ if match[1] == "=":
+ b=int(match[2:])
+ return int(bitrate) <= b
+ else:
+ b=int(match[1:])
+ return int(bitrate) < b
+
+ elif match[0] == "=":
+ b=int(match[1:])
+ return b==int(bitrate)
+ else:
+ b=int(match)
+ return b==int(bitrate)
+
+
+
def search(self,cad,maxMatches=None):
off=0
***************
*** 484,488 ****
for i in l.keys():
! if l[i][1] != bitrate:
continue
--- 530,534 ----
for i in l.keys():
! if not self.match_bitrate(bitrate,l[i][1]):
continue
***************
*** 492,495 ****
--- 538,542 ----
ls=string.split(l[i][2],":")
sec=int(ls[0])*60+int(ls[1])
+
if (tsec>=(sec-int(diftime))) and (tsec <= (sec+int(diftime))):
***************
*** 602,606 ****
def getAlbumFromDB(self,artist,album,bitrate):
f=freedb()
! l=f.searchDiscs(album)
l=f.filterDiscs(l,artist,album)
--- 649,653 ----
def getAlbumFromDB(self,artist,album,bitrate):
f=freedb()
! l=f.searchDiscs(artist+" "+album)
l=f.filterDiscs(l,artist,album)
***************
*** 616,636 ****
ldisc=ldisc+[(d,t,nt)]
if ldisc != []:
r=-1
! while (r<0 or r>cnt):
! sys.stdout.write("\nElige un disco (s+num para descripcion): ")
c=sys.stdin.readline()
! if string.upper(c[0]) == "S":
c=string.replace(c,"s","")
c=string.replace(c,"S","")
!
! for i in ldisc[int(c)][0]:
! #print i
! sys.stdout.write(i[0]+" - "+i[1]+" - "+i[2]+"\n")
r=-1
else:
! r=int(c[:-1])
if self.getAlbum(ldisc[r][0],artist,album,bitrate) == 0:
--- 663,711 ----
ldisc=ldisc+[(d,t,nt)]
+ ndiscs = cnt
if ldisc != []:
r=-1
! while (r<0 or r>ndiscs):
! sys.stdout.write("\nElige un disco (i para informacion de opciones): ")
!
c=sys.stdin.readline()
!
! if string.upper(c[0]) == "I":
! sys.stdout.write("\nSelecciona un valor para seleccionar un disco.\n")
! sys.stdout.write("I Muestra esta informacion.\n")
! sys.stdout.write("L Lista los discos hallados.\n")
! sys.stdout.write("S+Num Muestra las canciones del disco seleccionado.\n")
! sys.stdout.write("Q Salir del programa.\n")
! r=-1
! elif string.upper(c[0]) == "Q":
! sys.stdout.write("Good Bye")
! sys.exit(0)
! elif string.upper(c[0]) == "L":
! cnt=0
! for i in l:
! print string.rjust(str(cnt),2),i[2]," Tracks:",string.rjust(str(ldisc[cnt][2]),2)," Total Time:",ldisc[cnt][1]
! cnt=cnt+1
! r=-1
! elif string.upper(c[0]) == "S":
c=string.replace(c,"s","")
c=string.replace(c,"S","")
! try:
! ind=int(c)
! except:
! sys.stderr.write("Valor no valido: "+c)
! r=ind
! if (r>=0 and r<=ndiscs):
! sys.stdout.write("\n")
! for i in ldisc[ind][0]:
! #print i
! sys.stdout.write(i[0]+" - "+i[1]+" - "+i[2]+"\n")
r=-1
else:
! try:
! r=int(c[:-1])
! except:
! sys.stderr.write("Valor no valido: "+c)
if self.getAlbum(ldisc[r][0],artist,album,bitrate) == 0:
***************
*** 773,778 ****
sys.stdout.write("Album: ")
album=sys.stdin.readline()[:-1]
! sys.stdout.write("Bitrate: ")
! bitrate=sys.stdin.readline()[:-1]
ag.getAlbumFromDB(artist,album,bitrate)
--- 848,866 ----
sys.stdout.write("Album: ")
album=sys.stdin.readline()[:-1]
!
! bitrate = ""
! while bitrate == "":
! sys.stdout.write("Bitrate ( =,<,>,<=,>= + bitrate o ANY): ")
! bitrate=sys.stdin.readline()[:-1]
! if string.upper(bitrate) != "ANY":
! b=string.replace(bitrate,"=","")
! b=string.replace(b,"<","")
! b=string.replace(b,">","")
! try:
! b=int(b)
! except:
! bitrate = ""
! sys.stderr.write("Bitrate no valido.\n")
!
ag.getAlbumFromDB(artist,album,bitrate)
***************
*** 788,792 ****
bitrate=sys.stdin.readline()[:-1]
ag.getAlbumFromFile(f,bitrate)
! except:
print "El Fichero",f,"no existe."
--- 876,880 ----
bitrate=sys.stdin.readline()[:-1]
ag.getAlbumFromFile(f,bitrate)
! except IOError:
print "El Fichero",f,"no existe."
***************
*** 802,805 ****
--- 890,894 ----
#readCookie()
#search(self,cad,maxMatches=None)
+ #match_bitrate(match,bitrate)
#listVersions(self,code)
#queueSong(self,codSong,codVer)
|