mirror of
https://github.com/ytdl-org/youtube-dl
synced 2025-12-04 10:33:48 +00:00
parent
39378f7b5c
commit
d65882a022
@ -2177,17 +2177,20 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
return sts
|
return sts
|
||||||
|
|
||||||
def _mark_watched(self, video_id, player_response):
|
def _mark_watched(self, video_id, player_response):
|
||||||
playback_url = url_or_none(try_get(
|
|
||||||
player_response,
|
|
||||||
lambda x: x['playbackTracking']['videostatsPlaybackUrl']['baseUrl']))
|
|
||||||
if not playback_url:
|
|
||||||
return
|
|
||||||
|
|
||||||
# cpn generation algorithm is reverse engineered from base.js.
|
# cpn generation algorithm is reverse engineered from base.js.
|
||||||
# In fact it works even with dummy cpn.
|
# In fact it works even with dummy cpn.
|
||||||
CPN_ALPHABET = string.ascii_letters + string.digits + '-_'
|
CPN_ALPHABET = string.ascii_letters + string.digits + '-_'
|
||||||
cpn = ''.join(CPN_ALPHABET[random.randint(0, 256) & 63] for _ in range(16))
|
cpn = ''.join(CPN_ALPHABET[random.randint(0, 256) & 63] for _ in range(16))
|
||||||
|
|
||||||
|
for is_full, key in enumerate(('videostatsPlaybackUrl', 'videostatsWatchtimeUrl')):
|
||||||
|
label = 'fully ' if is_full > 0 else ''
|
||||||
|
|
||||||
|
playback_url = traverse_obj(player_response, (
|
||||||
|
'playbackTracking'. key, 'baseUrl', T(url_or_none)))
|
||||||
|
if not playback_url:
|
||||||
|
self.report_warning('Unable to mark {0}watched'.format(label))
|
||||||
|
continue
|
||||||
|
|
||||||
# more consistent results setting it to right before the end
|
# more consistent results setting it to right before the end
|
||||||
qs = parse_qs(playback_url)
|
qs = parse_qs(playback_url)
|
||||||
video_length = '{0}'.format(float((qs.get('len') or ['1.5'])[0]) - 1)
|
video_length = '{0}'.format(float((qs.get('len') or ['1.5'])[0]) - 1)
|
||||||
@ -2201,7 +2204,7 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
})
|
})
|
||||||
|
|
||||||
self._download_webpage(
|
self._download_webpage(
|
||||||
playback_url, video_id, 'Marking watched',
|
playback_url, video_id, 'Marking {0}watched'.format(label),
|
||||||
'Unable to mark watched', fatal=False)
|
'Unable to mark watched', fatal=False)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user