Exemple #1
0
 def update(self):
     if self.editing:
         return
     if self.selection_dirty:
         self._update_selection()
     thread.run_task(self._update_tags, self._update_items,
         thread_pool=self.tagger.priority_thread_pool)
Exemple #2
0
 def save(self):
     self.set_pending()
     metadata = Metadata()
     metadata.copy(self.metadata)
     thread.run_task(partial(self._save_and_rename, self.filename,
                             metadata),
                     self._saving_finished,
                     priority=2,
                     thread_pool=self.tagger.save_thread_pool)
Exemple #3
0
 def save(self):
     self.set_pending()
     metadata = Metadata()
     metadata.copy(self.metadata)
     thread.run_task(
         partial(self._save_and_rename, self.filename, metadata),
         self._saving_finished,
         priority=2,
         thread_pool=self.tagger.save_thread_pool)
Exemple #4
0
 def update(self, drop_album_caches=False):
     if self.editing:
         return
     new_selection = self.selection_dirty
     if self.selection_dirty:
         self._update_selection()
     thread.run_task(partial(self._update_tags, new_selection,
                             drop_album_caches),
                     self._update_items,
                     thread_pool=self.tagger.priority_thread_pool)
Exemple #5
0
 def callback(self, objs):
     for obj in objs:
         if (isinstance(obj, Track)):
             for f in obj.linked_files:
                 thread.run_task(
                     partial(self.process, None, f.metadata, obj, None,
                             True), partial(self._finish, f))
         elif (isinstance(obj, File)):
             thread.run_task(
                 partial(self.process, None, obj.metadata, None, None,
                         True), partial(self._finish, obj))
Exemple #6
0
 def cluster(self, objs, callback=None):
     """Group files with similar metadata to 'clusters'."""
     log.debug("Clustering %r", objs)
     files = iter_files_from_objects(objs)
     try:
         file = next(files)
     except StopIteration:
         files = self.unclustered_files.files
     else:
         files = itertools.chain([file], files)
     thread.run_task(partial(self._do_clustering, list(files)),
                     partial(self._clustering_finished, callback))
Exemple #7
0
 def callback(self, obj):
     def save(pf):
         metadata = Metadata()
         metadata.copy(pf.metadata)
         mf = MFile(pf.filename)
         if mf is not None:
             mf.delete()
         return pf._save_and_rename(pf.filename, metadata)
     for f in self.tagger.get_files_from_objects(obj, save=True):
         f.set_pending()
         thread.run_task(partial(save, f), f._saving_finished,
                         priority=2, thread_pool=f.tagger.save_thread_pool)
Exemple #8
0
    def callback(self, objs):
        albums = filter(
            lambda o: isinstance(o, Album) and not isinstance(o, NatAlbum),
            objs)
        nats = filter(lambda o: isinstance(o, NatAlbum), objs)

        for album in albums:
            thread.run_task(partial(self._calculate_albumgain, album),
                            partial(self._albumgain_callback, album))

        for natalbum in nats:
            thread.run_task(partial(self._calculate_natgain, natalbum),
                            partial(self._albumgain_callback, natalbum))
Exemple #9
0
    def lookup_cd(self, action):
        """Reads CD from the selected drive and tries to lookup the DiscID on MusicBrainz."""
        if isinstance(action, QtGui.QAction):
            device = unicode(action.text())
        elif config.setting["cd_lookup_device"] != "":
            device = config.setting["cd_lookup_device"].split(",", 1)[0]
        else:
            # rely on python-discid auto detection
            device = None

        disc = Disc()
        self.set_wait_cursor()
        thread.run_task(partial(disc.read, encode_filename(device)), partial(self._lookup_disc, disc))
Exemple #10
0
    def lookup_cd(self, action):
        """Reads CD from the selected drive and tries to lookup the DiscID on MusicBrainz."""
        if isinstance(action, QtWidgets.QAction):
            device = action.text()
        elif config.setting["cd_lookup_device"] != '':
            device = config.setting["cd_lookup_device"].split(",", 1)[0]
        else:
            # rely on python-discid auto detection
            device = None

        disc = Disc()
        self.set_wait_cursor()
        thread.run_task(partial(disc.read, encode_filename(device)),
                        partial(self._lookup_disc, disc))
Exemple #11
0
    def callback(self, objs):
        albums = filter(lambda o: isinstance(o, Album) and not isinstance(o,
                        NatAlbum), objs)
        nats = filter(lambda o: isinstance(o, NatAlbum), objs)

        for album in albums:
            thread.run_task(
                partial(self._calculate_albumgain, album),
                partial(self._albumgain_callback, album))

        for natalbum in nats:
            thread.run_task(
                partial(self._calculate_natgain, natalbum),
                partial(self._albumgain_callback, natalbum))
