Exemplo n.º 1
0
def log(msg, caller=None, level=LOGNOTICE):
    debug_enabled = getSetting('debug.enabled') == 'true'
    if not debug_enabled: return
    debug_location = getSetting('debug.location')

    if isinstance(msg, int): msg = lang(msg)  # for strings.po translations

    try:
        if py_tools.isPY3:
            if not msg.isprintable(
            ):  # ex. "\n" is not a printable character so returns False on those sort of cases
                msg = '%s (NORMALIZED by log_utils.log())' % normalize(msg)
            if isinstance(msg, py_tools.binary_type):
                msg = '%s (ENCODED by log_utils.log())' % (py_tools.ensure_str(
                    msg, errors='replace'))
        else:
            if not is_printable(
                    msg
            ):  # if not all(c in printable for c in msg): # isprintable() not available in py2
                msg = normalize(msg)
            if isinstance(msg, py_tools.binary_type):
                msg = '%s (ENCODED by log_utils.log())' % (
                    py_tools.ensure_text(msg))

        if caller == 'scraper_error': pass
        elif caller is not None and level != LOGERROR:
            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)
        elif 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)

        if debug_location == '1':
            log_file = joinPath(LOGPATH, 'fenomscrapers.log')
            if not existsPath(log_file):
                f = open(log_file, 'w')
                f.close()
            with open(log_file, 'a',
                      encoding='utf-8') as f:  #with auto cleans up and closes
                line = '[%s %s] %s: %s' % (
                    datetime.now().date(), str(datetime.now().time())[:8],
                    DEBUGPREFIX % debug_list[level], msg)
                f.write(line.rstrip('\r\n') + '\n')
                # f.writelines([line1, line2]) ## maybe an option for the 2 lines without using "\n"
        else:
            xbmc.log('%s: %s' % (DEBUGPREFIX % debug_list[level], msg, level))
    except Exception as e:
        import traceback
        traceback.print_exc()
        xbmc.log(
            '[ script.module.fenomonscrapers ] log_utils.log() Logging Failure: %s'
            % (e), LOGERROR)
Exemplo n.º 2
0
 def _get_auth(self):
     auth = None
     username = getSetting('easynews.user')
     password = getSetting('easynews.password')
     if username == '' or password == '': return auth
     try:  # Python 2
         user_info = '%s:%s' % (username, password)
         auth = 'Basic ' + b64encode(user_info)
     except:  # Python 3
         user_info = '%s:%s' % (username, password)
         user_info = user_info.encode('utf-8')
         auth = 'Basic ' + b64encode(user_info).decode('utf-8')
     return auth
Exemplo n.º 3
0
def enabledCheck(module_name):
	try:
		if getSetting('provider.' + module_name) == 'true': return True
		else: return False
	except:
		from fenomscrapers.modules import log_utils
		log_utils.error()
		return True
