def add_additional_data(self, item: Item, write: bool = False) -> None: """Fetch and store: * lyrics, if enabled * release description as comments """ guru = self.guru(item.mb_albumid or item.mb_trackid) backup = "" if item.comments.startswith == "Visit http": backup = item.comments item.comments = "" for bandcamp_field, item_field in ADDITIONAL_DATA_MAP.items(): if item_field in self.excluded_extra_fields: continue if getattr(item, item_field, None): self._info("{} field: already present on {}", item_field, item) continue setattr(item, item_field, getattr(guru, bandcamp_field)) if getattr(item, item_field, None): self._info("Obtained {} for {}", bandcamp_field, item) if not item.comments: item.comments = backup if write: item.try_write() item.store()
def test_singleton_cheat_mode(single_track_release): """In the cheat mode it should take around 1-2s to match a singleton.""" _, expected_release = single_track_release expected = expected_release.singleton pl = BandcampPlugin() item = Item() item.comments = "Visit " + expected.artist_id item.title = expected.artist + " - " + expected.title candidates = pl.item_candidates(item, expected.artist, item.title) track = next(candidates) assert vars(track) == vars(expected)