Esempio n. 1
0
 def printHeader(self, file_path):
     from stat import ST_SIZE
     file_size = os.stat(file_path)[ST_SIZE]
     size_str = utils.formatSize(file_size)
     printMsg("%s\t%s[ %s ]%s" %
              (boldText(os.path.basename(file_path), c=HEADER_COLOR),
               getColor(HEADER_COLOR), size_str, getColor(RESET)))
Esempio n. 2
0
 def printHeader(self, file_path):
     from stat import ST_SIZE
     file_size = os.stat(file_path)[ST_SIZE]
     size_str = utils.formatSize(file_size)
     printMsg("%s\t%s[ %s ]%s" %
              (boldText(os.path.basename(file_path), c=HEADER_COLOR),
               getColor(HEADER_COLOR), size_str, getColor(RESET)))
Esempio n. 3
0
 def printHeader(self, filePath):
     from stat import ST_SIZE
     fileSize = os.stat(filePath)[ST_SIZE]
     size_str = formatSize(fileSize).encode(ENCODING)
     print("\n%s\t%s[ %s ]%s" %
           (boldText(os.path.basename(filePath), HEADER_COLOR),
            getColor(HEADER_COLOR), size_str, getColor(RESET)))
     print("-" * 79)
Esempio n. 4
0
 def printHeader(self, filePath):
     from stat import ST_SIZE
     fileSize = os.stat(filePath)[ST_SIZE]
     size_str = formatSize(fileSize)
     print("\n%s\t%s[ %s ]%s" %
           (boldText(os.path.basename(filePath),
                     HEADER_COLOR()), HEADER_COLOR(), size_str, Fore.RESET))
     print("-" * 79)
Esempio n. 5
0
 def printHeader(self, filePath):
     from stat import ST_SIZE
     fileSize = os.stat(filePath)[ST_SIZE]
     size_str = formatSize(fileSize).encode(ENCODING)
     print("\n%s\t%s[ %s ]%s" % (boldText(os.path.basename(filePath),
                                          HEADER_COLOR),
                                 getColor(HEADER_COLOR), size_str,
                                 getColor(RESET)))
     print("-" * 79)
Esempio n. 6
0
 def printHeader(self, filePath):
     from stat import ST_SIZE
     fileSize = os.stat(filePath)[ST_SIZE]
     size_str = formatSize(fileSize)
     print("\n%s\t%s[ %s ]%s" % (boldText(os.path.basename(filePath),
                                          HEADER_COLOR()),
                                 HEADER_COLOR(), size_str,
                                 Fore.RESET))
     print("-" * 79)
Esempio n. 7
0
    def _getFileHeader(path, width):
        path = pathlib.Path(path)
        file_size = path.stat().st_size
        path_str = str(path)
        size_str = formatSize(file_size)
        size_len = len(size_str) + 5
        if len(path_str) + size_len >= width:
            path_str = "..." + str(path)[-(75 - size_len):]
        padding_len = width - len(path_str) - size_len

        return "{path}{color}{padding}[ {size} ]{reset}"\
               .format(path=boldText(path_str, c=HEADER_COLOR()),
                       color=HEADER_COLOR(),
                       padding=" " * padding_len,
                       size=size_str,
                       reset=Fore.RESET)
