Ejemplo n.º 1
0
 def on_authenticated(self, auth_dialog=True):
     """Triggered when device authentication has been completed"""
     kodi_log(u'Trakt authenticated successfully!', 1)
     ADDON.setSettingString('trakt_token', dumps(self.authorization))
     self.headers['Authorization'] = u'Bearer {0}'.format(self.authorization.get('access_token'))
     if auth_dialog:
         self.auth_dialog.close()
    def update_tvshows(self, force=False, **kwargs):
        nfos = self.get_tv_folder_nfos()

        # Update each show in folder
        nfos_total = len(nfos)
        for x, i in enumerate(nfos):
            self._update(x, nfos_total, message=u'{} {}...'.format(ADDON.getLocalizedString(32167), i['folder']))
            self.add_tvshow(tmdb_id=i['tmdb_id'], force=force)

        # Update last updated stamp
        ADDON.setSettingString('last_autoupdate', u'Last updated {}'.format(get_current_date_time()))
Ejemplo n.º 3
0
def set_defaultplayer(**kwargs):
    tmdb_type = kwargs.get('set_defaultplayer')
    setting_name = 'default_player_movies' if tmdb_type == 'movie' else 'default_player_episodes'
    default_player = Players(tmdb_type).select_player(detailed=True,
                                                      clear_player=True)
    if not default_player:
        return
    if not default_player.get('file') or not default_player.get('mode'):
        return ADDON.setSettingString(setting_name, '')
    ADDON.setSettingString(
        setting_name, u'{} {}'.format(default_player['file'],
                                      default_player['mode']))
Ejemplo n.º 4
0
def update_players():
    players_url = ADDON.getSettingString('players_url')
    players_url = xbmcgui.Dialog().input(ADDON.getLocalizedString(32313),
                                         defaultt=players_url)
    if not xbmcgui.Dialog().yesno(
            ADDON.getLocalizedString(32032),
            ADDON.getLocalizedString(32314).format(players_url)):
        return
    ADDON.setSettingString('players_url', players_url)
    downloader = Downloader(
        extract_to=
        'special://profile/addon_data/plugin.video.themoviedb.helper/players',
        download_url=players_url)
    downloader.get_extracted_zip()
Ejemplo n.º 5
0
def monitor_userlist():
    # Build list choices
    with busy_dialog():
        user_lists = []
        user_lists += TraktAPI().get_list_of_lists(
            'users/me/lists', authorize=True, next_page=False) or []
        user_lists += TraktAPI().get_list_of_lists(
            'users/likes/lists', authorize=True, next_page=False) or []
        saved_lists = _get_monitor_userlists()
        dialog_list = [i['label'] for i in user_lists]
        preselected = [
            x for x, i in enumerate(user_lists)
            if (i.get('params', {}).get('list_slug'),
                i.get('params', {}).get('user_slug')) in saved_lists
        ]

    # Ask user to choose lists
    indices = xbmcgui.Dialog().multiselect(ADDON.getLocalizedString(32312),
                                           dialog_list,
                                           preselect=preselected)
    if indices is None:
        return

    # Build the new settings and check that lists aren't over limit
    added_lists, added_users = [], []
    for x in indices:
        list_slug = user_lists[x].get('params', {}).get('list_slug')
        user_slug = user_lists[x].get('params', {}).get('user_slug')
        if get_userlist(user_slug, list_slug, confirm=50):
            added_lists.append(list_slug)
            added_users.append(user_slug)

    # Set the added lists to our settings
    if not added_lists or not added_users:
        return
    added_lists = ' | '.join(added_lists)
    added_users = ' | '.join(added_users)
    ADDON.setSettingString('monitor_userlist', added_lists)
    ADDON.setSettingString('monitor_userslug', added_users)

    # Update library?
    if xbmcgui.Dialog().yesno(xbmc.getLocalizedString(653),
                              ADDON.getLocalizedString(32132)):
        library_autoupdate(list_slugs=added_lists,
                           user_slugs=added_users,
                           busy_spinner=True)
Ejemplo n.º 6
0
    def logout(self):
        token = self.get_stored_token()

        if not xbmcgui.Dialog().yesno(ADDON.getLocalizedString(32212), ADDON.getLocalizedString(32213)):
            return

        if token:
            response = self.get_api_request('https://api.trakt.tv/oauth/revoke', postdata={
                'token': token.get('access_token', ''),
                'client_id': self.client_id,
                'client_secret': self.client_secret})
            if response and response.status_code == 200:
                msg = ADDON.getLocalizedString(32216)
                ADDON.setSettingString('trakt_token', '')
            else:
                msg = ADDON.getLocalizedString(32215)
        else:
            msg = ADDON.getLocalizedString(32214)

        xbmcgui.Dialog().ok(ADDON.getLocalizedString(32212), msg)
Ejemplo n.º 7
0
    def update_tvshows(self, force=False, **kwargs):
        nfos = []

        # Get TMDb IDs from nfo files in folder
        nfos_append = nfos.append  # For speed since we can't do a list comp easily here
        for f in xbmcvfs.listdir(BASEDIR_TV)[0]:
            tmdb_id = get_tmdb_id_nfo(BASEDIR_TV, f)
            nfos_append({'tmdb_id': tmdb_id, 'folder': f}) if tmdb_id else None

        # Update each show in folder
        nfos_total = len(nfos)
        for x, i in enumerate(nfos):
            self._update(x,
                         nfos_total,
                         message=u'{} {}...'.format(
                             ADDON.getLocalizedString(32167), i['folder']))
            self.add_tvshow(tmdb_id=i['tmdb_id'], force=force)

        # Update last updated stamp
        ADDON.setSettingString(
            'last_autoupdate',
            u'Last updated {}'.format(get_current_date_time()))