mirror of
https://github.com/yt-dlp/yt-dlp
synced 2025-01-30 20:34:40 +01:00
wip
This commit is contained in:
parent
d69dc87e96
commit
21f5db11da
1 changed files with 43 additions and 20 deletions
|
@ -1,23 +1,51 @@
|
||||||
import json
|
import json
|
||||||
|
import time
|
||||||
|
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import (
|
from ..utils import (
|
||||||
|
ExtractorError,
|
||||||
determine_ext,
|
determine_ext,
|
||||||
float_or_none,
|
float_or_none,
|
||||||
join_nonempty,
|
join_nonempty,
|
||||||
|
jwt_decode_hs256,
|
||||||
traverse_obj,
|
traverse_obj,
|
||||||
url_or_none,
|
url_or_none,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
class DailyWireBaseIE(InfoExtractor):
|
class DailyWireBaseIE(InfoExtractor):
|
||||||
|
_NETRC_MACHINE = 'dailywire'
|
||||||
_GRAPHQL_API = 'https://v2server.dailywire.com/app/graphql'
|
_GRAPHQL_API = 'https://v2server.dailywire.com/app/graphql'
|
||||||
|
_GRAPHQL_QUERY = 'query currentPerson { currentPerson { id } }'
|
||||||
|
_HEADERS = {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'apollographql-client-name': 'DW_WEBSITE',
|
||||||
|
'Origin': 'https://www.dailywire.com',
|
||||||
|
}
|
||||||
_JSON_PATH = {
|
_JSON_PATH = {
|
||||||
'episode': ('props', 'pageProps', 'episodeData', 'episode'),
|
'episode': ('props', 'pageProps', 'episodeData', 'episode'),
|
||||||
'videos': ('props', 'pageProps', 'videoData', 'video'),
|
'videos': ('props', 'pageProps', 'videoData', 'video'),
|
||||||
'podcasts': ('props', 'pageProps', 'episode'),
|
'podcasts': ('props', 'pageProps', 'episode'),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
def _perform_login(self, username, password):
|
||||||
|
if 'Authorization' in self._HEADERS:
|
||||||
|
return
|
||||||
|
if username != 'access_token':
|
||||||
|
raise ExtractorError(
|
||||||
|
'Login using username and password is not currently supported. '
|
||||||
|
'Use "--username access_token --password <access_token>" to login using an access token. '
|
||||||
|
'To get your access_token: login to the website, go to Developer Tools > Storage tab > Local Storage > https://www.dailywire.com > find the Key named access_token > copy the corresponding Value', expected=True)
|
||||||
|
try:
|
||||||
|
# validate the token
|
||||||
|
jwt = jwt_decode_hs256(password)
|
||||||
|
if time.time() >= jwt['exp']:
|
||||||
|
raise ValueError('jwt expired')
|
||||||
|
self._HEADERS['Authorization'] = f'Bearer {password}'
|
||||||
|
self.report_login()
|
||||||
|
except ValueError as e:
|
||||||
|
self.report_warning(f'Provided authorization token is invalid ({e!s}). Continuing as guest')
|
||||||
|
|
||||||
def _get_json(self, url):
|
def _get_json(self, url):
|
||||||
sites_type, slug = self._match_valid_url(url).group('sites_type', 'id')
|
sites_type, slug = self._match_valid_url(url).group('sites_type', 'id')
|
||||||
json_data = self._search_nextjs_data(self._download_webpage(url, slug), slug)
|
json_data = self._search_nextjs_data(self._download_webpage(url, slug), slug)
|
||||||
|
@ -62,24 +90,24 @@ class DailyWireIE(DailyWireBaseIE):
|
||||||
'series_id': 'ckzplm0a097fn0826r2vc3j7h',
|
'series_id': 'ckzplm0a097fn0826r2vc3j7h',
|
||||||
'series': 'China: The Enemy Within',
|
'series': 'China: The Enemy Within',
|
||||||
},
|
},
|
||||||
# }, {
|
}, {
|
||||||
# 'url': 'https://www.dailywire.com/episode/2-biden',
|
'url': 'https://www.dailywire.com/episode/2-biden',
|
||||||
# 'info_dict': {
|
'info_dict': {
|
||||||
# 'id': 'ckzsldx8pqpr50a26qgy90f92',
|
'id': 'ckzsldx8pqpr50a26qgy90f92',
|
||||||
# 'ext': 'mp4',
|
'ext': 'mp4',
|
||||||
# 'display_id': '2-biden',
|
'display_id': '2-biden',
|
||||||
# 'title': '2. Biden',
|
'title': '2. Biden',
|
||||||
# 'description': 'md5:23cbc63f41dc3f22d2651013ada70ce5',
|
'description': 'md5:23cbc63f41dc3f22d2651013ada70ce5',
|
||||||
# 'thumbnail': 'https://daily-wire-production.imgix.net/episodes/ckzsldx8pqpr50a26qgy90f92/ckzsldx8pqpr50a26qgy90f92-1648237379060.jpg',
|
'thumbnail': 'https://daily-wire-production.imgix.net/episodes/ckzsldx8pqpr50a26qgy90f92/ckzsldx8pqpr50a26qgy90f92-1648237379060.jpg',
|
||||||
# 'creators': ['Caroline Roberts'],
|
'creators': ['Caroline Roberts'],
|
||||||
# 'series_id': 'ckzplm0a097fn0826r2vc3j7h',
|
'series_id': 'ckzplm0a097fn0826r2vc3j7h',
|
||||||
# 'series': 'China: The Enemy Within',
|
'series': 'China: The Enemy Within',
|
||||||
# },
|
},
|
||||||
}, {
|
}, {
|
||||||
'url': 'https://www.dailywire.com/episode/ep-124-bill-maher',
|
'url': 'https://www.dailywire.com/episode/ep-124-bill-maher',
|
||||||
'info_dict': {
|
'info_dict': {
|
||||||
'id': 'cl0ngbaalplc80894sfdo9edf',
|
'id': 'cl0ngbaalplc80894sfdo9edf',
|
||||||
'ext': 'mp3', # note: mp3 when anonymous user, mp4 when insider user
|
'ext': 'mp4', # note: mp3 when anonymous user, mp4 when insider user
|
||||||
'display_id': 'ep-124-bill-maher',
|
'display_id': 'ep-124-bill-maher',
|
||||||
'title': 'Ep. 124 - Bill Maher',
|
'title': 'Ep. 124 - Bill Maher',
|
||||||
'thumbnail': 'https://daily-wire-production.imgix.net/episodes/cl0ngbaalplc80894sfdo9edf/cl0ngbaalplc80894sfdo9edf-1647065568518.jpg',
|
'thumbnail': 'https://daily-wire-production.imgix.net/episodes/cl0ngbaalplc80894sfdo9edf/cl0ngbaalplc80894sfdo9edf-1647065568518.jpg',
|
||||||
|
@ -98,12 +126,7 @@ class DailyWireIE(DailyWireBaseIE):
|
||||||
result = self._download_json(
|
result = self._download_json(
|
||||||
self._GRAPHQL_API, slug, note='Downloading JSON from GraphQL API',
|
self._GRAPHQL_API, slug, note='Downloading JSON from GraphQL API',
|
||||||
data=json.dumps({'query': self._GRAPHQL_QUERY, 'variables': {'slug': slug}}, separators=(',', ':')).encode(),
|
data=json.dumps({'query': self._GRAPHQL_QUERY, 'variables': {'slug': slug}}, separators=(',', ':')).encode(),
|
||||||
headers={
|
headers=self._HEADERS)['data']['episode']
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'apollographql-client-name': 'DW_WEBSITE',
|
|
||||||
'Origin': 'https://www.dailywire.com',
|
|
||||||
# 'Authorization': 'Bearer ...',
|
|
||||||
})['data']['episode']
|
|
||||||
# self.to_screen(json.dumps(result))
|
# self.to_screen(json.dumps(result))
|
||||||
return slug, result
|
return slug, result
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue