Merge branch 'master' into master

This commit is contained in:
lozioangie
2019-04-11 21:29:25 +02:00
committed by GitHub
44 changed files with 1735 additions and 330 deletions
+22 -17
View File
@@ -1841,7 +1841,7 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
item.category = channel_alt.capitalize()
category = "'%s'" % channel_alt
channel_py_alt = 'xyz123'
if channel in fail_over_list : #Si es un clone de Newpct1, se actualiza el canal y la categoría
if channel in fail_over_list : #Si es un clone de Newpct1, se actualiza el canal y la categoría
item.channel = channel_py
channel_py_alt = "'%s'" % channel_py
if item.channel_host: #y se borran resto de pasadas anteriores
@@ -1948,15 +1948,20 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
if lookup == True:
overwrite = False #Solo avisamos si hay cambios
i = 0
for activo, canal_org, canal_des, url_org, url_des, patron1, patron2, patron3, patron4, patron5, content_inc, content_exc, ow_force in intervencion_list:
i += 1
opt = ''
#Es esta nuestra entrada?
if activo == '1' and (canal_org == channel_alt or canal_org == item.category.lower() or channel_alt == 'videolibrary' or ow_force == 'del' or ow_force == 'emerg'):
if ow_force == 'del' or ow_force == 'emerg': #Si es un borrado de estructuras erroneas, hacemos un proceso aparte
canal_des_def = canal_des #Si hay canal de sustitución para item.library_urls, lo usamos
if item.url:
logger.debug('INTERV. LIST: ' + str(intervencion_list[i-1]) + ' / CHANNEL: ' + str(channel_alt) + ' / URL: ' + str(item.url))
if ow_force == 'del' or ow_force == 'emerg': #Si es un borrado de estructuras erroneas, hacemos un proceso aparte
canal_des_def = canal_des #Si hay canal de sustitución para item.library_urls, lo usamos
if not canal_des_def and canal_org in item.library_urls and len(item.library_urls) == 1: #Si no, lo extraemos de la url
canal_des_def = scrapertools.find_single_match(item.library_urls[canal_org], 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').lower() #salvamos la url actual de la estructura a borrar
canal_des_def = scrapertools.find_single_match(item.library_urls[canal_org], 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').lower() #salvamos la url actual de la estructura a borrar
url_total = ''
if item.url:
url_total = item.url #Si existe item.url, lo salvamos para futuro uso
@@ -1986,8 +1991,8 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
if canal_vid_alt not in intervencion: #... la sustituimos por la primera válida
item.url = url_vid
break
if canal_vid_alt in fail_over_list: #Si es un clone de Newpct1, salvamos la nueva categoría
item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').lower() #Salvamos categoría
if canal_vid_alt in fail_over_list: #Si es un clone de Newpct1, salvamos la nueva categoría
item.category = scrapertools.find_single_match(item.url, 'http.?\:\/\/(?:www.)?(\w+)\.\w+\/').lower() #Salvamos categoría
else:
item.category = canal_vid.capitalize() #si no, salvamos nueva categoría
logger.error('item.library_urls ACTUALIZADA: ' + str(item.library_urls))
@@ -2000,7 +2005,7 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
else:
if channel_alt == 'videolibrary': #Viene de videolibrary.list_movies: IMPRESCINDIBLE
for canal_vid, url_vid in item.library_urls.items():
if canal_org != canal_vid: #Miramos si canal_org de la regla está en item.library_urls
if canal_org != canal_vid: #Miramos si canal_org de la regla está en item.library_urls
continue
else:
channel_alt = canal_org #Sí, ponermos el nombre del canal de origen
@@ -2009,10 +2014,10 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
channel_alt = channel_py
if channel_alt == 'videolibrary':
continue
if item.contentType == "list": #Si viene de Videolibrary, le cambiamos ya el canal
if item.contentType == "list": #Si viene de Videolibrary, le cambiamos ya el canal
if item.channel != channel_py:
item.channel = canal_des #Cambiamos el canal. Si es clone, lo hace el canal
continue #Salimos sin hacer nada más. item está casi vacío
item.channel = canal_des #Cambiamos el canal. Si es clone, lo hace el canal
continue #Salimos sin hacer nada más. item está casi vacío
if item.contentType not in content_inc and "*" not in content_inc: #Está el contenido el la lista de incluidos
continue
if item.contentType in content_exc: #Está el contenido excluido?
@@ -2030,7 +2035,7 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
continue #... una intervención que afecte solo a una región
if ow_force == 'no' and it.library_urls: #Esta regla solo vale para findvideos...
continue #... salidmos si estamos actualizando
if lookup == True: #Queremos que el canal solo visualice sin migración?
if lookup == True: #Queremos que el canal solo visualice sin migración?
if ow_force != 'no':
overwrite = True #Avisamos que hay cambios
continue #Salimos sin tocar archivos
@@ -2052,14 +2057,14 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
if patron5: #Hay más expresión regex?
url += scrapertools.find_single_match(url_total, patron5) #La aplicamos a url
if url:
url_total = url #Guardamos la suma de los resultados intermedios
url_total = url #Guardamos la suma de los resultados intermedios
if item.channel == channel_py or channel in fail_over_list: #Si es Newpct1...
if item.contentType == "tvshow":
url_total = re.sub(r'\/\d+\/?$', '', url_total) #parece que con el título encuentra la serie, normalmente...
update_stat += 1 #Ya hemos actualizado algo
canal_org_des_list += [(canal_org, canal_des, url_total, opt, ow_force)] #salvamos el resultado para su proceso
if update_stat > 0 or delete_stat > 0: #Ha habido alguna actualización o borrado? Entonces salvamos
if update_stat > 0 or delete_stat > 0: #Ha habido alguna actualización o borrado? Entonces salvamos
if (update_stat > 0 and path != False) or item.ow_force == '1':
logger.error('** Lista de Actualizaciones a realizar: ' + str(canal_org_des_list))
for canal_org_def, canal_des_def, url_total, opt_def, ow_force_def in canal_org_des_list: #pasamos por todas las "parejas" cambiadas
@@ -2072,7 +2077,7 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
item.library_urls.update({canal_des_def: url_total})
it.library_urls = item.library_urls
if item.channel != channel_py and item.channel != 'videolibrary':
item.channel = canal_des_def #Cambiamos el canal. Si es clone, lo hace el canal
item.channel = canal_des_def #Cambiamos el canal. Si es clone, lo hace el canal
if channel_alt == item.category.lower(): #Actualizamos la Categoría y si la tenía
item.category = item.channel.capitalize()
if ow_force_def == 'force' and item.contentType != 'movie': #Queremos que el canal revise la serie entera?
@@ -2082,7 +2087,7 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
if it.library_urls and path != False and ow_force_def != 'no': #Continuamos si hay .nfo, path, y queremos actualizarlo
item.update_next = '1'
del item.update_next #Borramos estos campos para forzar la actualización ya
del item.update_next #Borramos estos campos para forzar la actualización ya
it.update_next = '1'
del it.update_next
@@ -2091,7 +2096,7 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
canal_org_des_list_ALT = [] #Creamos esta lista para salvar las parejas
canal_org_des_list_ALT.extend(canal_org_des_list) #... y borrar de la original las web caidas
for canal_org_def, canal_des_def, url_total, opt_def, ow_force_def in canal_org_des_list_ALT: #pasamos por las "parejas" a borrar
if "magnet:" in url_total or type(url_total) != str: #Si la url es un Magnet, o es una lista, pasamos
if "magnet:" in url_total or type(url_total) != str: #Si la url es un Magnet, o es una lista, pasamos
i += 1
continue
try:
@@ -2202,7 +2207,7 @@ def redirect_clone_newpct1(item, head_nfo=None, it=None, path=False, overwrite=F
else:
logger.error('Error en FINDVIDEOS: ' + archivo + ' / Regla: ' + canal_org_def + ', ' + opt_def + ', ' + ow_force_def)
if ow_force_def == 'emerg' and opt_def == '2': #Si era una operación para borrar urls de emergencia ...
if ow_force_def == 'emerg' and opt_def == '2': #Si era una operación para borrar urls de emergencia ...
if it.emergency_urls and not isinstance(it.emergency_urls, dict):
del it.emergency_urls
if it.emergency_urls and it.emergency_urls.get(item_movie.channel, False):
@@ -155,7 +155,7 @@ def limited(func):
inf = float('inf')
def Literal(type, value, raw, regex=None):
def Literal(type, value, raw, regex=None, comments=None):
if regex: # regex
return 'JsRegExp(%s)' % repr(compose_regex(value))
elif value is None: # null
@@ -165,12 +165,12 @@ def Literal(type, value, raw, regex=None):
return 'Js(%s)' % repr(value) if value != inf else 'Js(float("inf"))'
def Identifier(type, name):
def Identifier(type, name, comments=None):
return 'var.get(%s)' % repr(name)
@limited
def MemberExpression(type, computed, object, property):
def MemberExpression(type, computed, object, property, comments=None):
far_left = trans(object)
if computed: # obj[prop] type accessor
# may be literal which is the same in every case so we can save some time on conversion
@@ -183,12 +183,12 @@ def MemberExpression(type, computed, object, property):
return far_left + '.get(%s)' % prop
def ThisExpression(type):
def ThisExpression(type, comments=None):
return 'var.get(u"this")'
@limited
def CallExpression(type, callee, arguments):
def CallExpression(type, callee, arguments, comments=None):
arguments = [trans(e) for e in arguments]
if callee['type'] == 'MemberExpression':
far_left = trans(callee['object'])
@@ -210,14 +210,14 @@ def CallExpression(type, callee, arguments):
# ========== ARRAYS ============
def ArrayExpression(type, elements): # todo fix null inside problem
def ArrayExpression(type, elements, comments=None): # todo fix null inside problem
return 'Js([%s])' % ', '.join(trans(e) if e else 'None' for e in elements)
# ========== OBJECTS =============
def ObjectExpression(type, properties):
def ObjectExpression(type, properties, comments=None):
name = inline_stack.require('Object')
elems = []
after = ''
@@ -241,7 +241,7 @@ def ObjectExpression(type, properties):
return name
def Property(type, kind, key, computed, value, method, shorthand):
def Property(type, kind, key, computed, value, method, shorthand, comments=None):
if shorthand or computed:
raise NotImplementedError(
'Shorthand and Computed properties not implemented!')
@@ -256,7 +256,7 @@ def Property(type, kind, key, computed, value, method, shorthand):
@limited
def UnaryExpression(type, operator, argument, prefix):
def UnaryExpression(type, operator, argument, prefix, comments=None):
a = trans(
argument, standard=True
) # unary involve some complex operations so we cant use line shorteners here
@@ -271,7 +271,7 @@ def UnaryExpression(type, operator, argument, prefix):
@limited
def BinaryExpression(type, operator, left, right):
def BinaryExpression(type, operator, left, right, comments=None):
a = trans(left)
b = trans(right)
# delegate to our friends
@@ -279,7 +279,7 @@ def BinaryExpression(type, operator, left, right):
@limited
def UpdateExpression(type, operator, argument, prefix):
def UpdateExpression(type, operator, argument, prefix, comments=None):
a = trans(
argument, standard=True
) # also complex operation involving parsing of the result so no line length reducing here
@@ -287,7 +287,7 @@ def UpdateExpression(type, operator, argument, prefix):
@limited
def AssignmentExpression(type, operator, left, right):
def AssignmentExpression(type, operator, left, right, comments=None):
operator = operator[:-1]
if left['type'] == 'Identifier':
if operator:
@@ -319,12 +319,12 @@ six
@limited
def SequenceExpression(type, expressions):
def SequenceExpression(type, expressions, comments=None):
return reduce(js_comma, (trans(e) for e in expressions))
@limited
def NewExpression(type, callee, arguments):
def NewExpression(type, callee, arguments, comments=None):
return trans(callee) + '.create(%s)' % ', '.join(
trans(e) for e in arguments)
@@ -332,7 +332,7 @@ def NewExpression(type, callee, arguments):
@limited
def ConditionalExpression(
type, test, consequent,
alternate): # caused plenty of problems in my home-made translator :)
alternate, comments=None): # caused plenty of problems in my home-made translator :)
return '(%s if %s else %s)' % (trans(consequent), trans(test),
trans(alternate))
@@ -340,49 +340,49 @@ def ConditionalExpression(
# =========== STATEMENTS =============
def BlockStatement(type, body):
def BlockStatement(type, body, comments=None):
return StatementList(
body) # never returns empty string! In the worst case returns pass\n
def ExpressionStatement(type, expression):
def ExpressionStatement(type, expression, comments=None):
return trans(expression) + '\n' # end expression space with new line
def BreakStatement(type, label):
def BreakStatement(type, label, comments=None):
if label:
return 'raise %s("Breaked")\n' % (get_break_label(label['name']))
else:
return 'break\n'
def ContinueStatement(type, label):
def ContinueStatement(type, label, comments=None):
if label:
return 'raise %s("Continued")\n' % (get_continue_label(label['name']))
else:
return 'continue\n'
def ReturnStatement(type, argument):
def ReturnStatement(type, argument, comments=None):
return 'return %s\n' % (trans(argument)
if argument else "var.get('undefined')")
def EmptyStatement(type):
def EmptyStatement(type, comments=None):
return 'pass\n'
def DebuggerStatement(type):
def DebuggerStatement(type, comments=None):
return 'pass\n'
def DoWhileStatement(type, body, test):
def DoWhileStatement(type, body, test, comments=None):
inside = trans(body) + 'if not %s:\n' % trans(test) + indent('break\n')
result = 'while 1:\n' + indent(inside)
return result
def ForStatement(type, init, test, update, body):
def ForStatement(type, init, test, update, body, comments=None):
update = indent(trans(update)) if update else ''
init = trans(init) if init else ''
if not init.endswith('\n'):
@@ -398,7 +398,7 @@ def ForStatement(type, init, test, update, body):
return result
def ForInStatement(type, left, right, body, each):
def ForInStatement(type, left, right, body, each, comments=None):
res = 'for PyJsTemp in %s:\n' % trans(right)
if left['type'] == "VariableDeclaration":
addon = trans(left) # make sure variable is registered
@@ -417,7 +417,7 @@ def ForInStatement(type, left, right, body, each):
return res
def IfStatement(type, test, consequent, alternate):
def IfStatement(type, test, consequent, alternate, comments=None):
# NOTE we cannot do elif because function definition inside elif statement would not be possible!
IF = 'if %s:\n' % trans(test)
IF += indent(trans(consequent))
@@ -427,7 +427,7 @@ def IfStatement(type, test, consequent, alternate):
return IF + ELSE
def LabeledStatement(type, label, body):
def LabeledStatement(type, label, body, comments=None):
# todo consider using smarter approach!
inside = trans(body)
defs = ''
@@ -448,7 +448,7 @@ def LabeledStatement(type, label, body):
return defs + inside
def StatementList(lis):
def StatementList(lis, comments=None):
if lis: # ensure we don't return empty string because it may ruin indentation!
code = ''.join(trans(e) for e in lis)
return code if code else 'pass\n'
@@ -456,7 +456,7 @@ def StatementList(lis):
return 'pass\n'
def PyimportStatement(type, imp):
def PyimportStatement(type, imp, comments=None):
lib = imp['name']
jlib = 'PyImport_%s' % lib
code = 'import %s as %s\n' % (lib, jlib)
@@ -471,7 +471,7 @@ def PyimportStatement(type, imp):
return code
def SwitchStatement(type, discriminant, cases):
def SwitchStatement(type, discriminant, cases, comments=None):
#TODO there will be a problem with continue in a switch statement.... FIX IT
code = 'while 1:\n' + indent('SWITCHED = False\nCONDITION = (%s)\n')
code = code % trans(discriminant)
@@ -491,12 +491,12 @@ def SwitchStatement(type, discriminant, cases):
return code
def ThrowStatement(type, argument):
def ThrowStatement(type, argument, comments=None):
return 'PyJsTempException = JsToPyException(%s)\nraise PyJsTempException\n' % trans(
argument)
def TryStatement(type, block, handler, handlers, guardedHandlers, finalizer):
def TryStatement(type, block, handler, handlers, guardedHandlers, finalizer, comments=None):
result = 'try:\n%s' % indent(trans(block))
# complicated catch statement...
if handler:
@@ -516,13 +516,13 @@ def TryStatement(type, block, handler, handlers, guardedHandlers, finalizer):
return result
def LexicalDeclaration(type, declarations, kind):
def LexicalDeclaration(type, declarations, kind, comments=None):
raise NotImplementedError(
'let and const not implemented yet but they will be soon! Check github for updates.'
)
def VariableDeclarator(type, id, init):
def VariableDeclarator(type, id, init, comments=None):
name = id['name']
# register the name if not already registered
Context.register(name)
@@ -531,21 +531,21 @@ def VariableDeclarator(type, id, init):
return ''
def VariableDeclaration(type, declarations, kind):
def VariableDeclaration(type, declarations, kind, comments=None):
code = ''.join(trans(d) for d in declarations)
return code if code else 'pass\n'
def WhileStatement(type, test, body):
def WhileStatement(type, test, body, comments=None):
result = 'while %s:\n' % trans(test) + indent(trans(body))
return result
def WithStatement(type, object, body):
def WithStatement(type, object, body, comments=None):
raise NotImplementedError('With statement not implemented!')
def Program(type, body):
def Program(type, body, comments=None):
inline_stack.reset()
code = ''.join(trans(e) for e in body)
# here add hoisted elements (register variables and define functions)
@@ -559,7 +559,7 @@ def Program(type, body):
def FunctionDeclaration(type, id, params, defaults, body, generator,
expression):
expression, comments=None):
if generator:
raise NotImplementedError('Generators not supported')
if defaults:
@@ -610,7 +610,7 @@ def FunctionDeclaration(type, id, params, defaults, body, generator,
def FunctionExpression(type, id, params, defaults, body, generator,
expression):
expression, comments=None):
if generator:
raise NotImplementedError('Generators not supported')
if defaults:
+83
View File
@@ -0,0 +1,83 @@
MAPPING = {
'a': '(false+"")[1]',
'b': '([]["entries"]()+"")[2]',
'c': '([]["fill"]+"")[3]',
'd': '(undefined+"")[2]',
'e': '(true+"")[3]',
'f': '(false+"")[0]',
'g': '(false+[0]+String)[20]',
'h': '(+(101))["to"+String["name"]](21)[1]',
'i': '([false]+undefined)[10]',
'j': '([]["entries"]()+"")[3]',
'k': '(+(20))["to"+String["name"]](21)',
'l': '(false+"")[2]',
'm': '(Number+"")[11]',
'n': '(undefined+"")[1]',
'o': '(true+[]["fill"])[10]',
'p': '(+(211))["to"+String["name"]](31)[1]',
'q': '(+(212))["to"+String["name"]](31)[1]',
'r': '(true+"")[1]',
's': '(false+"")[3]',
't': '(true+"")[0]',
'u': '(undefined+"")[0]',
'v': '(+(31))["to"+String["name"]](32)',
'w': '(+(32))["to"+String["name"]](33)',
'x': '(+(101))["to"+String["name"]](34)[1]',
'y': '(NaN+[Infinity])[10]',
'z': '(+(35))["to"+String["name"]](36)',
'A': '(+[]+Array)[10]',
'B': '(+[]+Boolean)[10]',
'C': 'Function("return escape")()(("")["italics"]())[2]',
'D': 'Function("return escape")()([]["fill"])["slice"]("-1")',
'E': '(RegExp+"")[12]',
'F': '(+[]+Function)[10]',
'G': '(false+Function("return Date")()())[30]',
'I': '(Infinity+"")[0]',
'M': '(true+Function("return Date")()())[30]',
'N': '(NaN+"")[0]',
'O': '(NaN+Function("return{}")())[11]',
'R': '(+[]+RegExp)[10]',
'S': '(+[]+String)[10]',
'T': '(NaN+Function("return Date")()())[30]',
'U': '(NaN+Function("return{}")()["to"+String["name"]]["call"]())[11]',
' ': '(NaN+[]["fill"])[11]',
'"': '("")["fontcolor"]()[12]',
'%': 'Function("return escape")()([]["fill"])[21]',
'&': '("")["link"](0+")[10]',
'(': '(undefined+[]["fill"])[22]',
')': '([0]+false+[]["fill"])[20]',
'+': '(+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]])+[])[2]',
',': '([]["slice"]["call"](false+"")+"")[1]',
'-': '(+(.+[0000000001])+"")[2]',
'.': '(+(+!+[]+[+!+[]]+(!![]+[])[!+[]+!+[]+!+[]]+[!+[]+!+[]]+[+[]])+[])[+!+[]]',
'/': '(false+[0])["italics"]()[10]',
':': '(RegExp()+"")[3]',
';': '("")["link"](")[14]',
'<': '("")["italics"]()[0]',
'=': '("")["fontcolor"]()[11]',
'>': '("")["italics"]()[2]',
'?': '(RegExp()+"")[2]',
'[': '([]["entries"]()+"")[0]',
']': '([]["entries"]()+"")[22]',
'{': '(true+[]["fill"])[20]',
'}': '([]["fill"]+"")["slice"]("-1")'
}
SIMPLE = {
'false': '![]',
'true': '!![]',
'undefined': '[][[]]',
'NaN': '+[![]]',
'Infinity': '+(+!+[]+(!+[]+[])[!+[]+!+[]+!+[]]+[+!+[]]+[+[]]+[+[]]+[+[]])' # +"1e1000"
}
def jsunc(jscString):
for key in sorted(MAPPING, key=lambda k: len(MAPPING[k]), reverse=True):
if MAPPING.get(key) in jscString:
jscString = jscString.replace(MAPPING.get(key), '"{}"'.format(key))
for key in sorted(SIMPLE, key=lambda k: len(SIMPLE[k]), reverse=True):
if SIMPLE.get(key) in jscString:
jscString = jscString.replace(SIMPLE.get(key), '{}'.format(key))
return jscString
+1
View File
@@ -275,6 +275,7 @@ def quasard_thread(monitor):
except IOError:
time.sleep(1) # nothing to read, sleep
log.info("quasard: proc.return code: %s" % str(proc.returncode))
if proc.returncode == 0 or xbmc.abortRequested:
break