def __init__(self, item, rescan=False): self.artist = '' self.album = '' self.year = '' self.length = 0 item.build() songs = [] for i in item.playlist: if not callable(i): for p in plugin.mimetype('audio'): songs += p.get(None, [ i ]) else: songs.append(i) for song in songs: if not hasattr(song, 'filename'): continue try: data = mediainfo.get(song.filename) for type in ('artist', 'album'): setattr(self, type, self.strcmp(getattr(self, type), data[type])) self.year = self.strcmp(self.year, data['userdate']) if data['length']: self.length += int(data['length']) except OSError: pass if not self.length: return for type in ('artist', 'album', 'year', 'length'): if getattr(self, type): mediainfo.set(item.filename, type, getattr(self, type))
def __init__(self, dirname, force=False, rescan=False): self.artist = '' self.album = '' self.year = '' self.length = 0 self.changed = False self.force = force self.tag = eyeD3.Tag() cachefile = vfs.getoverlay(os.path.join(dirname, '..', 'freevo.cache')) subdirs = util.getdirnames(dirname, softlinks=False) filelist = None if not rescan: for subdir in subdirs: d = AudioParser(subdir, rescan) if d.changed: break else: # no changes in all subdirs, looks good if os.path.isfile(cachefile) and \ os.stat(dirname)[stat.ST_MTIME] <= os.stat(cachefile)[stat.ST_MTIME]: # and no changes in here. Do not parse everything again if force: # forces? We need to load our current values info = mediainfo.get(dirname) if info: for type in ('artist', 'album', 'year', 'length'): if info.has_key(type): setattr(self, type, info[type]) return if not filelist: filelist = util.match_files(dirname, config.AUDIO_SUFFIX) if not filelist and not subdirs: # no files in here? We are done return # ok, something changed here, too bad :-( self.changed = True self.force = False # scan all subdirs for subdir in subdirs: d = AudioParser(subdir, force=True, rescan=rescan) for type in ('artist', 'album', 'year'): setattr(self, type, self.strcmp(getattr(self, type), getattr(d, type))) self.length += d.length # cache dir first mediainfo.cache_dir(dirname) use_tracks = True for song in filelist: try: data = mediainfo.get(song) for type in ('artist', 'album'): setattr(self, type, self.strcmp(getattr(self, type), data[type])) self.year = self.strcmp(self.year, data['date']) if data['length']: self.length += int(data['length']) use_tracks = use_tracks and data['trackno'] except OSError: pass if use_tracks and (self.album or self.artist): mediainfo.set(dirname, 'audio_advanced_sort', True) if not self.length: return for type in ('artist', 'album', 'year', 'length'): if getattr(self, type): mediainfo.set(dirname, type, getattr(self, type)) data = mediainfo.get(dirname) modtime = os.stat(dirname)[stat.ST_MTIME] if not data['coverscan'] or data['coverscan'] != modtime: data.store('coverscan', modtime) self.extract_image(dirname)
def __init__(self, dirname, force=False, rescan=False): self.artist = '' self.album = '' self.year = '' self.length = 0 self.changed = False self.force = force self.tag = eyeD3.Tag() cachefile = vfs.getoverlay(os.path.join(dirname, '..', 'freevo.cache')) subdirs = util.getdirnames(dirname, softlinks=False) filelist = None if not rescan: for subdir in subdirs: d = AudioParser(subdir, rescan) if d.changed: break else: # no changes in all subdirs, looks good if os.path.isfile(cachefile) and os.stat(dirname)[stat.ST_MTIME] <= os.stat(cachefile)[stat.ST_MTIME]: # and no changes in here. Do not parse everything again if force: # forces? We need to load our current values info = mediainfo.get(dirname) if info: for type in ('artist', 'album', 'year', 'length'): if info.has_key(type): setattr(self, type, info[type]) return if not filelist: filelist = util.match_files(dirname, config.AUDIO_SUFFIX) if not filelist and not subdirs: # no files in here? We are done return # ok, something changed here, too bad :-( self.changed = True self.force = False # scan all subdirs for subdir in subdirs: d = AudioParser(subdir, force=True, rescan=rescan) for type in ('artist', 'album', 'year'): setattr(self, type, self.strcmp(getattr(self, type), getattr(d, type))) self.length += d.length # cache dir first mediainfo.cache_dir(dirname) use_tracks = True for song in filelist: try: data = mediainfo.get(song) for type in ('artist', 'album'): setattr(self, type, self.strcmp(getattr(self, type), data[type])) self.year = self.strcmp(self.year, data['userdate']) if data['length']: self.length += int(data['length']) use_tracks = use_tracks and data['trackno'] except OSError: pass if use_tracks and (self.album or self.artist): mediainfo.set(dirname, 'audio_advanced_sort', True) if not self.length: return for type in ('artist', 'album', 'year', 'length'): if getattr(self, type): mediainfo.set(dirname, type, getattr(self, type)) data = mediainfo.get(dirname) modtime = os.stat(dirname)[stat.ST_MTIME] if not data['coverscan'] or data['coverscan'] != modtime: data.store('coverscan', modtime) self.extract_image(dirname)