]> git.bitcoin.ninja Git - youtube-dl/commitdiff
[youtube] Fix mark watched (closes #18546)
authorSergey M․ <dstftw@gmail.com>
Sun, 16 Dec 2018 12:35:48 +0000 (19:35 +0700)
committerSergey M․ <dstftw@gmail.com>
Sun, 16 Dec 2018 12:40:49 +0000 (19:40 +0700)
youtube_dl/extractor/youtube.py

index c582ab2ff7cfc1445b40a7c989de945b39a14c52..44c25c11cd09b93847f69c2a032b7cabe5e01f66 100644 (file)
@@ -48,6 +48,7 @@ from ..utils import (
     unified_strdate,
     unsmuggle_url,
     uppercase_escape,
+    url_or_none,
     urlencode_postdata,
 )
 
@@ -1386,8 +1387,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
             self._downloader.report_warning(err_msg)
             return {}
 
-    def _mark_watched(self, video_id, video_info):
-        playback_url = video_info.get('videostats_playback_base_url', [None])[0]
+    def _mark_watched(self, video_id, video_info, player_response):
+        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:
             return
         parsed_playback_url = compat_urlparse.urlparse(playback_url)
@@ -2122,7 +2126,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
 
         self._sort_formats(formats)
 
-        self.mark_watched(video_id, video_info)
+        self.mark_watched(video_id, video_info, player_response)
 
         return {
             'id': video_id,