mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-15 13:43:04 +00:00
Compare commits
No commits in common. "379a4f161d4ad3e40932dcf5aca6e6fb9715ab28" and "9809740ba5cc5daf53e690d104a37aa6545e53f9" have entirely different histories.
379a4f161d
...
9809740ba5
@ -119,16 +119,16 @@ class DropoutIE(InfoExtractor):
|
|||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
display_id = self._match_id(url)
|
display_id = self._match_id(url)
|
||||||
|
login_err, webpage = False, ''
|
||||||
webpage = None
|
try:
|
||||||
if self._get_cookies('https://www.dropout.tv').get('_session'):
|
|
||||||
webpage = self._download_webpage(url, display_id)
|
|
||||||
if not webpage or '<div id="watch-unauthorized"' in webpage:
|
|
||||||
login_err = self._login(display_id)
|
login_err = self._login(display_id)
|
||||||
webpage = self._download_webpage(url, display_id)
|
webpage = self._download_webpage(url, display_id)
|
||||||
if login_err and '<div id="watch-unauthorized"' in webpage:
|
finally:
|
||||||
|
if not login_err:
|
||||||
|
self._download_webpage('https://www.dropout.tv/logout', display_id, note='Logging out', fatal=False)
|
||||||
|
elif '<div id="watch-unauthorized"' in webpage:
|
||||||
if login_err is True:
|
if login_err is True:
|
||||||
self.raise_login_required(method='any')
|
self.raise_login_required(method='password')
|
||||||
raise ExtractorError(login_err, expected=True)
|
raise ExtractorError(login_err, expected=True)
|
||||||
|
|
||||||
embed_url = self._search_regex(r'embed_url:\s*["\'](.+?)["\']', webpage, 'embed url')
|
embed_url = self._search_regex(r'embed_url:\s*["\'](.+?)["\']', webpage, 'embed url')
|
||||||
|
@ -2643,45 +2643,30 @@ class YoutubeIE(YoutubeBaseInfoExtractor):
|
|||||||
return sts
|
return sts
|
||||||
|
|
||||||
def _mark_watched(self, video_id, player_responses):
|
def _mark_watched(self, video_id, player_responses):
|
||||||
for is_full, key in enumerate(('videostatsPlaybackUrl', 'videostatsWatchtimeUrl')):
|
playback_url = get_first(
|
||||||
label = 'fully ' if is_full else ''
|
player_responses, ('playbackTracking', 'videostatsPlaybackUrl', 'baseUrl'),
|
||||||
url = get_first(player_responses, ('playbackTracking', key, 'baseUrl'),
|
expected_type=url_or_none)
|
||||||
expected_type=url_or_none)
|
if not playback_url:
|
||||||
if not url:
|
self.report_warning('Unable to mark watched')
|
||||||
self.report_warning(f'Unable to mark {label}watched')
|
return
|
||||||
return
|
parsed_playback_url = compat_urlparse.urlparse(playback_url)
|
||||||
parsed_url = compat_urlparse.urlparse(url)
|
qs = compat_urlparse.parse_qs(parsed_playback_url.query)
|
||||||
qs = compat_urlparse.parse_qs(parsed_url.query)
|
|
||||||
|
|
||||||
# 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 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_'
|
CPN_ALPHABET = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_'
|
||||||
cpn = ''.join(CPN_ALPHABET[random.randint(0, 256) & 63] for _ in range(0, 16))
|
cpn = ''.join(CPN_ALPHABET[random.randint(0, 256) & 63] for _ in range(0, 16))
|
||||||
|
|
||||||
# # more consistent results setting it to right before the end
|
qs.update({
|
||||||
video_length = [str(float((qs.get('len') or ['1.5'])[0]) - 1)]
|
'ver': ['2'],
|
||||||
|
'cpn': [cpn],
|
||||||
|
})
|
||||||
|
playback_url = compat_urlparse.urlunparse(
|
||||||
|
parsed_playback_url._replace(query=compat_urllib_parse_urlencode(qs, True)))
|
||||||
|
|
||||||
qs.update({
|
self._download_webpage(
|
||||||
'ver': ['2'],
|
playback_url, video_id, 'Marking watched',
|
||||||
'cpn': [cpn],
|
'Unable to mark watched', fatal=False)
|
||||||
'cmt': video_length,
|
|
||||||
'el': 'detailpage', # otherwise defaults to "shorts"
|
|
||||||
})
|
|
||||||
|
|
||||||
if is_full:
|
|
||||||
# these seem to mark watchtime "history" in the real world
|
|
||||||
# they're required, so send in a single value
|
|
||||||
qs.update({
|
|
||||||
'st': video_length,
|
|
||||||
'et': video_length,
|
|
||||||
})
|
|
||||||
|
|
||||||
url = compat_urlparse.urlunparse(
|
|
||||||
parsed_url._replace(query=compat_urllib_parse_urlencode(qs, True)))
|
|
||||||
|
|
||||||
self._download_webpage(
|
|
||||||
url, video_id, f'Marking {label}watched',
|
|
||||||
'Unable to mark watched', fatal=False)
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _extract_urls(webpage):
|
def _extract_urls(webpage):
|
||||||
|
@ -1343,7 +1343,7 @@ class YoutubeDLHandler(compat_urllib_request.HTTPHandler):
|
|||||||
|
|
||||||
req.headers = handle_youtubedl_headers(req.headers)
|
req.headers = handle_youtubedl_headers(req.headers)
|
||||||
|
|
||||||
return super().do_request_(req)
|
return req
|
||||||
|
|
||||||
def http_response(self, req, resp):
|
def http_response(self, req, resp):
|
||||||
old_resp = resp
|
old_resp = resp
|
||||||
|
Loading…
Reference in New Issue
Block a user