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 _listPlugins(config):
    from eyed3.utils.cli import GREEN, GREY, boldText, colorText

    print("")

    def header(name):
        is_default = name == DEFAULT_PLUGIN
        return (boldText("* ", c=GREEN if is_default else None) +
                boldText(name, c=None))

    all_plugins = eyed3.plugins.load(reload=True, paths=_getPluginPath(config))
    # Create a new dict for sorted display
    plugin_names = []
    for plugin in set(all_plugins.values()):
        plugin_names.append(plugin.NAMES[0])

    print("Type 'eyeD3 --plugin=<name> --help' for more help")
    print("")

    plugin_names.sort()
    for name in plugin_names:
        plugin = all_plugins[name]

        alt_names = plugin.NAMES[1:]
        alt_names = " (%s)" % ", ".join(alt_names) if alt_names else ""

        print("%s %s:" % (header(name), alt_names))
        for l in textwrap.wrap(plugin.SUMMARY,
                               initial_indent=' ' * 2,
                               subsequent_indent=' ' * 2):
            print(boldText(l, c=GREY))
        print("")
Esempio n. 3
0
def _listPlugins(config):
    from eyed3.utils.cli import GREEN, GREY, boldText, colorText

    print("")
    def header(name):
        is_default = name == DEFAULT_PLUGIN
        return (boldText("* ", c=GREEN if is_default else None) + 
                boldText(name, c=None))

    all_plugins = eyed3.plugins.load(reload=True, paths=_getPluginPath(config))
    # Create a new dict for sorted display
    plugin_names = []
    for plugin in set(all_plugins.values()):
        plugin_names.append(plugin.NAMES[0])

    print("Type 'eyeD3 --plugin=<name> --help' for more help")
    print("")

    plugin_names.sort()
    for name in plugin_names:
        plugin = all_plugins[name]

        alt_names = plugin.NAMES[1:]
        alt_names = " (%s)" % ", ".join(alt_names) if alt_names else ""

        print("%s %s:" % (header(name), alt_names))
        for l in textwrap.wrap(plugin.SUMMARY,
                               initial_indent=' ' * 2,
                               subsequent_indent=' ' * 2):
            print(boldText(l, c=GREY))
        print("")
Esempio n. 4
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. 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).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. 7
0
 def printAudioInfo(self, info):
     if isinstance(info, mp3.Mp3AudioInfo):
         printMsg(
             boldText("Time: ") +
             "%s\tMPEG%d, Layer %s\t[ %s @ %s Hz - %s ]" %
             (utils.formatTime(info.time_secs), info.mp3_header.version,
              "I" * info.mp3_header.layer, info.bit_rate_str,
              info.mp3_header.sample_freq, info.mp3_header.mode))
         printMsg("-" * 79)
Esempio n. 8
0
 def printAudioInfo(self, info):
     if isinstance(info, mp3.Mp3AudioInfo):
         printMsg(boldText("Time: ") +
                  "%s\tMPEG%d, Layer %s\t[ %s @ %s Hz - %s ]" %
                  (utils.formatTime(info.time_secs),
                   info.mp3_header.version,
                   "I" * info.mp3_header.layer,
                   info.bit_rate_str,
                   info.mp3_header.sample_freq, info.mp3_header.mode))
         printMsg("-" * 79)
