Ejemplo n.º 1
0
    def _embed_art(self):
        """
        > embed album artwork into each track
        * artwork is temporarily downloaded first, and removed later
        * artwork is embed with the mutagen library
        """
        pretty_print("%dim%downloading temporary artwork to embed")
        raw_file = wgetter.download(self.art_url)
        artwork_data = open(raw_file, "rb").read()
        all_tracks = [file for file in os.listdir() if \
            os.path.splitext(file)[1] == ".mp3"]

        for track in all_tracks:
            muta_track = mutagen.mp3.MP3(track)
            muta_track["APIC:Cover"] = mutagen.id3.APIC(
                encoding=3,
                mime="image/jpeg",
                type=3,
                desc="Cover",
                data=artwork_data
            )
            muta_track.save()
            pretty_print("%dim%embeded artowork for track \"{0}\"".format(track))

        try:
            os.remove(raw_file)
            pretty_print("%dim%deleted temporary artwork")
        except (PermissionError, OSError):
            show_status("%dim%%red%failed %reset%to delete temporary art file " + raw_file)
Ejemplo n.º 2
0
 def _download_art(self):
     """
     > download album artwork using the wgetter module
     * file is renamed to "front.jpg"
     """
     try:
         pretty_print("%green%downloading %reset%artwork")
         raw_file = wgetter.download(self.art_url)
         os.rename(raw_file, "front.jpg")
     except (FileNotFoundError, FileExistsError):
         pretty_print("%red%failed %reset%to download or rename artwork")
     finally:
         if os.path.isfile(raw_file):
             os.remove(raw_file)
Ejemplo n.º 3
0
    def _download_tracks(self):
        """
        > download tracks using the wgetter module
        * files are renamed to "{trackno}. {trackname}.mp3"
        """
        for track in self.tracks:
            if track["track_num"] in self.config["exclude"]:
                pretty_print("%red%skipping %reset%track #{0} \"{1}\"".format(
                    track["track_num"], track["title"])
                )
                continue

            pretty_print("%green%downloading %reset%track #{0} \"{1}\"".format(
                track["track_num"], track["title"])
            )
            raw_file = wgetter.download("http:" + track["url"])
            new_file = "{0}. {1}.mp3".format(track["track_num"], track["title"])
            os.rename(raw_file, new_file)
            self._write_tags(new_file, track["track_num"])