Example #1
0
def log(msg, level=LOGNOTICE):
    debug_enabled = control.setting('addon_debug')
    debug_log = control.setting('debug.location')

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

    if not control.setting('addon_debug') == 'true':
        return

    try:
        if isinstance(msg, unicode):
            msg = '%s (ENCODED)' % (msg.encode('utf-8'))

        if not control.setting('debug.location') == '0':
            log_file = os.path.join(LOGPATH, 'placenta.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:
            pass
Example #2
0
 def __init__(self):
     self.priority = 1
     self.language = ['en']
     self.domain = ['1337x.to', '1337x.is', '1337x.st', '1337x.ws', '1337x.eu', '1337x.se']
     self.base_link = 'https://1337x.to'
     self.search_link = '/search/%s/1/'
     self.min_seeders = int(control.setting('torrent.min.seeders'))
Example #3
0
 def __init__(self):
     self.priority = 1
     self.language = ['en']
     self.domains = ['zooqle.com']
     self.base_link = 'https://zooqle.com'
     self.search_link = '/search?q=%s'
     self.min_seeders = int(control.setting('torrent.min.seeders'))
Example #4
0
 def __init__(self):
     self.priority = 1
     self.language = ['en']
     self.domains = ['yts.am']
     self.base_link = 'https://yts.am/'
     self.search_link = '/browse-movies/%s/all/all/0/latest'
     self.min_seeders = int(control.setting('torrent.min.seeders'))
Example #5
0
 def __init__(self):
     self.priority = 1
     self.language = ['en']
     self.domains = ['www.skytorrents.lol']
     self.base_link = 'https://www.skytorrents.lol/'
     self.search_link = '?query=%s'
     self.min_seeders = int(control.setting('torrent.min.seeders'))
Example #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.setting('ororo.user')
        self.password = control.setting('ororo.pass')
        self.headers = {
            'Authorization':
            'Basic %s' % base64.b64encode('%s:%s' %
                                          (self.user, self.password)),
            'User-Agent':
            'Placenta for Kodi'
        }
Example #7
0
 def __init__(self):
     self.priority = 1
     self.language = ['en']
     self.domains = [
         'pirateproxy.live', 'thepiratebay.org', 'thepiratebay.fun',
         'thepiratebay.asia', 'tpb.party', 'thepiratebay3.org',
         'thepiratebayz.org', 'thehiddenbay.com', 'piratebay.live',
         'thepiratebay.zone'
     ]
     self._base_link = None
     self.search_link = '/s/?q=%s&page=0&&video=on&orderby=99'
     self.min_seeders = int(control.setting('torrent.min.seeders'))
Example #8
0
def timeoutsyncTVShows():
    timeout = cache.timeout(syncTVShows, control.setting('trakt.user').strip())
    return timeout
Example #9
0
def cachesyncTVShows(timeout=0):
    indicators = cache.get(syncTVShows, timeout,
                           control.setting('trakt.user').strip())
    return indicators
Example #10
0
def __getTrakt(url, post=None):
    try:
        url = urlparse.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.setting('trakt.token')
            })

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

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

        if resp_code in [
                '500', '502', '503', '504', '520', '521', '522', '524'
        ]:
            log_utils.log('Temporary Trakt Error: %s' % resp_code,
                          log_utils.LOGWARNING)
            return
        elif resp_code in ['404']:
            log_utils.log('Object Not Found : %s' % resp_code,
                          log_utils.LOGWARNING)
            return


#        elif resp_code in ['429']:
#            log_utils.log('Trakt Rate Limit Reached: %s' % resp_code, log_utils.LOGWARNING)
#            return

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

        oauth = urlparse.urljoin(BASE_URL, '/oauth/token')
        opost = {
            'client_id': V2_API_KEY,
            'client_secret': CLIENT_SECRET,
            'redirect_uri': REDIRECT_URI,
            'grant_type': 'refresh_token',
            'refresh_token': control.setting('trakt.refresh')
        }

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

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

        control.setSetting(id='trakt.token', value=token)
        control.setSetting(id='trakt.refresh', value=refresh)

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

        result = client.request(url,
                                post=post,
                                headers=headers,
                                output='extended',
                                error=True)
        return result[0], result[2]
    except Exception as e:
        log_utils.log('Unknown Trakt Error: %s' % e, log_utils.LOGWARNING)
        pass
Example #11
0
def getTraktIndicatorsInfo():
    indicators = control.setting('indicators') if getTraktCredentialsInfo(
    ) == False else control.setting('indicators.alt')
    indicators = True if indicators == '1' else False
    return indicators
Example #12
0
def getTraktCredentialsInfo():
    user = control.setting('trakt.user').strip()
    token = control.setting('trakt.token')
    refresh = control.setting('trakt.refresh')
    if (user == '' or token == '' or refresh == ''): return False
    return True