Esempio n. 8
0
    def handleFile(self, f):
        super(LameInfoPlugin, self).handleFile(f)

        self.printHeader(f)
        if not self.audio_file or not self.audio_file.info.lame_tag:
            printMsg('No LAME Tag')
            return

        format = '%-20s: %s'
        lt = self.audio_file.info.lame_tag
        if not lt.has_key('infotag_crc'):
            try:
                printMsg('%s: %s' % ('Encoder Version', lt['encoder_version']))
            except KeyError:
                pass
            return

        values = []

        values.append(('Encoder Version', lt['encoder_version']))
        values.append(('LAME Tag Revision', lt['tag_revision']))
        values.append(('VBR Method', lt['vbr_method']))
        values.append(('Lowpass Filter', lt['lowpass_filter']))

        if lt.has_key('replaygain'):
           try:
               peak = lt['replaygain']['peak_amplitude']
               db = 20 * math.log10(peak)
               val = '%.8f (%+.1f dB)' % (peak, db)
               values.append(('Peak Amplitude', val))
           except KeyError:
               pass
           for type in ['radio', 'audiofile']:
               try:
                   gain = lt['replaygain'][type]
                   name = '%s Replay Gain' % gain['name'].capitalize()
                   val = '%s dB (%s)' % (gain['adjustment'], gain['originator'])
                   values.append((name, val))
               except KeyError:
                   pass

        values.append(('Encoding Flags', ' '.join((lt['encoding_flags']))))
        if lt['nogap']:
            values.append(('No Gap', ' and '.join(lt['nogap'])))
        values.append(('ATH Type', lt['ath_type']))
        values.append(('Bitrate (%s)' % lt['bitrate'][1], lt['bitrate'][0]))
        values.append(('Encoder Delay', '%s samples' % lt['encoder_delay']))
        values.append(('Encoder Padding', '%s samples' % lt['encoder_padding']))
        values.append(('Noise Shaping', lt['noise_shaping']))
        values.append(('Stereo Mode', lt['stereo_mode']))
        values.append(('Unwise Settings', lt['unwise_settings']))
        values.append(('Sample Frequency', lt['sample_freq']))
        values.append(('MP3 Gain', '%s (%+.1f dB)' % (lt['mp3_gain'],
                                                      lt['mp3_gain'] * 1.5)))
        values.append(('Preset', lt['preset']))
        values.append(('Surround Info', lt['surround_info']))
        values.append(('Music Length', '%s' % formatSize(lt['music_length'])))
        values.append(('Music CRC-16', '%04X' % lt['music_crc']))
        values.append(('LAME Tag CRC-16', '%04X' % lt['infotag_crc']))

        for v in values:
            printMsg(format % (v))
Esempio n. 9
0
    def handleFile(self, f):
        super(LameInfoPlugin, self).handleFile(f)

        self.printHeader(f)
        if not self.audio_file or not self.audio_file.info.lame_tag:
            printMsg('No LAME Tag')
            return

        format = '%-20s: %s'
        lt = self.audio_file.info.lame_tag
        if not lt.has_key('infotag_crc'):
            try:
                printMsg('%s: %s' % ('Encoder Version', lt['encoder_version']))
            except KeyError:
                pass
            return

        values = []

        values.append(('Encoder Version', lt['encoder_version']))
        values.append(('LAME Tag Revision', lt['tag_revision']))
        values.append(('VBR Method', lt['vbr_method']))
        values.append(('Lowpass Filter', lt['lowpass_filter']))

        if lt.has_key('replaygain'):
            try:
                peak = lt['replaygain']['peak_amplitude']
                db = 20 * math.log10(peak)
                val = '%.8f (%+.1f dB)' % (peak, db)
                values.append(('Peak Amplitude', val))
            except KeyError:
                pass
            for type in ['radio', 'audiofile']:
                try:
                    gain = lt['replaygain'][type]
                    name = '%s Replay Gain' % gain['name'].capitalize()
                    val = '%s dB (%s)' % (gain['adjustment'],
                                          gain['originator'])
                    values.append((name, val))
                except KeyError:
                    pass

        values.append(('Encoding Flags', ' '.join((lt['encoding_flags']))))
        if lt['nogap']:
            values.append(('No Gap', ' and '.join(lt['nogap'])))
        values.append(('ATH Type', lt['ath_type']))
        values.append(('Bitrate (%s)' % lt['bitrate'][1], lt['bitrate'][0]))
        values.append(('Encoder Delay', '%s samples' % lt['encoder_delay']))
        values.append(
            ('Encoder Padding', '%s samples' % lt['encoder_padding']))
        values.append(('Noise Shaping', lt['noise_shaping']))
        values.append(('Stereo Mode', lt['stereo_mode']))
        values.append(('Unwise Settings', lt['unwise_settings']))
        values.append(('Sample Frequency', lt['sample_freq']))
        values.append(
            ('MP3 Gain',
             '%s (%+.1f dB)' % (lt['mp3_gain'], lt['mp3_gain'] * 1.5)))
        values.append(('Preset', lt['preset']))
        values.append(('Surround Info', lt['surround_info']))
        values.append(('Music Length', '%s' % formatSize(lt['music_length'])))
        values.append(('Music CRC-16', '%04X' % lt['music_crc']))
        values.append(('LAME Tag CRC-16', '%04X' % lt['infotag_crc']))

        for v in values:
            printMsg(format % (v))
Esempio n. 10
0
 def _get_output_for(self, audio_file):
     from stat import ST_SIZE
     file_size = os.stat(audio_file.path)[ST_SIZE]
     return formatSize(file_size)
