Merge remote-tracking branch 'origin/master'

This commit is contained in:
marco
2020-04-07 23:48:24 +02:00
9 changed files with 108 additions and 149 deletions

View File

@@ -1,13 +1,10 @@
# -*- coding: utf-8 -*-
# ------------------------------------------------------------
# Canale per AnimeSaturn
# Thanks to 4l3x87
# ----------------------------------------------------------
from core import support
# __channel__ = "animesaturn"
# host = support.config.get_setting("channel_host", __channel__)
host = support.config.get_channel_url()
headers={'X-Requested-With': 'XMLHttpRequest'}
@@ -31,11 +28,8 @@ def search(item, texto):
search = texto
item.contentType = 'tvshow'
anime = True
patron = r'href="(?P<url>[^"]+)"[^>]+>[^>]+>(?P<title>[^<|(]+)(?:(?P<lang>\(([^\)]+)\)))?<|\)'
patron = r'<a href="(?P<url>[^"]+)"[^>]+> <span>(?P<title>[^<\(]+)(?:\s*\((?P<year>\d+)\))?(?:\s*\((?P<lang>[A-Za-z-]+)\))?'
action = 'check'
def itemHook(item):
item.url = item.url.replace('www.','')
return item
return locals()
@@ -59,37 +53,52 @@ def newest(categoria):
@support.scrape
def menu(item):
patronMenu = r'u>(?P<title>[^<]+)<u>(?P<url>.*?)</div> </div>'
patronMenu = r'<div class="col-md-13 bg-dark-as-box-shadow p-2 text-white text-center">(?P<title>[^"<]+)<(?P<url>.*?)(?:"lista-top"|"clearfix")'
action = 'peliculas'
def itemHook(item):
item.url = item.url.replace('www.','')
return item
item.args = 'top'
return locals()
@support.scrape
def peliculas(item):
anime = True
deflang= 'Sub-ITA'
if item.args == 'updated':
post = "page=" + str(item.page if item.page else 1) if item.page > 1 else None
page= support.match(item, patron=r'data-page="(\d+)" title="Next">', post=post, headers=headers).match
patron = r'<img alt="[^"]+" src="(?P<thumb>[^"]+)" [^>]+></div></a>\s*<a href="(?P<url>[^"]+)"><div class="testo">(?P<title>[^\(<]+)(?:(?P<lang>\(([^\)]+)\)))?</div></a>\s*<a href="[^"]+"><div class="testo2">[^\d]+(?P<episode>\d+)</div></a>'
if page: nextpage = page
item.contentType='episode'
action = 'findvideos'
elif item.args == 'top':
data = item.url
patron = r'<a href="(?P<url>[^"]+)">[^>]+>(?P<title>[^<\(]+)(?:\((?P<year>[0-9]+)\))?(?:\((?P<lang>[A-Za-z]+)\))?</div></a><div class="numero">(?P<title2>[^<]+)</div>.*?src="(?P<thumb>[^"]+)"'
action = 'check'
action = 'check'
page = None
post = "page=" + str(item.page if item.page else 1) if item.page > 1 else None
if item.args == 'top':
data=item.url
patron = r'light">(?P<title2>[^<]+)</div>\s(?P<title>[^<]+)[^>]+>[^>]+>\s<a href="(?P<url>[^"]+)">(?:<a[^>]+>|\s*)<img alt="[^"]+" src="(?P<thumb>[^"]+)"'
else:
pagination = ''
if item.args == 'incorso': patron = r'"slider_title"\s*href="(?P<url>[^"]+)"><img src="(?P<thumb>[^"]+)"[^>]+>(?P<title>[^\(<]+)(?:\((?P<year>\d+)\))?</a>'
else: patron = r'href="(?P<url>[^"]+)"[^>]+>[^>]+>(?P<title>.+?)(?:\((?P<lang>ITA)\))?(?:(?P<year>\((\d+)\)))?</span>'
action = 'check'
def itemHook(item):
item.url = item.url.replace('www.','')
return item
data = support.match(item, post=post, headers=headers).data
if item.args == 'updated':
page= support.match(data, patron=r'data-page="(\d+)" title="Next">').match
patron = r'<a href="(?P<url>[^"]+)" title="(?P<title>[^"(]+)(?:\s*\((?P<year>\d+)\))?(?:\s*\((?P<lang>[A-Za-z-]+)\))?"><img src="(?P<thumb>[^"]+)"[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>\s\s*(?P<type>[^\s]+)\s*(?P<episode>\d+)'
typeContentDict = {'Movie':'movie', 'Episodio':'episode'} #item.contentType='episode'
action = 'findvideos'
def itemlistHook(itemlist):
if page:
itemlist.append(
support.Item(channel=item.channel,
action = item.action,
contentType=item.contentType,
title=support.typo(support.config.get_localized_string(30992), 'color kod bold'),
url=item.url,
page= page,
args=item.args,
thumbnail=support.thumb()))
return itemlist
else:
pagination = ''
if item.args == 'incorso':
patron = r'<a href="(?P<url>[^"]+)"[^>]+>(?P<title>[^<(]+)(?:\s*\((?P<year>\d+)\))?(?:\s*\((?P<lang>[A-za-z-]+)\))?</a>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>\s*<img width="[^"]+" height="[^"]+" src="(?P<thumb>[^"]+)"[^>]+>[^>]+>[^>]+>[^>]+>[^>]+>(?P<plot>[^<]+)<'
else:
patron = r'href="(?P<url>[^"]+)"[^>]+>[^>]+>(?P<title>.+?)(?:\((?P<lang>ITA)\))?(?:(?P<year>\((\d+)\)))?</span>'
return locals()
@@ -110,21 +119,18 @@ def check(item):
@support.scrape
def episodios(item):
if item.contentType != 'movie': anime = True
patron = r'<strong" style="[^"]+">(?P<title>[^<]+)</b></strong></td>\s*<td style="[^"]+"><a href="(?P<url>[^"]+)"'
def itemHook(item):
item.url = item.url.replace('www.','')
return item
patron = r'<a href="(?P<url>[^"]+)"[^>]+>\s*(?P<title>[^<]+)</a>'
return locals()
def findvideos(item):
support.log()
itemlist = []
# support.dbg()
urls = support.match(item, patron=r'<a href="([^"]+)"><div class="downloadestreaming">', headers=headers, debug=False).matches
if urls:
links = support.match(urls[0].replace('www.',''), patron=r'(?:<source type="[^"]+"\s*src=|file:\s*)"([^"]+)"', headers=headers, debug=False)
for link in links.matches:
url = support.match(item, patron=r'<a href="([^"]+)">[^>]+>[^>]+>G', headers=headers, debug=False).match
support.log(url)
if url:
links = support.match(url, patron=r'(?:<source type="[^"]+"\s*src=|file:\s*)"([^"]+)"', headers=headers, debug=False).matches
for link in links:
itemlist.append(
support.Item(channel=item.channel,
action="play",
@@ -136,7 +142,7 @@ def findvideos(item):
show=item.show,
contentType=item.contentType,
folder=False))
return support.server(item, links, itemlist=itemlist)
return support.server(item, itemlist=itemlist)

