def __init__(self, container): self.container = container # fix #737 EasyID3 doesn't recognize subtitle and comment tags EasyID3.RegisterTextKey("comments", "COMM") EasyID3.RegisterTextKey("subtitle", "TIT3") EasyMP4Tags.RegisterTextKey("comments", "desc") EasyMP4Tags.RegisterFreeformKey("subtitle", "SUBTITLE")
def add_tag_m4a(self, fichero, name_cancion, parDir, directorio): # No Funciona patronMusicam4a = re.compile('.\.m4a') if patronMusicam4a.search(str(fichero)): name_cancion = name_cancion.rstrip( ".m4a" ) # ahora al nombre le quitamos la extension que queda fea. try: print( "file", os.path.basename(str(fichero)), "directory_1", os.path.basename(str(self.ruta)), "dir_2:", os.path.basename( os.path.dirname(os.path.normpath(str(self.ruta))))) EasyMP4Tags.RegisterTextKey("artist", "@ART") audioTag = EasyMP4(str(fichero)) audioTag['title'] = name_cancion audioTag['artist'] = parDir audioTag['album'] = directorio EasyMP4.RegisterTextKey("album_artist", "TPE2") audioTag['album_artist'] = "" print(audioTag['title'], "nuevo") audioTag.save() except: audioTag = mutagen.File(fichero, easy=True) audioTag.add_tags() audioTag['title'] = name_cancion audioTag['album'] = directorio audioTag['artist'] = parDir print("No existe un tag previo") audioTag.save(v2_version=3) audioTag.save()
# Python 2 from UserDict import DictMixin as MutableMapping # Set up logging logFormatter = logging.Formatter('%(asctime)s %(levelname)s: %(message)s') logger = logging.getLogger(__name__) logger.setLevel(logging.INFO) logger.handlers = [] logger.addHandler(logging.StreamHandler()) for handler in logger.handlers: handler.setFormatter(logFormatter) # Support checksums for MP3 and M4A/MP4 EasyID3.RegisterTXXXKey('transfercoder_src_checksum', 'TRANSFERCODER_SRC_CHECKSUM') EasyMP4Tags.RegisterFreeformKey('transfercoder_src_checksum', 'Transfercoder Source Checksum') def call_silent(cmd: Union[str, Sequence[str]], *args, **kwargs) -> int: """Like subprocess.call, but redirects stdin/out/err to null device.""" nullsrc = open(os.devnull, "r") nullsink = open(os.devnull, "w") kwargs['stdin'] = nullsrc kwargs['stdout'] = nullsink kwargs['stderr'] = nullsink logger.debug("Calling command: %s", repr(cmd)) return call(cmd, *args, **kwargs) def del_hidden(paths: List[str]) -> None: """Remove hidden paths from list of paths This modifies its argument *in place* rather than returning it, so it
from mutagen.easymp4 import EasyMP4Tags from rganalysis.common import logger, format_gain, format_peak, parse_gain, parse_peak from rganalysis.backends import GainComputer from rganalysis.fixup_id3 import fixup_ID3 rg_tags = ( 'replaygain_track_gain', 'replaygain_track_peak', 'replaygain_album_gain', 'replaygain_album_peak', 'replaygain_reference_loudness', ) for tag in rg_tags: # Support replaygain tags for M4A/MP4 EasyMP4Tags.RegisterFreeformKey(tag, tag) def fullpath(f: str) -> str: '''os.path.realpath + expanduser''' return os.path.realpath(os.path.expanduser(f)) def Property(function: Callable) -> Callable: keys = 'fget', 'fset', 'fdel' func_locals = {'doc':function.__doc__} def probe_func(frame, event, arg): # type: ignore if event == 'return': locals = frame.f_locals func_locals.update(dict((k,locals.get(k)) for k in keys)) sys.settrace(None) return probe_func sys.settrace(probe_func)