Esempio n. 1
0
def main(dir):
    matches = {}
    artists = {}
    count = 0
    for f in os.listdir(dir):
        print "file", f
        if os.path.splitext(f)[1] not in supported_types:
            print "skipping", f
            continue
        code = fp.fingerprint(os.path.join(dir, f))
        match = echonest.fp_lookup(code)
        echonest.pp(match)
Esempio n. 2
0
def main(dir):
	matches = {}
	artists = {}
	count = 0
	for f in os.listdir(dir):
		print "file",f
		if os.path.splitext(f)[1] not in supported_types:
			print "skipping",f
			continue
		code = fp.fingerprint(os.path.join(dir, f))
		match = echonest.fp_lookup(code)
		echonest.pp(match)
Esempio n. 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()
Esempio n. 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()