Esempio n. 11
0
    def handleDone(self):
        if not self.albums:
            printMsg(u"No albums found.")
            return

        for album in self.albums:
            audio_files = self.albums[album]
            if not audio_files:
                continue
            audio_files.sort(key=lambda af: af.tag.track_num)

            max_title_len = 0
            avg_bitrate = 0
            encoder_info = ''
            for audio_file in audio_files:
                tag = audio_file.tag
                # Compute maximum title length
                title_len = len(tag.title)
                if title_len > max_title_len:
                    max_title_len = title_len
                # Compute average bitrate
                avg_bitrate += audio_file.info.bit_rate[1]
                # Grab the last lame version in case not all files have one
                if "encoder_version" in audio_file.info.lame_tag:
                    version = audio_file.info.lame_tag['encoder_version']
                    encoder_info = (version or encoder_info)
            avg_bitrate = avg_bitrate / len(audio_files)

            printMsg("")
            printMsg("Artist   : %s" % audio_files[0].tag.artist)
            printMsg("Album    : %s" % album)
            printMsg("Released : %s" %
                     (audio_files[0].tag.original_release_date or
                      audio_files[0].tag.release_date))
            printMsg("Recorded : %s" % audio_files[0].tag.recording_date)
            genre = audio_files[0].tag.genre
            if genre:
                genre = genre.name
            else:
                genre = ""
            printMsg("Genre    : %s" % genre)

            printMsg("")
            printMsg("Source  : ")
            printMsg("Encoder : %s" % encoder_info)
            printMsg("Codec   : mp3")
            printMsg("Bitrate : ~%s K/s @ %s Hz, %s" %
                     (avg_bitrate, audio_files[0].info.sample_freq,
                      audio_files[0].info.mode))
            printMsg("Tag     : ID3 %s" %
                     versionToString(audio_files[0].tag.version))

            printMsg("")
            printMsg("Ripped By: ")

            printMsg("")
            printMsg("Track Listing")
            printMsg("-------------")
            count = 0
            total_time = 0
            total_size = 0
            for audio_file in audio_files:
                tag = audio_file.tag
                count += 1

                title = tag.title
                title_len = len(title)
                padding = " " * ((max_title_len - title_len) + 3)
                time_secs = audio_file.info.time_secs
                total_time += time_secs
                total_size += audio_file.info.size_bytes

                zero_pad = "0" * (len(str(len(audio_files))) - len(str(count)))
                printMsg(" %s%d. %s%s(%s)" %
                         (zero_pad, count, title, padding,
                          formatTime(time_secs)))

            printMsg("")
            printMsg("Total play time : %s" %
                     formatTime(total_time))
            printMsg("Total size      : %s" %
                     formatSize(total_size))

            printMsg("")
            printMsg("=" * 78)
            printMsg(".NFO file created with eyeD3 %s on %s" %
                     (VERSION, time.asctime()))
            printMsg("For more information about eyeD3 go to %s" %
                     "http://eyeD3.nicfit.net/")
            printMsg("=" * 78)
Esempio n. 12
0
 def _get_output_for(self, audio_file):
     from stat import ST_SIZE
     file_size = os.stat(audio_file.path)[ST_SIZE]
     return formatSize(file_size)
