def log(msg, level=LOGNOTICE): debug_enabled = control.setting('addon_debug') debug_log = control.setting('debug.location') if xbmc: 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, 'openscrapers.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
def get_api(self): try: user_name = control.setting('furk.user_name') user_pass = control.setting('furk.user_pass') api_key = control.setting('furk.api') if api_key == '': if user_name == '' or user_pass == '': return s = requests.Session() link = (self.base_link + self.login_link % (user_name, user_pass)) p = s.post(link) p = json.loads(p.text) if p['status'] == 'ok': api_key = p['api_key'] control.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 __init__(self): self.priority = 1 self.language = ['en'] self.domains = ['streamlord.com'] self.base_link = 'http://www.streamlord.com' self.search_link = '/searchtest.php' self.user = control.setting('streamlord.user') self.password = control.setting('streamlord.pass')
def __init__(self): self.priority = 1 self.language = ['pl'] self.domains = ['segos.es'] self.base_link = 'https://segos.es' self.search_link = '/?search=%s' self.user_name = control.setting('segos.username') self.user_pass = control.setting('segos.password')
def __init__(self): self.priority = 1 self.language = ['de'] self.domains = ['serienstream.to'] self.base_link = 'https://serienstream.to' self.search_link = '/ajax/search' self.login = control.setting('serienstream.user') self.password = control.setting('serienstream.pass') self.cookie = '' self.user_agent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36'
def __init__(self): self.priority = 1 self.language = ['de'] self.domains = ['seriesever.net'] self.base_link = 'http://seriesever.net' self.search_link = 'service/search?q=%s' self.part_link = 'service/get_video_part' self.login_link = 'service/login' self.user = control.setting('seriesever.user') self.password = control.setting('seriesever.pass')
def __init__(self): self.priority = 1 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.setting('furk.user_name') self.user_pass = control.setting('furk.user_pass') self.api_key = control.setting('furk.api') self.search_limit = control.setting('furk.limit') self.files = []
def __init__(self): self.priority = 0 self.language = ['de'] self.domains = ['pron.ee'] self.base_link = 'https://www.pron.ee' self.search_link = '/api/search/%s/?apikey=%s&getmeta=0&query=%s&count=%d&from=%d' self.types = ['stream'] self.streamLimit = control.setting('pron.limit') if self.streamLimit == '': self.streamLimit = 100 self.streamLimit = int(self.streamLimit) self.streamIncrease = 100 self.api = control.setting('pron.api') self.debrid = control.setting('pron.download') if self.debrid == 'true': self.types = ['stream', 'download'] self.extensions = ['mp4', 'mpg', 'mpeg', 'mp2', 'm4v', 'm2v', 'mkv', 'avi', 'flv', 'asf', '3gp', '3g2', 'wmv', 'mov', 'qt', 'webm', 'vob', '']
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'))
def __init__(self): self.priority = 1 self.language = ['en'] self.domains = ['eztv.io'] self.base_link = 'https://eztv.io/' self.search_link = '/search/%s' self.min_seeders = int(control.setting('torrent.min.seeders'))
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'))
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'))
def __init__(self): self.priority = 0 self.language = ['en'] self.domains = ['pron.tv'] self.base_link = 'http://pron.tv' self.search_link = '/api/search/%s/?apikey=%s&getmeta=0&query=%s&count=%d&from=%d' self.types = ['stream'] self.streamLimit = control.setting('pron.limit') if self.streamLimit == '': self.streamLimit = 100 self.streamLimit = int(self.streamLimit) self.streamIncrease = 100 self.api = control.setting('pron.api') self.debrid = control.setting('pron.download') if self.debrid == 'true': self.types = ['stream', 'download'] self.rlsFilter = ['FRENCH', 'LATINO', 'SELF', 'SAMPLE', 'EXTRA']
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'))
def __init__(self): self.priority = 1 self.language = ['en', 'de', 'fr', 'ko', 'pl', 'pt', 'ru'] self.domains = ['yts.am', 'yts.lt'] # Old yts.ag self.base_link = 'https://yts.lt' self.search_link = '/browse-movies/%s/all/all/0/latest' self.min_seeders = int(control.setting('torrent.min.seeders'))
def __init__(self): self.priority = 35 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': self._get_auth(), 'User-Agent': 'Placenta for Kodi'}
def log(msg, caller=None, level=LOGNOTICE): debug_enabled = control.setting('debug.enabled') debug_log = control.setting('debug.location') print(DEBUGPREFIX + ' Debug Enabled?: ' + str(debug_enabled)) print(DEBUGPREFIX + ' Debug Log?: ' + str(debug_log)) if control.setting('debug.enabled') != 'true': return try: if caller is not None and level == LOGDEBUG: func = inspect.currentframe().f_back.f_code line_number = inspect.currentframe().f_back.f_lineno caller = "%s.%s()" % (caller, func.co_name) msg = 'From func name: %s Line # :%s\n msg : %s' % ( caller, line_number, msg) if caller is not None and level == LOGERROR: msg = 'From func name: %s.%s() Line # :%s\n msg : %s' % ( caller[0], caller[1], caller[2], msg) try: if isinstance(msg, unicode): msg = '%s (ENCODED)' % (msg.encode('utf-8')) except: pass if not control.setting('debug.location') == '0': log_file = os.path.join(LOGPATH, 'openscrapers.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
def status(torrent=False): debrid_check = debrid_resolvers != [] if debrid_check is True: if torrent: enabled = control.setting('torrent.enabled') if enabled == '' or enabled.lower() == 'true': return True else: return False return debrid_check
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'))
def __init__(self): self.priority = 1 self.language = ['en'] self.domains = [ 'kickass.vc', 'kickasstorrents.bz', 'kkickass.com', 'kkat.net', 'kickass-kat.com', 'kickasst.net', 'kickasst.org', 'kickasstorrents.id', 'thekat.cc', 'thekat.ch' ] self._base_link = None self.search_link = '/usearch/%s' self.min_seeders = int(control.setting('torrent.min.seeders'))
def remove_lang(release_title, episode_title=None): try: fmt = release_title_strip(release_title) if fmt is None: return False # log_utils.log('fmt = %s for release_title = %s' % (str(fmt), str(release_title)), __name__, log_utils.LOGDEBUG) if episode_title: episode_title = episode_title.lower().replace("'", "") episode_title = re.sub('[^a-z0-9]+', '.', episode_title) fmt = '%s' % re.sub(episode_title, '', fmt) filter_undesirables = control.setting('filter.undesirables') == 'true' filter_foreign_single_audio = control.setting( 'filter.foreign.single.audio') == 'true' if filter_undesirables: if any(value in fmt for value in UNDESIREABLES): return True if any(value in fmt for value in DUBBED): return True if any(value in fmt for value in SUBS): return True # if any(value in fmt for value in ADDS): # return True if filter_foreign_single_audio: if any(value in fmt for value in LANG) and not any( value in fmt for value in ['.eng.', '.en.', 'english']): return True if any(value in fmt for value in ABV_LANG) and not any( value in fmt for value in ['.eng.', '.en.', 'english']): return True if fmt.endswith('.srt.') and not any( value in fmt for value in ['with.srt', '.avi', '.mkv', '.mp4']): return True return False except: log_utils.error() return False
def _get_auth(self): auth = None username = control.setting('easynews.user') password = control.setting('easynews.password') if username == '' or password == '': return auth try: # Python 2 user_info = '%s:%s' % (username, password) auth = 'Basic ' + base64.b64encode(user_info) except: # Python 3 user_info = '%s:%s' % (username, password) user_info = user_info.encode('utf-8') auth = 'Basic ' + base64.b64encode(user_info).decode('utf-8') return auth
def timeoutsyncTVShows(): timeout = cache.timeout(syncTVShows, control.setting('trakt.user').strip()) return timeout
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
def getTraktIndicatorsInfo(): indicators = control.setting('indicators') if getTraktCredentialsInfo( ) == False else control.setting('indicators.alt') indicators = True if indicators == '1' else False return indicators
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
def cachesyncTVShows(timeout=0): indicators = cache.get(syncTVShows, timeout, control.setting('trakt.user').strip()) return indicators
# while not xbmc.Monitor().abortRequested(): # try: # if xbmc.Monitor().waitForAbort(60*60): # break # if control.setting('checkAddonUpdates') == 'true': # check_for_addon_update() def check_for_addon_update(): log_utils.log('OpenScrapers checking available updates', log_utils.LOGNOTICE) try: import re import requests repo_xml = requests.get('https://raw.githubusercontent.com/a4k-openproject/repository.openscrapers/master/zips/addons.xml') if not repo_xml.status_code == 200: log_utils.log('Could not connect to repo XML, status: %s' % repo_xml.status_code, log_utils.LOGNOTICE) return repo_version = re.findall(r'<addon id=\"script.module.openscrapers\".*version=\"(\d*.\d*.\d*.\d*)\"', repo_xml.text)[0] local_version = control.addonVersion() if control.check_version_numbers(local_version, repo_version): while control.condVisibility('Library.IsScanningVideo'): control.sleep(10000) log_utils.log('A newer version of OpenScrapers is available. Installed Version: v%s, Repo Version: v%s' % (local_version, repo_version), log_utils.LOGNOTICE) control.notification(title = 'default', message = 'A new verison of OpenScrapers is available from the repository. Please consider updating to v%s' % repo_version, icon = 'default', time=5000, sound=False) except: log_utils.error() pass if control.setting('checkAddonUpdates') == 'true': check_for_addon_update()
def sources(self, url, hostDict, hostprDict): sources = [] try: api_key = control.setting('filepursuit.api') if api_key == '': return sources headers = { "x-rapidapi-host": "filepursuit.p.rapidapi.com", "x-rapidapi-key": api_key } if url is None: return sources data = parse_qs(url) data = dict([(i, data[i][0]) if data[i] else (i, '') for i in data]) self.title = data[ 'tvshowtitle'] if 'tvshowtitle' in data else data['title'] self.title = self.title.replace('&', 'and').replace( 'Special Victims Unit', 'SVU') self.aliases = data['aliases'] self.hdlr = 'S%02dE%02d' % ( int(data['season']), int(data['episode']) ) if 'tvshowtitle' in data else data['year'] self.year = data['year'] query = '%s %s' % (self.title, self.hdlr) query = re.sub('(\\\|/| -|:|;|\*|\?|"|\'|<|>|\|)', '', query) url = self.search_link % quote_plus(query) url = urljoin(self.base_link, url) # log_utils.log('url = %s' % url, log_utils.LOGDEBUG) r = client.request(url, headers=headers) r = json.loads(r) if 'not_found' in r['status']: return sources results = r['files_found'] for item in results: try: size = int(item['file_size_bytes']) except: size = 0 try: name = item['file_name'] except: name = item['file_link'].split('/')[-1] if source_utils.remove_lang(name): continue if not source_utils.check_title(self.title, self.aliases, name, self.hdlr, self.year): continue url = item['file_link'] quality, info = source_utils.get_release_quality(name, url) try: dsize, isize = source_utils.convert_size(size, to='GB') if isize: info.insert(0, isize) except: source_utils.scraper_error('FILEPURSUIT') dsize = 0 pass info = ' | '.join(info) sources.append({ 'source': 'direct', 'quality': quality, 'name': name, 'language': "en", 'url': url, 'info': info, 'direct': True, 'debridonly': False, 'size': dsize }) return sources except: source_utils.scraper_error('FILEPURSUIT') return sources