Passaggio User-agent e referer al player di kodi e avviso contenuto non ancora disponibile su streamingcommunity

This commit is contained in:
marco
2022-01-07 18:24:24 +01:00
parent c21ae8cf07
commit 542cb33c03
2 changed files with 27 additions and 1 deletions

View File

@@ -235,6 +235,9 @@ def play(item):
scws_id = support.match(data, patron=r'scws_id"\s*:\s*(\d+)').match
if not scws_id:
if '<strong>Prossimamente' in data:
platformtools.dialog_ok('StreamingCommunity', 'Il sito notifica che il contenuto sarà disponibile prossimamente')
platformtools.play_canceled = True
return []
# Calculate Token

View File

@@ -977,6 +977,8 @@ def get_window():
def play_video(item, strm=False, force_direct=False, autoplay=False):
from core import httptools
logger.debug()
logger.debug(item.tostring('\n'))
@@ -994,7 +996,6 @@ def play_video(item, strm=False, force_direct=False, autoplay=False):
# pass referer
if item.referer:
from core import httptools
httptools.default_headers['Referer'] = item.referer
# Open the selection dialog to see the available options
@@ -1016,6 +1017,28 @@ def play_video(item, strm=False, force_direct=False, autoplay=False):
# we get the selected video
mediaurl, view, mpd, hls = get_video_seleccionado(item, seleccion, video_urls, autoplay)
if not mediaurl: return
headers = {'User-Agent': httptools.get_user_agent(), 'Referer': item.referer}
# Kodi does not seems to allow this, leaving there as may work in the future
# if config.get_setting('resolver_dns'):
# try:
# import urllib.parse as urlparse
# except ImportError:
# import urlparse
# from lib import doh
# try:
# parse = urlparse.urlparse(mediaurl)
# if parse.netloc:
# domain = parse.netloc
# if not scrapertools.find_single_match(domain, '\d+\.\d+\.\d+\.\d+'):
# ip = doh.query(domain)[0]
# logger.info('Query DoH: ' + domain + ' = ' + str(ip))
# parse = list(parse)
# parse[1] = ip
# mediaurl = urlparse.urlunparse(parse)
# headers['Host'] = domain
# except:
# logger.error('Failed to resolve hostname, fallback to normal dns')
mediaurl = mediaurl + '|' + urllib.urlencode(headers)
# video information is obtained.
xlistitem = xbmcgui.ListItem(item.title, path=item.url)