def check_tv_show(tvshow_id=None, child_type="all", autofix=False, accumulate=False, interactive=False, filter=""): """Check constraints for season/episodes of this TV show Arguments --------- tvshow_id: str the Wiki ID of the television series, in the format Q######. child_type: str one of "episode", "season", "series", or "all" autofix: bool whether or not to attempt auto-fixing constraint failures accumulate: bool whether or not to accumulate all fixes before applying them to WikiData interactive: bool whether or not to prompt for confirmation before making edits filter: str a comma-separated list of properties in the format P###. Only edits for these properties will be applied. """ if child_type == "episode": instance_types = [wp.TELEVISION_SERIES_EPISODE] elif child_type == "season": instance_types = [wp.TELEVISION_SERIES_SEASON] elif child_type == "series": instance_types = [wp.TELEVISION_SERIES] elif child_type == "all": instance_types = [ wp.TELEVISION_SERIES, wp.TELEVISION_SERIES_SEASON, wp.TELEVISION_SERIES_EPISODE ] for instance_of_type in instance_types: key_val_pairs = { wp.PART_OF_THE_SERIES.pid: tvshow_id, wp.INSTANCE_OF.pid: instance_of_type } query = generate_sparql_query(key_val_pairs) gen = WikidataSPARQLPageGenerator(query) if instance_of_type == wp.TELEVISION_SERIES: gen = [ItemPage(Site().data_repository(), tvshow_id)] bot = getbot(gen, autofix=autofix, accumulate=accumulate, always=(not interactive), property_filter=filter) bot.run()
def previous(self) -> Optional[Season]: """The previous season, if any""" # Check if it has the FOLLOWS field set previous_season_itempage = self.first_claim(wp.FOLLOWS.pid) if previous_season_itempage is not None: return Season(previous_season_itempage) # Find the item that has the FOLLOWED_BY field set to this item query = generate_sparql_query({wp.FOLLOWED_BY.pid: self.qid}) gen = WikidataSPARQLPageGenerator(query) follows = next(gen, None) if follows is not None: return Season(follows) # Find the item whose ordinal is one lower for this series if self.ordinal_in_series is not None: return self.previous_in_series return None
def next(self) -> Optional[Season]: """The next season, if any""" # Check if it has the FOLLOWED_BY field set next_season_itempage = self.first_claim(wp.FOLLOWED_BY.pid) if next_season_itempage is not None: return Season(next_season_itempage) # Find the item that has the FOLLOWS field set to this item query = generate_sparql_query({wp.FOLLOWS.pid: self.qid}) gen = WikidataSPARQLPageGenerator(query) is_followed_by = next(gen, None) if is_followed_by is not None: return Season(is_followed_by) # Find the item whose ordinal is one higher for this series if self.ordinal_in_series is not None: return self.next_in_series return None
def check_tv_show(tvshow_id=None, child_type="episode", autofix=False, accumulate=False, always=False, filter=""): """Check constraints for season/episodes of this TV show TVSHOW_ID is the ID of the television series, in the format Q######. """ if child_type == "episode": instance_types = [wp.TELEVISION_SERIES_EPISODE] elif child_type == "season": instance_types = [wp.TELEVISION_SERIES_SEASON] elif child_type == "series": instance_types = [wp.TELEVISION_SERIES] elif child_type == "all": instance_types = [ wp.TELEVISION_SERIES, wp.TELEVISION_SERIES_SEASON, wp.TELEVISION_SERIES_EPISODE ] for instance_of_type in instance_types: key_val_pairs = { wp.PART_OF_THE_SERIES.pid: tvshow_id, wp.INSTANCE_OF.pid: instance_of_type } query = generate_sparql_query(key_val_pairs) gen = WikidataSPARQLPageGenerator(query) if instance_of_type == wp.TELEVISION_SERIES: gen = [ItemPage(Site().data_repository(), tvshow_id)] bot = getbot(gen, autofix=autofix, accumulate=accumulate, always=always, property_filter=filter) bot.run()