Skip to content

Commit

Permalink
Add context menu item to play live stream from start anxdpanic#320
Browse files Browse the repository at this point in the history
  • Loading branch information
MoojMidge committed Aug 4, 2024
1 parent f81540b commit bd4ec9b
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 0 deletions.
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
3 changes: 3 additions & 0 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 @@ -434,6 +435,8 @@ def video_playback_item(context, video_item, show_fanart=None, **_kwargs):
props['inputstream.adaptive.manifest_config'] = dumps({
'timeshift_bufferlimit': 4 * 60 * 60,
})
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({
Expand Down
7 changes: 7 additions & 0 deletions 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 Down
2 changes: 2 additions & 0 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 @@ -325,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 bd4ec9b

Please sign in to comment.