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 increment_play_count_on_item(item: Item, store=True, write=True): # clear_dirty is necessary to make sure that `ordering_score` and # `ordering_info` will not get stored to the library item.clear_dirty() item["play_count"] = item.get("play_count", 0) + 1 if store: item.store() if write: item.write()