Fix Metalvideo e Youtube (Necessarie API personali)
This commit is contained in:
@@ -9,37 +9,33 @@ host = 'https://metalvideo.com'
|
||||
headers = {'X-Requested-With': 'XMLHttpRequest'}
|
||||
|
||||
|
||||
@support.scrape
|
||||
@support.menu
|
||||
def mainlist(item):
|
||||
menu = [('Generi',['', 'genres']),
|
||||
('Ultimi Video',['/videos/latest', 'peliculas']),
|
||||
('Top Video',['/videos/top', 'peliculas']),
|
||||
('Cerca...',['','search',])]
|
||||
return locals()
|
||||
|
||||
|
||||
@support.scrape
|
||||
def genres(item):
|
||||
item.url = host
|
||||
action = 'peliculas'
|
||||
patronBlock = r'<ul class="dropdown-menu(?P<block>.*?)</ul>\s*</div'
|
||||
patron = r'<a href="(?P<url>[^"]+)"(?: class="")?>(?P<title>[^<]+)<'
|
||||
patronBlock = r'<div class="swiper-slide">(?P<block>.*?)<button'
|
||||
patron = r'class="" href="(?P<url>[^"]+)[^>]+>(?P<title>[^<]+)<'
|
||||
def itemHook(item):
|
||||
item.thumbnail = support.thumb('music')
|
||||
item.contentType = 'music'
|
||||
return item
|
||||
def itemlistHook(itemlist):
|
||||
itemlist.pop(0)
|
||||
itemlist.append(
|
||||
support.Item(
|
||||
channel=item.channel,
|
||||
title=support.typo('Cerca...', 'bold'),
|
||||
contentType='music',
|
||||
url=item.url,
|
||||
action='search',
|
||||
thumbnail=support.thumb('search')))
|
||||
|
||||
support.channel_config(item, itemlist)
|
||||
return itemlist
|
||||
return locals()
|
||||
|
||||
@support.scrape
|
||||
def peliculas(item):
|
||||
# debug=True
|
||||
action = 'findvideos'
|
||||
patron= r'<img src="[^"]+" alt="(?P<title>[^"]+)" data-echo="(?P<thumb>[^"]+)"(?:[^>]+>){7}<a href="(?P<url>[^"]+)"'
|
||||
patronNext = r'<a href="([^"]+)">(?:»|»)'
|
||||
patron= r'<a href="(?P<url>[^"]+)"[^>]+>\s*<img src="(?P<thumb>[^"]+)" alt="(?P<title>[^"]+)"[^>]*>'
|
||||
patronNext = r'<a href="([^"]+)" data-load="[^"]+" class="[^"]+" title="Next'
|
||||
typeContentDict = {'': 'music'}
|
||||
def itemHook(item):
|
||||
item.contentType = 'music'
|
||||
@@ -54,7 +50,7 @@ def findvideos(item):
|
||||
|
||||
def search(item, text):
|
||||
support.info(text)
|
||||
item.url = host + '/search.php?keywords=' + text + '&video-id='
|
||||
item.url = host + '/search?keyword=' + text
|
||||
try:
|
||||
return peliculas(item)
|
||||
# Continua la ricerca in caso di errore
|
||||
|
||||
@@ -1107,7 +1107,7 @@ def play_video(item, strm=False, force_direct=False, autoplay=False):
|
||||
# logger.error('Failed to resolve hostname, fallback to normal dns')
|
||||
from core import support
|
||||
# support.dbg()
|
||||
if '|' not in mediaurl and item.referer != False:
|
||||
if '|' not in mediaurl and item.referer != False and 'youtube' not in mediaurl:
|
||||
mediaurl = mediaurl + '|' + urllib.urlencode(headers)
|
||||
|
||||
# video information is obtained.
|
||||
|
||||
@@ -19,44 +19,45 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
|
||||
import xbmc
|
||||
from xbmcaddon import Addon
|
||||
logger.debug("(page_url='%s')" % page_url)
|
||||
video_urls = []
|
||||
video_urls = [['Youtube', 'plugin://plugin.video.youtube/play/?video_id='+ page_url.split('=')[-1]]]
|
||||
|
||||
video_id = scrapertools.find_single_match(page_url, '(?:v=|embed/)([A-z0-9_-]{11})')
|
||||
inputstream = platformtools.install_inputstream()
|
||||
|
||||
try:
|
||||
__settings__ = Addon(name)
|
||||
if inputstream: __settings__.setSetting('kodion.video.quality.mpd', 'true')
|
||||
else: __settings__.setSetting('kodion.video.quality.mpd', 'false')
|
||||
# video_urls = [['con YouTube', 'plugin://plugin.video.youtube/play/?video_id=' + video_id ]]
|
||||
except:
|
||||
path = xbmc.translatePath('special://home/addons/' + name)
|
||||
if filetools.exists(path):
|
||||
if platformtools.dialog_yesno(config.get_localized_string(70784), config.get_localized_string(70818)):
|
||||
xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id":1, "method": "Addons.SetAddonEnabled", "params": { "addonid": "' + name + '", "enabled": true }}')
|
||||
else: return [['','']]
|
||||
else:
|
||||
xbmc.executebuiltin('InstallAddon(' + name + ')', wait=True)
|
||||
try: Addon(name)
|
||||
except: return [['','']]
|
||||
my_addon = xbmcaddon.Addon('plugin.video.youtube')
|
||||
addon_dir = xbmc.translatePath( my_addon.getAddonInfo('path') )
|
||||
sys.path.append(filetools.join( addon_dir, 'resources', 'lib' ) )
|
||||
# video_id = scrapertools.find_single_match(page_url, '(?:v=|embed/)([A-z0-9_-]{11})')
|
||||
# inputstream = platformtools.install_inputstream()
|
||||
|
||||
# load all dependencies for yt addon
|
||||
dependencies = support.match(filetools.read(filetools.join(addon_dir, 'addon.xml')), patron=r'addon="([^"]+)').matches
|
||||
for dep in dependencies:
|
||||
sys.path.append(filetools.join(config.get_runtime_path(), '..', dep, 'lib'))
|
||||
sys.path.append(filetools.join(config.get_runtime_path(), '..', dep, 'resources', 'modules'))
|
||||
from youtube_resolver import resolve
|
||||
try:
|
||||
for stream in resolve(page_url):
|
||||
# title = scrapertools.find_single_match(stream['title'], '(\d+p)')
|
||||
if scrapertools.find_single_match(stream['title'], r'(\d+p)'):
|
||||
video_urls.append([re.sub(r'(\[[^\]]+\])', '', stream['title']), stream['url']])
|
||||
video_urls.sort(key=lambda it: int(it[0].split("p", 1)[0]))
|
||||
except:
|
||||
pass
|
||||
# try:
|
||||
# __settings__ = Addon(name)
|
||||
# if inputstream: __settings__.setSetting('kodion.video.quality.mpd', 'true')
|
||||
# else: __settings__.setSetting('kodion.video.quality.mpd', 'false')
|
||||
# # video_urls = [['con YouTube', 'plugin://plugin.video.youtube/play/?video_id=' + video_id ]]
|
||||
# except:
|
||||
# path = xbmc.translatePath('special://home/addons/' + name)
|
||||
# if filetools.exists(path):
|
||||
# if platformtools.dialog_yesno(config.get_localized_string(70784), config.get_localized_string(70818)):
|
||||
# xbmc.executeJSONRPC('{"jsonrpc": "2.0", "id":1, "method": "Addons.SetAddonEnabled", "params": { "addonid": "' + name + '", "enabled": true }}')
|
||||
# else: return [['','']]
|
||||
# else:
|
||||
# xbmc.executebuiltin('InstallAddon(' + name + ')', wait=True)
|
||||
# try: Addon(name)
|
||||
# except: return [['','']]
|
||||
# my_addon = xbmcaddon.Addon('plugin.video.youtube')
|
||||
# addon_dir = xbmc.translatePath( my_addon.getAddonInfo('path') )
|
||||
# sys.path.append(filetools.join( addon_dir, 'resources', 'lib' ) )
|
||||
|
||||
# # load all dependencies for yt addon
|
||||
# dependencies = support.match(filetools.read(filetools.join(addon_dir, 'addon.xml')), patron=r'addon="([^"]+)').matches
|
||||
# for dep in dependencies:
|
||||
# sys.path.append(filetools.join(config.get_runtime_path(), '..', dep, 'lib'))
|
||||
# sys.path.append(filetools.join(config.get_runtime_path(), '..', dep, 'resources', 'modules'))
|
||||
# from youtube_resolver import resolve
|
||||
# try:
|
||||
# for stream in resolve(page_url):
|
||||
# # title = scrapertools.find_single_match(stream['title'], '(\d+p)')
|
||||
# if scrapertools.find_single_match(stream['title'], r'(\d+p)'):
|
||||
# video_urls.append([re.sub(r'(\[[^\]]+\])', '', stream['title']), stream['url']])
|
||||
# video_urls.sort(key=lambda it: int(it[0].split("p", 1)[0]))
|
||||
# except:
|
||||
# pass
|
||||
|
||||
return video_urls
|
||||
|
||||
|
||||
Reference in New Issue
Block a user