def get_mp3_tags(file): from mp3_tagger import MP3File if util.get_file_extension(file).lower() != 'mp3': raise FileTypeError('File %s is not an mp3 file') # Create MP3File instance. mp3 = MP3File(file) return {'artist' : mp3.artist, 'author' : mp3.artist, 'song' : mp3.song, 'title' : mp3.song, \ 'album' : mp3.album, 'year' : mp3.year, 'track' : mp3.track, 'genre' : mp3.genre, 'comment' : mp3.comment}
def get_tags(self): """Returns all file MP3 tags""" from mp3_tagger import MP3File if util.get_file_extension(self.filename).lower() != 'mp3': raise media.FileTypeError('File %s is not an mp3 file') # Create MP3File instance. mp3 = MP3File(self.filename) self.artist = mp3.artist self.title = mp3.song self.album = mp3.album self.year = mp3.year self.track = mp3.track self.genre = mp3.genre self.comment = mp3.comment
def get_file_specs(self): '''Reads file format specs''' self.format = self.specs['format']['format_name'] if self.format == 'mov,mp4,m4a,3gp,3g2,mj2': ext = util.get_file_extension(self.filename) if re.match('^(mp4|mov)', ext, re.IGNORECASE): self.format = ext.lower() self.format_long = self.specs['format']['format_long_name'] self.nb_streams = int(self.specs['format']['nb_streams']) self.size = int(self.specs['format']['size']) try: self.bitrate = int(self.specs['format']['bit_rate']) except KeyError as e: util.logger.error("JSON %s has no key %s\n", util.json_fmt(self.specs), e.args[0]) try: self.duration = float(self.specs['format']['duration']) except KeyError as e: util.logger.error("JSON %s has no key %s\n", util.json_fmt(self.specs), e.args[0])
def build_target_file(source_file, profile): extension = util.get_profile_extension(profile) if extension is None: extension = util.get_file_extension(source_file) return util.add_postfix(source_file, profile, extension)