Fix Youtube

This commit is contained in:
Alhaziel01
2021-01-09 16:30:22 +01:00
parent b489ee97b7
commit 9e58ed9e50
2 changed files with 18 additions and 13 deletions

View File

@@ -62,11 +62,13 @@ def start(itemlist, item):
# Save the current value of "Action and Player Mode" in preferences
user_config_setting_action = config.get_setting("default_action")
user_config_setting_player = config.get_setting("player_mode")
# user_config_setting_player = config.get_setting("player_mode")
# Enable the "View in high quality" action (if the server returns more than one quality, eg gdrive)
if not user_config_setting_action: config.set_setting("default_action", 2)
# if user_config_setting_player != 0: config.set_setting("player_mode", 0)
# Priorities when ordering itemlist:
# 0: Servers and qualities
# 1: Qualities and servers
@@ -208,8 +210,6 @@ def start(itemlist, item):
videoitem = autoplay_elem['videoitem']
if videoitem.server.lower() not in max_intentos_servers:
max_intentos_servers[videoitem.server.lower()] = max_intentos
if videoitem.server.lower() in ['youtube'] and user_config_setting_player != 0:
config.set_setting("player_mode", 0)
# If the maximum number of attempts of this server have been reached, we jump to the next
if max_intentos_servers[videoitem.server.lower()] == 0:
@@ -269,7 +269,7 @@ def start(itemlist, item):
# Restore if necessary the previous value of "Action and Player Mode" in preferences
if not user_config_setting_action: config.set_setting("default_action", user_config_setting_action)
config.set_setting("player_mode", user_config_setting_player)
# if user_config_setting_player != 0: config.set_setting("player_mode", user_config_setting_player)
return itemlist

View File

@@ -1,5 +1,5 @@
# s-*- coding: utf-8 -*-
import xbmc, xbmcaddon, sys, re
from core import httptools, scrapertools, filetools
from platformcode import config, logger, platformtools
@@ -21,20 +21,17 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
logger.debug("(page_url='%s')" % page_url)
video_urls = []
if not page_url.startswith("http"):
page_url = "http://www.youtube.com/watch?v=%s" % page_url
logger.debug(" page_url->'%s'" % page_url)
video_id = scrapertools.find_single_match(page_url, '(?:v=|embed/)([A-z0-9_-]{11})')
inputstream = platformtools.install_inputstream()
# from core.support import dbg;dbg()
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 ]]
# video_urls = [['con YouTube', 'plugin://plugin.video.youtube/play/?video_id=' + video_id ]]
except:
if filetools.exists(xbmc.translatePath('special://profile/addons/' + name)):
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 [['','']]
@@ -42,7 +39,15 @@ def get_video_url(page_url, premium=False, user="", password="", video_password=
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' ) )
from youtube_resolver import resolve
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]))
return get_video_url(page_url)
return video_urls