Skip to content

Commit

Permalink
Merge pull request #864 from MoojMidge/master
Browse files Browse the repository at this point in the history
v7.0.9+beta.10
  • Loading branch information
MoojMidge committed Aug 4, 2024
2 parents 86ad02a + 0a95ac0 commit cd99500
Show file tree
Hide file tree
Showing 11 changed files with 78 additions and 28 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.9" provider-name="anxdpanic, bromix, MoojMidge">
<addon id="plugin.video.youtube" name="YouTube" version="7.0.9+beta.10" 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
8 changes: 8 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## v7.0.9+beta.10
### Fixed
- Don't retry player requests for offline live streams
- Fix incorrectly updating playing live stream details

### New
- Add context menu item to play live stream from start #320

## v7.0.9+beta.9
### Fixed
- Fix not properly defining default audio role #861
Expand Down
4 changes: 4 additions & 0 deletions resources/language/resource.language.en_gb/strings.po
Original file line number Diff line number Diff line change
Expand Up @@ -1580,3 +1580,7 @@ msgstr ""
msgctxt "#30818"
msgid "Are you sure you want to refresh settings.xml?"
msgstr ""

msgctxt "#30819"
msgid "Play from start"
msgstr ""
2 changes: 2 additions & 0 deletions resources/lib/youtube_plugin/kodion/constants/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
PLAY_FORCE_AUDIO = 'audio_only'
PLAY_PROMPT_QUALITY = 'ask_for_quality'
PLAY_PROMPT_SUBTITLES = 'prompt_for_subtitles'
PLAY_TIMESHIFT = 'timeshift'
PLAY_WITH = 'play_with'

# Stored data
Expand Down Expand Up @@ -122,6 +123,7 @@
'PLAY_FORCE_AUDIO',
'PLAY_PROMPT_QUALITY',
'PLAY_PROMPT_SUBTITLES',
'PLAY_TIMESHIFT',
'PLAY_WITH',

# Stored data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
PLAY_FORCE_AUDIO,
PLAY_PROMPT_QUALITY,
PLAY_PROMPT_SUBTITLES,
PLAY_TIMESHIFT,
PLAY_WITH,
VALUE_FROM_STR,
)
Expand All @@ -44,6 +45,7 @@ class AbstractContext(object):
PLAY_FORCE_AUDIO,
PLAY_PROMPT_SUBTITLES,
PLAY_PROMPT_QUALITY,
PLAY_TIMESHIFT,
PLAY_WITH,
'confirmed',
'clip',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -259,6 +259,7 @@ class XbmcContext(AbstractContext):
'video.more': 30548,
'video.play.ask_for_quality': 30730,
'video.play.audio_only': 30708,
'video.play.timeshift': 30819,
'video.play.with': 30540,
'video.play.with_subtitles': 30702,
'video.queue': 30511,
Expand Down Expand Up @@ -673,6 +674,7 @@ def use_inputstream_adaptive(self, prompt=False):
# functionality
'drm': loose_version('2.2.12'),
'live': loose_version('2.0.12'),
'timeshift': loose_version('2.5.2'),
'ttml': loose_version('20.0.0'),
# properties
'config_prop': loose_version('21.4.11'),
Expand Down
15 changes: 15 additions & 0 deletions resources/lib/youtube_plugin/kodion/items/menu_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
PLAY_FORCE_AUDIO,
PLAY_PROMPT_QUALITY,
PLAY_PROMPT_SUBTITLES,
PLAY_TIMESHIFT,
PLAY_WITH,
)

Expand Down Expand Up @@ -431,6 +432,20 @@ def play_ask_for_quality(context, video_id):
)


def play_timeshift(context, video_id):
return (
context.localize('video.play.timeshift'),
context.create_uri(
(PATHS.PLAY,),
{
'video_id': video_id,
PLAY_TIMESHIFT: True,
},
run=True,
),
)


def history_remove(context, video_id):
return (
context.localize('history.remove'),
Expand Down
28 changes: 18 additions & 10 deletions resources/lib/youtube_plugin/kodion/items/xbmc/xbmc_items.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
PLAYLISTITEM_ID,
PLAYLIST_ID,
PLAY_COUNT,
PLAY_TIMESHIFT,
PLAY_WITH,
SUBSCRIPTION_ID,
VIDEO_ID,
Expand Down Expand Up @@ -380,7 +381,9 @@ def video_playback_item(context, video_item, show_fanart=None, **_kwargs):
settings = context.get_settings()
headers = video_item.get_headers()
license_key = video_item.get_license_key()
is_external = context.get_ui().get_property(PLAY_WITH)

ui = context.get_ui()
is_external = ui.get_property(PLAY_WITH)
is_strm = context.get_param('strm')
mime_type = None

Expand All @@ -402,6 +405,8 @@ def video_playback_item(context, video_item, show_fanart=None, **_kwargs):
}

if video_item.use_isa_video() and context.use_inputstream_adaptive():
capabilities = context.inputstream_adaptive_capabilities()

use_mpd = video_item.use_mpd_video()
if use_mpd:
manifest_type = 'mpd'
Expand All @@ -422,18 +427,21 @@ def video_playback_item(context, video_item, show_fanart=None, **_kwargs):
else:
props['inputstreamaddon'] = 'inputstream.adaptive'

