Skip to content

Commit

Permalink
Merge pull request #846 from MoojMidge/master
Browse files Browse the repository at this point in the history
v7.0.9+beta.4
  • Loading branch information
MoojMidge authored Jul 25, 2024
2 parents fee15d4 + b8ba653 commit 62cc545
Show file tree
Hide file tree
Showing 32 changed files with 520 additions and 355 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.3" provider-name="anxdpanic, bromix, MoojMidge">
<addon id="plugin.video.youtube" name="YouTube" version="7.0.9+beta.4" 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
14 changes: 14 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## v7.0.9+beta.4
### Fixed
- Fix issues with next page and jump to page in related video listings
- Attempt to workaround issue with getting system idle time on Xbox #839
- Better handle unknown errors in player request responses #845
- Fix double playback due to busy dialog crash workaround

### Changed
- Respect disable certificate verification setting with cURL in ISA #841
- Update bookmarks when listing rather than only using item snapshot

### New
- Enable loop to first page on last page of manually paginated listings (My Subscriptions)

## v7.0.9+beta.3
### Fixed
- Fix navigating to search page after playback and prompt re-opening
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,5 +472,5 @@ def get_listitem_info(detail_name):
def tear_down(self):
pass

def wakeup(self):
def wakeup(self, target, timeout=None):
raise NotImplementedError()
22 changes: 14 additions & 8 deletions resources/lib/youtube_plugin/kodion/context/xbmc/xbmc_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,8 @@ def set_addon_enabled(self, addon_id, enabled=True):
error.get('message', 'unknown')))
return False

