Пример #1
0
def _make_session(token):
    sess = _do_lastfm_query("GET", "auth.getSession", token=token)
    key = sess["session"][0]["key"][0]
    fp = open(os.path.expanduser("~/.lastfmsess"), "w")
    fp.write(key)
    fp.close()
    print "session successfully created. thank you."
Пример #2
0
def _make_session(token):
	sess = _do_lastfm_query("GET", "auth.getSession", token=token)
	key = sess["session"][0]["key"][0]
	fp = open(os.path.expanduser("~/.lastfmsess"), "w")
	fp.write(key)
	fp.close()
	print "session successfully created. thank you."
Пример #3
0
def main(file):
    statusfile = os.path.expanduser("~/.scrobbyl")
    lines = []
    if os.path.exists(statusfile):
        fp = open(statusfile, "r")
        lines = fp.readlines()
        fp.close()
    lasttime = 0
    lastartist = ""
    lasttrack = ""
    if len(lines) == 3:
        lasttime = int(lines[0])
        lastartist = lines[1]
        lasttrack = lines[2]

    f = fingerprint(file)

    code = f[0]["code"]
    song = echonest.fp_lookup(code)
    echonest.pp(song)

    if "response" in song and "status" in song["response"] \
      and song["response"]["status"]["message"] == "Success" \
      and len(song["response"]["songs"]) > 0:

        track = song["response"]["songs"][0]["title"]
        artist = song["response"]["songs"][0]["artist_name"]
        now = time.time()

        print(now - lasttime)
        if now - lasttime < 100:
            # Only scrobble if we've just been playing
            if lasttrack != "" and lasttrack != track:
                print "Last track was", lasttrack, "now", track, ", scrobbling"
            else:
                print "same song"
        else:
            print "too long since we last did it,", now - lasttime
        fp = open(statusfile, "w")
        fp.write("%d\n%s\n%s" % (now, artist, track))
        fp.close()
Пример #4
0
def main(file):
	statusfile = os.path.expanduser("~/.scrobbyl")
	lines = []
	if os.path.exists(statusfile):
		fp = open(statusfile, "r")
		lines = fp.readlines()
		fp.close()
	lasttime = 0
	lastartist = ""
	lasttrack = ""
	if len(lines) == 3:
		lasttime = int(lines[0])
		lastartist = lines[1]
		lasttrack = lines[2]
	
	f = fingerprint(file)

	code = f[0]["code"]
	song = echonest.fp_lookup(code)
	echonest.pp(song)

	if "response" in song and "status" in song["response"] \
			and song["response"]["status"]["message"] == "Success" \
			and len(song["response"]["songs"]) > 0:

		track = song["response"]["songs"][0]["title"]
		artist = song["response"]["songs"][0]["artist_name"]
		now = time.time()

		print (now-lasttime)
		if now - lasttime < 100:
			# Only scrobble if we've just been playing
			if lasttrack != "" and lasttrack != track:
				print "Last track was",lasttrack,"now",track,", scrobbling"
			else:
				print "same song"
		else:
			print "too long since we last did it,", now-lasttime
		fp = open(statusfile, "w")
		fp.write("%d\n%s\n%s" % (now, artist, track))
		fp.close()
Пример #5
0
def save_id():
	with open(ID_FNAME, 'wb') as fp:
		fp.write(lastId)
		fp.close()