Esempio n. 13
0
    def handleDone(self):
        if not self.albums:
            printMsg(u"No albums found.")
            return

        for album in self.albums:
            audio_files = self.albums[album]
            if not audio_files:
                continue
            audio_files.sort(key=lambda af: af.tag.track_num)

            max_title_len = 0
            avg_bitrate = 0
            encoder_info = ''
            for audio_file in audio_files:
                tag = audio_file.tag
                # Compute maximum title length
                title_len = len(tag.title)
                if title_len > max_title_len:
                    max_title_len = title_len
                # Compute average bitrate
                avg_bitrate += audio_file.info.bit_rate[1]
                # Grab the last lame version in case not all files have one
                if "encoder_version" in audio_file.info.lame_tag:
                    version = audio_file.info.lame_tag['encoder_version']
                    encoder_info = (version or encoder_info)
            avg_bitrate = avg_bitrate / len(audio_files)

            printMsg("")
            printMsg("Artist   : %s" % audio_files[0].tag.artist)
            printMsg("Album    : %s" % album)
            printMsg("Released : %s" % audio_files[0].tag.best_release_date)
            genre = audio_files[0].tag.genre
            if genre:
                genre = genre.name
            else:
                genre = ""
            printMsg("Genre    : %s" % genre)

            printMsg("")
            printMsg("Source  : ")
            printMsg("Encoder : %s" % encoder_info)
            printMsg("Codec   : mp3")
            printMsg("Bitrate : ~%s K/s @ %s Hz, %s" %
                     (avg_bitrate, audio_files[0].info.sample_freq,
                      audio_files[0].info.mode))
            printMsg("Tag     : ID3 %s" %
                     versionToString(audio_files[0].tag.version))

            printMsg("")
            printMsg("Ripped By: ")

            printMsg("")
            printMsg("Track Listing")
            printMsg("-------------")
            count = 0
            total_time = 0
            total_size = 0
            for audio_file in audio_files:
                tag = audio_file.tag
                count += 1

                title = tag.title
                title_len = len(title)
                padding = " " * ((max_title_len - title_len) + 3)
                time_secs = audio_file.info.time_secs
                total_time += time_secs
                total_size += audio_file.info.size_bytes

                zero_pad = "0" * (len(str(len(audio_files))) - len(str(count)))
                printMsg(
                    " %s%d. %s%s(%s)" %
                    (zero_pad, count, title, padding, formatTime(time_secs)))

            printMsg("")
            printMsg("Total play time : %s" % formatTime(total_time))
            printMsg("Total size      : %s" % formatSize(total_size))

            printMsg("")
            printMsg("=" * 78)
            printMsg(".NFO file created with eyeD3 %s on %s" %
                     (VERSION, time.asctime()))
            printMsg("For more information about eyeD3 go to %s" %
                     "http://eyeD3.nicfit.net/")
            printMsg("=" * 78)
Esempio n. 14
0
    def handleFile(self, f, *_, **__):
        super().handleFile(f)
        if self.audio_file is None:
            return

        self.printHeader(f)
        if (self.audio_file.info is None or not self.audio_file.info.lame_tag):
            printMsg("No LAME Tag")
            return

        lt = self.audio_file.info.lame_tag
        if "infotag_crc" not in lt:
            try:
                printMsg(f"Encoder Version: {lt['encoder_version']}")
            except KeyError:
                pass
            return

        values = [
            ("Encoder Version", lt['encoder_version']),
            ("LAME Tag Revision", lt['tag_revision']),
            ("VBR Method", lt['vbr_method']),
            ("Lowpass Filter", lt['lowpass_filter']),
        ]

        if "replaygain" in lt:
            try:
                peak = lt["replaygain"]["peak_amplitude"]
                db = 20 * math.log10(peak)
                val = "%.8f (%+.1f dB)" % (peak, db)
                values.append(("Peak Amplitude", val))
            except KeyError:
                pass
            for type_ in ["radio", "audiofile"]:
                try:
                    gain = lt["replaygain"][type_]
                    name = "%s Replay Gain" % gain['name'].capitalize()
                    val = "%s dB (%s)" % (gain['adjustment'],
                                          gain['originator'])
                    values.append((name, val))
                except KeyError:
                    pass

        values.append(("Encoding Flags", " ".join((lt["encoding_flags"]))))
        if lt["nogap"]:
            values.append(("No Gap", " and ".join(lt["nogap"])))
        values.append(("ATH Type", lt["ath_type"]))
        values.append(("Bitrate (%s)" % lt["bitrate"][1], lt["bitrate"][0]))
        values.append(("Encoder Delay", "%s samples" % lt["encoder_delay"]))
        values.append(
            ("Encoder Padding", "%s samples" % lt["encoder_padding"]))
        values.append(("Noise Shaping", lt["noise_shaping"]))
        values.append(("Stereo Mode", lt["stereo_mode"]))
        values.append(("Unwise Settings", lt["unwise_settings"]))
        values.append(("Sample Frequency", lt["sample_freq"]))
        values.append(
            ("MP3 Gain",
             "%s (%+.1f dB)" % (lt["mp3_gain"], lt["mp3_gain"] * 1.5)))
        values.append(("Preset", lt["preset"]))
        values.append(("Surround Info", lt["surround_info"]))
        values.append(("Music Length", "%s" % formatSize(lt["music_length"])))
        values.append(("Music CRC-16", "%04X" % lt["music_crc"]))
        values.append(("LAME Tag CRC-16", "%04X" % lt["infotag_crc"]))

        for v in values:
            printMsg(f"{v[0]:<20}: {v[1]}")