예제 #1
0
def set_artists(audio: EasyID3, artists):
    """
    Sets an artist for an EasyID3 object
    :param audio: EasyID3
    :param artist: string or list[str] of the artist or artists
    """
    audio['artist'] = artists
    audio.save()
예제 #2
0
def set_title(audio: EasyID3, title: str):
    """
    Sets a title for an EasyID3 object
    :param audio: EasyID3 Object
    :param title: string
    """
    audio['title'] = title
    audio.save()
예제 #3
0
def set_album_artist(audio: EasyID3, album_artist):
    """
    Sets an album coverist for an EasyID3 object
    :param audio: EasyID3
    :param album_artist: name of the album coverist
    """
    audio['albumartist'] = album_artist
    audio.save()
예제 #4
0
def set_album(audio: EasyID3, album):
    """
    Sets an album for an EasyID3 object
    :param audio: EasyID3
    :param album: string name of the album
    """
    audio['album'] = album
    audio.save()
예제 #5
0
def convert_file(file_path):
    mp3_file = file_path.replace(".mp4", ".mp3")
    if not os.path.isfile(mp3_file):
        clip = AudioFileClip(file_path)
        clip.write_audiofile(mp3_file)
        clip.close()
        mp4 = MP4(file_path)
        mp3 = EID(mp3_file)
        mp3["title"] = mp4.tags.get("\xa9nam")  # video title
        mp3["artist"] = mp4.tags.get(
            "\xa9ART")  # video author (channel video came from)
        mp3["album"] = mp4.tags.get("\xa9alb")
        mp3.save()  # save changes to video
        os.remove(file_path)
예제 #6
0
 def tag_and_rename(self, filepath, filename, outpath, artist, title):
     path_to_file = os.path.join(filepath, filename)
     userpath = os.path.expanduser('~')
     rel_filepath = re.sub(userpath, '', filepath)
     rel_outpath = re.sub(userpath, '', outpath)
     #        outpath = os.path.join(userpath, rel_outpath, rel_filepath)
     outpath = userpath + rel_outpath + rel_filepath
     if not os.path.exists(outpath):
         os.makedirs(outpath)
     try:
         audio_file = ID(path_to_file)
     except mutagen.id3.ID3NoHeaderError:
         audio_file = mutagen.File(path_to_file, easy=True)
         audio_file.add_tags()
     audio_file.delete()
     audio_file['artist'] = 'artist'
     audio_file['title'] = 'title'
     audio_file.save()
     print("Renaming to: {} - {}.mp3".format(artist, title))
     os.rename(path_to_file,
               os.path.join(outpath, artist + ' - ' + title + '.mp3'))