Skip to content

Commit

Permalink
Merge pull request #850 from MoojMidge/master
Browse files Browse the repository at this point in the history
v7.0.9+beta.5
  • Loading branch information
MoojMidge committed Jul 27, 2024
2 parents 11a9686 + f3a3059 commit b5c119d
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 17 deletions.
2 changes: 1 addition & 1 deletion addon.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="plugin.video.youtube" name="YouTube" version="7.0.9+beta.4" provider-name="anxdpanic, bromix, MoojMidge">
<addon id="plugin.video.youtube" name="YouTube" version="7.0.9+beta.5" provider-name="anxdpanic, bromix, MoojMidge">
<requires>
<import addon="xbmc.python" version="3.0.0"/>
<import addon="script.module.requests" version="2.27.1"/>
Expand Down
7 changes: 7 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## v7.0.9+beta.5
### Fixed
- Fix disabling certification verification #841
- Fix not using player request fallbacks #845
- Fix incorrectly identifying VP9 streams #833
- Fix videos not able to be re-opened from Kodi playlist #810

## v7.0.9+beta.4
### Fixed
- Fix issues with next page and jump to page in related video listings
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,3 +81,4 @@
HTTPD_PORT = 'kodion.http.port' # (number)
HTTPD_LISTEN = 'kodion.http.listen' # (string)
HTTPD_WHITELIST = 'kodion.http.ip.whitelist' # (string)
HTTPD_IDLE_SLEEP = 'youtube.http.idle_sleep' # (bool)
4 changes: 2 additions & 2 deletions resources/lib/youtube_plugin/kodion/items/xbmc/xbmc_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,11 +418,11 @@ def video_playback_item(context, video_item, show_fanart=None, **_kwargs):

