Skip to content

Commit

Permalink
Merge pull request #856 from MoojMidge/master
Browse files Browse the repository at this point in the history
v7.0.9+beta.7
  • Loading branch information
MoojMidge authored Aug 3, 2024
2 parents cbaed54 + 15a4319 commit 5a6e7c1
Show file tree
Hide file tree
Showing 13 changed files with 167 additions and 133 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.6" provider-name="anxdpanic, bromix, MoojMidge">
<addon id="plugin.video.youtube" name="YouTube" version="7.0.9+beta.7" 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
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## v7.0.9+beta.7
### New
- Improve use of progressive streams
- Improve stream selection for HLS stream in InputStream.Adaptive

## v7.0.9+beta.6
### Fixed
- Fix http server not working in Kodi 18
Expand Down
6 changes: 3 additions & 3 deletions resources/lib/youtube_plugin/kodion/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@

# Addon paths
ADDON_ID = 'plugin.video.youtube'
ADDON_PATH = 'special://home/addons/{id}'.format(id=ADDON_ID)
DATA_PATH = 'special://profile/addon_data/{id}'.format(id=ADDON_ID)
ADDON_PATH = 'special://home/addons/' + ADDON_ID
DATA_PATH = 'special://profile/addon_data/' + ADDON_ID
MEDIA_PATH = ADDON_PATH + '/resources/media'
RESOURCE_PATH = ADDON_PATH + '/resources'
TEMP_PATH = 'special://temp/{id}'.format(id=ADDON_ID)
TEMP_PATH = 'special://temp/' + ADDON_ID

# Const values
VALUE_FROM_STR = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
MPD_STREAM_SELECT = 'kodion.mpd.stream.select' # (int)
MPD_QUALITY_SELECTION = 'kodion.mpd.quality.selection' # (int)
MPD_STREAM_FEATURES = 'kodion.mpd.stream.features' # (list[str])
VIDEO_STREAM_SELECT = 'kodion.video.stream.select' # (int)
VIDEO_QUALITY_ASK = 'kodion.video.quality.ask' # (bool)
VIDEO_QUALITY = 'kodion.video.quality' # (int)
AUDIO_ONLY = 'kodion.audio_only' # (bool)
Expand Down
16 changes: 11 additions & 5 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 @@
SUBSCRIPTION_ID,
VIDEO_ID,
)
from ...utils import current_system_version, datetime_parser, redact_ip_from_url
from ...utils import current_system_version, datetime_parser, redact_ip


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|' % redact_ip_from_url(uri))
context.log_debug('Converting VideoItem |%s|' % redact_ip(uri))

settings = context.get_settings()
headers = video_item.get_headers()
Expand All @@ -402,15 +402,21 @@ def video_playback_item(context, video_item, show_fanart=None, **_kwargs):
}

if video_item.use_isa_video() and context.use_inputstream_adaptive():
if video_item.use_mpd_video():
use_mpd = video_item.use_mpd_video()
if use_mpd:
manifest_type = 'mpd'
mime_type = 'application/dash+xml'
if 'auto' in settings.stream_select():
props['inputstream.adaptive.stream_selection_type'] = 'adaptive'
else:
manifest_type = 'hls'
mime_type = 'application/x-mpegURL'

stream_select = settings.stream_select()
if not use_mpd and 'list' in stream_select:
props['inputstream.adaptive.stream_selection_type'] = 'manual-osd'
elif 'auto' in stream_select:
props['inputstream.adaptive.stream_selection_type'] = 'adaptive'
props['inputstream.adaptive.chooser_resolution_max'] = 'auto'