Esempio n. 9
0
    def printTag(self, tag):
        if isinstance(tag, id3.Tag):
            if self.args.quiet:
                printMsg("ID3 %s: %d frames" %
                         (id3.versionToString(tag.version),
                          len(tag.frame_set)))
                return

            printMsg("ID3 %s:" % id3.versionToString(tag.version))
            artist = tag.artist if tag.artist else u""
            title = tag.title if tag.title else u""
            album = tag.album if tag.album else u""
            printMsg("%s: %s" % (boldText("title"), title))
            printMsg("%s: %s" % (boldText("artist"), artist))
            printMsg("%s: %s" % (boldText("album"), album))

            for date, date_label in [
                    (tag.release_date, "release date"),
                    (tag.original_release_date, "original release date"),
                    (tag.recording_date, "recording date"),
                    (tag.encoding_date, "encoding date"),
                    (tag.tagging_date, "tagging date"),
                    ]:
                if date:
                    printMsg("%s: %s" % (boldText(date_label), str(date)))

            track_str = ""
            (track_num, track_total) = tag.track_num
            if track_num != None:
                track_str = str(track_num)
                if track_total:
                    track_str += "/%d" % track_total

            genre = tag.genre
            genre_str = "%s: %s (id %s)" % (boldText("genre"),
                                            genre.name,
                                            str(genre.id)) if genre else u""
            printMsg("%s: %s\t\t%s" % (boldText("track"), track_str, genre_str))

            # PCNT
            play_count = tag.play_count
            if tag.play_count is not None:
                 printMsg("%s %d" % (boldText("Play Count:"), play_count))

            # POPM
            for popm in tag.popularities:
                printMsg("%s [email: %s] [rating: %d] [play count: %d]" %
                         (boldText("Popularity:"), popm.email, popm.rating,
                          popm.count))

            # TBPM
            bpm = tag.bpm
            if bpm is not None:
                 printMsg("%s %d" % (boldText("BPM:"), bpm))

            # TPUB
            pub = tag.publisher
            if pub is not None:
                 printMsg("%s %s" % (boldText("Publisher/label:"), pub))

            # UFID
            for ufid in tag.unique_file_ids:
                printMsg("%s [%s] : %s" % \
                        (boldText("Unique File ID:"), ufid.owner_id,
                         ufid.uniq_id.encode("string_escape")))

            # COMM
            for c in tag.comments:
                printMsg("%s: [Description: %s] [Lang: %s]\n%s" %
                         (boldText("Comment"), c.description or "",
                          c.lang or "", c.text or ""))

            # USLT
            for l in tag.lyrics:
                printMsg("%s: [Description: %s] [Lang: %s]\n%s" %
                         (boldText("Lyrics"), l.description or u"",
                          l.lang or "", l.text))

            # TXXX
            for f in tag.user_text_frames:
                printMsg("%s: [Description: %s]\n%s" %
                         (boldText("UserTextFrame"), f.description, f.text))

            # URL frames
            for desc, url in ( ("Artist URL", tag.artist_url),
                               ("Audio source URL", tag.audio_source_url),
                               ("Audio file URL", tag.audio_file_url),
                               ("Internet radio URL", tag.internet_radio_url),
                               ("Commercial URL", tag.commercial_url),
                               ("Payment URL", tag.payment_url),
                               ("Publisher URL", tag.publisher_url),
                               ("Copyright URL", tag.copyright_url),
                             ):
                if url:
                    printMsg("%s: %s" % (boldText(desc), url))


            # user url frames
            for u in tag.user_url_frames:
                printMsg("%s [Description: %s]: %s" % (u.id, u.description,
                                                       u.url))

            # APIC
            for img in tag.images:
                if img.mime_type != ImageFrame.URL_MIME_TYPE:
                    printMsg("%s: [Size: %d bytes] [Type: %s]" %
                        (boldText(img.picTypeToString(img.picture_type) +
                                  " Image"),
                        len(img.image_data),
                        img.mime_type))
                    printMsg("Description: %s" % img.description)
                    printMsg("")
                    if self.args.write_images_dir:
                        img_path = "%s%s" % (self.args.write_images_dir, os.sep)
                        if not os.path.isdir(img_path):
                            raise IOError("Directory does not exist: %s" %
                                          img_path)
                        img_file = self._getDefaultNameForImage(img)
                        count = 1
                        while os.path.exists(os.path.join(img_path, img_file)):
                            img_file = self._getDefaultNameForImage(img,
                                                                    str(count))
                            count += 1
                        printWarning("Writing %s..." % os.path.join(img_path,
                                                                    img_file))
                        with open(os.path.join(img_path, img_file), "wb") as fp:
                            fp.write(img.image_data)
                else:
                    printMsg("%s: [Type: %s] [URL: %s]" %
                        (boldText(img.picTypeToString(img.picture_type) +
                                  " Image"),
                        img.mime_type, img.image_url))
                    printMsg("Description: %s" % img.description)
                    printMsg("")

            # GOBJ
            for obj in tag.objects:
                printMsg("%s: [Size: %d bytes] [Type: %s]" %
                         (boldText("GEOB"), len(obj.object_data),
                          obj.mime_type))
                printMsg("Description: %s" % obj.description)
                printMsg("Filename: %s" % obj.filename)
                printMsg("\n")
                if self.args.write_objects_dir:
                    obj_path = "%s%s" % (self.args.write_objects_dir, os.sep)
                    if not os.path.isdir(obj_path):
                        raise IOError("Directory does not exist: %s" % obj_path)
                    obj_file = self._getDefaultNameForObject(obj)
                    count = 1
                    while os.path.exists(os.path.join(obj_path, obj_file)):
                        obj_file = self._getDefaultNameForObject(obj,
                                                                 str(count))
                        count += 1
                    printWarning("Writing %s..." % os.path.join(obj_path,
                                                                obj_file))
                    with open(os.path.join(obj_path, obj_file), "wb") as fp:
                        fp.write(obj.object_data)

            # PRIV
            for p in tag.privates:
                printMsg("%s: [Data: %d bytes]" % (boldText("PRIV"),
                                                   len(p.data)))
                printMsg("Owner Id: %s" % p.owner_id)

            # MCDI
            if tag.cd_id:
                printMsg("\n%s: [Data: %d bytes]" % (boldText("MCDI"),
                                                     len(tag.cd_id)))

            # USER
            if tag.terms_of_use:
                printMsg("\nTerms of Use (%s): %s" % (boldText("USER"),
                                                      tag.terms_of_use))

            if self.args.verbose:
                printMsg("-" * 79)
                printMsg("%d ID3 Frames:" % len(tag.frame_set))
                for fid in tag.frame_set:
                    num_frames = len(tag.frame_set[fid])
                    count = " x %d" % num_frames if num_frames > 1 else ""
                    printMsg("%s%s" % (fid, count))
        else:
            raise TypeError("Unknown tag type: " + str(type(tag)))
