Skip to content

Commit

Permalink
Merge pull request #678 from MoojMidge/master
Browse files Browse the repository at this point in the history
v7.0.5+beta.4
  • Loading branch information
MoojMidge authored Apr 2, 2024
2 parents d813ff4 + 587b088 commit 8456e80
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 33 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.5+beta.3" provider-name="anxdpanic, bromix, MoojMidge">
<addon id="plugin.video.youtube" name="YouTube" version="7.0.5+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
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## v7.0.5+beta.4
### Fixed
- Fix typo that caused android player requests to fail

## v7.0.5+beta.3
### Fixed
- Fix error message when rating video #666
Expand Down
11 changes: 4 additions & 7 deletions resources/lib/youtube_plugin/youtube/client/request_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@


class YouTubeRequestClient(BaseRequestsClass):
_ANDROID_PARAMS = 'CgIIAdgDAQ==',
_ANDROID_PARAMS = 'CgIIAdgDAQ=='
# yt-dlp has chosen the following value, but this results in the android
# player response not including adaptive formats
# _ANDROID_PARAMS = 'CgIIAQ==',
# player response returning unexpected details sometimes. To be investigated
# _ANDROID_PARAMS = 'CgIIAQ=='

CLIENTS = {
# 4k no VP9 HDR
Expand Down Expand Up @@ -57,9 +57,6 @@ class YouTubeRequestClient(BaseRequestsClass):
'_query_subtitles': True,
'json': {
'params': _ANDROID_PARAMS,
# yt-dlp has chosen the following value, but this results in the
# player response not including adaptive formats
# 'params': 'CgIIAQ==',
'context': {
'client': {
'clientName': 'ANDROID',
Expand Down Expand Up @@ -263,7 +260,7 @@ class YouTubeRequestClient(BaseRequestsClass):
'request': {
'internalExperimentFlags': [],
'useSsl': True,
}
},
},
'playbackContext': {
'contentPlaybackContext': {
Expand Down
61 changes: 36 additions & 25 deletions resources/lib/youtube_plugin/youtube/helper/video_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -1264,7 +1264,14 @@ def _get_video_info(self):
.get('playerMicroformatRenderer', {}))
streaming_data = result.get('streamingData', {})
is_live = video_details.get('isLiveContent', False)
thumb_suffix = '_live' if is_live else ''
if is_live:
live_type = _settings.live_stream_type()
live_dvr = video_details.get('isLiveDvrEnabled', False)
thumb_suffix = '_live'
else:
live_type = None
live_dvr = False
thumb_suffix = ''

meta_info = {
'video': {
Expand Down Expand Up @@ -1366,10 +1373,26 @@ def _get_video_info(self):
self._cipher = Cipher(self._context, javascript=self._player_js)

manifest_url = main_stream = None
live_type = _settings.live_stream_type() if is_live else None

if live_type == 'isa_mpd' and 'dashManifestUrl' in streaming_data:
manifest_url = streaming_data['dashManifestUrl']
if '?' in manifest_url:
manifest_url += '&mpd_version=5'
elif manifest_url.endswith('/'):
manifest_url += 'mpd_version/5'
else:
manifest_url += '/mpd_version/5'

video_stream = {
'url': manifest_url,
'meta': meta_info,
'headers': curl_headers,
'license_info': license_info,
'playback_stats': playback_stats
}
details = self.FORMAT.get('9998')
video_stream.update(details)
stream_list.append(video_stream)
elif 'hlsManifestUrl' in streaming_data:
stream_list.extend(self._load_hls_manifest(
streaming_data['hlsManifestUrl'],
Expand Down Expand Up @@ -1433,32 +1456,15 @@ def _get_video_info(self):
manifest_url, main_stream = self._generate_mpd_manifest(
video_data, audio_data, subs_data, license_info.get('url')
)
live_type = None

# extract non-adaptive streams
if all_fmts:
stream_list.extend(self._create_stream_list(
all_fmts, meta_info, client['headers'], playback_stats
))

if manifest_url:
video_stream = {
'url': manifest_url,
'meta': meta_info,
'headers': curl_headers,
'license_info': license_info,
'playback_stats': playback_stats
}

if live_type:
if '?' in manifest_url:
video_stream['url'] = manifest_url + '&mpd_version=5'
elif manifest_url.endswith('/'):
video_stream['url'] = manifest_url + 'mpd_version/5'
else:
video_stream['url'] = manifest_url + '/mpd_version/5'
details = self.FORMAT.get('9998')
elif main_stream:
if main_stream:
details = self.FORMAT.get('9999').copy()

video_info = main_stream['video']
Expand Down Expand Up @@ -1495,8 +1501,14 @@ def _get_video_info(self):

details['title'] = ''.join(details['title'])

video_stream.update(details)
stream_list.append(video_stream)
video_stream.update(details)
stream_list.append(video_stream)

# extract non-adaptive streams
if all_fmts:
stream_list.extend(self._create_stream_list(
all_fmts, meta_info, client['headers'], playback_stats
))

if not stream_list:
raise YouTubeException('No streams found')
Expand All @@ -1517,8 +1529,6 @@ def _process_stream_data(self, stream_data, default_lang_code='und'):
self.FRACTIONAL_FPS_SCALE)
stream_select = _settings.stream_select()



audio_data = {}
video_data = {}
preferred_audio = {
Expand Down Expand Up @@ -1694,7 +1704,7 @@ def _process_stream_data(self, stream_data, default_lang_code='und'):
.replace("<", "&lt;")
.replace(">", "&gt;"))

data[mime_group][itag] = data[quality_group][itag] = {
details = {
'mimeType': mime_type,
'baseUrl': url,
'mediaType': media_type,
Expand All @@ -1721,6 +1731,7 @@ def _process_stream_data(self, stream_data, default_lang_code='und'):
'sampleRate': sample_rate,
'channels': channels,
}
data[mime_group][itag] = data[quality_group][itag] = details

if not video_data:
self._context.log_debug('Generate MPD: No video mime-types found')
Expand Down

3 comments on commit 8456e80

@DjDiabolik
Copy link
Contributor

@DjDiabolik DjDiabolik commented on 8456e80 Apr 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MoojMidge or @anxdpanic
It's present a lot of issue when i try to watch this, right now, completed live stream... at this link:
https://www.youtube.com/watch?v=ONfihi52srg

When i open it by Kodi it's start like cutted at begin..... it's duration about 2 hours instead the original 2 hours and 24 minutes and.

without any logical explanation kodi starts playing exactly from here:
https://youtu.be/ONfihi52srg?t=1484

Kodi skip whitout any sense the first exact 24 minutes and 44 seconds.... because there's append ?

@MoojMidge
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please don't comment on commits with unrelated issues in future. Just open an actual issue and include the relevant details so that it can be properly tracked.

For recently completed live streams, the VOD streams take some time to be made available. Until such time as they are available, the existing live stream is used with a back buffer enabled to act like a DVR. The plugin plays the live streams using a specific type of manifest provided by YouTube and by default it currently uses HLS manifests. These HLS manifests only have a buffer length of 2 hours.

@DjDiabolik
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@MoojMidge
In fact when I was trying to watch the live show it had just ended 38 minutes earlier....... most likely too little "margin" time to obtain the complete live on VOD :)
excellent explanation... clear and simply perfect.

Please sign in to comment.