def test_check_not_duplicate_and_succeed_extraction(self): self.tagger.webservice.get = Mock(wraps=self.mock_get_fail) ab_feature_extraction( self.tagger, self.file.metadata["musicbrainz_recordingid"], "test.mp3", partial(self.mock_ab_extractor_callback_extraction_succeeded, self.tagger, self.file))
def extract_and_submit_acousticbrainz_features(self, objs): """Extract AcousticBrainz features and submit them.""" if not self.ab_extractor.available(): return for file in iter_files_from_objects(objs): # Skip unmatched files if not file.can_extract(): log.warning( "AcousticBrainz requires a MusicBrainz Recording ID, but file does not have it: %s" % file.filename) # And process matched ones else: file.set_pending() # Check if file was either already processed or sent to the AcousticBrainz server if file.acousticbrainz_features_file: results = (file.acousticbrainz_features_file, 0, "Writing results") ab_extractor_callback(self, file, results, False) elif file.acousticbrainz_is_duplicate: results = (None, 0, "Duplicate") ab_extractor_callback(self, file, results, False) else: file.acousticbrainz_error = False # Launch the acousticbrainz on a separate process log.debug("Extracting AcousticBrainz features from %s" % file.filename) ab_feature_extraction( self, file.metadata["musicbrainz_recordingid"], file.filename, partial(ab_extractor_callback, self, file))
def test_check_duplicate(self): self.tagger.webservice.get = Mock(wraps=self.mock_get_succeed) ab_feature_extraction( self.tagger, self.file.metadata["musicbrainz_recordingid"], self.file.filename, partial(self.mock_ab_extractor_callback_duplicate, self.tagger, self.file))
def test_submit_succeeded(self): self.file.set_pending() self.tagger.webservice.post = Mock(wraps=self.mock_post_succeed) ab_feature_extraction( self.tagger, self.file.metadata["musicbrainz_recordingid"], "test.mp3", partial(ab_extractor_callback, self.tagger, self.file) )