if current_system_version.compatible(21, 0):
isa_capabilities = context.inputstream_adaptive_capabilities()
if video_item.live and isa_capabilities['manifest_config_prop']:
if video_item.live and 'manifest_config_prop' in isa_capabilities:
props['inputstream.adaptive.manifest_config'] = dumps({
'timeshift_bufferlimit': 4 * 60 * 60,
})
if not settings.verify_ssl() and isa_capabilities['config_prop']:
if not settings.verify_ssl() and 'config_prop' in isa_capabilities:
props['inputstream.adaptive.config'] = dumps({
'ssl_verify_peer': False,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def __init__(self, context):

self.httpd = None
self.httpd_thread = None
self.httpd_sleep_allowed = True
self.httpd_sleep_allowed = settings.httpd_sleep_allowed()

self.system_idle = False
self.refresh = False
Expand Down Expand Up @@ -106,7 +106,7 @@ def onNotification(self, sender, method, data):
self.interrupt = True
elif target == SERVER_WAKEUP:
if not self.httpd and self.httpd_required():
self.httpd_sleep_allowed = False
self.httpd_sleep_allowed = None
self.start_httpd()
if data.get('response_required'):
self.set_property(WAKEUP, target)
Expand Down Expand Up @@ -164,6 +164,10 @@ def onSettingsChanged(self):
self._whitelist = whitelist
httpd_restart = httpd_started

sleep_allowed = settings.httpd_sleep_allowed()
if sleep_allowed is False:
self.httpd_sleep_allowed = False

if self.httpd_required(settings):
if httpd_restart:
self.restart_httpd()
Expand Down
5 changes: 4 additions & 1 deletion resources/lib/youtube_plugin/kodion/network/requests.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,11 @@ class SSLHTTPAdapter(HTTPAdapter):

def init_poolmanager(self, *args, **kwargs):
kwargs['ssl_context'] = self._ssl_context
super(SSLHTTPAdapter, self).init_poolmanager(*args, **kwargs)
return super(SSLHTTPAdapter, self).init_poolmanager(*args, **kwargs)

def cert_verify(self, conn, url, verify, cert):
self._ssl_context.check_hostname = bool(verify)
return super(SSLHTTPAdapter, self).cert_verify(conn, url, verify, cert)

class BaseRequestsClass(object):
_session = Session()
Expand Down
9 changes: 6 additions & 3 deletions resources/lib/youtube_plugin/kodion/service_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ def run():
httpd_idle_time_ms = 0
monitor.shutdown_httpd(sleep=True)
else:
if pop_property(SERVER_POST_START):
monitor.httpd_sleep_allowed = True
httpd_idle_time_ms = 0
if monitor.httpd_sleep_allowed is None:
if pop_property(SERVER_POST_START):
monitor.httpd_sleep_allowed = True
httpd_idle_time_ms = 0
else:
pop_property(SERVER_POST_START)
else:
if httpd_idle_time_ms >= httpd_ping_period_ms:
httpd_idle_time_ms = 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,11 @@ def httpd_whitelist(self):
allow_list.append('.'.join(map(str, octets)))
return allow_list

def httpd_sleep_allowed(self, value=None):
if value is not None:
return self.set_bool(SETTINGS.HTTPD_IDLE_SLEEP, value)
return self.get_bool(SETTINGS.HTTPD_IDLE_SLEEP, True)

def api_config_page(self):
return self.get_bool(SETTINGS.API_CONFIG_PAGE, False)

Expand Down
22 changes: 14 additions & 8 deletions resources/lib/youtube_plugin/youtube/helper/stream_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,9 @@ class StreamInfo(YouTubeRequestClient):
# video - order based on comparative compression ratio
'av01': 1,
'vp9': 0.75,
'vp09': 0.75,
'vp8': 0.55,
'vp08': 0.55,
'avc1': 0.5,
'h.264': 0.5,
'h.263': 0.4,
Expand Down Expand Up @@ -1360,17 +1362,19 @@ def _get_stream_info(self):
if self._access_token:
client_data['_access_token'] = self._access_token

last_status = None
num_errors = num_requests = 0
while 1:
for client_name in self._prioritised_clients:
if status is not None:
if last_status:
self._context.log_warning(
'Failed to retrieve video info - '
'video_id: {0}, client: {1}, auth: {2},\n'
'status: {3}, reason: {4}'.format(
video_id,
client['_name'],
bool(client.get('_access_token')),
status,
last_status,
reason or 'UNKNOWN',
)
)
Expand All @@ -1393,9 +1397,10 @@ def _get_stream_info(self):
**client
)

num_requests += 1
video_details = result.get('videoDetails', {})
playability_status = result.get('playabilityStatus', {})
status = playability_status.get('status', '').upper()
status = playability_status.get('status', 'ERROR').upper()
reason = playability_status.get('reason', '')

if video_details and video_id != video_details.get('videoId'):
Expand All @@ -1406,7 +1411,6 @@ def _get_stream_info(self):
if status == 'OK':
break
elif status in {
'',
'AGE_CHECK_REQUIRED',
'AGE_VERIFICATION_REQUIRED',
'CONTENT_CHECK_REQUIRED',
Expand All @@ -1415,6 +1419,9 @@ def _get_stream_info(self):
'LOGIN_REQUIRED',
'UNPLAYABLE',
}:
if not last_status or status == last_status:
num_errors += 1
last_status = status
if (playability_status.get('desktopLegacyAgeGateReason')
and _settings.age_gate()):
break
Expand Down Expand Up @@ -1447,17 +1454,16 @@ def _get_stream_info(self):
)
if url and url.startswith('//support.google.com/youtube/answer/12318250'):
status = 'CONTENT_NOT_AVAILABLE_IN_THIS_APP'
continue
else:
self._context.log_debug(
'Unknown playabilityStatus in player response:\n|{0}|'
.format(playability_status)
)
continue
break
# Only attempt to remove Authorization header if clients iterable
# was exhausted i.e. request attempted using all clients
else:
if num_errors == num_requests:
break
if '_access_token' in client_data:
del client_data['_access_token']
continue
Expand Down Expand Up @@ -1787,7 +1793,7 @@ def _process_stream_data(self, stream_data, default_lang_code='und'):
codec = re.match(r'codecs="([a-z0-9]+([.\-][0-9](?="))?)', codecs)
if codec:
codec = codec.group(1)
if codec.startswith('vp9'):
if codec.startswith(('vp9', 'vp09')):
codec = 'vp9'
elif codec.startswith('dts'):
codec = 'dts'
Expand Down
5 changes: 5 additions & 0 deletions resources/settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -994,6 +994,11 @@
<data>RunScript($ID,config/show_client_ip)</data>
<control format="action" type="button"/>
</setting>
<setting id="youtube.http.idle_sleep" type="boolean" label="13018" help="">
<level>0</level>
<default>true</default>
<control type="toggle"/>
</setting>
</group>
</category>
<category id="maintenance" label="30552" help="">
Expand Down

0 comments on commit b5c119d

Please sign in to comment.