Exemple #1
0
def log(msg, level=LOGNOTICE):
    debug_enabled = control.addon('plugin.video.koditvr').getSetting(
        'addon_debug')
    debug_log = control.addon('plugin.video.koditvr').getSetting(
        'debug.location')

    print(DEBUGPREFIX + ' Debug Enabled?: ' + str(debug_enabled))
    print(DEBUGPREFIX + ' Debug Log?: ' + str(debug_log))

    if not control.addon('plugin.video.koditvr').getSetting(
            'addon_debug') == 'true':
        return

    try:
        if isinstance(msg, six.text_type):
            msg = '%s (ENCODED)' % (control.six_encode(msg))

        if not control.addon('plugin.video.koditvr').getSetting(
                'debug.location') == '0':
            log_file = os.path.join(LOGPATH, 'koditvr.log')
            if not os.path.exists(log_file):
                f = open(log_file, 'w')
                f.close()
            with open(log_file, 'a') as f:
                line = '[%s %s] %s: %s' % (datetime.now().date(),
                                           str(datetime.now().time())[:8],
                                           DEBUGPREFIX, msg)
                f.write(line.rstrip('\r\n') + '\n')
        else:
            print('%s: %s' % (DEBUGPREFIX, msg))
    except Exception as e:
        try:
            xbmc.log('Logging Failure: %s' % (e), level)
        except Exception:
            pass
Exemple #2
0
    def get_api(self):

        try:

            api_key = self.api_key

            if api_key == '':
                if self.user_name == '' or self.user_pass == '':
                    return

                else:
                    s = requests.Session()
                    link = (self.base_link + self.login_link % (self.user_name, self.user_pass))
                    p = s.post(link)
                    p = json.loads(p.text)

                    if p['status'] == 'ok':
                        api_key = p['api_key']
                        control.addon('plugin.video.koditvr').setSetting('furk.api', api_key)
                    else:
                        pass

            return api_key

        except:
            print("Unexpected error in Furk Script: check_api", sys.exc_info()[0])
            exc_type, exc_obj, exc_tb = sys.exc_info()
            print(exc_type, exc_tb.tb_lineno)
            pass
def getTraktAddonEpisodeInfo():
    try: scrobble = control.addon('script.trakt').getSetting('scrobble_episode')
    except: scrobble = ''
    try: ExcludeHTTP = control.addon('script.trakt').getSetting('ExcludeHTTP')
    except: ExcludeHTTP = ''
    try: authorization = control.addon('script.trakt').getSetting('authorization')
    except: authorization = ''
    if scrobble == 'true' and ExcludeHTTP == 'false' and not authorization == '': return True
    else: return False
Exemple #4
0
 def __init__(self):
     self.priority = 0
     self.language = ['en']
     self.domain = 'furk.net/'
     self.base_link = 'https://www.furk.net'
     self.meta_search_link = "/api/plugins/metasearch?api_key=%s&q=%s&cached=yes" \
                             "&match=%s&moderated=%s%s&sort=relevance&type=video&offset=0&limit=%s"
     self.tfile_link = "/api/file/get?api_key=%s&t_files=1&id=%s"
     self.login_link = "/api/login/login?login=%s&pwd=%s"
     self.user_name = control.addon('plugin.video.koditvr').getSetting('furk.user_name')
     self.user_pass = control.addon('plugin.video.koditvr').getSetting('furk.user_pass')
     self.api_key = control.addon('plugin.video.koditvr').getSetting('furk.api')
     self.search_limit = control.addon('plugin.video.koditvr').getSetting('furk.limit')
     self.files = []
def __getTrakt(url, post=None):
    try:
        url = urllib_parse.urljoin(BASE_URL, url)
        post = json.dumps(post) if post else None
        headers = {'Content-Type': 'application/json', 'trakt-api-key': V2_API_KEY, 'trakt-api-version': 2}

        if getTraktCredentialsInfo():
            headers.update({'Authorization': 'Bearer %s' % control.addon('plugin.video.koditvr').getSetting('trakt.token')})

        result = client.request(url, post=post, headers=headers, output='extended', error=True)
        result = utils.byteify(result)

        resp_code = result[1]
        resp_header = result[2]
        result = result[0]

        if resp_code in ['423', '500', '502', '503', '504', '520', '521', '522', '524']:
            log_utils.log('Trakt Error: %s' % str(resp_code))
            control.infoDialog('Trakt Error: ' + str(resp_code), sound=True)
            return
        elif resp_code in ['429']:
            log_utils.log('Trakt Rate Limit Reached: %s' % str(resp_code))
            control.infoDialog('Trakt Rate Limit Reached: ' + str(resp_code), sound=True)
            return
        elif resp_code in ['404']:
            log_utils.log('Object Not Found : %s' % str(resp_code))
            return

        if resp_code not in ['401', '405']:
            return result, resp_header

        koditvr = urllib_parse.urljoin(BASE_URL, '/koditvr/token')
        opost = {'client_id': V2_API_KEY, 'client_secret': CLIENT_SECRET, 'redirect_uri': REDIRECT_URI, 'grant_type': 'refresh_token', 'refresh_token': control.addon('plugin.video.koditvr').getSetting('trakt.refresh')}

        result = client.request(koditvr, post=json.dumps(opost), headers=headers)
        result = utils.json_loads_as_str(result)

        token, refresh = result['access_token'], result['refresh_token']
        print('Info - ' + str(token))
        control.addon('plugin.video.koditvr').setSetting(id='trakt.token', value=token)
        control.addon('plugin.video.koditvr').setSetting(id='trakt.refresh', value=refresh)

        headers['Authorization'] = 'Bearer %s' % token

        result = client.request(url, post=post, headers=headers, output='extended', error=True)
        result = utils.byteify(result)
        return result[0], result[2]
    except:
        log_utils.log('getTrakt Error', 1)
        pass
