Exemplo n.º 1
0
Arquivo: db.py Projeto: gstofer/strmr
def selectPlay(id):
	"""
		select a song to play based on the song ID
	"""
	song = music.song()
	sql = "SELECT id, title, path, filename, hash, base FROM songs " \
		+ "WHERE id = " + str(id) + ";"
	c, conn = connect()
	c.execute(sql)
	sinfo = c.fetchone()
	
	if sinfo[0]:
		song.id = sinfo[0]
	if sinfo[1]:
		song.name = sinfo[1]
	if sinfo[2]:
		song.path = sinfo[2]
	if sinfo[3]:
		song.filename = sinfo[3]
	if sinfo[4]:
		song.hash = sinfo[4]
	if sinfo[5]:
		song.base = sinfo[5]
	
	return song
Exemplo n.º 2
0
def enterDB(dbQueue, lock):
	"""
		Method used to enter song objects into the database
	"""
	# while the dbQueue is not empty
	while not dbQueue.empty():
		try:
			# acquire the lock
			lock.acquire()
			# attempt to get something out of the queue for 5 seconds
			base, path, file = dbQueue.get(timeout=5)
			lock.release()
			
			# set the songpath
			songpath = os.path.realpath(path)
			
			# create a song object from the songpath, the file and the base 
			# music directory
			song = music.song(path=songpath, filename=file, base=base)
			
			# song.pullInfo gets information from the ID3 tags on the files
			song.pullInfo()
			
			# enter song information into the database
			db.enterSong(song)
			
			# if there are 2 entries left in the queue sleep to allow worker 
			# more time to parse through the folders
			if dbQueue.qsize() < 2:
				print "Sleeping to get more entries"
				time.sleep(3)
		except Empty:
			print "Empty DB Queue"
Exemplo n.º 3
0
Arquivo: db.py Projeto: gstofer/strmr
def selectSongs():
	"""
		select every song with the album name and artist name
	"""
	sql ="select songs.title, artist.name, album.name from songs, album, " \
	+ "artist join songs_album on songs.id=songs_album.songs_id " \
	+ "join songs_artist on songs.id=songs_artist.songs_id " \
	+ "where album.id=songs_album.album_id " \
	+ "and artist.id=songs_artist.artist_id"
	c, conn = connect()
	retr = c.execute(sql)
	songs = []
	for entry in retr:
		songs.append(music.song(title=entry[0], artist=entry[1], album=entry[2]))
	return songs