예제 #1
0
    def __init__(self):
        sys.path.append('python-audio-tools')

        import audiotools
        import audiotools.accuraterip

        cd_drive = os.path.realpath('/dev/cdrom')

        names = []
        for i, track in enumerate(cd):
            md = meta[0][i]
            filename = '{1} - {0} - {2}.mp3'.format(md.track_number,
                                                    md.artist_name,
                                                    md.track_name)
            names.append(filename)

        format = audiotools.TYPE_MAP['mp3']
        quali = 'standard'

        track = cd[1]
        ripper = audiotools.accuraterip.AccurateRipReader(track)

        md = meta[0][i]

        options = OptionParser()
        msg = audiotools.Messenger('cdaudio', options)
        prog = audiotools.SingleProgressDisplay(msg, filename)
        riprog = audiotools.PCMReaderProgress(ripper,
                                              track.length() * (44100 / 75),
                                              update)  #prog.update)

        format.from_pcm(filename,
                        riprog,
                        quali,
                        total_pcm_frames=track.length() * (44100 / 75))
예제 #2
0
def walk_dirs(dir):
    num_song = 0
    songs = []
    for dirname, dirnames, filenames in os.walk(dir, followlinks=True):
	# print path to all subdirectories
	for subdirname in dirnames:
	    songs.extend(walk_dirs(subdirname))

	options = {"verbosity":"normal"}
	msg = audiotools.Messenger("music_crawler", options)
	# print path to all filenames
	for filename in filenames:
	    file_extension = os.path.splitext(filename)[1]
	    if file_extension in MUSIC_FILE_TYPES:
		song = {}
		song["full_path"] = os.path.join(os.path.abspath(dirname), filename)
		song[file_extension[1:]] = song["full_path"]
		try:
		    #using open_files because it supports a messenger object
		    song_audio_file = audiotools.open_files([song["full_path"]], messenger=msg)
		    if len(song_audio_file) > 0:
			song_audio_file = song_audio_file[0]
		    else:
			print "couldn't open dat file: "+filename
			continue
		except Exception as e:
		    print "Could not open file: "+song["full_path"]+". Error: "+str(e)
		    continue #skip song
		try:
		    song_metadata = song_audio_file.get_metadata()
		except Exception as e:
		    print "Could not open get file metadata: "+song["full_path"]+". Error: "+str(e)
		    continue #skip song

		if song_metadata is None:
		    song["title"] = os.path.splitext(filename)[0]
		    song["artist"] = "Unknown artist"
		    song["album"] = "Unknown album"
		    song["number"] = ""
		    song["year"] = ""
		else:
		    song["title"] = song_metadata.track_name if song_metadata.track_name else filename
		    song["artist"] = song_metadata.artist_name if song_metadata.artist_name else "Unknown artist"
		    song["album"] = song_metadata.album_name if song_metadata.album_name else "Unknown album"
		    song["number"] = song_metadata.track_number if song_metadata.track_number else ""
		    song["year"] = song_metadata.year if song_metadata.year else ""

		if len(song["year"]) > 4:
		    song["year"] = song["year"][:4]
		#if len(song.items()) > 2: #only store the song if there is information besides pathname and extension
		songs.append(song)
    return songs
예제 #3
0
                        help=_.OPT_CUESHEET_TRACKVERIFY)

    parser.add_argument("-j",
                        "--joint",
                        type=int,
                        default=MAX_CPUS,
                        dest="max_processes",
                        help=_.OPT_JOINT)

    parser.add_argument("filenames",
                        metavar="PATH",
                        nargs="+",
                        help=_.OPT_INPUT_FILENAME_OR_DIR)

    options = parser.parse_args()
    msg = audiotools.Messenger(options.verbosity == "quiet")

    if not options.accuraterip:
        queued_files = set()  # a set of Filename objects already encountered
        queue = audiotools.ExecProgressQueue(msg)
        for track in get_tracks(options.filenames, queued_files,
                                options.accept_list):
            queue.execute(
                function=verify,
                progress_text=audiotools.Filename(
                    track.filename).__unicode__(),
                completion_output=(display_results_tty if msg.output_isatty()
                                   else display_results),
                track=track)

        msg.ansi_clearline()
예제 #4
0
iloop = 1
oloop = 1
cframes = 0
wthrd = ""

if sys.argv.__len__() <= 1:
    print("Usage: %s [audio_file]" % sys.argv[0])
    sys.exit(1)

def signal_handler(signum, frame):
    pass

signal(SIGALRM, signal_handler)

msg = audiotools.Messenger()

try:
    afile = audiotools.open(sys.argv[1])
    mixer = alsaaudio.Mixer()
    cvol = mixer.getvolume()[0]

    dtemplate = "[keypress]: j to jump 10 seconds forward, q to quit, " \
                "v to increase the vol by 10%%, d to decrease the vol by " \
                "10%%, " \
                "current vol gain [%s]%%"
    pgrs = audiotools.SingleProgressDisplay(msg, dtemplate % cvol)

    sframes = afile.total_frames()
    aformat = alsaaudio.PCM_FORMAT_S16_LE if sys.byteorder == 'little' else \
        alsaaudio.PCM_FORMAT_S16_BE
예제 #5
0
#statusbar.pack(fill=gui.X, side=gui.BOTTOM)

sys.exit(0)


def update(current, total):
    print '\r', current, total


format = audiotools.TYPE_MAP['mp3']
quali = 'standard'

track = cd[1]
ripper = audiotools.accuraterip.AccurateRipReader(track)

md = meta[0][i]

options = OptionParser()
msg = audiotools.Messenger('cdaudio', options)
prog = audiotools.SingleProgressDisplay(msg, filename)
riprog = audiotools.PCMReaderProgress(ripper,
                                      track.length() * (44100 / 75),
                                      update)  #prog.update)

format.from_pcm(filename,
                riprog,
                quali,
                total_pcm_frames=track.length() * (44100 / 75))

print 'done!'