Exemple #12
0
    def _load(self, filename):
        self.log.debug("Loading file %r", filename)
        metadata = Metadata()
        do_tracks = False
        temp_lines = {}
        current_track = None

        with open(filename, "rb") as cuesheet:
            for line in cuesheet:
                line = line.decode("utf-8")
                splitline = line.split()
                key = splitline[0]
                value = " ".join(splitline[1:]).strip()
                if not do_tracks:
                    if not key == "TRACK":
                        if key == "FILE":
                            self.fileline = value
                        else:
                            self.kv_to_metadata(key, value, metadata)
                    else:
                        do_tracks = True
                        current_track = value.split()[0]
                        temp_lines[current_track] = []
                else:
                    if key == "TRACK":
                        current_track = value.split()[0]
                        temp_lines[current_track] = []
                    temp_lines[current_track].append(line)

        for k, text_metadata in temp_lines.items():
            fake_filename = u"%s #%s" % (filename, k)
            cuefile = CueSheetTrack(filename, self, k, metadata)
            self.tracks.append(cuefile)
            self.tagger.files[fake_filename] = cuefile
            thread.run_task(
                partial(cuefile._load, text_metadata),
                partial(
                    cuefile._loading_finished,
                    partial(
                        self.tagger._file_loaded,
                        None
                        )
                    ),
                QtCore.Qt.LowEventPriority + 1)
        self.tagger.remove_files([self])
        return metadata
Exemple #13
0
 def update(self):
     if self.editing:
         return
     if self.selection_dirty:
         self._update_selection()
     thread.run_task(self._update_tags, self._update_items)
Exemple #14
0
 def _add_file_to_queue(self, file):
     thread.run_task(partial(self._generate_moodbar, file),
                     partial(self._moodbar_callback, file))
Exemple #15
0
 def on_file_load_processor(file):
     thread.run_task(
         partial(load_attrs_to_metadata, file),
         partial(load_attrs_to_metadata_finished, file))
Exemple #16
0
 def on_file_save_processor(file):
     thread.run_task(
         partial(set_attrs_from_metadata, file),
         partial(set_attrs_from_metadata_finished, file))
Exemple #17
0
 def _add_file_to_queue(self, file):
     thread.run_task(
         partial(self._generate_moodbar, file),
         partial(self._moodbar_callback, file))
Exemple #18
0
 def load(self, callback):
     thread.run_task(
         partial(self._load, self.filename),
         partial(self._loading_finished, callback),
         priority=1)
Exemple #19
0
 def load(self, callback):
     thread.run_task(
         partial(self._load_check, self.filename),
         partial(self._loading_finished, callback),
         priority=1)
Exemple #20
0
 def update(self):
     if self.editing:
         return
     if self.selection_dirty:
         self._update_selection()
     thread.run_task(self._update_tags, self._update_items)
Exemple #21
0
 def callback(self, objs):
     albums = [o for o in objs if isinstance(o, Album)]
     for album in albums:
         thread.run_task(
             partial(self._calculate_albumgain, album),
             partial(self._albumgain_callback, album))
Exemple #22
0
 def process(result=None, error=None):
     if result:
         if error is None:
             self.add_files(result)
         thread.run_task(get_files, process)
Exemple #23
0
 def _add_file_to_queue(self, file):
     thread.run_task(
         partial(self._calculate_bpm, file),
         partial(self._calculate_bpm_callback, file))
Exemple #24
0
 def _add_file_to_queue(self, file):
     thread.run_task(
         partial(self._calculate_replaygain, file),
         partial(self._replaygain_callback, file))
Exemple #25
0
 def callback(self, objs):
     albums = [o for o in objs if isinstance(o, Album)]
     for album in albums:
         thread.run_task(partial(self._calculate_albumgain, album),
                         partial(self._albumgain_callback, album))
Exemple #26
0
 def processTrack(self, album, metadata, track, release):
     for f in track.linked_files:
         thread.run_task(
             partial(self.process, album, metadata, track, release, False),
             partial(self._finish, f))
Exemple #27
0
 def processFile(self, track, file):
     thread.run_task(
         partial(self.process, None, file.metadata, track, None, False),
         partial(self._finish, file))
Exemple #28
0
 def process(result=None, error=None):
     if result:
         if error is None:
             self.add_files(result)
         thread.run_task(get_files, process)
Exemple #29
0
 def _add_file_to_queue(self, file):
     settings = bpm_slider_settings[config.setting["bpm_slider_parameter"]]
     thread.run_task(partial(self._calculate_bpm, file, settings),
                     partial(self._calculate_bpm_callback, file))