Exemple #6
0
    def __init__(self):
        self.priority = 1
        self.language = ['en']
        self.domains = ['ororo.tv']
        self.base_link = 'https://ororo.tv'
        self.moviesearch_link = '/api/v2/movies'
        self.tvsearch_link = '/api/v2/shows'
        self.movie_link = '/api/v2/movies/%s'
        self.show_link = '/api/v2/shows/%s'
        self.episode_link = '/api/v2/episodes/%s'

        self.user = control.addon('plugin.video.theoath').getSetting('ororo.user')
        self.password = control.addon('plugin.video.theoath').getSetting('ororo.pass')
        self.headers = {
        'Authorization': 'Basic %s' % base64.b64encode('%s:%s' % (self.user, self.password)),
        'User-Agent': 'Covenant for Kodi'
        }
Exemple #7
0
from koditvrscrapers.modules import control

LOGDEBUG = xbmc.LOGDEBUG
LOGINFO = xbmc.LOGINFO
LOGNOTICE = xbmc.LOGNOTICE if control.getKodiVersion() < 19 else xbmc.LOGINFO
LOGWARNING = xbmc.LOGWARNING
LOGERROR = xbmc.LOGERROR
LOGFATAL = xbmc.LOGFATAL
LOGNONE = xbmc.LOGNONE

name = control.addonInfo('name')
DEBUGPREFIX = '[ koditvrscrapers DEBUG ]'
LOGPATH = control.transPath('special://logpath/')
log_file = os.path.join(LOGPATH, 'koditvr.log')
debug_enabled = control.addon('plugin.video.koditvr').getSetting('addon.debug')


def log(msg, trace=0):

    if not debug_enabled == 'true':
        return

    try:
        if trace == 1:
            failure = six.ensure_str(traceback.format_exc())
            _msg = '%s: %s' % (six.ensure_text(msg), failure)
        else:
            _msg = '%s' % six.ensure_text(msg)

        #if not debug_log == '0':
Exemple #8
0
try:
    from sqlite3 import dbapi2 as db, OperationalError
except ImportError:
    from pysqlite2 import dbapi2 as db, OperationalError

from koditvrscrapers.modules import control

if six.PY2:
    str = unicode
elif six.PY3:
    str = unicode = basestring = str

cache_table = 'cache'
data_path = xbmc.translatePath(
    control.addon('plugin.video.koditvr').getAddonInfo('profile')).decode(
        'utf-8')


def get(function_, duration, *args, **table):

    try:

        response = None

        f = repr(function_)
        f = re.sub(r'.+\smethod\s|.+function\s|\sat\s.+|\sof\s.+', '', f)

        a = hashlib.md5()
        for i in args:
            a.update(str(i))
def timeoutsyncTVShows():
    timeout = cache.timeout(syncTVShows, control.addon('plugin.video.koditvr').getSetting('trakt.user').strip())
    if not timeout: timeout = 0
    return timeout
def cachesyncTVShows(timeout=0):
    indicators = cache.get(syncTVShows, timeout, control.addon('plugin.video.koditvr').getSetting('trakt.user').strip())
    return indicators
def timeoutsyncMovies():
    timeout = cache.timeout(syncMovies, control.addon('plugin.video.koditvr').getSetting('trakt.user').strip())
    return timeout
def getTraktIndicatorsInfo():
    indicators = control.addon('plugin.video.koditvr').getSetting('indicators') if getTraktCredentialsInfo() == False else control.addon('plugin.video.koditvr').getSetting('indicators.alt')
    indicators = True if indicators == '1' else False
    return indicators
def getTraktCredentialsInfo():
    user = control.addon('plugin.video.koditvr').getSetting('trakt.user').strip()
    token = control.addon('plugin.video.koditvr').getSetting('trakt.token')
    refresh = control.addon('plugin.video.koditvr').getSetting('trakt.refresh')
    if (user == '' or token == '' or refresh == ''): return False
    return True
