Example #1
0
	def loadTrackList(mainwindow, albumID):
		#print('show albums for artist ' + artistID + ' and album '+ str(albumID))
		serverinfo = settings.getServerInfo()

		if {} == serverinfo:
			print("Login failed!")
			return

		try:
			conn = libsonic.Connection(serverinfo['host'], serverinfo['username'], serverinfo['password'], serverinfo['port'])
		except urllib.error.HTTPError:
			print("User/pass fail")

		print ("Getting album " + str(albumID))
		try:
			# @TODO: use ifModifiedSince with caching
			print("getTrackList()")
			tracks = conn.getAlbum(albumID)
			album = tracks["album"]
			pprint(album)
			songCount = album["songCount"]
			saveTracks(serverinfo, album)
		except urllib.error.HTTPError:
			print("authfail while getting album")
			return -1
		except KeyError, e:
			print("[getArtistsFromServer] KeyError: something was wrong with the data")
			return -1
Example #2
0
	def loadArtistList(mainwindow):
		"""
		Refresh artists listing
		"""
		# fetch artists, @TODO: has ifModifiedSince for caching
		serverinfo = settings.getServerInfo()
		print(serverinfo)

		hasCache = cache.haveCachedArtists(serverinfo)

		if False == hasCache:
			mainwindow.onRefreshbuttonClicked(mainwindow)
			#artists = mainwindow.getArtistsFromServer(serverinfo)
			#cache.saveArtists(serverinfo, artists)
		else:
			print("get from cache")


		artists = cache.getArtists(serverinfo)


		mainwindow.artistliststore.clear()
		previousLetter = ''

		mainwindow.artistliststore.append([-1, 'All artists'])
		for artist in artists:
			#print(artist)
			thisLetter = artist['indexLetter']
			#print(thisLetter)

			if thisLetter != previousLetter:
				#print(thisLetter)
				previousLetter = thisLetter

			mainwindow.artistliststore.append([artist['id'], artist['name']])
Example #3
0
	def onConnectbuttonClicked(self, widget):
		print("Connecting...")

		#settings.createdb()
		serverinfo = settings.getServerInfo()
		#pprint(serverinfo)

		conn = libsonic.Connection(serverinfo['host'], serverinfo['username'], serverinfo['password'], serverinfo['port'])

		songs = conn.getRandomSongs(size=2)
		pprint(songs)
Example #4
0
	def loadAlbumList(mainwindow, artistID):
		# Allow sorting on the column
		#self.tvcolumn.set_sort_column_id(0)

		# Allow drag and drop reordering of rows
		#self.treeview.set_reorderable(True)

		print('show albums for artist ?', artistID)


		serverinfo = settings.getServerInfo()
		#conn = libsonic.Connection(serverinfo['host'], serverinfo['username'], serverinfo['password'], serverinfo['port'])
		#albums = conn.getMusicDirectory(artistid)
		#albums = conn.getArtist(artistID)
		albums = cache.getAlbums(serverinfo, artistID)
		#pprint(albums)
		
		mainwindow.albumliststore.clear()
		mainwindow.albumliststore.append([-1, 'All albums'])
		for album in albums:
			#pprint(album)
			mainwindow.albumliststore.append([album['id'], album['name']])
Example #5
0
		def run(self):
			if True == self.mainwindow.refreshing:
				# Already refreshing
				print("Already refreshing from server, ignore")
				return

			print("Refreshing...")
			#self.mainwindow.progressbar.pulse()
			
			self.mainwindow.refreshing = True
			serverinfo = settings.getServerInfo()
			cache.clearArtists(serverinfo)
			cache.saveArtists(serverinfo, self.getArtistsFromServer(serverinfo))
			
			# refresh artist list in window
			self.mainwindow.loadArtistList()
			
			artists = cache.getArtists(serverinfo)
			
			print("also storing albums:")
			cache.clearAlbums(serverinfo)
			
			result = self.cacheAllAlbumsFromServer(serverinfo, artists)
			self.mainwindow.refreshing = False