1
0
Fork 0
mirror of https://github.com/ytdl-org/youtube-dl.git synced 2024-11-28 21:22:13 +00:00

[youtube] Fix mark watched (closes #18546)

This commit is contained in:
Sergey M․ 2018-12-16 19:35:48 +07:00
parent c984196cf1
commit 21c340b83f
No known key found for this signature in database
GPG key ID: 2C393E0F18A9236D

View file

@ -48,6 +48,7 @@ from ..utils import (
unified_strdate, unified_strdate,
unsmuggle_url, unsmuggle_url,
uppercase_escape, uppercase_escape,
url_or_none,
urlencode_postdata, urlencode_postdata,
) )
@ -1386,8 +1387,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
self._downloader.report_warning(err_msg) self._downloader.report_warning(err_msg)
return {} return {}
def _mark_watched(self, video_id, video_info): def _mark_watched(self, video_id, video_info, player_response):
playback_url = video_info.get('videostats_playback_base_url', [None])[0] playback_url = url_or_none(try_get(
player_response,
lambda x: x['playbackTracking']['videostatsPlaybackUrl']['baseUrl']) or try_get(
video_info, lambda x: x['videostats_playback_base_url'][0]))
if not playback_url: if not playback_url:
return return
parsed_playback_url = compat_urlparse.urlparse(playback_url) parsed_playback_url = compat_urlparse.urlparse(playback_url)
@ -2122,7 +2126,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
self._sort_formats(formats) self._sort_formats(formats)
self.mark_watched(video_id, video_info) self.mark_watched(video_id, video_info, player_response)
return { return {
'id': video_id, 'id': video_id,