if current_system_version.compatible(19, 0):
props['inputstream'] = 'inputstream.adaptive'
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ def run(self):
if rating == 'none':
rating_match = re.search(
r'/(?P<video_id>[^/]+)/(?P<rating>[^/]+)',
'/{0}/{1}/'.format(self.video_id, rating)
'/'.join(('', self.video_id, rating, ''))
)
self._provider.on_video_x(
self._provider,
Expand Down
4 changes: 2 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, PATHS, TEMP_PATH
from ..logger import log_debug, log_error
from ..utils import validate_ip_address, redact_ip_from_url, wait
from ..utils import validate_ip_address, redact_ip, wait


class HTTPServer(TCPServer):
Expand Down Expand Up @@ -97,7 +97,7 @@ def do_GET(self):
stripped_path = self.path.rstrip('/')
if stripped_path != PATHS.PING:
log_debug('HTTPServer: GET |{path}|'.format(
path=redact_ip_from_url(self.path)
path=redact_ip(self.path)
))

if not self.connection_allowed():
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -388,10 +388,16 @@ def stream_features(self, value=None):
}

def stream_select(self, value=None):
if self.use_mpd_videos():
setting = SETTINGS.MPD_STREAM_SELECT
default = 3
else:
setting = SETTINGS.VIDEO_STREAM_SELECT
default = 2

if value is not None:
return self.set_int(SETTINGS.MPD_STREAM_SELECT, value)
default = 3
value = self.get_int(SETTINGS.MPD_STREAM_SELECT, default)
return self.set_int(setting, value)
value = self.get_int(setting, default)
if value in self._STREAM_SELECT:
return self._STREAM_SELECT[value]
return self._STREAM_SELECT[default]
Expand Down
4 changes: 2 additions & 2 deletions resources/lib/youtube_plugin/kodion/utils/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
loose_version,
make_dirs,
merge_dicts,
redact_ip_from_url,
redact_ip,
rm_dir,
seconds_to_duration,
select_stream,
Expand All @@ -45,7 +45,7 @@
'loose_version',
'make_dirs',
'merge_dicts',
'redact_ip_from_url',
'redact_ip',
'rm_dir',
'seconds_to_duration',
'select_stream',
Expand Down
6 changes: 3 additions & 3 deletions resources/lib/youtube_plugin/kodion/utils/methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def _stream_sort(_stream):

original_value = log_data.get('url')
if original_value:
log_data['url'] = redact_ip_from_url(original_value)
log_data['url'] = redact_ip(original_value)

context.log_debug('Stream {0}:\n{1}'.format(idx, log_data))

Expand Down Expand Up @@ -270,7 +270,7 @@ def get_kodi_setting_value(setting, process=None):


def get_kodi_setting_bool(setting):
return xbmc.getCondVisibility('System.GetBool({0})'.format(setting))
return xbmc.getCondVisibility(setting.join(('System.GetBool(', ')')))


def validate_ip_address(ip_address):
Expand Down Expand Up @@ -312,5 +312,5 @@ def wait(timeout=None):
return xbmc.Monitor().waitForAbort(timeout)


def redact_ip_from_url(url):
def redact_ip(url):
return re.sub(r'([?&/])ip([=/])[^?&/]+', '\g<1>ip\g<2><redacted>', url)
4 changes: 2 additions & 2 deletions resources/lib/youtube_plugin/youtube/client/youtube.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def update_watch_history(self, context, video_id, url, status=None):
'Accept': '*/*',
'Accept-Language': 'en-US,en;q=0.5',
'DNT': '1',
'Referer': 'https://www.youtube.com/watch?v={0}'.format(video_id),
'Referer': 'https://www.youtube.com/watch?v=' + video_id,
'User-Agent': ('Mozilla/5.0 (Linux; Android 10; SM-G981B)'
' AppleWebKit/537.36 (KHTML, like Gecko)'
' Chrome/80.0.3987.162 Mobile Safari/537.36'),
Expand Down Expand Up @@ -1976,7 +1976,7 @@ def _error_hook(self, **kwargs):
else:
notification = message

title = '{0}: {1}'.format(self._context.get_name(), reason)
title = ': '.join((self._context.get_name(), reason))
if ok_dialog:
self._context.get_ui().on_ok(title, notification)
else:
Expand Down
Loading

0 comments on commit 5a6e7c1

Please sign in to comment.