def add_files(self, filenames, target=None): """Add files to the tagger.""" ignoreregex = None pattern = config.setting['ignore_regex'] if pattern: ignoreregex = re.compile(pattern) ignore_hidden = config.setting["ignore_hidden_files"] new_files = [] tmp_files = {} for filename in filenames: filename = os.path.normpath(os.path.realpath(filename)) if ignore_hidden and is_hidden(filename): log.debug("File ignored (hidden): %s" % (filename)) continue if ignoreregex is not None and ignoreregex.search(filename): log.info("File ignored (matching %s): %s" % (pattern, filename)) continue if filename not in self.files: file = open_file(filename) if file: tmp_files[filename] = file new_files.append(file) if new_files and self.check_load(new_files): for filename in tmp_files: file = open_file(filename) self.files[filename] = file log.debug("Adding files %r", new_files) new_files.sort(key=lambda x: x.filename) if target is None or target is self.unmatched_files: self.unmatched_files.add_files(new_files) target = None for file in new_files: file.load(partial(self._file_loaded, target=target))
def add_files(self, filenames, target=None): """Add files to the tagger.""" ignoreregex = None pattern = config.setting['ignore_regex'] if pattern: ignoreregex = re.compile(pattern) ignore_hidden = config.setting["ignore_hidden_files"] new_files = [] for filename in filenames: filename = os.path.normpath(os.path.realpath(filename)) if ignore_hidden and is_hidden(filename): log.debug("File ignored (hidden): %r" % (filename)) continue # Ignore .smbdelete* files which Applie iOS SMB creates by renaming a file when it cannot delete it if os.path.basename(filename).startswith(".smbdelete"): log.debug("File ignored (.smbdelete): %r", filename) continue if ignoreregex is not None and ignoreregex.search(filename): log.info("File ignored (matching %r): %r" % (pattern, filename)) continue if filename not in self.files: file = open_file(filename) if file: self.files[filename] = file new_files.append(file) if new_files: log.debug("Adding files %r", new_files) new_files.sort(key=lambda x: x.filename) if target is None or target is self.unclustered_files: self.unclustered_files.add_files(new_files) target = None for file in new_files: file.load(partial(self._file_loaded, target=target))
def add_files(self, filenames, target=None): """Add files to the tagger.""" ignoreregex = None pattern = config.setting['ignore_regex'] if pattern: ignoreregex = re.compile(pattern) ignore_hidden = not config.persist["show_hidden_files"] new_files = [] for filename in filenames: filename = os.path.normpath(os.path.realpath(filename)) if ignore_hidden and is_hidden_path(filename): log.debug("File ignored (hidden): %s" % (filename)) continue if ignoreregex is not None and ignoreregex.search(filename): log.info("File ignored (matching %s): %s" % (pattern, filename)) continue if filename not in self.files: file = open_file(filename) if file: self.files[filename] = file new_files.append(file) if new_files: log.debug("Adding files %r", new_files) new_files.sort(key=lambda x: x.filename) if target is None or target is self.unmatched_files: self.unmatched_files.add_files(new_files) target = None for file in new_files: file.load(partial(self._file_loaded, target=target))
def add_files(self, filenames, target=None): """Add files to the tagger.""" ignoreregex = None config = get_config() pattern = config.setting['ignore_regex'] if pattern: try: ignoreregex = re.compile(pattern) except re.error as e: log.error( "Failed evaluating regular expression for ignore_regex: %s", e) ignore_hidden = config.setting["ignore_hidden_files"] new_files = [] for filename in filenames: filename = normpath(filename) if ignore_hidden and is_hidden(filename): log.debug("File ignored (hidden): %r" % (filename)) continue # Ignore .smbdelete* files which Applie iOS SMB creates by renaming a file when it cannot delete it if os.path.basename(filename).startswith(".smbdelete"): log.debug("File ignored (.smbdelete): %r", filename) continue if ignoreregex is not None and ignoreregex.search(filename): log.info("File ignored (matching %r): %r" % (pattern, filename)) continue if filename not in self.files: file = open_file(filename) if file: self.files[filename] = file new_files.append(file) QtCore.QCoreApplication.processEvents() if new_files: log.debug("Adding files %r", new_files) new_files.sort(key=lambda x: x.filename) self.window.set_sorting(False) self._pending_files_count += len(new_files) unmatched_files = [] for i, file in enumerate(new_files): file.load( partial(self._file_loaded, target=target, unmatched_files=unmatched_files)) # Calling processEvents helps processing the _file_loaded # callbacks in between, which keeps the UI more responsive. # Avoid calling it to often to not slow down the loading to much # Using an uneven number to have the unclustered file counter # not look stuck in certain digits. if i % 17 == 0: QtCore.QCoreApplication.processEvents()
def add_files(self, filenames): """Add files to the tagger.""" self.log.debug("Adding files %r", filenames) new_files = [] for filename in filenames: filename = os.path.normpath(os.path.realpath(filename)) if filename not in self.files: file = open_file(filename) if file: self.files[filename] = file new_files.append(file) if new_files: self.unmatched_files.add_files(new_files) for file in new_files: file.load(self._file_loaded)
def add_files(self, filenames, target=None): """Add files to the tagger.""" log.debug("Adding files %r", filenames) new_files = [] for filename in filenames: filename = os.path.normpath(os.path.realpath(filename)) if filename not in self.files: file = open_file(filename) if file: self.files[filename] = file new_files.append(file) if new_files: if target is None or target is self.unmatched_files: self.unmatched_files.add_files(new_files) target = None for file in new_files: file.load(partial(self._file_loaded, target=target))
def encodeFinished(self): self._encode_process_count -= 1 if self._encode_process_count == 0: for path, track in self._flac_files: f = open_file(path) f.parent = track self.tagger.files[path] = f track.add_file(f) f.load(lambda *_, **__: True) if len(self._flac_files) != self._expected_num_tracks: self.log.debug('Ripping/encoding was aborted.') return self.log.debug('Encoding successful!') self.album.load() self.widget.ui.finished_button.setEnabled(True) self._tmpdir = tempfile.mkdtemp()
def add_files(self, filenames, target=None, result=None): """Add files to the tagger.""" if result: filenames = result # Handles add_directory task results coming from a worker thread ignoreregex = None pattern = config.setting['ignore_regex'] if pattern: try: ignoreregex = re.compile(pattern) except re.error as e: log.error( "Failed evaluating regular expression for ignore_regex: %s", e) ignore_hidden = config.setting["ignore_hidden_files"] new_files = [] for filename in filenames: filename = os.path.normpath(os.path.realpath(filename)) if ignore_hidden and is_hidden(filename): log.debug("File ignored (hidden): %r" % (filename)) continue # Ignore .smbdelete* files which Applie iOS SMB creates by renaming a file when it cannot delete it if os.path.basename(filename).startswith(".smbdelete"): log.debug("File ignored (.smbdelete): %r", filename) continue if ignoreregex is not None and ignoreregex.search(filename): log.info("File ignored (matching %r): %r" % (pattern, filename)) continue if filename not in self.files: file = open_file(filename) if file: self.files[filename] = file new_files.append(file) QtCore.QCoreApplication.processEvents() if new_files: log.debug("Adding files %r", new_files) new_files.sort(key=lambda x: x.filename) self.window.set_sorting(False) self._pending_files_count += len(new_files) for file in new_files: file.load(partial(self._file_loaded, target=target)) QtCore.QCoreApplication.processEvents()
def _encode(self, album): """Encodes the previously ripped CD to Flac.""" flac_opts = self.config.setting['cdripper_flac_opts'] try: for track in album.tracks: self.tagger.window.set_statusbar_message( 'Encoding "%s"...', track.metadata['title']) track_number = track.metadata['tracknumber'].zfill(2) wav_name = 'track%s.cdda.wav' % track_number wav_path = os.path.join(self.target_path, wav_name) flac_name = '%s %s.flac' % (track_number, track.metadata['title']) flac_path = os.path.join(self.target_path, flac_name) output_args = ('-o', flac_path, wav_path) cmd_line = ('flac', ) + tuple(flac_opts.split()) + output_args #subprocess.check_call(cmd_line) f = open_file(flac_path) track.add_file(f) except subprocess.CalledProcessError: album.log.error(traceback.format_exc()) album.load()