Exemplo n.º 4
0
	def get_api(self):
		try:
			user_name = getSetting('furk.user_name')
			user_pass = getSetting('furk.user_pass')
			api_key = getSetting('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 = jsloads(p.text)
				if p['status'] == 'ok':
					api_key = p['api_key']
					setSetting('furk.api', api_key)
				else: pass
			return api_key
		except:
			source_utils.scraper_error('FURK')
Exemplo n.º 5
0
 def __init__(self):
     self.priority = 25
     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 = getSetting('ororo.user')
     self.password = getSetting('ororo.pass')
     self.headers = {
         'Authorization': self._get_auth(),
         'User-Agent': 'Placenta for Kodi'
     }
     self.movie = False
     self.tvshow = True
Exemplo n.º 6
0
def undesirablesSelect():
    chosen = getSetting('undesirables.choice').replace(' ', '').split(',')
    try:
        preselect = [UNDESIRABLES.index(i) for i in chosen]
    except:
        preselect = [UNDESIRABLES.index(i) for i in UNDESIRABLES]
    choices = multiselectDialog(UNDESIRABLES, preselect=preselect)
    if not choices: return
    choices = [UNDESIRABLES[i] for i in choices]
    setSetting('undesirables.choice', ','.join(choices))
Exemplo n.º 7
0
    def sources(self, data, hostDict):
        sources = []
        if not data: return sources
        try:
            api_key = getSetting('filepursuit.api')
            if api_key == '': return sources
            headers = {
                "x-rapidapi-host": "filepursuit.p.rapidapi.com",
                "x-rapidapi-key": api_key
            }

            title = data['tvshowtitle'] if 'tvshowtitle' in data else data[
                'title']
            title = title.replace('&', 'and').replace('Special Victims Unit',
                                                      'SVU')
            aliases = data['aliases']
            episode_title = data['title'] if 'tvshowtitle' in data else None
            year = data['year']
            hdlr = 'S%02dE%02d' % (int(data['season']), int(
                data['episode'])) if 'tvshowtitle' in data else year

            query = '%s %s' % (title, hdlr)
            query = re.sub(r'(\\\|/| -|:|;|\*|\?|"|\'|<|>|\|)', '', query)
            url = '%s%s' % (self.base_link,
                            self.search_link % quote_plus(query))
            # log_utils.log('url = %s' % url, log_utils.LOGDEBUG)

            r = client.request(url, headers=headers)
            if not r: return sources
            r = jsloads(r)
            if 'not_found' in r['status']: return sources
            results = r['files_found']
        except:
            source_utils.scraper_error('FILEPURSUIT')
            return sources
        for item in results:
            try:
                url = item['file_link']
                try:
                    size = int(item['file_size_bytes'])
                except:
                    size = 0
                try:
                    name = item['file_name']
                except:
                    name = item['file_link'].split('/')[-1]
                name = source_utils.clean_name(name)

                if not source_utils.check_title(title, aliases, name, hdlr,
                                                year):
                    continue
                name_info = source_utils.info_from_name(
                    name, title, year, hdlr, episode_title)
                if source_utils.remove_lang(name_info): continue

                # link_header = client.request(url, output='headers', timeout='5') # to slow to check validity of links
                # if not any(value in str(link_header) for value in ['stream', 'video/mkv']): continue

                quality, info = source_utils.get_release_quality(
                    name_info, url)
                try:
                    dsize, isize = source_utils.convert_size(size, to='GB')
                    if isize: info.insert(0, isize)
                except:
                    dsize = 0
                info = ' | '.join(info)

                sources.append({
                    'provider': 'filepursuit',
                    'source': 'direct',
                    'quality': quality,
                    'name': name,
                    'name_info': name_info,
                    'language': "en",
                    'url': url,
                    'info': info,
                    'direct': True,
                    'debridonly': False,
                    'size': dsize
                })
            except:
                source_utils.scraper_error('FILEPURSUIT')
        return sources
Exemplo n.º 8
0
# -*- coding: UTF-8 -*-

import os
from pkgutil import walk_packages
from fenomscrapers.modules.control import setting as getSetting

debug = getSetting('debug.enabled') == 'true'

def sources(specified_folders=None):
	try:
		sourceDict = []
		sourceFolder = getScraperFolder()
		sourceFolderLocation = os.path.join(os.path.dirname(__file__), sourceFolder)
		sourceSubFolders = [x[1] for x in os.walk(sourceFolderLocation)][0]
		sourceSubFolders = [x for x in sourceSubFolders if  '__pycache__' not in x]
		if specified_folders:
			sourceSubFolders = specified_folders
		for i in sourceSubFolders:
			for loader, module_name, is_pkg in walk_packages([os.path.join(sourceFolderLocation, i)]):
				if is_pkg: continue
				if enabledCheck(module_name):
					try:
						module = loader.find_module(module_name).load_module(module_name)
						sourceDict.append((module_name, module.source()))
					except Exception as e:
						if debug:
							from fenomscrapers.modules import log_utils
							log_utils.log('Error: Loading module: "%s": %s' % (module_name, e), level=log_utils.LOGWARNING)
		return sourceDict
	except:
		from fenomscrapers.modules import log_utils
Exemplo n.º 9
0
    def sources(self, data, hostDict):
        sources = []
        if not data: return sources
        auth = self._get_auth()
        if not auth: return sources
        try:
            title_chk = getSetting('easynews.title.chk') == 'true'

            title = data['tvshowtitle'] if 'tvshowtitle' in data else data[
                'title']
            title = title.replace('&', 'and').replace('Special Victims Unit',
                                                      'SVU')
            aliases = data['aliases']

            episode_title = data['title'] if 'tvshowtitle' in data else None
            year = data['year']
            years = [str(year),
                     str(int(year) +
                         1), str(int(year) -
                                 1)] if 'tvshowtitle' not in data else None
            hdlr = 'S%02dE%02d' % (int(data['season']), int(
                data['episode'])) if 'tvshowtitle' in data else year

            query = self._query(data)
            url, params = self._translate_search(query)
            headers = {'Authorization': auth}
            results = requests.get(url,
                                   params=params,
                                   headers=headers,
                                   timeout=15).json()
            down_url = results.get('downURL')
            dl_farm = results.get('dlFarm')
            dl_port = results.get('dlPort')
            files = results.get('data', [])
        except:
            source_utils.scraper_error('EASYNEWS')
            return sources
        for item in files:
            try:
                post_hash, post_title, ext, duration = item['0'], item[
                    '10'], item['11'], item['14']
                # log_utils.log('post_title = %s' % post_title, __name__, log_utils.LOGDEBUG)
                checks = [False] * 5
                if 'alangs' in item and item['alangs'] and 'eng' not in item[
                        'alangs']:
                    checks[1] = True
                if re.match(r'^\d+s', duration) or re.match(
                        '^[0-5]m', duration):
                    checks[2] = True
                if 'passwd' in item and item['passwd']: checks[3] = True
                if 'virus' in item and item['virus']: checks[4] = True
                if 'type' in item and item['type'].upper() != 'VIDEO':
                    checks[5] = True
                if any(checks): continue

                stream_url = down_url + quote(
                    '/%s/%s/%s%s/%s%s' %
                    (dl_farm, dl_port, post_hash, ext, post_title, ext))
                name = source_utils.clean_name(post_title)
                # log_utils.log('name = %s' % name, __name__, log_utils.LOGDEBUG)
                name_chk = name
                if 'tvshowtitle' in data:
                    name_chk = re.sub(r'S\d+([.-])E\d+', hdlr, name_chk, 1,
                                      re.I)
                    name_chk = re.sub(r'^tvp[.-]', '', name_chk, 1, re.I)
                name_chk = re.sub(r'disney[.-]gallery[.-]star[.-]wars[.-]', '',
                                  name_chk, 0, re.I)
                name_chk = re.sub(r'marvels[.-]', '', name_chk, 0, re.I)
                if title_chk:
                    if not source_utils.check_title(title, aliases, name_chk,
                                                    hdlr, year, years):
                        continue

                name_info = source_utils.info_from_name(
                    name_chk, title, year, hdlr, episode_title)
                if source_utils.remove_lang(name_info): continue

                file_dl = stream_url + '|Authorization=%s' % (quote(auth))

                quality, info = source_utils.get_release_quality(
                    name_info, file_dl)
                try:
                    size = float(int(item['rawSize']))
                    dsize, isize = source_utils.convert_size(size, to='GB')
                    if isize: info.insert(0, isize)
                except:
                    dsize = 0
                info = ' | '.join(info)

                sources.append({
                    'provider': 'easynews',
                    'source': 'direct',
                    'name': name,
                    'name_info': name_info,
                    'quality': quality,
                    'language': "en",
                    'url': file_dl,
                    'info': info,
                    'direct': True,
                    'debridonly': False,
                    'size': dsize
                })
            except:
                source_utils.scraper_error('EASYNEWS')
        return sources
Exemplo n.º 10
0
 def __init__(self):
     self.priority = 1
     self.language = ['en']
     self.title_chk = (getSetting('gdrive.title.chk') == 'true')
     self.movie = True
     self.tvshow = True
Exemplo n.º 11
0
# -*- coding: utf-8 -*-
# (updated 11-04-2021)
'''
	Fenomscrapers Project
'''

import re
import requests
try:  #Py2
    from urllib import unquote, quote_plus
except ImportError:  #Py3
    from urllib.parse import unquote, quote_plus
from fenomscrapers.modules.control import setting as getSetting
from fenomscrapers.modules import source_utils

cloudflare_worker_url = getSetting('gdrive.cloudflare_url').strip()


def getResults(searchTerm):
    url = '{}/searchjson/{}'.format(cloudflare_worker_url, searchTerm)
    if not url.startswith("https://"): url = "https://" + url
    # log_utils.log('query url = %s' % url)
    results = requests.get(url).json()
    return results


class source:
    def __init__(self):
        self.priority = 1
        self.language = ['en']
        self.title_chk = (getSetting('gdrive.title.chk') == 'true')