def authTrakt():
    try:
        if getTraktCredentialsInfo() == True:
            if control.yesnoDialog(control.lang(32511) + '[CR]' + control.lang(32512), heading='Trakt'):
                control.addon('plugin.video.koditvr').setSetting(id='trakt.user', value='')
                control.addon('plugin.video.koditvr').setSetting(id='trakt.authed', value='')
                control.addon('plugin.video.koditvr').setSetting(id='trakt.token', value='')
                control.addon('plugin.video.koditvr').setSetting(id='trakt.refresh', value='')
            raise Exception()

        result = getTraktAsJson('/koditvr/device/code', {'client_id': V2_API_KEY})
        verification_url = control.lang(32513) % result['verification_url']
        user_code = six.ensure_text(control.lang(32514) % result['user_code'])
        expires_in = int(result['expires_in'])
        device_code = result['device_code']
        interval = result['interval']

        progressDialog = control.progressDialog
        progressDialog.create('Trakt')

        for i in list(range(0, expires_in)):
            try:
                percent = int(100 * float(i) / int(expires_in))
                progressDialog.update(max(1, percent), verification_url + '[CR]' + user_code)
                if progressDialog.iscanceled(): break
                time.sleep(1)
                if not float(i) % interval == 0: raise Exception()
                r = getTraktAsJson('/koditvr/device/token', {'client_id': V2_API_KEY, 'client_secret': CLIENT_SECRET, 'code': device_code})
                if 'access_token' in r: break
            except:
                pass

        try: progressDialog.close()
        except: pass

        token, refresh = r['access_token'], r['refresh_token']

        headers = {'Content-Type': 'application/json', 'trakt-api-key': V2_API_KEY, 'trakt-api-version': 2, 'Authorization': 'Bearer %s' % token}


        result = client.request(urllib_parse.urljoin(BASE_URL, '/users/me'), headers=headers)
        result = utils.json_loads_as_str(result)

        user = result['username']
        authed = '' if user == '' else str('yes')

        print('info - ' + token)
        control.addon('plugin.video.koditvr').setSetting(id='trakt.user', value=user)
        control.addon('plugin.video.koditvr').setSetting(id='trakt.authed', value=authed)
        control.addon('plugin.video.koditvr').setSetting(id='trakt.token', value=token)
        control.addon('plugin.video.koditvr').setSetting(id='trakt.refresh', value=refresh)
        raise Exception()
    except:
        control.openSettings('4.1')
import simplejson as json

from koditvrscrapers.modules import cache
from koditvrscrapers.modules import cleandate
from koditvrscrapers.modules import client
from koditvrscrapers.modules import control
from koditvrscrapers.modules import log_utils
from koditvrscrapers.modules import utils

if six.PY2:
    str = unicode
elif six.PY3:
    str = unicode = basestring = str

BASE_URL = 'https://api.trakt.tv'
V2_API_KEY = control.addon('plugin.video.koditvr').getSetting('trakt.client_id')
CLIENT_SECRET = control.addon('plugin.video.koditvr').getSetting('trakt.client_secret')
REDIRECT_URI = 'urn:ietf:wg:koditvr:2.0:oob'

if V2_API_KEY == "" or CLIENT_SECRET == "":
    V2_API_KEY = base64.b64decode("OGQ5Njg1M2Y0MGQ1MWJkMDY2MWI2Mzc4ZjUzYzM0ZTM2YzVjZTQzZjM0MmI0YTg0NWI3Nzk4N2Q0NjZjMjY0ZQ==")
    CLIENT_SECRET = base64.b64decode("NTg2ZDAzNGJhNzM3OGU2ZDY4Y2NjODE5ZWE4M2M5ZmU5N2I5ODg1Yjk2YTQ1ZGQ2OTQ1OWI3OWNkZGU0MmU4OQ==")

def __getTrakt(url, post=None):
    try:
        url = urllib_parse.urljoin(BASE_URL, url)
        post = json.dumps(post) if post else None
        headers = {'Content-Type': 'application/json', 'trakt-api-key': V2_API_KEY, 'trakt-api-version': 2}

        if getTraktCredentialsInfo():
            headers.update({'Authorization': 'Bearer %s' % control.addon('plugin.video.koditvr').getSetting('trakt.token')})
import six

try:
    from sqlite3 import dbapi2 as db, OperationalError
except ImportError:
    from pysqlite2 import dbapi2 as db, OperationalError

from koditvrscrapers.modules import control

if six.PY2:
    str = unicode
elif six.PY3:
    str = unicode = basestring = str

cache_table = 'cache'
data_path = control.transPath(control.addon('plugin.video.theoath').getAddonInfo('profile'))

def get(function_, duration, *args, **table):

    try:

        response = None

        f = repr(function_)
        f = re.sub(r'.+\smethod\s|.+function\s|\sat\s.+|\sof\s.+', '', f)

        a = hashlib.md5()
        for i in args:
            a.update(str(i))
        a = str(a.hexdigest())