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