mirror of
https://github.com/yt-dlp/yt-dlp
synced 2025-06-13 11:10:53 -05:00
[ie/youtube] Fix --mark-watched
support (#13222)
Closes #11532 Authored by: iednod55, brian6932 Co-authored-by: iednod55 <210167282+iednod55@users.noreply.github.com>
This commit is contained in:
parent
6121559e02
commit
b5be29fa58
@ -2402,6 +2402,11 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
return sts
|
return sts
|
||||||
|
|
||||||
def _mark_watched(self, video_id, player_responses):
|
def _mark_watched(self, video_id, player_responses):
|
||||||
|
# cpn generation algorithm is reverse engineered from base.js.
|
||||||
|
# In fact it works even with dummy cpn.
|
||||||
|
CPN_ALPHABET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_'
|
||||||
|
cpn = ''.join(CPN_ALPHABET[random.randint(0, 256) & 63] for _ in range(16))
|
||||||
|
|
||||||
for is_full, key in enumerate(('videostatsPlaybackUrl', 'videostatsWatchtimeUrl')):
|
for is_full, key in enumerate(('videostatsPlaybackUrl', 'videostatsWatchtimeUrl')):
|
||||||
label = 'fully ' if is_full else ''
|
label = 'fully ' if is_full else ''
|
||||||
url = get_first(player_responses, ('playbackTracking', key, 'baseUrl'),
|
url = get_first(player_responses, ('playbackTracking', key, 'baseUrl'),
|
||||||
@ -2412,11 +2417,6 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
parsed_url = urllib.parse.urlparse(url)
|
parsed_url = urllib.parse.urlparse(url)
|
||||||
qs = urllib.parse.parse_qs(parsed_url.query)
|
qs = urllib.parse.parse_qs(parsed_url.query)
|
||||||
|
|
||||||
# cpn generation algorithm is reverse engineered from base.js.
|
|
||||||
# In fact it works even with dummy cpn.
|
|
||||||
CPN_ALPHABET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_'
|
|
||||||
cpn = ''.join(CPN_ALPHABET[random.randint(0, 256) & 63] for _ in range(16))
|
|
||||||
|
|
||||||
# # more consistent results setting it to right before the end
|
# # more consistent results setting it to right before the end
|
||||||
video_length = [str(float((qs.get('len') or ['1.5'])[0]) - 1)]
|
video_length = [str(float((qs.get('len') or ['1.5'])[0]) - 1)]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user