def send_notification(self, method, data=True):
@staticmethod
def send_notification(method, data=True):
jsonrpc(method='JSONRPC.NotifyAll',
params={'sender': ADDON_ID,
'message': method,
Expand Down Expand Up @@ -675,9 +676,13 @@ def use_inputstream_adaptive(self, prompt=False):
# - any Falsy value to exclude capability regardless of version
# - True to include capability regardless of version
_ISA_CAPABILITIES = {
'live': loose_version('2.0.12'),
# functionality
'drm': loose_version('2.2.12'),
'live': loose_version('2.0.12'),
'ttml': loose_version('20.0.0'),
# properties
'config_prop': loose_version('21.4.11'),
'manifest_config_prop': loose_version('21.4.5'),
# audio codecs
'vorbis': loose_version('2.3.14'),
# unknown when Opus audio support was implemented
Expand Down Expand Up @@ -779,21 +784,22 @@ def wakeup(self, target, timeout=None):

pop_property = self.get_ui().pop_property
no_timeout = timeout < 0
remaining = timeout
wait_period = 0.1
remaining = timeout = timeout * 1000
wait_period_ms = 100
wait_period = wait_period_ms / 1000

while no_timeout or remaining > 0:
awake = pop_property(WAKEUP)
if awake:
if awake == target:
self.log_debug('Wakeup |{0}| in {1}s'
self.log_debug('Wakeup |{0}| in {1}ms'
.format(awake, timeout - remaining))
else:
self.log_error('Wakeup |{0}| in {1}s - expected |{2}|'
self.log_error('Wakeup |{0}| in {1}ms - expected |{2}|'
.format(awake, timeout - remaining, target))
break
wait(wait_period)
remaining -= wait_period
remaining -= wait_period_ms
else:
self.log_error('Wakeup |{0}| timed out in {1}s'
self.log_error('Wakeup |{0}| timed out in {1}ms'
.format(target, timeout))
29 changes: 24 additions & 5 deletions resources/lib/youtube_plugin/kodion/debug.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ class Profiler(object):
__slots__ = (
'__weakref__',
'_enabled',
'_num_lines',
'_print_callees',
'_profiler',
'_reuse',
'_timer',
Expand Down Expand Up @@ -115,9 +117,13 @@ def __init__(self,
enabled=True,
lazy=True,
name=__name__,
num_lines=20,
print_callees=False,
reuse=False,
timer=None):
self._enabled = enabled
self._num_lines = num_lines
self._print_callees = print_callees
self._profiler = None
self._reuse = reuse
self._timer = timer
Expand All @@ -140,7 +146,9 @@ def __exit__(self, exc_type=None, exc_val=None, exc_tb=None):
return

log_debug('Profiling stats: {0}'.format(self.get_stats(
reuse=self._reuse
num_lines=self._num_lines,
print_callees=self._print_callees,
reuse=self._reuse,
)))
if not self._reuse:
self.tear_down()
Expand Down Expand Up @@ -218,18 +226,27 @@ def enable(self, flush=False):
else:
self._profiler.enable()

def get_stats(self, flush=True, reuse=False):
def get_stats(self,
flush=True,
num_lines=20,
print_callees=False,
reuse=False):
if not (self._enabled and self._profiler):
return None

self.disable()

output_stream = self._StringIO()
try:
self._Stats(
stats = self._Stats(
self._profiler,
stream=output_stream
).strip_dirs().sort_stats('cumulative', 'time').print_stats(20)
)
stats.strip_dirs().sort_stats('cumulative', 'time')
if print_callees:
stats.print_callees(num_lines)
else:
stats.print_stats(num_lines)
output = output_stream.getvalue()
# Occurs when no stats were able to be generated from profiler
except TypeError:
Expand All @@ -245,7 +262,9 @@ def get_stats(self, flush=True, reuse=False):

def print_stats(self):
log_debug('Profiling stats: {0}'.format(self.get_stats(
reuse=self._reuse
num_lines=self._num_lines,
print_callees=self._print_callees,
reuse=self._reuse,
)))

def tear_down(self):
Expand Down
5 changes: 1 addition & 4 deletions resources/lib/youtube_plugin/kodion/items/base_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,10 @@


class BaseItem(object):
VERSION = 3

_version = 3
_playable = False

def __init__(self, name, uri, image=None, fanart=None):
self._version = BaseItem.VERSION

self._name = None
self.set_name(name)

Expand Down
26 changes: 16 additions & 10 deletions resources/lib/youtube_plugin/kodion/items/directory_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,24 +85,30 @@ def set_action(self, value):
if isinstance(value, bool):
self._is_action = value

def set_subscription_id(self, value):
self._subscription_id = value

def get_subscription_id(self):
@property
def subscription_id(self):
return self._subscription_id

def set_channel_id(self, value):
self._channel_id = value
@subscription_id.setter
def subscription_id(self, value):
self._subscription_id = value

def get_channel_id(self):
@property
def channel_id(self):
return self._channel_id

def set_playlist_id(self, value):
self._playlist_id = value
@channel_id.setter
def channel_id(self, value):
self._channel_id = value

def get_playlist_id(self):
@property
def playlist_id(self):
return self._playlist_id

@playlist_id.setter
def playlist_id(self, value):
self._playlist_id = value

@property
def next_page(self):
return self._next_page
Expand Down
3 changes: 2 additions & 1 deletion resources/lib/youtube_plugin/kodion/items/next_page_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ def __init__(self, context, params, image=None, fanart=None):
items_per_page = params.get('items_per_page', 50)
can_jump = ('next_page_token' not in params
and not path.startswith(('/channel',
'/special/recommendations')))
'/special/recommendations',
'/special/related_videos')))
if 'page_token' not in params and can_jump:
params['page_token'] = self.create_page_token(page, items_per_page)

Expand Down
24 changes: 16 additions & 8 deletions resources/lib/youtube_plugin/kodion/items/video_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -374,28 +374,36 @@ def video_id(self):
def video_id(self, value):
self._video_id = value

def get_channel_id(self):
@property
def channel_id(self):
return self._channel_id

def set_channel_id(self, value):
@channel_id.setter
def channel_id(self, value):
self._channel_id = value

def get_subscription_id(self):
@property
def subscription_id(self):
return self._subscription_id

def set_subscription_id(self, value):
@subscription_id.setter
def subscription_id(self, value):
self._subscription_id = value

def get_playlist_id(self):
@property
def playlist_id(self):
return self._playlist_id

def set_playlist_id(self, value):
@playlist_id.setter
def playlist_id(self, value):
self._playlist_id = value

def get_playlist_item_id(self):
@property
def playlist_item_id(self):
return self._playlist_item_id

def set_playlist_item_id(self, value):
@playlist_item_id.setter
def playlist_item_id(self, value):
self._playlist_item_id = value

def get_code(self):
Expand Down
29 changes: 17 additions & 12 deletions resources/lib/youtube_plugin/kodion/items/xbmc/xbmc_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,16 +411,21 @@ def video_playback_item(context, video_item, show_fanart=None, **_kwargs):
manifest_type = 'hls'
mime_type = 'application/x-mpegURL'

inputstream_property = ('inputstream'
if current_system_version.compatible(19, 0) else
'inputstreamaddon')
props[inputstream_property] = 'inputstream.adaptive'
if current_system_version.compatible(19, 0):
props['inputstream'] = 'inputstream.adaptive'
else:
props['inputstreamaddon'] = 'inputstream.adaptive'

if current_system_version.compatible(21, 0):
if video_item.live:
isa_capabilities = context.inputstream_adaptive_capabilities()
if video_item.live and isa_capabilities['manifest_config_prop']:
props['inputstream.adaptive.manifest_config'] = dumps({
'timeshift_bufferlimit': 4 * 60 * 60,
})
if not settings.verify_ssl() and isa_capabilities['config_prop']:
props['inputstream.adaptive.config'] = dumps({
'ssl_verify_peer': False,
})
else:
props['inputstream.adaptive.manifest_type'] = manifest_type

Expand Down Expand Up @@ -532,17 +537,17 @@ def directory_listitem(context, directory_item, show_fanart=None, **_kwargs):
else:
special_sort = 'top'

prop_value = directory_item.get_subscription_id()
prop_value = directory_item.subscription_id
if prop_value:
special_sort = None
props[SUBSCRIPTION_ID] = prop_value

prop_value = directory_item.get_channel_id()
prop_value = directory_item.channel_id
if prop_value:
special_sort = None
props[CHANNEL_ID] = prop_value

prop_value = directory_item.get_playlist_id()
prop_value = directory_item.playlist_id
if prop_value:
special_sort = None
props[PLAYLIST_ID] = prop_value
Expand Down Expand Up @@ -679,22 +684,22 @@ def video_listitem(context,
props[VIDEO_ID] = prop_value

# make channel_id property available for keymapping
prop_value = video_item.get_channel_id()
prop_value = video_item.channel_id
if prop_value:
props[CHANNEL_ID] = prop_value

# make subscription_id property available for keymapping
prop_value = video_item.get_subscription_id()
prop_value = video_item.subscription_id
if prop_value:
props[SUBSCRIPTION_ID] = prop_value

# make playlist_id property available for keymapping
prop_value = video_item.get_playlist_id()
prop_value = video_item.playlist_id
if prop_value:
props[PLAYLIST_ID] = prop_value

# make playlist_item_id property available for keymapping
prop_value = video_item.get_playlist_item_id()
prop_value = video_item.playlist_item_id
if prop_value:
props[PLAYLISTITEM_ID] = prop_value

Expand Down
16 changes: 16 additions & 0 deletions resources/lib/youtube_plugin/kodion/monitors/service_monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
class ServiceMonitor(xbmc.Monitor):
_settings_changes = 0
_settings_state = None
get_idle_time = xbmc.getGlobalIdleTime

def __init__(self, context):
self._context = context
Expand All @@ -43,6 +44,7 @@ def __init__(self, context):
self.httpd_thread = None
self.httpd_sleep_allowed = True

self.system_idle = False
self.refresh = False
self.interrupt = False

Expand Down Expand Up @@ -114,6 +116,20 @@ def onNotification(self, sender, method, data):
self._context.reload_access_manager()
self.refresh_container()

def onScreensaverActivated(self):
self.system_idle = True

def onScreensaverDeactivated(self):
self.system_idle = False
self.interrupt = True

def onDPMSActivated(self):
self.system_idle = True

def onDPMSDeactivated(self):
self.system_idle = False
self.interrupt = True

def onSettingsChanged(self):
self._settings_changes += 1
if self._settings_state == 'defer':
Expand Down
Loading

0 comments on commit 62cc545

Please sign in to comment.