if current_system_version.compatible(21, 0):
isa_capabilities = context.inputstream_adaptive_capabilities()
if video_item.live and 'manifest_config_prop' in isa_capabilities:
if not current_system_version.compatible(21, 0):
props['inputstream.adaptive.manifest_type'] = manifest_type

if video_item.live:
if 'manifest_config_prop' in capabilities:
props['inputstream.adaptive.manifest_config'] = dumps({
'timeshift_bufferlimit': 4 * 60 * 60,
})
if not settings.verify_ssl() and 'config_prop' in isa_capabilities:
props['inputstream.adaptive.config'] = dumps({
'ssl_verify_peer': False,
})
else:
props['inputstream.adaptive.manifest_type'] = manifest_type
if ui.pop_property(PLAY_TIMESHIFT) and 'timeshift' in capabilities:
props['inputstream.adaptive.play_timeshift_buffer'] = True

if not settings.verify_ssl() and 'config_prop' in capabilities:
props['inputstream.adaptive.config'] = dumps({
'ssl_verify_peer': False,
})

if headers:
props['inputstream.adaptive.manifest_headers'] = headers
Expand Down
25 changes: 13 additions & 12 deletions resources/lib/youtube_plugin/youtube/helper/stream_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -1422,6 +1422,9 @@ def load_stream_info(self, video_id):
and playability.get('desktopLegacyAgeGateReason')):
abort = True
break
elif status == 'LIVE_STREAM_OFFLINE':
abort = True
break
elif status == 'OK':
break
elif status in {
Expand Down Expand Up @@ -1526,18 +1529,16 @@ def load_stream_info(self, video_id):
thumb_suffix = ''

meta_info = {
'video': {
'id': video_id,
'title': unescape(video_details.get('title', '')
.encode('raw_unicode_escape')
.decode('raw_unicode_escape')),
'status': {
'unlisted': microformat.get('isUnlisted', False),
'private': video_details.get('isPrivate', False),
'crawlable': video_details.get('isCrawlable', False),
'family_safe': microformat.get('isFamilySafe', False),
'live': is_live,
},
'id': video_id,
'title': unescape(video_details.get('title', '')
.encode('raw_unicode_escape')
.decode('raw_unicode_escape')),
'status': {
'unlisted': microformat.get('isUnlisted', False),
'private': video_details.get('isPrivate', False),
'crawlable': video_details.get('isCrawlable', False),
'family_safe': microformat.get('isFamilySafe', False),
'live': is_live,
},
'channel': {
'id': video_details.get('channelId', ''),
Expand Down
9 changes: 8 additions & 1 deletion resources/lib/youtube_plugin/youtube/helper/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,6 +813,13 @@ def update_video_infos(provider, context, video_id_dict,
)
)

if video_item.live:
context_menu.append(
menu_items.play_timeshift(
context, video_id
)
)

if context_menu:
context_menu.append(menu_items.separator())
video_item.add_context_menu(context_menu)
Expand All @@ -829,7 +836,7 @@ def update_play_info(provider, context, video_id, video_item, video_stream,
settings = context.get_settings()
ui = context.get_ui()

meta_data = video_stream.get('meta', None)
meta_data = video_stream.get('meta')
if meta_data:
video_item.live = meta_data.get('status', {}).get('live', False)
video_item.set_subtitles(meta_data.get('subtitles', None))
Expand Down
9 changes: 5 additions & 4 deletions resources/lib/youtube_plugin/youtube/helper/yt_play.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
PLAY_FORCE_AUDIO,
PLAY_PROMPT_QUALITY,
PLAY_PROMPT_SUBTITLES,
PLAY_TIMESHIFT,
PLAY_WITH,
SERVER_POST_START,
SERVER_WAKEUP,
Expand Down Expand Up @@ -108,8 +109,6 @@ def _play_stream(provider, context):
video_id)

metadata = stream.get('meta', {})
video_details = metadata.get('video', {})

if is_external:
url = urlunsplit((
'http',
Expand All @@ -119,7 +118,8 @@ def _play_stream(provider, context):
'',
))
stream['url'] = url
video_item = VideoItem(video_details.get('title', ''), stream['url'])

video_item = VideoItem(metadata.get('title', ''), stream['url'])

use_history = not (screensaver or incognito or stream.get('live'))
use_remote_history = use_history and settings.use_remote_history()
Expand All @@ -145,7 +145,7 @@ def _play_stream(provider, context):
playback_data = {
'video_id': video_id,
'channel_id': metadata.get('channel', {}).get('id', ''),
'video_status': video_details.get('status', {}),
'video_status': metadata.get('status', {}),
'playing_file': video_item.get_uri(),
'play_count': play_count,
'use_remote_history': use_remote_history,
Expand Down Expand Up @@ -326,6 +326,7 @@ def process(provider, context, **_kwargs):

force_play = False
for param in {PLAY_FORCE_AUDIO,
PLAY_TIMESHIFT,
PLAY_PROMPT_QUALITY,
PLAY_PROMPT_SUBTITLES,
PLAY_WITH}.intersection(param_keys):
Expand Down

0 comments on commit cd99500

Please sign in to comment.