コード例 #1
0
def log_request(**kwargs):
    with busy_dialog():
        kwargs['response'] = None
        if not kwargs.get('url'):
            kwargs['url'] = xbmcgui.Dialog().input('URL')
        if not kwargs['url']:
            return
        if kwargs.get('log_request').lower() == 'trakt':
            kwargs['response'] = TraktAPI().get_response_json(kwargs['url'])
        else:
            kwargs['response'] = TMDb().get_response_json(kwargs['url'])
        if not kwargs['response']:
            xbmcgui.Dialog().ok(kwargs['log_request'].capitalize(),
                                u'{}\nNo Response!'.format(kwargs['url']))
            return
        filename = validify_filename(u'{}_{}.json'.format(
            kwargs['log_request'], kwargs['url']))
        dumps_to_file(kwargs, 'log_request', filename)
        xbmcgui.Dialog().ok(
            kwargs['log_request'].capitalize(),
            u'[B]{}[/B]\n\n{}\n{}\n{}'.format(
                kwargs['url'],
                xbmc.translatePath('special://profile/addon_data/'),
                'plugin.video.themoviedb.helper/log_request', filename))
        xbmcgui.Dialog().textviewer(filename,
                                    dumps(kwargs['response'], indent=2))
コード例 #2
0
 def save_player(self, player, filename, confirm=True):
     if confirm and not xbmcgui.Dialog().yesno(
             ADDON.getLocalizedString(32336),
             ADDON.getLocalizedString(32337).format(filename),
             yeslabel=xbmc.getLocalizedString(190),
             nolabel=ADDON.getLocalizedString(32338)):
         return
     with busy_dialog():
         self.players[filename] = player  # Update our players dictionary
         self.dialog_players = _get_dialog_players(
             self.players)  # Update our dialog list
         dumps_to_file(player,
                       PLAYERS_BASEDIR_SAVE,
                       filename,
                       indent=4,
                       join_addon_data=False)  # Write out file
コード例 #3
0
 def _out(self):  # TODO: Check logging value
     filename = u'{}.json'.format(
         get_todays_date(str_fmt='%Y-%m-%d-%H%M%S'))
     dumps_to_file(self.logging, 'log_library', filename)