Example #1
0
def update_repos():
    """Force an update of the repositories"""
    if get_global_setting(
            'general.addonupdates') == 0:  # Automatic updates is enabled
        execute_builtin('UpdateAddonRepos')
        ok_dialog(heading=localize(30450),
                  message=localize(30451))  # Repositories are being updated
    else:
        ok_dialog(heading=localize(30452),
                  message=localize(30453))  # Automatic updates is disabled
        show_settings_addons()
    def __map_seasons(self, program, seasons, episodes):
        import random
        season_items = []
        sort = 'label'
        ascending = True
        content = 'seasons'

        episode = random.choice(episodes)
        info_labels = self._metadata.get_info_labels(episode, season=True)
        program_type = episode.get('programType')

        # Reverse sort seasons if program_type is 'reeksaflopend' or 'daily'
        if program_type in ('daily', 'reeksaflopend'):
            ascending = False

        # Add an "* All seasons" list item
        if get_global_setting('videolibrary.showallitems') is True:
            season_items.append(TitleItem(
                title=localize(30133),
                path=url_for('programs', program=program, season='allseasons'),
                art_dict=self._metadata.get_art(episode, season='allseasons'),
                info_dict=info_labels,
            ))

        # NOTE: Sort the episodes ourselves, because Kodi does not allow to set to 'ascending'
        seasons = sorted(seasons, key=lambda k: k['key'], reverse=not ascending)

        for season in seasons:
            season_key = season.get('key', '')
            try:
                # If more than 300 episodes exist, we may end up with an empty season (Winteruur)
                episode = random.choice([e for e in episodes if e.get('seasonName') == season_key])
            except IndexError:
                episode = episodes[0]

            label = '%s %s' % (localize(30131), season_key)
            season_items.append(TitleItem(
                title=label,
                path=url_for('programs', program=program, season=season_key),
                art_dict=self._metadata.get_art(episode, season=True),
                info_dict=info_labels,
                prop_dict=self._metadata.get_properties(episode),
            ))
        return season_items, sort, ascending, content