Removed unused, commented out sections
git-svn-id: file:///home/anna/Desktop/ocarina-legacy/mithos/ocarina@58 1daee41c-8060-4895-b1f0-2197c00d777a
This commit is contained in:
parent
34f40a7165
commit
a75984f950
|
@ -1,6 +1,7 @@
|
|||
import gtk
|
||||
import gobject
|
||||
import os
|
||||
import thread
|
||||
|
||||
from label import Label
|
||||
from queue import Queue
|
||||
|
@ -38,16 +39,11 @@ class ContentPane(gtk.HBox):
|
|||
def makeLeftSide(self):
|
||||
vbox = gtk.VBox(False,0)
|
||||
vbox.show()
|
||||
|
||||
self.albumArt = Image(None,None)
|
||||
#vbox.pack_start(self.albumArt,False,False,0)
|
||||
vbox.pack_start(self.albumArt,False,False,0)
|
||||
|
||||
self.data.scrobbler = Scrobbler(self.data)
|
||||
vbox.pack_start(self.data.scrobbler,False,False,0)
|
||||
|
||||
self.divider.add(vbox)
|
||||
#self.divider.add1(self.data.scrobbler)
|
||||
|
||||
|
||||
# Right side has tabs, current song info, controls, and more
|
||||
|
@ -128,7 +124,7 @@ class ContentPane(gtk.HBox):
|
|||
self.tabs.show()
|
||||
|
||||
# Ann array of function pointers that gets passed to List
|
||||
funcs = [self.next,self.setLabels,self.plause,self.setAlbumArt]
|
||||
funcs = (self.next,self.setLabels,self.plause,self.setAlbumArt)
|
||||
|
||||
self.queue = Queue(self.data,funcs)
|
||||
self.playlist = Playlist(self.data,self.queue,funcs)
|
||||
|
@ -229,6 +225,7 @@ class ContentPane(gtk.HBox):
|
|||
self.plause(None,None)
|
||||
self.data.scrobbler.nowPlaying(self.data.song.info)
|
||||
self.gotoCurSong()
|
||||
self.changeImg()
|
||||
self.status = ""
|
||||
self.data.dump()
|
||||
|
||||
|
@ -249,14 +246,26 @@ class ContentPane(gtk.HBox):
|
|||
|
||||
# Load album art
|
||||
def setAlbumArt(self,file):
|
||||
file = file.rsplit('/',1)[0]
|
||||
file = file.rsplit(os.path.sep,1)[0]
|
||||
file = os.path.join(file,"AlbumArt.jpg")
|
||||
self.albumArt.hide()
|
||||
# Fetch album art if we don't have it yet
|
||||
if not os.path.exists(file):
|
||||
info = self.data.song.info
|
||||
self.data.scrobbler.fetchAlbumArt(info.artist,info.album,file)
|
||||
self.albumArt.set(file)
|
||||
self.resizeAlbumArt()
|
||||
thread.start_new_thread(self.fetchAlbumArt,(info.artist,info.album,file))
|
||||
else:
|
||||
self.albumArt.set(file)
|
||||
self.resizeAlbumArt()
|
||||
self.albumArt.show()
|
||||
|
||||
|
||||
def fetchAlbumArt(self,artist,album,file):
|
||||
info = self.data.song.info
|
||||
self.data.scrobbler.fetchAlbumArt(artist,album,file)
|
||||
if os.path.exists(file):
|
||||
self.albumArt.set(file)
|
||||
self.resizeAlbumArt()
|
||||
self.albumArt.show()
|
||||
|
||||
|
||||
def resizeAlbumArt(self):
|
||||
|
@ -349,6 +358,7 @@ class ContentPane(gtk.HBox):
|
|||
self.library.storeCols()
|
||||
|
||||
|
||||
# This is called whenever the divider changes
|
||||
def moveDivider(self,pane,event):
|
||||
if event.name=="position":
|
||||
self.data.divider = pane.get_position()
|
||||
|
|
|
@ -16,9 +16,6 @@ class LibList(List):
|
|||
self.pbaralign.show()
|
||||
self.updating = False
|
||||
|
||||
self.populated = False
|
||||
#for file in self.data.library.files:
|
||||
# self.insert(file)
|
||||
self.count = self.data.library.count#len(self.data.library.files)
|
||||
self.makeLabel()
|
||||
self.makeRCMenu()
|
||||
|
@ -33,11 +30,15 @@ class LibList(List):
|
|||
def visible(self,func):
|
||||
List.visible(self,func)
|
||||
if (func == "show") and (self.populated == False):
|
||||
for file in self.data.library.files:
|
||||
List.insert(self,file)
|
||||
self.populated = True
|
||||
self.makeLabel()
|
||||
self.timeText()
|
||||
self.populate()
|
||||
|
||||
|
||||
# Populate the library
|
||||
def populate(self):
|
||||
for file in self.data.library.files:
|
||||
List.insert(self,file)
|
||||
List.populate(self)
|
||||
|
||||
|
||||
def stopUpdates(self):
|
||||
self.updating = False
|
||||
|
@ -54,6 +55,7 @@ class LibList(List):
|
|||
|
||||
def filterRows(self,string):
|
||||
if self.updating == True:
|
||||
self.filterQuick(string)
|
||||
return
|
||||
List.filterRows(self,string)
|
||||
|
||||
|
@ -82,5 +84,5 @@ class LibList(List):
|
|||
|
||||
def insert(self,file):
|
||||
if self.populated == False:
|
||||
self.visible("show")
|
||||
self.populate()
|
||||
List.insert(self,file)
|
||||
|
|
|
@ -5,7 +5,7 @@ from menuItem import MenuItem
|
|||
from song import Song
|
||||
|
||||
class List(gtk.ScrolledWindow):
|
||||
def __init__(self,data,text,(nextFunc,labelFunc,plauseFunc,albumArtFunc)):
|
||||
def __init__(self, data, text, funcs):#(nextFunc,labelFunc,plauseFunc,albumArtFunc) ):
|
||||
gtk.ScrolledWindow.__init__(self)
|
||||
self.show()
|
||||
self.set_policy(gtk.POLICY_AUTOMATIC,gtk.POLICY_AUTOMATIC)
|
||||
|
@ -14,13 +14,18 @@ class List(gtk.ScrolledWindow):
|
|||
self.data = data
|
||||
|
||||
# Function pointers...whoo...
|
||||
self.next = nextFunc
|
||||
self.labels = labelFunc
|
||||
self.plause = plauseFunc
|
||||
self.setAlbumArt = albumArtFunc
|
||||
#self.next = nextFunc
|
||||
#self.labels = labelFunc
|
||||
#self.plause = plauseFunc
|
||||
#self.setAlbumArt = albumArtFunc
|
||||
self.next = funcs[0]
|
||||
self.labels = funcs[1]
|
||||
self.plause = funcs[2]
|
||||
self.setAlbumArt = funcs[3]
|
||||
|
||||
self.count = 0
|
||||
self.seconds = 0
|
||||
self.populated = False
|
||||
|
||||
self.makeList()
|
||||
|
||||
|
@ -37,8 +42,7 @@ class List(gtk.ScrolledWindow):
|
|||
self.filter.set_visible_func(self.hideRows,"")
|
||||
self.sort = gtk.TreeModelSort(self.filter)
|
||||
self.tree.set_model(self.sort)
|
||||
|
||||
#self.align.show()
|
||||
|
||||
|
||||
def makeList(self):
|
||||
self.list = gtk.ListStore(int,str,str,str,str,int)
|
||||
|
@ -260,3 +264,10 @@ class List(gtk.ScrolledWindow):
|
|||
else:
|
||||
width = 110
|
||||
self.cols[i].set_fixed_width(width)
|
||||
|
||||
|
||||
# Called after populating the list
|
||||
def populate(self):
|
||||
self.populated = True
|
||||
self.makeLabel()
|
||||
self.timeText()
|
||||
|
|
|
@ -6,27 +6,27 @@ class Playlist(List):
|
|||
def __init__(self,data,queue,funcs):
|
||||
List.__init__(self,data,"Playlist",funcs)
|
||||
self.queue = queue
|
||||
#for file in self.data.curList:
|
||||
# List.insert(self,file)
|
||||
self.populated = False
|
||||
self.makeRCMenu()
|
||||
|
||||
|
||||
def visible(self,func):
|
||||
List.visible(self,func)
|
||||
if (func == "show") and (self.populated == False):
|
||||
for file in self.data.curList:
|
||||
List.insert(self,file)
|
||||
self.populated = True
|
||||
self.makeLabel()
|
||||
self.timeText()
|
||||
self.populate()
|
||||
|
||||
|
||||
def populate(self):
|
||||
for file in self.data.curList:
|
||||
List.insert(self,file)
|
||||
List.populate(self)
|
||||
|
||||
|
||||
# Insert songs into the list
|
||||
def insert(self,file):
|
||||
if self.populated == False:
|
||||
self.visible("show")
|
||||
self.populate()
|
||||
List.insert(self,file)
|
||||
self.data.curList+=[file]
|
||||
#self.populated = True
|
||||
|
||||
|
||||
def drop(self):
|
||||
|
|
|
@ -4,7 +4,6 @@ class Queue(List):
|
|||
def __init__(self,data,funcs):
|
||||
List.__init__(self,data,"Queue",funcs)
|
||||
self.data = data
|
||||
self.populated = False
|
||||
self.count = len(self.data.curQ)
|
||||
self.makeLabel()
|
||||
|
||||
|
@ -13,7 +12,7 @@ class Queue(List):
|
|||
def getNext(self):
|
||||
# Populate the queue
|
||||
if self.populated == False:
|
||||
self.visible("show")
|
||||
self.populate()
|
||||
# No songs in queue, return false
|
||||
if len(self.list) == 0:
|
||||
return False
|
||||
|
@ -27,8 +26,8 @@ class Queue(List):
|
|||
break
|
||||
self.remove(self.list.get_iter_root())
|
||||
|
||||
# Removed 7/30/2009 (Do I really need to do this?)
|
||||
#self.filterRows(self.string)
|
||||
# Load song and update the label
|
||||
self.filterQuick(self.string)
|
||||
self.loadSong(self.data.library.files[self.data.curSong])
|
||||
return True
|
||||
|
||||
|
@ -37,7 +36,7 @@ class Queue(List):
|
|||
# Updates the visible treeview and the self.data.curQ array
|
||||
def insert(self,file):
|
||||
if self.populated == False:
|
||||
self.visible("show")
|
||||
self.populate()
|
||||
List.insert(self,file)
|
||||
self.data.curQ += [file]
|
||||
|
||||
|
@ -46,11 +45,14 @@ class Queue(List):
|
|||
def visible(self,func):
|
||||
List.visible(self,func)
|
||||
if (func == "show") and (self.populated == False):
|
||||
for file in self.data.curQ:
|
||||
List.insert(self,file)
|
||||
self.populated = True
|
||||
self.makeLabel()
|
||||
self.timeText()
|
||||
self.populate()
|
||||
|
||||
|
||||
# Populate the list
|
||||
def populate(self):
|
||||
for file in self.data.curQ:
|
||||
List.insert(self,file)
|
||||
List.populate(self)
|
||||
|
||||
|
||||
# Filters things quicker because it does not have to show/hide rows
|
||||
|
|
|
@ -93,7 +93,7 @@ class Scrobbler(gtk.VBox):
|
|||
|
||||
|
||||
def handshake(self,widgit,data):
|
||||
print "shaking hands"
|
||||
#print "shaking hands"
|
||||
url = "http://post.audioscrobbler.com/?hs=true"
|
||||
list = [("hs","true")]
|
||||
(url,list) = self.addParam(url,list,"p","1.2.1")
|
||||
|
@ -105,6 +105,8 @@ class Scrobbler(gtk.VBox):
|
|||
(url,list) = self.addParam(url,list,"a",self.authToken(tstp))
|
||||
(url,list) = self.addParam(url,list,"api_key",self.key)
|
||||
status = self.placeRequest(url).readlines()
|
||||
if status == None:
|
||||
return
|
||||
if status[0].strip() != "OK":
|
||||
return
|
||||
self.session = status[1].strip()
|
||||
|
@ -113,6 +115,7 @@ class Scrobbler(gtk.VBox):
|
|||
#for line in status:
|
||||
# print line.strip()
|
||||
|
||||
|
||||
def nowPlaying(self,info):
|
||||
if self.data.lfm == "":
|
||||
return
|
||||
|
@ -130,8 +133,11 @@ class Scrobbler(gtk.VBox):
|
|||
#status = self.placeRequest(url).readlines()
|
||||
req = urllib2.Request(self.npurl,data)
|
||||
req.add_header("User-Agent","Ocarina")
|
||||
status = urllib2.urlopen(req)
|
||||
self.fetchSimilar(info.artist)
|
||||
try:
|
||||
status = urllib2.urlopen(req)
|
||||
self.fetchSimilar(info.artist)
|
||||
except:
|
||||
return
|
||||
#if status[0].strip() == "OK":
|
||||
# print "Submission successful"
|
||||
|
||||
|
@ -170,7 +176,10 @@ class Scrobbler(gtk.VBox):
|
|||
data = urllib.urlencode(vals)
|
||||
req = urllib2.Request(self.suburl,data)
|
||||
req.add_header("User-Agent","Ocarina")
|
||||
status = urllib2.urlopen(req)
|
||||
try:
|
||||
status = urllib2.urlopen(req)
|
||||
except:
|
||||
return
|
||||
#for line in status:
|
||||
# print line
|
||||
#print status
|
||||
|
@ -183,6 +192,8 @@ class Scrobbler(gtk.VBox):
|
|||
(url,list) = self.addParam(url,list,"limit","10")
|
||||
(url,list) = self.addParam(url,list,"api_key",self.key)
|
||||
status = self.parseRequest(url)
|
||||
if status == None:
|
||||
return
|
||||
list = status.firstChild.nextSibling.childNodes
|
||||
for i in range(list.length):
|
||||
node = list.item(i)
|
||||
|
@ -204,6 +215,8 @@ class Scrobbler(gtk.VBox):
|
|||
(url,list) = self.addParam(url,list,"album",album)
|
||||
(url,list) = self.addParam(url,list,"api_key",self.key)
|
||||
status = self.parseRequest(url)
|
||||
if status == None:
|
||||
return
|
||||
list = status.childNodes
|
||||
imgUrl = ""
|
||||
for i in range(list.length):
|
||||
|
@ -212,12 +225,16 @@ class Scrobbler(gtk.VBox):
|
|||
if node.hasChildNodes() == True:
|
||||
if node.tagName == "image":
|
||||
imgUrl = node.firstChild.data
|
||||
print imgUrl
|
||||
imgIn = urllib2.urlopen(imgUrl)
|
||||
out = open(path,'w')
|
||||
out.write(imgIn.read())
|
||||
imgIn.close()
|
||||
out.close()
|
||||
|
||||
if imgUrl:
|
||||
try:
|
||||
imgIn = urllib2.urlopen(imgUrl)
|
||||
out = open(path,'w')
|
||||
out.write(imgIn.read())
|
||||
imgIn.close()
|
||||
out.close()
|
||||
except:
|
||||
print "Error opening:",imgUrl
|
||||
|
||||
|
||||
|
||||
|
@ -263,8 +280,16 @@ class Scrobbler(gtk.VBox):
|
|||
req = urllib2.Request(url)
|
||||
req.add_header('User-Agent','Ocarina')
|
||||
#return minidom.parse(urllib2.urlopen(req)).documentElement
|
||||
return urllib2.urlopen(req)
|
||||
try:
|
||||
return urllib2.urlopen(req)
|
||||
except:
|
||||
return None
|
||||
|
||||
|
||||
def parseRequest(self,url):
|
||||
return minidom.parse(self.placeRequest(url)).documentElement
|
||||
request = self.placeRequest(url)
|
||||
if not (request == None):
|
||||
return minidom.parse(request).documentElement
|
||||
else:
|
||||
return None
|
||||
#return minidom.parse(self.placeRequest(url)).documentElement
|
||||
|
|
Loading…
Reference in New Issue