def getLocalTrackInfo(track): s = track if type(s) == str or type(s) == unicode: s = parseSPurl(s) # log("getLocalTrackInfo","Finding local file in index") artist = '%' + (s[0].split('?'))[0] + '%' album = '%' + (s[1].split('?'))[0] + '%' title = '%' + (s[2].split('?'))[0] + '%' duration = s[3] log('getLocalTrackInfo', "Called for '" + str(s) + "'") log('getLocalTrackInfo', "Searching index using artist:'" + urllib.unquote(s[0]) + "', album: '" + urllib.unquote(s[1]) + "', title: '" + urllib.unquote(s[2]) + "', duration: '" + duration + "'") conn = sql.connect(config.db) c = conn.cursor() c.execute('SELECT * FROM itunes WHERE artist LIKE ? AND album ' + 'LIKE ? AND name LIKE ? AND duration = ?;', (artist, album, title, duration)) r = c.fetchone() if type(r) != tuple: c.execute('SELECT * FROM itunes WHERE artist LIKE ?' + ' AND album LIKE ? AND name LIKE ?;', (artist, album, title)) r = c.fetchone() if type(r) != tuple: c.execute('SELECT * FROM itunes WHERE artist LIKE ? AND name LIKE ?;', (artist, title)) r = c.fetchone() if r is not None: t = {} t['location'] = eval(r[1]) t['artist'] = r[2] t['album'] = r[3] t['name'] = r[4] t['year'] = r[5] t['track'] = r[6] t['duration'] = r[7] t['persistent_id'] = r[8] t['pid_low'] = r[9] t['pid_high'] = r[10] t['img'] = 'http://' + net.getAddress() + '/' + r[11] conn.close() return t else: t = None conn.close() return t
return t # -------------------------------------- # # End of Track and Art Metadata Handling # # -------------------------------------- # # --------------------------------------------------------------------------- # # --------------------------------------------------------------------------- # # ---- # # main # # ---- # if __name__ == "__main__": log('Hello', "Welcome to PoleyMote") log('IP', 'PoleyMote now running on http://' + net.getAddress()) mw = web.httpserver.StaticMiddleware app = web.application(urls, globals()).wsgifunc(mw) try: threading.Timer(1, net.startBroadcastServer).start() threading.Timer(3, getStarted).start() WSGIServer(('', config.http_port), app).serve_forever() except KeyboardInterrupt: sys.exit() # ----------- # # end of main # # ----------- # # -------------- # # Still Building #