Esempio n. 10
0
 def header(name):
     is_default = name == DEFAULT_PLUGIN
     return (boldText("* ", c=GREEN if is_default else None) +
             boldText(name, c=None))
Esempio n. 11
0
 def header(name):
     is_default = name == DEFAULT_PLUGIN
     return (boldText("* ", c=GREEN if is_default else None) + 
             boldText(name, c=None))
Esempio n. 12
0
    def printTag(self, tag):
        if isinstance(tag, id3.Tag):
            if self.args.quiet:
                printMsg(
                    "ID3 %s: %d frames" %
                    (id3.versionToString(tag.version), len(tag.frame_set)))
                return

            printMsg("ID3 %s:" % id3.versionToString(tag.version))
            artist = tag.artist if tag.artist else u""
            title = tag.title if tag.title else u""
            album = tag.album if tag.album else u""
            printMsg("%s: %s" % (boldText("title"), title))
            printMsg("%s: %s" % (boldText("artist"), artist))
            printMsg("%s: %s" % (boldText("album"), album))

            for date, date_label in [
                (tag.release_date, "release date"),
                (tag.original_release_date, "original release date"),
                (tag.recording_date, "recording date"),
                (tag.encoding_date, "encoding date"),
                (tag.tagging_date, "tagging date"),
            ]:
                if date:
                    printMsg("%s: %s" % (boldText(date_label), str(date)))

            track_str = ""
            (track_num, track_total) = tag.track_num
            if track_num != None:
                track_str = str(track_num)
                if track_total:
                    track_str += "/%d" % track_total

            genre = tag.genre
            genre_str = "%s: %s (id %s)" % (boldText("genre"), genre.name,
                                            str(genre.id)) if genre else u""
            printMsg("%s: %s\t\t%s" %
                     (boldText("track"), track_str, genre_str))

            # PCNT
            play_count = tag.play_count
            if tag.play_count is not None:
                printMsg("%s %d" % (boldText("Play Count:"), play_count))

            # POPM
            for popm in tag.popularities:
                printMsg("%s [email: %s] [rating: %d] [play count: %d]" %
                         (boldText("Popularity:"), popm.email, popm.rating,
                          popm.count))

            # TBPM
            bpm = tag.bpm
            if bpm is not None:
                printMsg("%s %d" % (boldText("BPM:"), bpm))

            # TPUB
            pub = tag.publisher
            if pub is not None:
                printMsg("%s %s" % (boldText("Publisher/label:"), pub))

            # UFID
            for ufid in tag.unique_file_ids:
                printMsg("%s [%s] : %s" % \
                        (boldText("Unique File ID:"), ufid.owner_id,
                         ufid.uniq_id.encode("string_escape")))

            # COMM
            for c in tag.comments:
                printMsg("%s: [Description: %s] [Lang: %s]\n%s" %
                         (boldText("Comment"), c.description or "", c.lang
                          or "", c.text or ""))

            # USLT
            for l in tag.lyrics:
                printMsg("%s: [Description: %s] [Lang: %s]\n%s" %
                         (boldText("Lyrics"), l.description or u"", l.lang
                          or "", l.text))

            # TXXX
            for f in tag.user_text_frames:
                printMsg("%s: [Description: %s]\n%s" %
                         (boldText("UserTextFrame"), f.description, f.text))

            # URL frames
            for desc, url in (
                ("Artist URL", tag.artist_url),
                ("Audio source URL", tag.audio_source_url),
                ("Audio file URL", tag.audio_file_url),
                ("Internet radio URL", tag.internet_radio_url),
                ("Commercial URL", tag.commercial_url),
                ("Payment URL", tag.payment_url),
                ("Publisher URL", tag.publisher_url),
                ("Copyright URL", tag.copyright_url),
            ):
                if url:
                    printMsg("%s: %s" % (boldText(desc), url))

            # user url frames
            for u in tag.user_url_frames:
                printMsg("%s [Description: %s]: %s" %
                         (u.id, u.description, u.url))

            # APIC
            for img in tag.images:
                if img.mime_type != ImageFrame.URL_MIME_TYPE:
                    printMsg("%s: [Size: %d bytes] [Type: %s]" % (boldText(
                        img.picTypeToString(img.picture_type) +
                        " Image"), len(img.image_data), img.mime_type))
                    printMsg("Description: %s" % img.description)
                    printMsg("")
                    if self.args.write_images_dir:
                        img_path = "%s%s" % (self.args.write_images_dir,
                                             os.sep)
                        if not os.path.isdir(img_path):
                            raise IOError("Directory does not exist: %s" %
                                          img_path)
                        img_file = self._getDefaultNameForImage(img)
                        count = 1
                        while os.path.exists(os.path.join(img_path, img_file)):
                            img_file = self._getDefaultNameForImage(
                                img, str(count))
                            count += 1
                        printWarning("Writing %s..." %
                                     os.path.join(img_path, img_file))
                        with open(os.path.join(img_path, img_file),
                                  "wb") as fp:
                            fp.write(img.image_data)
                else:
                    printMsg("%s: [Type: %s] [URL: %s]" % (boldText(
                        img.picTypeToString(img.picture_type) +
                        " Image"), img.mime_type, img.image_url))
                    printMsg("Description: %s" % img.description)
                    printMsg("")

            # GOBJ
            for obj in tag.objects:
                printMsg(
                    "%s: [Size: %d bytes] [Type: %s]" %
                    (boldText("GEOB"), len(obj.object_data), obj.mime_type))
                printMsg("Description: %s" % obj.description)
                printMsg("Filename: %s" % obj.filename)
                printMsg("\n")
                if self.args.write_objects_dir:
                    obj_path = "%s%s" % (self.args.write_objects_dir, os.sep)
                    if not os.path.isdir(obj_path):
                        raise IOError("Directory does not exist: %s" %
                                      obj_path)
                    obj_file = self._getDefaultNameForObject(obj)
                    count = 1
                    while os.path.exists(os.path.join(obj_path, obj_file)):
                        obj_file = self._getDefaultNameForObject(
                            obj, str(count))
                        count += 1
                    printWarning("Writing %s..." %
                                 os.path.join(obj_path, obj_file))
                    with open(os.path.join(obj_path, obj_file), "wb") as fp:
                        fp.write(obj.object_data)

            # PRIV
            for p in tag.privates:
                printMsg("%s: [Data: %d bytes]" %
                         (boldText("PRIV"), len(p.data)))
                printMsg("Owner Id: %s" % p.owner_id)

            # MCDI
            if tag.cd_id:
                printMsg("\n%s: [Data: %d bytes]" %
                         (boldText("MCDI"), len(tag.cd_id)))

            # USER
            if tag.terms_of_use:
                printMsg("\nTerms of Use (%s): %s" %
                         (boldText("USER"), tag.terms_of_use))

            if self.args.verbose:
                printMsg("-" * 79)
                printMsg("%d ID3 Frames:" % len(tag.frame_set))
                for fid in tag.frame_set:
                    num_frames = len(tag.frame_set[fid])
                    count = " x %d" % num_frames if num_frames > 1 else ""
                    printMsg("%s%s" % (fid, count))
        else:
            raise TypeError("Unknown tag type: " + str(type(tag)))