mirror of
https://github.com/ytdl-org/youtube-dl
synced 2024-12-25 06:25:51 +01:00
parent
34866b4836
commit
799207e838
@ -42,6 +42,11 @@ try:
|
|||||||
except ImportError: # Python 2
|
except ImportError: # Python 2
|
||||||
import cookielib as compat_cookiejar
|
import cookielib as compat_cookiejar
|
||||||
|
|
||||||
|
try:
|
||||||
|
import http.cookies as compat_cookies
|
||||||
|
except ImportError: # Python 2
|
||||||
|
import Cookie as compat_cookies
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import html.entities as compat_html_entities
|
import html.entities as compat_html_entities
|
||||||
except ImportError: # Python 2
|
except ImportError: # Python 2
|
||||||
@ -436,6 +441,7 @@ __all__ = [
|
|||||||
'compat_basestring',
|
'compat_basestring',
|
||||||
'compat_chr',
|
'compat_chr',
|
||||||
'compat_cookiejar',
|
'compat_cookiejar',
|
||||||
|
'compat_cookies',
|
||||||
'compat_expanduser',
|
'compat_expanduser',
|
||||||
'compat_get_terminal_size',
|
'compat_get_terminal_size',
|
||||||
'compat_getenv',
|
'compat_getenv',
|
||||||
|
@ -14,10 +14,12 @@ import xml.etree.ElementTree
|
|||||||
|
|
||||||
from ..compat import (
|
from ..compat import (
|
||||||
compat_cookiejar,
|
compat_cookiejar,
|
||||||
|
compat_cookies,
|
||||||
compat_HTTPError,
|
compat_HTTPError,
|
||||||
compat_http_client,
|
compat_http_client,
|
||||||
compat_urllib_error,
|
compat_urllib_error,
|
||||||
compat_urllib_parse_urlparse,
|
compat_urllib_parse_urlparse,
|
||||||
|
compat_urllib_request,
|
||||||
compat_urlparse,
|
compat_urlparse,
|
||||||
compat_str,
|
compat_str,
|
||||||
)
|
)
|
||||||
@ -1074,6 +1076,12 @@ class InfoExtractor(object):
|
|||||||
None, '/', True, False, expire_time, '', None, None, None)
|
None, '/', True, False, expire_time, '', None, None, None)
|
||||||
self._downloader.cookiejar.set_cookie(cookie)
|
self._downloader.cookiejar.set_cookie(cookie)
|
||||||
|
|
||||||
|
def _get_cookies(self, url):
|
||||||
|
""" Return a compat_cookies.SimpleCookie with the cookies for the url """
|
||||||
|
req = compat_urllib_request.Request(url)
|
||||||
|
self._downloader.cookiejar.add_cookie_header(req)
|
||||||
|
return compat_cookies.SimpleCookie(req.get_header('Cookie'))
|
||||||
|
|
||||||
def get_testcases(self, include_onlymatching=False):
|
def get_testcases(self, include_onlymatching=False):
|
||||||
t = getattr(self, '_TEST', None)
|
t = getattr(self, '_TEST', None)
|
||||||
if t:
|
if t:
|
||||||
|
@ -62,7 +62,6 @@ class ViewsterIE(InfoExtractor):
|
|||||||
}]
|
}]
|
||||||
|
|
||||||
_ACCEPT_HEADER = 'application/json, text/javascript, */*; q=0.01'
|
_ACCEPT_HEADER = 'application/json, text/javascript, */*; q=0.01'
|
||||||
_AUTH_TOKEN = '/YqhSYsx8EaU9Bsta3ojlA=='
|
|
||||||
|
|
||||||
def _download_json(self, url, video_id, note='Downloading JSON metadata', fatal=True):
|
def _download_json(self, url, video_id, note='Downloading JSON metadata', fatal=True):
|
||||||
request = compat_urllib_request.Request(url)
|
request = compat_urllib_request.Request(url)
|
||||||
@ -72,6 +71,10 @@ class ViewsterIE(InfoExtractor):
|
|||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
|
# Get 'api_token' cookie
|
||||||
|
self._request_webpage(url, video_id)
|
||||||
|
cookies = self._get_cookies(url)
|
||||||
|
self._AUTH_TOKEN = compat_urllib_parse.unquote(cookies['api_token'].value)
|
||||||
|
|
||||||
info = self._download_json(
|
info = self._download_json(
|
||||||
'https://public-api.viewster.com/search/%s' % video_id,
|
'https://public-api.viewster.com/search/%s' % video_id,
|
||||||
|
Loading…
Reference in New Issue
Block a user