def find_even_more_tracks(fname,tracknum,possible_releases): gotone = False if fname.lower().endswith(".flac"): return mp3data = parsemp3.parsemp3(fname) if "TIT2" not in mp3data["v2"]: return ftrackname = mp3data["v2"]["TIT2"] for (rid,v) in possible_releases.items(): release = lookups.get_release_by_releaseid(rid) rtrackname = release.tracks[tracknum-1].title if rtrackname.lower() == ftrackname.lower(): yield release.tracks[tracknum-1]
def main(): file = os.path.abspath(sys.argv[1]) data = parsemp3.parsemp3(sys.argv[1]) print data["duration"]/1000 tracklen = data["duration"]/1000 splits = math.ceil(tracklen/20) for i in range(splits): start = i * 20 end = start + 20 print "start",start,"end",end (fd,outfile)=tempfile.mkstemp(suffix=".wav") os.close(fd) args = ["ffmpeg", "-y", "-i", file, "-ac", "1", "-ar", "22050", "-f", "wav", "-t", "20", "-ss", "%d" %start, outfile] subprocess.call(args, stderr=open("/dev/null", "w")) os.rename(outfile, "data/%d.wav" %start)
def main(): file = os.path.abspath(sys.argv[1]) data = parsemp3.parsemp3(sys.argv[1]) print data["duration"] / 1000 tracklen = data["duration"] / 1000 splits = math.ceil(tracklen / 20) for i in range(splits): start = i * 20 end = start + 20 print "start", start, "end", end (fd, outfile) = tempfile.mkstemp(suffix=".wav") os.close(fd) args = [ "ffmpeg", "-y", "-i", file, "-ac", "1", "-ar", "22050", "-f", "wav", "-t", "20", "-ss", "%d" % start, outfile ] subprocess.call(args, stderr=open("/dev/null", "w")) os.rename(outfile, "data/%d.wav" % start)
def __read_tags_mp3(filename): data = parsemp3.parsemp3(filename) mp3tags = data["v2"] tags = {} if "TIT2" in mp3tags: tags[TITLE] = mp3tags["TIT2"] if "TPE1" in mp3tags: tags[ARTIST] = mp3tags["TPE1"] if "TALB" in mp3tags: tags[ALBUM] = mp3tags["TALB"] if "TYER" in mp3tags: tags[YEAR] = mp3tags["TYER"] if "TDAT" in mp3tags: tags[DATE] = mp3tags["TDAT"] if "TXXX" in mp3tags: if type(mp3tags["TXXX"]) == type([]): parts = mp3tags["TXXX"] else: parts = [mp3tags["TXXX"]] for i in parts: (k,v) = tuple(i.split("\0")) if k == "MusicBrainz Artist Id": tags[ARTIST_ID] = v elif k == "MusicBrainz Album Id": tags[ALBUM_ID] = v if "UFID" in mp3tags: if type(mp3tags["UFID"]) == type([]): parts = mp3tags["UFID"] else: parts = [mp3tags["UFID"]] for i in parts: (k,v) = tuple(i.split("\0")) if k == "http://musicbrainz.org": tags[TRACK_ID] = v return tags