Skip to content

Commit

Permalink
Merge pull request #804 from MoojMidge/master
Browse files Browse the repository at this point in the history
v7.0.8+beta.3
  • Loading branch information
MoojMidge authored Jun 18, 2024
2 parents 4dae3c9 + 89761d2 commit adfef50
Show file tree
Hide file tree
Showing 9 changed files with 60 additions and 34 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.8+beta.2" provider-name="anxdpanic, bromix, MoojMidge">
<addon id="plugin.video.youtube" name="YouTube" version="7.0.8+beta.3" 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
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v7.0.8+beta.3
### Fixed
- Additional fixes for redacting IP addresses in debug logs #801
- Various minor fixes for external player use
- Fix trying to access playlists for account that has no Youtube channel #803

## v7.0.8+beta.2
### Fixed
- Fix various caching issues #786 #797
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,6 @@ def set_addon_enabled(self, addon_id, enabled=True):
return False

def send_notification(self, method, data=True):
self.log_debug('send_notification: |%s| -> |%s|' % (method, data))
jsonrpc(method='JSONRPC.NotifyAll',
params={'sender': ADDON_ID,
'message': method,
Expand Down
11 changes: 5 additions & 6 deletions resources/lib/youtube_plugin/kodion/items/xbmc/xbmc_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
SWITCH_PLAYER_FLAG,
VIDEO_ID,
)
from ...utils import current_system_version, datetime_parser
from ...utils import current_system_version, datetime_parser, redact_ip_from_url


def set_info(list_item, item, properties, set_play_count=True, resume=True):
Expand Down Expand Up @@ -375,7 +375,7 @@ def set_info(list_item, item, properties, set_play_count=True, resume=True):

def video_playback_item(context, video_item, show_fanart=None, **_kwargs):
uri = video_item.get_uri()
context.log_debug('Converting VideoItem |%s|' % uri)
context.log_debug('Converting VideoItem |%s|' % redact_ip_from_url(uri))

settings = context.get_settings()
headers = video_item.get_headers()
Expand Down Expand Up @@ -437,10 +437,9 @@ def video_playback_item(context, video_item, show_fanart=None, **_kwargs):
mime_type = uri.split('mime=', 1)[1].split('&', 1)[0]
mime_type = mime_type.replace('%2F', '/')

if (headers and uri.startswith('http') and not (
settings.default_player_web_urls()
or (is_external and settings.alternative_player_web_urls())
)):
if (headers and uri.startswith('http')
and not (is_external
or settings.default_player_web_urls())):
kwargs['path'] = '|'.join((uri, headers))

list_item = xbmcgui.ListItem(**kwargs)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ def start_httpd(self):

def shutdown_httpd(self, sleep=False):
if self.httpd:
if sleep and self._context.get_settings().api_config_page():
if sleep and self.httpd_required(while_sleeping=True):
return
log_debug('HTTPServer: Shutting down |{ip}:{port}|'
.format(ip=self._old_httpd_address,
Expand All @@ -214,5 +214,9 @@ def restart_httpd(self):
def ping_httpd(self):
return self.httpd and httpd_status(self._context)

def httpd_required(self):
def httpd_required(self, while_sleeping=False):
if while_sleeping:
settings = self._context.get_settings()
return (settings.api_config_page()
or settings.support_alternative_player())
return self._use_httpd
6 changes: 4 additions & 2 deletions resources/lib/youtube_plugin/kodion/network/http_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
)
from ..constants import ADDON_ID, LICENSE_TOKEN, LICENSE_URL, TEMP_PATH, paths
from ..logger import log_debug, log_error
from ..utils import validate_ip_address, wait
from ..utils import validate_ip_address, redact_ip_from_url, wait


class HTTPServer(TCPServer):
Expand Down Expand Up @@ -94,7 +94,9 @@ def do_GET(self):
# Strip trailing slash if present
stripped_path = self.path.rstrip('/')
if stripped_path != paths.PING:
log_debug('HTTPServer: GET |{path}|'.format(path=self.path))
log_debug('HTTPServer: GET |{path}|'.format(
path=redact_ip_from_url(self.path)
))

if not self.connection_allowed():
self.send_error(403)
Expand Down
6 changes: 4 additions & 2 deletions resources/lib/youtube_plugin/kodion/utils/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,10 @@ def select_stream(context,
item for item in stream_data_list
if (not item.get('adaptive')
or (not item.get('live') and use_adaptive)
or (live_type.startswith('isa_') and item.get('hls/video'))
or (live_type == 'isa_mpd' and item.get('dash/video')))
or (item.get('live')
and live_type.startswith('isa')
and ((live_type == 'isa_mpd' and item.get('dash/video'))
or item.get('hls/video'))))
]

if not stream_list:
Expand Down
52 changes: 33 additions & 19 deletions resources/lib/youtube_plugin/youtube/helper/video_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ def _get_stream_format(self, itag, info=None, max_height=None, **kwargs):
if video_info:
video_height = video_info.get('height', 0)
if max_height and video_height > max_height:
return None
return False
video_sort = (
video_height
* self.QUALITY_FACTOR.get(video_info.get('codec'), 1)
Expand Down Expand Up @@ -980,15 +980,19 @@ def _load_hls_manifest(self, url, is_live=False, meta_info=None,
headers=curl_headers,
playback_stats=playback_stats,
)
if yt_format:
if is_live:
yt_format['live'] = True
yt_format['title'] = 'Live ' + yt_format['title']
stream_list.append(yt_format)
if yt_format is None:
self._context.log_debug('Unknown itag: {itag}\n{stream}'.format(
itag=itag, stream=redact_ip_from_url(match[0]),
))
if (not yt_format
or yt_format.get('discontinued')
or yt_format.get('unsupported')):
continue
self._context.log_debug('Unknown itag: {itag}\n{stream}'.format(
itag=itag, stream=redact_ip_from_url(match[0])
))

if is_live:
yt_format['live'] = True
yt_format['title'] = 'Live ' + yt_format['title']
stream_list.append(yt_format)

return stream_list

Expand Down Expand Up @@ -1027,33 +1031,43 @@ def _create_stream_list(self,
for stream_map in streams:
url = stream_map.get('url')
conn = stream_map.get('conn')
stream = stream_map.get('stream')

if not url and conn:
url = '%s?%s' % (conn, unquote(stream_map['stream']))
if not url and conn and stream:
new_url = '%s?%s' % (conn, unquote(stream))
elif not url and self._cipher and 'signatureCipher' in stream_map:
url = self._process_signature_cipher(stream_map)
new_url = self._process_signature_cipher(stream_map)
else:
new_url = url

if not url:
if not new_url:
continue
url, _ = self._process_url_params(url)
new_url, _ = self._process_url_params(new_url)

itag = str(stream_map['itag'])
stream_map['itag'] = itag
yt_format = self._get_stream_format(
itag=itag,
max_height=selected_height,
title='',
url=url,
url=new_url,
meta=meta_info,
headers=curl_headers,
playback_stats=playback_stats,
)
if not yt_format:
if yt_format is None:
if url:
stream_map['url'] = redact_ip_from_url(url)
if conn:
stream_map['conn'] = redact_ip_from_url(conn)
if stream:
stream_map['stream'] = redact_ip_from_url(stream)
self._context.log_debug('Unknown itag: {itag}\n{stream}'.format(
itag=itag, stream=redact_ip_from_url(stream_map)
itag=itag, stream=stream_map,
))
continue
if (yt_format.get('discontinued') or yt_format.get('unsupported')
if (not yt_format
or yt_format.get('discontinued')
or yt_format.get('unsupported')
or (yt_format.get('dash/video')
and not yt_format.get('dash/audio'))):
continue
Expand Down
2 changes: 1 addition & 1 deletion resources/lib/youtube_plugin/youtube/provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -1257,7 +1257,7 @@ def on_root(self, context, re_match):
if logged_in and settings.get_bool('youtube.folder.liked_videos.show', True):
resource_manager = self.get_resource_manager(context)
playlists = resource_manager.get_related_playlists(channel_id='mine')
if 'likes' in playlists:
if playlists and 'likes' in playlists:
liked_videos_item = DirectoryItem(
localize('video.liked'),
create_uri(('channel', 'mine', 'playlist', playlists['likes'])),
Expand Down

0 comments on commit adfef50

Please sign in to comment.