def run(self, args, skip_targets=False): """ Common argument parsing """ args = super(MusaScriptCommand, self).parse_args(args) self.prefixes = TreePrefixes() if skip_targets: return [], [], [] trees, tracks, metadata = [], [], [] for path in args.paths: if os.path.isdir(path): trees.append(Tree(path)) else: try: tracks.append(Track(path)) except TreeError: match = match_metadata(path) if match is not None: metadata.append(match) tracks_found = False for d in trees: if not len(d): continue tracks_found = True break if not tracks_found and not len(tracks) and not len(metadata): return [], [], [] return trees, tracks, metadata
def __init__(self, path, metadata=None): if metadata is None: metadata = match_metadata(path) if metadata is None: raise TreeError('Not a metadata file: {0}'.format(path)) self.path = path_string(path) self.extension = os.path.splitext(self.path)[1][1:].lower() if self.extension == '': self.extension = None self.metadata = metadata
def load(self): super(Album, self).load() self.metadata_files = [] for name in os.listdir(self.path): if match_codec(name) is not None: self.files.append((self.path, name)) else: metadata = match_metadata(name) if metadata is not None: self.metadata_files.append(MetaDataFile(os.path.join(self.path, name), metadata)) self.files.sort()
def load(self): IterableTrackFolder.load(self) self.metadata_files = [] for f in os.listdir(self.path): if match_codec(f) is not None: self.files.append((self.path, f)) else: metadata = match_metadata(f) if metadata is not None: self.metadata_files.append(MetaDataFile(os.path.join(self.path, f), metadata)) self.files.sort()