def account_info_to_dialog(self):
     from datetime import datetime
     import math
     try:
         accountInfo = self.account_info()
         expires = datetime.fromtimestamp(accountInfo['premium_until'])
         days_remaining = (expires - datetime.today()).days
         expires = expires.strftime("%A, %B %d, %Y")
         points_used = int(
             math.floor(float(accountInfo['space_used']) / 1073741824.0))
         space_used = float(int(accountInfo['space_used'])) / 1073741824
         percentage_used = str(
             round(float(accountInfo['limit_used']) * 100.0, 1))
         items = []
         items += [control.lang(40040) % accountInfo['customer_id']]
         items += [control.lang(40041) % expires]
         items += [control.lang(40042) % days_remaining]
         items += [control.lang(40043) % points_used]
         items += [control.lang(40044) % space_used]
         items += [control.lang(40045) % percentage_used]
         return control.selectDialog(items, 'Premiumize')
     except:
         log_utils.error()
         pass
     return
Пример #2
0
 def account_info_to_dialog(self):
     from datetime import datetime
     import time
     try:
         userInfo = self.account_info()
         try:
             expires = datetime.strptime(userInfo['expiration'],
                                         FormatDateTime)
         except:
             expires = datetime(*(time.strptime(userInfo['expiration'],
                                                FormatDateTime)[0:6]))
         days_remaining = (expires - datetime.today()).days
         expires = expires.strftime("%A, %B %d, %Y")
         items = []
         items += [control.lang(40035) % userInfo['email']]
         items += [control.lang(40036) % userInfo['username']]
         items += [control.lang(40037) % userInfo['type'].capitalize()]
         items += [control.lang(40041) % expires]
         items += [control.lang(40042) % days_remaining]
         items += [control.lang(40038) % userInfo['points']]
         return control.selectDialog(items, 'Real-Debrid')
     except:
         log_utils.error()
         pass
     return
Пример #3
0
 def account_info_to_dialog(self):
     from datetime import datetime, timedelta
     try:
         account_info, stats = self.extended_account_info()
         username = account_info['user']['username']
         timezone = account_info['account']['timezone']
         joined = control.jsondate_to_datetime(
             account_info['user']['joined_at'], "%Y-%m-%dT%H:%M:%S.%fZ")
         private = account_info['user']['private']
         vip = account_info['user']['vip']
         if vip: vip = '%s Years' % str(account_info['user']['vip_years'])
         total_given_ratings = stats['ratings']['total']
         movies_collected = stats['movies']['collected']
         movies_watched = stats['movies']['watched']
         movies_watched_minutes = ("{:0>8}".format(
             str(timedelta(
                 minutes=stats['movies']['minutes'])))).split(', ')
         movies_watched_minutes = control.lang(40071) % (
             movies_watched_minutes[0],
             movies_watched_minutes[1].split(':')[0],
             movies_watched_minutes[1].split(':')[1])
         shows_collected = stats['shows']['collected']
         shows_watched = stats['shows']['watched']
         episodes_watched = stats['episodes']['watched']
         episodes_watched_minutes = ("{:0>8}".format(
             str(timedelta(
                 minutes=stats['episodes']['minutes'])))).split(', ')
         episodes_watched_minutes = control.lang(40071) % (
             episodes_watched_minutes[0],
             episodes_watched_minutes[1].split(':')[0],
             episodes_watched_minutes[1].split(':')[1])
         heading = control.lang(32315)
         items = []
         items += [control.lang(40036) % username]
         items += [control.lang(40063) % timezone]
         items += [control.lang(40064) % joined]
         items += [control.lang(40065) % private]
         items += [control.lang(40066) % vip]
         items += [control.lang(40067) % str(total_given_ratings)]
         items += [
             control.lang(40068) %
             (movies_collected, movies_watched, movies_watched_minutes)
         ]
         items += [control.lang(40069) % (shows_collected, shows_watched)]
         items += [
             control.lang(40070) %
             (episodes_watched, episodes_watched_minutes)
         ]
         return control.selectDialog(items, heading)
     except:
         log_utils.error()
         return
Пример #4
0
def upload_LogFile():
    from myaccounts.modules.control import notification
    url = 'https://paste.kodi.tv/'
    log_file = joinPath(LOGPATH, 'myaccounts.log')
    if not existsPath(log_file):
        return notification(
            message='Log File not found, likely logging is not enabled.')
    try:
        import requests
        from myaccounts.modules.control import addonVersion, selectDialog
        f = open(log_file, 'r', encoding='utf-8', errors='ignore')
        text = f.read()
        f.close()
        UserAgent = 'MyAccounts %s' % addonVersion()
        response = requests.post(url + 'documents',
                                 data=text.encode('utf-8', errors='ignore'),
                                 headers={'User-Agent': UserAgent})
        # log('log_response: ' + str(response))
        if 'key' in response.json():
            result = url + response.json()['key']
            log('My Accounts log file uploaded to: %s' % result)
            from sys import platform as sys_platform
            supported_platform = any(value in sys_platform
                                     for value in ['win32', 'linux2'])
            highlight_color = 'gold'
            list = [
                ('[COLOR %s]url:[/COLOR]  %s' % (highlight_color, str(result)),
                 str(result))
            ]
            if supported_platform:
                list += [('[COLOR %s]  -- Copy url To Clipboard[/COLOR]' %
                          highlight_color, ' ')]
            select = selectDialog([i[0] for i in list], lang(32349))
            if 'Copy url To Clipboard' in list[select][0]:
                copy2clip(list[select - 1][1])
        elif 'message' in response.json():
            notification(message='myaccounts Log upload failed: %s' %
                         str(response.json()['message']))
            log('My Accounts Log upload failed: %s' %
                str(response.json()['message']),
                level=LOGERROR)
        else:
            notification(message='myaccounts Log upload failed')
            log('My Accounts Log upload failed: %s' % response.text,
                level=LOGERROR)
    except:
        error('My Accounts log upload failed')
        notification(message='pastebin post failed: See log for more info')
Пример #5
0
 def account_info_to_dialog(self):
     from datetime import datetime
     try:
         account_info = self.account_info()['user']
         username = account_info['username']
         email = account_info['email']
         status = 'Premium' if account_info['isPremium'] else 'Not Active'
         expires = datetime.fromtimestamp(account_info['premiumUntil'])
         days_remaining = (expires - datetime.today()).days
         heading = control.lang(40059).upper()
         items = []
         items += [control.lang(40036) % username]
         items += [control.lang(40035) % email]
         items += [control.lang(40037) % status]
         items += [control.lang(40041) % expires]
         items += [control.lang(40042) % days_remaining]
         return control.selectDialog(items, 'All Debrid')
     except:
         log_utils.error()
     return