KoD 1.7.4

- Nuove visualizzazioni Server\n- Fix Gestione Viste\n- Aggiunto Pluto TV\n- Fix e migliorie varie\n\n
This commit is contained in:
marco
2022-02-12 12:54:50 +01:00
parent fa99565e9f
commit 41e0823f62
86 changed files with 1660 additions and 3471 deletions
+2
View File
@@ -29,6 +29,8 @@ def start(itemlist, item):
if item.global_search or item.from_action or item.contentAction: # from_action means that's a special function calling this (ex: add to videolibrary)
return itemlist
if len([s for s in itemlist if s.server]) == 1:
return itemlist
logger.debug()
global PLAYED
+2 -2
View File
@@ -355,7 +355,7 @@ class Item(object):
dump = "".encode("utf8")
return str(urllib.quote(base64.b64encode(dump)))
def fromurl(self, url):
def fromurl(self, url, silent=False):
"""
Generate an item from a text string. The string can be created by the tourl () function or have
the old format: plugin: //plugin.video.kod/? channel = ... (+ other parameters)
@@ -369,7 +369,7 @@ class Item(object):
decoded = False
try:
str_item = base64.b64decode(urllib.unquote(url))
json_item = json.load(str_item, object_hook=self.toutf8)
json_item = json.load(str_item, object_hook=self.toutf8, silent=silent)
if json_item is not None and len(json_item) > 0:
self.__dict__.update(json_item)
decoded = True
+10 -3
View File
@@ -16,15 +16,22 @@ if sys.version_info[0] >= 3: PY3 = True; unicode = str; unichr = chr; long = int
def load(*args, **kwargs):
silent = False
if 'silent' in kwargs:
silent = kwargs['silent']
kwargs.pop('silent')
if "object_hook" not in kwargs:
kwargs["object_hook"] = to_utf8
try:
value = json.loads(*args, **kwargs)
except:
logger.error("**NOT** able to load the JSON")
logger.error(traceback.format_exc())
logger.error('ERROR STACK ' + str(stack()[1][3]))
if not silent:
logger.error("**NOT** able to load the JSON")
logger.error(traceback.format_exc())
if len(stack()) > 1:
logger.error('ERROR STACK {}'.format(stack()[2]) )
value = {}
return value
+46
View File
@@ -504,3 +504,49 @@ def title_unify(title):
u_title = spl[0] if len(spl[0]) > 5 else spl[1]
return u_title.strip()
def girc(page_data, url, co):
"""
Code adapted from https://github.com/vb6rocod/utils/
Copyright (C) 2019 vb6rocod
and https://github.com/addon-lab/addon-lab_resolver_Project
Copyright (C) 2021 ADDON-LAB, KAR10S
"""
import re
from core import httptools
hdrs = {'Referer': url}
rurl = 'https://www.google.com/recaptcha/api.js'
aurl = 'https://www.google.com/recaptcha/api2'
key = re.search(r'(?:src="{0}\?.*?render|data-sitekey)="?([^"]+)'.format(rurl), page_data)
if key:
key = key.group(1)
rurl = '{0}?render={1}'.format(rurl, key)
page_data1 = httptools.downloadpage(rurl, headers=hdrs).data
v = re.findall('releases/([^/]+)', page_data1)[0]
rdata = {'ar': 1,
'k': key,
'co': co,
'hl': 'en',
'v': v,
'size': 'invisible',
'cb': '123456789'}
page_data2 = httptools.downloadpage('{0}/anchor?{1}'.format(aurl, httptools.urlparse.urlencode(rdata)), headers=hdrs).data
rtoken = re.search('recaptcha-token.+?="([^"]+)', page_data2)
if rtoken:
rtoken = rtoken.group(1)
else:
return ''
pdata = {'v': v,
'reason': 'q',
'k': key,
'c': rtoken,
'sa': '',
'co': co}
hdrs.update({'Referer': aurl})
page_data3 = httptools.downloadpage('{0}/reload?k={1}'.format(aurl, key), post=pdata, headers=hdrs).data
gtoken = re.search('rresp","([^"]+)', page_data3)
if gtoken:
return gtoken.group(1)
return ''
+1 -1
View File
@@ -254,7 +254,7 @@ def resolve_video_urls_for_playing(server, url, video_password="", muestra_dialo
if isinstance(video_password, list):
return video_password, len(video_password) > 0, "<br/>".join(error_messages)
logger.info("Server: %s, url is good" % server)
video_urls.append(["%s [%s]" % (urlparse.urlparse(url)[2][-4:], config.get_localized_string(30137)), url])
video_urls.append(["%s [%s]" % (urlparse.urlparse(url)[2].split('|')[0][-4:], config.get_localized_string(30137)), url])
# Find out the video URL
else:
+65 -27
View File
@@ -604,11 +604,11 @@ def scrape(func):
if function == 'episodios': autorenumber.start(itemlist, item)
else: autorenumber.start(itemlist)
if action != 'play' and 'patronMenu' not in args and not disabletmdb and function != 'episodios' \
and item.contentType in ['movie', 'tvshow', 'episode', 'undefined']:
if action != 'play' and 'patronMenu' not in args and 'patronGenreMenu' not in args \
and not stackCheck(['add_tvshow', 'get_newest']) and (function not in ['episodes', 'mainlist'] \
or (function in ['episodes'] and config.get_setting('episode_info'))):
tmdb.set_infoLabels_itemlist(itemlist, seekTmdb=True)
if not group and not args.get('groupExplode') and ((pagination and len(matches) <= pag * pagination) or not pagination): # next page with pagination
if patronNext and inspect.stack()[1][3] not in ['newest'] and len(inspect.stack()) > 2 and inspect.stack()[2][3] not in ['get_channel_results']:
nextPage(itemlist, item, data, patronNext, function)
@@ -655,9 +655,7 @@ def scrape(func):
# itemlist = filterLang(item, itemlist) # causa problemi a newest
if config.get_setting('trakt_sync'):
from core import trakt_tools
trakt_tools.trakt_check(itemlist)
check_trakt(itemlist)
return itemlist
return wrapper
@@ -731,6 +729,7 @@ def dooplay_search(item, blacklist=""):
def dooplay_search_vars(item, blacklist):
actLike = 'peliculas'
if item.contentType == 'undefined': # ricerca globale
type = '(?P<type>movies|tvshows)'
typeActionDict = {'findvideos': ['movies'], 'episodios': ['tvshows']}
@@ -1280,26 +1279,23 @@ def server(item, data='', itemlist=[], headers='', AutoPlay=True, CheckLinks=Tru
videoitem.server = videoitem.server.lower()
if videoitem.video_urls or srv_param.get('active', False):
title = typo(item.contentTitle.strip(), 'bold') if item.contentType == 'movie' or (config.get_localized_string(30161) in item.title) else item.title
vi = item.clone(server=videoitem.server,
extraInfo=videoitem.extraInfo,
serverName=videoitem.serverName,
url=videoitem.url,
videoUrls= videoitem.videoUrlsn,
ch_name=channeltools.get_channel_parameters(item.channel)['title'],
action = "play")
quality = videoitem.quality if videoitem.quality else item.quality if item.quality else ''
videoitem.title = (title if item.channel not in ['url'] else '')\
+ (typo(videoitem.title, '_ color kod [] bold') if videoitem.title else "")\
+ (typo(videoitem.quality, '_ color kod []') if videoitem.quality else "")\
+ (typo(videoitem.contentLanguage, '_ color kod []') if videoitem.contentLanguage else "")\
+ (typo(videoitem.extraInfo, '_ color kod []') if videoitem.extraInfo else "")
videoitem.plot = typo(videoitem.title, 'bold') + (typo(quality, '_ [] bold') if quality else '')
videoitem.channel = item.channel
videoitem.fulltitle = item.fulltitle
videoitem.show = item.show
if not videoitem.video_urls: videoitem.thumbnail = item.thumbnail
videoitem.contentType = item.contentType
videoitem.infoLabels = item.infoLabels
videoitem.quality = quality
videoitem.referer = item.referer if item.referer else item.url
videoitem.action = "play"
# videoitem.nfo = item.nfo
# videoitem.strm_path = item.strm_path
if videoitem.title: vi.serverName = videoitem.title
if videoitem.quality: vi.quality = videoitem.quality
if not vi.referer: vi.referer = item.url
vi.contentFanart = item.infoLabels['fanart']
vi.contentThumb = item.infoLabels['fanart']
if videoitem.forcethumb:
vi.thumbnail = videoitem.thumbnail
vi.forcethumb = True
videoitem = vi
return videoitem
# non threaded for webpdb
@@ -1409,7 +1405,7 @@ def addQualityTag(item, itemlist, data, patron):
"DTS": "audio ricavato dai dischi DTS2, quindi la qualità audio è elevata.",
"LD": "laudio è stato registrato tramite jack collegato alla macchina da presa, pertanto di discreta qualità.",
"DD": "audio ricavato dai dischi DTS cinema. Laudio è di buona qualità, ma potreste riscontrare il fatto che non potrebbe essere più riproducibile.",
"AC3": "audio in Dolby Digital puo' variare da 2.0 a 5.1 canali in alta qualità.",
"AC3": "audio in Dolby Digital può variare da 2.0 a 5.1 canali in alta qualità.",
"MP3": "codec per compressione audio utilizzato MP3.",
"RESYNC": "il film è stato lavorato e re sincronizzato con una traccia audio. A volte potresti riscontrare una mancata sincronizzazione tra audio e video.",
}
@@ -1436,7 +1432,7 @@ def addQualityTag(item, itemlist, data, patron):
descr = ''
itemlist.insert(0,Item(channel=item.channel,
action="",
title=typo(qualityStr, '[] color kod bold'),
title=typo(qualityStr, 'bold'),
fulltitle=qualityStr,
plot=descr,
folder=False,
@@ -1600,3 +1596,45 @@ def thumb(item_itemlist_string=None, genre=False, live=False):
else:
return get_thumb('next.png')
def vttToSrt(data):
# Code adapted by VTT_TO_SRT.PY (c) Jansen A. Simanullang
ret = ''
data = re.sub(r'(\d\d:\d\d:\d\d).(\d\d\d) --> (\d\d:\d\d:\d\d).(\d\d\d)(?:[ \-\w]+:[\w\%\d:]+)*\n', r'\1,\2 --> \3,\4\n', data)
data = re.sub(r'(\d\d:\d\d).(\d\d\d) --> (\d\d:\d\d).(\d\d\d)(?:[ \-\w]+:[\w\%\d:]+)*\n', r'00:\1,\2 --> 00:\3,\4\n', data)
data = re.sub(r'(\d\d).(\d\d\d) --> (\d\d).(\d\d\d)(?:[ \-\w]+:[\w\%\d:]+)*\n', r'00:00:\1,\2 --> 00:00:\3,\4\n', data)
data = re.sub(r'WEBVTT\n', '', data)
data = re.sub(r'Kind:[ \-\w]+\n', '', data)
data = re.sub(r'Language:[ \-\w]+\n', '', data)
data = re.sub(r'<c[.\w\d]*>', '', data)
data = re.sub(r'</c>', '', data)
data = re.sub(r'<\d\d:\d\d:\d\d.\d\d\d>', '', data)
data = re.sub(r'::[\-\w]+\([\-.\w\d]+\)[ ]*{[.,:;\(\) \-\w\d]+\n }\n', '', data)
data = re.sub(r'Style:\n##\n', '', data)
lines = data.split(os.linesep)
for n, line in enumerate(lines):
if re.match(r"((\d\d:){2}\d\d),(\d{3}) --> ((\d\d:){2}\d\d),(\d{3})", line):
ret += str(n + 1) + os.linesep + line + os.linesep
else:
ret += line + os.linesep
return ret
def check_trakt(itemlist):
if config.get_setting('trakt_sync'):
from core import trakt_tools
trakt_tools.trakt_check(itemlist)
return itemlist
def stackCheck(values):
stacks = [s[3] for s in inspect.stack()]
logger.debug('STAKS', stacks)
if type(values) == str:
return values in stacks
else:
return any(v in values for v in stacks)
+11 -15
View File
@@ -393,18 +393,17 @@ def set_infoLabels_item(item, seekTmdb=True, search_language=def_lang):
if search_type == 'tv':
# Serial search by title and filtering your results if necessary
searched_title = scrapertools.unescape(item.infoLabels['tvshowtitle'])
# searched_title = searched_title.split('-')[0].strip()
otmdb = Tmdb(searched_text=searched_title, search_type=search_type,
search_language=search_language, filtro=item.infoLabels.get('filtro', {}),
year=item.infoLabels['year'])
else:
# Movie search by title ...
# if item.infoLabels['year'] or item.infoLabels['filtro']:
# ...and year or filter
searched_title = scrapertools.unescape(item.infoLabels['title'])
# searched_title = searched_title.split('-')[0].strip()
# from core.support import dbg;dbg()
otmdb = Tmdb(searched_text=searched_title, search_type=search_type, search_language=search_language,
filtro=item.infoLabels.get('filtro', {}), year=item.infoLabels['year'])
if otmdb is not None and not otmdb.get_id():
otmdb = Tmdb(searched_text=searched_title, search_type=search_type, search_language=search_language,
filtro=item.infoLabels.get('filtro', {}), year=item.infoLabels['year'])
filtro=item.infoLabels.get('filtro', {}))
if otmdb is not None:
if otmdb.get_id() and config.get_setting("tmdb_plus_info", default=False):
# If the search has been successful and you are not looking for a list of items,
@@ -471,10 +470,9 @@ def find_and_set_infoLabels(item):
item.infoLabels['year'] = year[1:-1]
if not item.infoLabels.get("tmdb_id") or not item.infoLabels.get("tmdb_id")[0].isdigit():
if not item.infoLabels.get("imdb_id"):
otmdb_global = Tmdb(searched_text=scrapertools.unescape(title), search_type=search_type, year=item.infoLabels['year'])
else:
otmdb_global = Tmdb(external_id=item.infoLabels.get("imdb_id"), external_source="imdb_id", search_type=search_type)
if item.infoLabels.get("imdb_id"): otmdb_global = Tmdb(external_id=item.infoLabels.get("imdb_id"), external_source="imdb_id", search_type=search_type)
else: otmdb_global = Tmdb(searched_text=scrapertools.unescape(title), search_type=search_type, year=item.infoLabels['year'])
elif not otmdb_global or str(otmdb_global.result.get("id")) != item.infoLabels['tmdb_id']:
otmdb_global = Tmdb(id_Tmdb=item.infoLabels['tmdb_id'], search_type=search_type, search_language=def_lang)
@@ -537,10 +535,7 @@ def get_nfo(item, search_groups=False):
info_nfo = 'https://www.themoviedb.org/tv/{}/episode_group/{}'.format(item.infoLabels['tmdb_id'], Id)
return info_nfo + '\n'
else: return
# from core.support import dbg;dbg()
# if "season" in item.infoLabels and "episode" in item.infoLabels:
# info_nfo = "https://www.themoviedb.org/tv/{}/season/{}/episode/{}" .format(item.infoLabels['tmdb_id'], item.contentSeason, item.contentEpisodeNumber)
# else:
info_nfo = ', '.join(item.infoLabels['url_scraper'])
return info_nfo + '\n'
@@ -644,10 +639,11 @@ class ResultDictDefault(dict):
def __missing__(self, key):
"""
default values in case the requested key does not exist
default values in case the requested key does not exist
"""
if key in ['genre_ids', 'genre', 'genres']:
return list()
elif key == 'images_posters':
posters = dict()
if 'images' in list(super(ResultDictDefault, self).keys()) and 'posters' in super(ResultDictDefault, self).__getitem__('images'):
+17 -16
View File
@@ -3,11 +3,14 @@
# -*- Created for Alfa-addon -*-
# -*- By the Alfa Develop Group -*
#from builtins import str
import os, xbmc
from core import httptools, jsontools
from core import httptools, jsontools
from core.item import Item
from platformcode import config, logger
from threading import Thread
import sys
if sys.version_info[0] >= 3: from concurrent import futures
else: from concurrent_py2 import futures
@@ -26,7 +29,7 @@ def auth_trakt():
post = {'client_id': client_id}
post = jsontools.dump(post)
# Se solicita url y código de verificación para conceder permiso a la app
url = "http://api.trakt.tv/oauth/device/code"
url = "http://api-v2launch.trakt.tv/oauth/device/code"
data = httptools.downloadpage(url, post=post, headers=headers).data
data = jsontools.load(data)
item.verify_url = data["verification_url"]
@@ -57,14 +60,13 @@ def token_trakt(item):
try:
if item.extra == "renew":
refresh = config.get_setting("refresh_token_trakt", "trakt")
url = "http://api.trakt.tv/oauth/device/token"
url = "https://api.trakt.tv/oauth/token"
post = {'refresh_token': refresh, 'client_id': client_id, 'client_secret': client_secret,
'redirect_uri': 'urn:ietf:wg:oauth:2.0:oob', 'grant_type': 'refresh_token'}
post = jsontools.dump(post)
data = httptools.downloadpage(url, post=post, headers=headers).data
data = httptools.downloadpage(url, post=post).data
data = jsontools.load(data)
elif item.action == "token_trakt":
url = "http://api.trakt.tv/oauth/device/token"
url = "https://api-v2launch.trakt.tv/oauth/device/token"
post = "code=%s&client_id=%s&client_secret=%s" % (item.device_code, client_id, client_secret)
data = httptools.downloadpage(url, post=post, headers=headers).data
data = jsontools.load(data)
@@ -83,7 +85,7 @@ def token_trakt(item):
config.set_setting("trakt_sync", False)
return
url = "http://api.trakt.tv/oauth/device/token"
url = "http://api-v2launch.trakt.tv/oauth/device/token"
post = {'code': item.device_code, 'client_id': client_id, 'client_secret': client_secret}
post = jsontools.dump(post)
data = httptools.downloadpage(url, post=post, headers=headers).data
@@ -106,9 +108,7 @@ def token_trakt(item):
config.set_setting("refresh_token_trakt", refresh, "trakt")
if not item.folder:
platformtools.dialog_notification(config.get_localized_string(60255), config.get_localized_string(60256))
if config.is_xbmc():
import xbmc
xbmc.executebuiltin("Container.Refresh")
xbmc.executebuiltin("Container.Refresh")
return
except:
@@ -166,8 +166,12 @@ def get_trakt_watched(id_type, mediatype, update=False):
if token_auth:
headers.append(['Authorization', "Bearer %s" % token_auth])
url = "https://api.trakt.tv/sync/watched/%s" % mediatype
data = httptools.downloadpage(url, headers=headers).data
watched_dict = jsontools.load(data)
data = httptools.downloadpage(url, headers=headers)
if data.code == 401:
token_trakt(Item(extra="renew"))
return get_trakt_watched(id_type, mediatype, update)
watched_dict = jsontools.load(data.data)
if mediatype == 'shows':
@@ -266,14 +270,12 @@ def ask_install_script():
def wait_for_update_trakt():
logger.debug()
t = Thread(target=update_all)
t = Thread(update_all)
t.setDaemon(True)
t.start()
t.is_alive()
def update_all():
# from core.support import dbg;dbg()
from time import sleep
logger.debug()
sleep(20)
@@ -282,4 +284,3 @@ def update_all():
for mediatype in ['movies', 'shows']:
trakt_data = get_trakt_watched('tmdb', mediatype, True)
update_trakt_data(mediatype, trakt_data)
+2 -2
View File
@@ -974,7 +974,7 @@ def add_movie(item):
@param item: item to be saved.
"""
logger.debug()
from platformcode.launcher import set_search_temp; set_search_temp(item)
# from platformcode.launcher import set_search_temp; set_search_temp(item)
item.contentType = 'movie'
# To disambiguate titles, TMDB is caused to ask for the really desired title
@@ -1023,7 +1023,7 @@ def add_tvshow(item, channel=None, itemlist=[]):
logger.debug("show=#" + item.show + "#")
item.contentType = 'tvshow'
from platformcode.launcher import set_search_temp; set_search_temp(item)
# from platformcode.launcher import set_search_temp; set_search_temp(item)
if item.channel == "downloads":
itemlist = [item.clone()]