def __init__(self): self.songs = [] for (dirpath, dirname, filenames) in os.walk('C:\\Users\\Matt\\Music\\Music'): for i in filenames: if i.find('.mp3') != -1: path = dirpath + "\\" + i self.songs.append(songClass.song(path))
def run(self): self.running = True self.host = '' self.port = 8888 self.songs = [] for (dirpath, dirname, filenames) in os.walk('C:\\Users\\TomDoug\\Music'): for i in filenames: if i.find('.mp3') != -1: path = dirpath + "\\" + i #makes a new instance of the song class for each song self.songs.append(songClass.song(path)) self.s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) print 'socket created' self.s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) self.s.bind((self.host, self.port)) print "Socket binded" self.s.listen(5) self.clsock, addr = self.s.accept() self.inputLoop()
def get_songs_by_artist(self, artist): match = [] try: self.con = sqlite3.connect('songs.db') self.cur = self.con.cursor() self.cur.execute("SELECT * FROM Songs WHERE Artist=? ORDER BY Title ASC", ([artist])) res = self.cur.fetchall() for s in res: match.append(song(s[0])) print "found songs?" except sqlite3.Error, e: print str(e) print "SQL ERROR"