View File

@@ -482,6 +482,7 @@ class UnshortenIt(object):
def _unshorten_vcrypt(self, uri):
uri = uri.replace('.net','.pw')
try:
headers = {}
if 'myfoldersakstream.php' in uri or '/verys/' in uri:

View File

@@ -229,9 +229,8 @@ def open_settings():
from specials import videolibrary
from platformcode import xbmc_videolibrary
if settings_pre.get('downloadpath', None) != settings_post.get('downloadpath', None) and \
is_xbmc() and get_setting("videolibrary_kodi"):
xbmc_videolibrary.update_sources(settings_pre.get('downloadpath', None), settings_post.get('downloadpath', None))
if settings_pre.get('downloadpath', None) != settings_post.get('downloadpath', None):
xbmc_videolibrary.update_sources(settings_post.get('downloadpath', None), settings_pre.get('downloadpath', None))
# si se ha cambiado la ruta de la videoteca llamamos a comprobar directorios para que lo cree y pregunte
# automaticamente si configurar la videoteca
@@ -499,6 +498,10 @@ def verify_directories_created():
# si se crea el directorio
filetools.mkdir(content_path)
from platformcode import xbmc_videolibrary
xbmc_videolibrary.update_sources(get_setting("videolibrarypath"))
xbmc_videolibrary.update_sources(get_setting("downloadpath"))
try:
from core import scrapertools
# Buscamos el archivo addon.xml del skin activo

View File

@@ -153,7 +153,7 @@ def render_items(itemlist, parent_item):
return
# if there's no item, add "no elements" item
if not len(itemlist):
itemlist.append(Item(title=config.get_localized_string(60347)))
itemlist.append(Item(title=config.get_localized_string(60347), thumbnail=get_thumb('nofolder.png')))
for item in itemlist:
item_url = item.tourl()
@@ -293,7 +293,7 @@ def render_items_old(itemlist, parent_item):
# Si no hay ningun item, mostramos un aviso
if not len(itemlist):
itemlist.append(Item(title=config.get_localized_string(60347)))
itemlist.append(Item(title=config.get_localized_string(60347), thumbnail=get_thumb('nofolder.png')))
genre = False
if 'nero' in parent_item.title:
@@ -353,9 +353,9 @@ def render_items_old(itemlist, parent_item):
item.thumbnail = get_thumb("next.png")
elif 'add' in item.action:
if 'pelicula' in item.action:
item.thumbnail = get_thumb("videolibrary_movie.png")
item.thumbnail = get_thumb("add_to_videolibrary.png")
elif 'serie' in item.action:
item.thumbnail = get_thumb("videolibrary_tvshow.png")
item.thumbnail = get_thumb("add_to_videolibrary.png")
if (unify_enabled or force_unify) and parent_item.channel not in ['kodfavourites']:
# Formatear titulo con unify

View File

@@ -884,6 +884,9 @@ def update_db(old_path, new_path, old_movies_folder, new_movies_folder, old_tvsh
p += 5
progress.update(p, config.get_localized_string(20000), config.get_localized_string(80013))
progress.update(100)
xbmc.sleep(1000)
progress.close()
xbmc.executebuiltin('XBMC.ReloadSkin()')
@@ -961,6 +964,7 @@ def clean_db():
sql = 'DELETE from episode WHERE idEpisode=%s' % idEpisode
nun_records, records = execute_sql_kodi(sql)
progress.update(100)
xbmc.sleep(1000)
progress.close()
xbmc.executebuiltin('XBMC.ReloadSkin()')
@@ -1030,112 +1034,52 @@ def execute_sql_kodi(sql):
return nun_records, records
def add_sources(path):
def update_sources(new='', old=''):
logger.info()
if new == old: return True
try:
SOURCES_PATH = xbmc.translatePath("special://userdata/sources.xml")
if os.path.exists(SOURCES_PATH):
if filetools.isfile(SOURCES_PATH):
xmldoc = minidom.parse(SOURCES_PATH)
else:
# Crear documento
xmldoc = minidom.Document()
nodo_sources = xmldoc.createElement("sources")
source_nodes = xmldoc.createElement("sources")
for type in ['programs', 'video', 'music', 'picture', 'files']:
nodo_type = xmldoc.createElement(type)
element_default = xmldoc.createElement("default")
element_default.setAttribute("pathversion", "1")
nodo_type.appendChild(element_default)
nodo_sources.appendChild(nodo_type)
xmldoc.appendChild(nodo_sources)
# Buscamos el nodo video
nodo_video = xmldoc.childNodes[0].getElementsByTagName("video")[0]
# Buscamos el path dentro de los nodos_path incluidos en el nodo_video
nodos_paths = nodo_video.getElementsByTagName("path")
list_path = [p.firstChild.data for p in nodos_paths]
logger.debug(list_path)
if path in list_path:
logger.debug("The path %s already exists in sources.xml" % path)
return True
logger.debug("The path %s does not exist in sources.xml" % path)
# Si llegamos aqui es por q el path no esta en sources.xml, asi q lo incluimos
nodo_source = xmldoc.createElement("source")
# Nodo <name>
nodo_name = xmldoc.createElement("name")
sep = os.sep
if path.startswith("special://") or scrapertools.find_single_match(path, '(^\w+:\/\/)'):
sep = "/"
name = path
if path.endswith(sep):
name = path[:-1]
nodo_name.appendChild(xmldoc.createTextNode(name.rsplit(sep)[-1]))
nodo_source.appendChild(nodo_name)
# Nodo <path>
nodo_path = xmldoc.createElement("path")
nodo_path.setAttribute("pathversion", "1")
nodo_path.appendChild(xmldoc.createTextNode(path))
nodo_source.appendChild(nodo_path)
# Nodo <allowsharing>
nodo_allowsharing = xmldoc.createElement("allowsharing")
nodo_allowsharing.appendChild(xmldoc.createTextNode('true'))
nodo_source.appendChild(nodo_allowsharing)
# Añadimos <source> a <video>
nodo_video.appendChild(nodo_source)
# Guardamos los cambios
if not PY3:
filetools.write(SOURCES_PATH,
'\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()]))
else:
filetools.write(SOURCES_PATH,
b'\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()]),
vfs=False)
logger.debug("The path %s has been added to sources.xml" % path)
return True
except:
logger.debug("An error occurred. The path %s has not been added to sources.xml" % path)
return False
def update_sources(old, new=''):
logger.info()
if new == old: return
SOURCES_PATH = xbmc.translatePath("special://userdata/sources.xml")
if filetools.isfile(SOURCES_PATH):
xmldoc = minidom.parse(SOURCES_PATH)
source_nodes.appendChild(nodo_type)
xmldoc.appendChild(source_nodes)
# collect nodes
# nodes = xmldoc.getElementsByTagName("video")
video_node = xmldoc.childNodes[0].getElementsByTagName("video")[0]
paths_node = video_node.getElementsByTagName("path")
# delete old path
for node in paths_node:
if node.firstChild.data == old:
parent = node.parentNode
remove = parent.parentNode
remove.removeChild(parent)
if old:
# delete old path
for node in paths_node:
if node.firstChild.data == old:
parent = node.parentNode
remove = parent.parentNode
remove.removeChild(parent)
# write changes
if sys.version_info[0] >= 3: #PY3
filetools.write(SOURCES_PATH, '\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()]))
else:
filetools.write(SOURCES_PATH, b'\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()]), vfs=False)
# write changes
if sys.version_info[0] >= 3: #PY3
filetools.write(SOURCES_PATH, '\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()]))
else:
filetools.write(SOURCES_PATH, b'\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()]), vfs=False)
logger.debug("The path %s has been removed from sources.xml" % old)
if new:
# create new path
list_path = [p.firstChild.data for p in paths_node]
if new in list_path:
logger.info("The path %s already exists in sources.xml" % new)
return
return True
logger.info("The path %s does not exist in sources.xml" % new)
# if the path does not exist we create one
@@ -1172,8 +1116,10 @@ def update_sources(old, new=''):
else:
filetools.write(SOURCES_PATH, b'\n'.join([x for x in xmldoc.toprettyxml().encode("utf-8").splitlines() if x.strip()]), vfs=False)
logger.debug("The path %s has been added to sources.xml" % new)
else:
logger.debug("sources.xml not found!")
return True
except:
logger.debug("An error occurred. The path %s has not been added/updated to sources.xml" % old)
return False
def ask_set_content(silent=False):
@@ -1182,8 +1128,8 @@ def ask_set_content(silent=False):
def do_config(custom=False):
if set_content("movie", True, custom) and set_content("tvshow", True, custom) and \
add_sources(config.get_setting("videolibrarypath")) and \
add_sources(config.get_setting("downloadpath")):
update_sources(config.get_setting("videolibrarypath")) and \
update_sources(config.get_setting("downloadpath")):
platformtools.dialog_ok(config.get_localized_string(80026), config.get_localized_string(70104))
config.set_setting("videolibrary_kodi", True)
update()

View File

@@ -58,7 +58,7 @@
<!-- Downloads -->
<category label="30153">
<setting id="downloadenabled" type="bool" label="70689" default="false"/>
<setting id="downloadpath" type="folder" label="30017" visible="eq(-1,true)" default="special://profile/addon_data/plugin.video.kod/downloads" subsetting="true"/>
<setting id="downloadpath" type="folder" label="30017" visible="eq(-1,true)" default="special://profile/addon_data/plugin.video.kod/downloads" subsetting="true" option="writeable"/>
<setting id="downloadlistpath" type="folder" label="30018" visible="eq(-2,true)" default="special://profile/addon_data/plugin.video.kod/downloads/list" subsetting="true"/>
<setting id="library_add" type="bool" label="70230" default="false"/>
<setting id="library_move" type="bool" label="70231" default="false" visible="eq(-1,true)" subsetting="true"/>
@@ -87,7 +87,7 @@
<setting id="video_thumbnail_type" type="select" label="70131" lvalues="70132|70133" default="1"/>
<!-- View Mode-->
<setting label="70754" type="lsep"/>
<setting id="skin_name" label='Skin Name' type="text" default="skin.estuary" visible="false"/>>
<setting id="skin_name" label='Skin Name' type="text" default="skin.estuary" visible="false"/>
<setting id="view_mode_addon" type="action" label="70009" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiJ2aWV3X21vZGUiLA0KICAgICJjaGFubmVsIjoic2hvcnRjdXRzIiwNCgkidHlwZSI6ImFkZG9uIg0KfQ==)" default= "Default, 0"/>
<setting id="view_mode_channel" type="action" label="30118" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiJ2aWV3X21vZGUiLA0KICAgICJjaGFubmVsIjoic2hvcnRjdXRzIiwNCgkidHlwZSI6ImNoYW5uZWwiDQp9)" default= "Default, 0"/>
<setting id="view_mode_movie" type="action" label="30122" action="RunPlugin(plugin://plugin.video.kod/?ew0KICAgICJhY3Rpb24iOiJ2aWV3X21vZGUiLA0KICAgICJjaGFubmVsIjoic2hvcnRjdXRzIiwNCgkidHlwZSI6Im1vdmllIg0KfQ==)" default= "Default, 0"/>

View File

@@ -52,7 +52,7 @@ TAG_TYPE = "Type"
def renumber(itemlist, item='', typography=''):
log()
dict_series = load(itemlist[0])
dict_series = load(itemlist[0]) if len(itemlist) > 0 else {}
if item:
item.channel = item.from_channel if item.from_channel else item.channel

View File

@@ -98,13 +98,13 @@ def mainlist(item):
set_category_context(new_item)
itemlist.append(new_item)
if channel_language == "all":
# if list_canales['Italiano']:
thumbnail = get_thumb("channels_italian.png")
new_item = Item(channel=item.channel, action="novedades", extra="italiano", title=config.get_localized_string(70563),
thumbnail=thumbnail)
set_category_context(new_item)
itemlist.append(new_item)
# if channel_language == "all":
# # if list_canales['Italiano']:
# thumbnail = get_thumb("italian.png")
# new_item = Item(channel=item.channel, action="novedades", extra="italiano", title=config.get_localized_string(70563),
# thumbnail=thumbnail)
# set_category_context(new_item)
# itemlist.append(new_item)
# if list_canales['Torrent']:
# thumbnail = get_thumb("channels_torrent.png")
@@ -118,9 +118,9 @@ def mainlist(item):
thumbnail=thumbnail)
set_category_context(new_item)
itemlist.append(new_item)
thumbnail = get_thumb("setting_0.png")
itemlist.append(Item(channel='shortcuts', action="SettingOnPosition", category=5, setting=0,
title=typo(config.get_localized_string(70285), 'bold color kod')))
title=typo(config.get_localized_string(70285), 'bold color kod'), thumbnail=thumbnail))
return itemlist

View File

@@ -31,7 +31,9 @@ def mainlist(item):
itemlist.append(Item(channel=item.channel, action="list_tvshows", title=config.get_localized_string(60600),
category=config.get_localized_string(70271),
thumbnail=get_thumb("videolibrary_tvshow.png")))
itemlist.append(Item(channel='shortcuts', action="SettingOnPosition", category=2, setting=0, title=typo(config.get_localized_string(70287),'bold color kod')))
itemlist.append(Item(channel='shortcuts', action="SettingOnPosition",
category=2, setting=0, title=typo(config.get_localized_string(70287),'bold color kod'),
thumbnail = get_thumb("setting_0.png")))
return itemlist
@@ -719,13 +721,14 @@ def move_videolibrary(current_path, new_path, current_movies_folder, new_movies_
if current_path != new_path and not filetools.listdir(current_path) and not "plugin.video.kod\\videolibrary" in current_path:
filetools.rmdirtree(current_path)
from platformcode import xbmc_videolibrary
xbmc_videolibrary.update_sources(backup_new_path, backup_current_path)
if config.is_xbmc() and config.get_setting("videolibrary_kodi"):
from platformcode import xbmc_videolibrary
xbmc_videolibrary.update_sources(backup_current_path, backup_new_path)
xbmc_videolibrary.update_db(backup_current_path, backup_new_path, current_movies_folder, new_movies_folder, current_tvshows_folder, new_tvshows_folder, progress)
progress.update(100)
progress.close()
else:
progress.update(100)
xbmc.sleep(1000)
progress.close()
if notify:
platformtools.dialog_notification(config.get_localized_string(20000), config.get_localized_string(80014), icon=0, time=5000, sound=False)