Ejemplo n.º 1
0
    def run(self):
        from datetime import datetime
        from myaccounts.modules import alldebrid
        from myaccounts.modules import premiumize
        from myaccounts.modules import realdebrid
        xbmc.log(
            '[ script.module.myaccounts ]  Debrid Account Expiry Notification Service Starting...',
            LOGNOTICE)
        self.duration = [(15, 10), (11, 7), (8, 4), (5, 2), (3, 0)]
        if control.setting('alldebrid.username') != '' and control.setting(
                'alldebrid.expiry.notice') == 'true':
            account_info = alldebrid.AllDebrid().account_info()['user']
            if account_info:
                if not account_info['isSubscribed']:
                    # log_utils.log('AD account_info = %s' % account_info, log_utils.LOGNOTICE)
                    expires = datetime.fromtimestamp(
                        account_info['premiumUntil'])
                    days_remaining = (expires - datetime.today()).days  # int
                    if self.withinRangeCheck('alldebrid', days_remaining):
                        control.notification(
                            message='AllDebrid Account expires in %s days' %
                            days_remaining,
                            icon=control.joinPath(control.artPath(),
                                                  'alldebrid.png'))

        if control.setting('premiumize.username') != '' and control.setting(
                'premiumize.expiry.notice') == 'true':
            account_info = premiumize.Premiumize().account_info()
            if account_info:
                # log_utils.log('PM account_info = %s' % account_info, log_utils.LOGNOTICE)
                expires = datetime.fromtimestamp(account_info['premium_until'])
                days_remaining = (expires - datetime.today()).days  # int
                if self.withinRangeCheck('premiumize', days_remaining):
                    control.notification(
                        message='Premiumize.me Account expires in %s days' %
                        days_remaining,
                        icon=control.joinPath(control.artPath(),
                                              'premiumize.png'))

        if control.setting('realdebrid.username') != '' and control.setting(
                'realdebrid.expiry.notice') == 'true':
            account_info = realdebrid.RealDebrid().account_info()
            if account_info:
                import time
                # log_utils.log('RD account_info = %s' % account_info, log_utils.LOGNOTICE)
                FormatDateTime = "%Y-%m-%dT%H:%M:%S.%fZ"
                try:
                    expires = datetime.strptime(account_info['expiration'],
                                                FormatDateTime)
                except:
                    expires = datetime(*(time.strptime(
                        account_info['expiration'], FormatDateTime)[0:6]))
                days_remaining = (expires - datetime.today()).days  # int
                if self.withinRangeCheck('realdebrid', days_remaining):
                    control.notification(
                        message='Real-Debrid Account expires in %s days' %
                        days_remaining,
                        icon=control.joinPath(control.artPath(),
                                              'realdebrid.png'))
Ejemplo n.º 2
0
# -*- coding: utf-8 -*-
"""
	My Accounts
"""

import requests

from myaccounts.modules import control
from myaccounts.modules import log_utils

CLIENT_ID = '776741998'  # used to auth
BaseUrl = 'https://www.premiumize.me/api'
account_info_url = '%s/account/info' % BaseUrl
pm_icon = control.joinPath(control.artPath(), 'premiumize.png')


class Premiumize:
    name = "Premiumize.me"

    def __init__(self):
        self.token = control.setting('premiumize.token')
        self.headers = {
            'User-Agent': 'My Accounts for Kodi',
            'Authorization': 'Bearer %s' % self.token
        }
        self.server_notifications = False

    def _get(self, url):
        try:
            response = requests.get(url, headers=self.headers,
                                    timeout=15).json()
Ejemplo n.º 3
0
# -*- coding: utf-8 -*-
'''
	My Accounts
'''

import requests
import time

from myaccounts.modules import control
from myaccounts.modules import log_utils

trakt_icon = control.joinPath(control.artPath(), 'trakt.png')


class Trakt():
    def __init__(self):
        self.api_endpoint = 'https://api-v2launch.trakt.tv/%s'
        self.client_id = '1ff09b52d009f286be2d9bdfc0314c688319cbf931040d5f8847e7694a01de42'
        self.client_secret = '0c5134e5d15b57653fefed29d813bfbd58d73d51fb9bcd6442b5065f30c4d4dc'
        self.expires_at = control.setting('trakt.expires')
        self.token = control.setting('trakt.token')

    def call(self,
             path,
             data=None,
             with_auth=True,
             method=None,
             suppress_error_notification=False):
        try:

            def error_notification(line1, error):
Ejemplo n.º 4
0
	My Accounts
"""

import json
import requests

from myaccounts.modules import control
from myaccounts.modules import log_utils

FormatDateTime = "%Y-%m-%dT%H:%M:%S.%fZ"
rest_base_url = 'https://api.real-debrid.com/rest/1.0/'
oauth_base_url = 'https://api.real-debrid.com/oauth/v2/'
device_code_url = 'device/code?%s'
credentials_url = 'device/credentials?%s'

rd_icon = control.joinPath(control.artPath(), 'realdebrid.png')


class RealDebrid:
    def __init__(self):
        self.token = control.setting('realdebrid.token')
        self.client_ID = control.setting('realdebrid.client_id')
        if self.client_ID == '':
            self.client_ID = 'X245A4XAIBGVM'
        self.secret = control.setting('realdebrid.secret')
        self.device_code = ''
        self.auth_timeout = 0
        self.auth_step = 0

    def _get(self, url, fail_check=False, token_ck=False):
        try:
Ejemplo n.º 5
0
# -*- coding: utf-8 -*-
"""
	My Accounts
"""

import requests
from myaccounts.modules import control
from myaccounts.modules import log_utils

base_url = 'https://api.alldebrid.com/v4/'
user_agent = 'My%20Accounts%20for%20Kodi'
ad_icon = control.joinPath(control.artPath(), 'alldebrid.png')


class AllDebrid:
    name = "AllDebrid"

    def __init__(self):
        self.token = control.setting('alldebrid.token')
        self.timeout = 15.0

    def _get(self, url, url_append=''):
        result = None
        try:
            if self.token == '': return None
            url = base_url + url + '?agent=%s&apikey=%s' % (
                user_agent, self.token) + url_append
            result = requests.get(url, timeout=self.timeout).json()
            if result.get('status') == 'success':
                if 'data' in result: result = result['data']
        except requests.exceptions.ConnectionError: