mirror of
https://github.com/yt-dlp/yt-dlp
synced 2025-02-14 20:48:16 +01:00
Use the same device_id in playlists
This commit is contained in:
parent
f87558f7a5
commit
058ac436ba
2 changed files with 26 additions and 8 deletions
|
@ -1868,6 +1868,9 @@ The following extractors use this feature:
|
||||||
#### digitalconcerthall
|
#### digitalconcerthall
|
||||||
* `prefer_combined_hls`: Prefer extracting combined/pre-merged video and audio HLS formats. This will exclude 4K/HEVC video and lossless/FLAC audio formats, which are only available as split video/audio HLS formats
|
* `prefer_combined_hls`: Prefer extracting combined/pre-merged video and audio HLS formats. This will exclude 4K/HEVC video and lossless/FLAC audio formats, which are only available as split video/audio HLS formats
|
||||||
|
|
||||||
|
#### anigamer
|
||||||
|
* `device_id`: (optional) Device ID got from `https://ani.gamer.com.tw/ajax/getdeviceid.php` (bound to cookies and `User-Agent` HTTP header). The extractor will automatically fetch one if it is not present. E.g. `"anigamer:device_id=1234567890abcdef1234567890abcdef1234567890abcdef1234567890ab"`
|
||||||
|
|
||||||
**Note**: These options may be changed/removed in the future without concern for backward compatibility
|
**Note**: These options may be changed/removed in the future without concern for backward compatibility
|
||||||
|
|
||||||
<!-- MANPAGE: MOVE "INSTALLATION" SECTION HERE -->
|
<!-- MANPAGE: MOVE "INSTALLATION" SECTION HERE -->
|
||||||
|
|
|
@ -1,5 +1,11 @@
|
||||||
from .common import InfoExtractor
|
from .common import InfoExtractor
|
||||||
from ..utils import float_or_none, smuggle_url, unified_timestamp, unsmuggle_url
|
from ..utils import (
|
||||||
|
ExtractorError,
|
||||||
|
float_or_none,
|
||||||
|
smuggle_url,
|
||||||
|
unified_timestamp,
|
||||||
|
unsmuggle_url,
|
||||||
|
)
|
||||||
from ..utils.traversal import traverse_obj
|
from ..utils.traversal import traverse_obj
|
||||||
|
|
||||||
|
|
||||||
|
@ -18,10 +24,13 @@ class AniGamerIE(InfoExtractor):
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
url, unsmuggled_data = unsmuggle_url(url, {})
|
url, unsmuggled_data = unsmuggle_url(url, {})
|
||||||
video_id = self._match_id(url)
|
video_id = self._match_id(url)
|
||||||
device_id = self._download_json(
|
device_id = (
|
||||||
'https://ani.gamer.com.tw/ajax/getdeviceid.php', video_id,
|
self._configuration_arg('device_id', [None], casesense=True)[0]
|
||||||
'Downloading device ID', 'Failed to download device ID',
|
or unsmuggled_data.get('device_id')
|
||||||
headers=self.geo_verification_headers())['deviceid']
|
or self._download_json(
|
||||||
|
'https://ani.gamer.com.tw/ajax/getdeviceid.php', video_id,
|
||||||
|
'Downloading device ID', 'Failed to download device ID',
|
||||||
|
headers=self.geo_verification_headers())['deviceid'])
|
||||||
metadata = {}
|
metadata = {}
|
||||||
format_id = '0'
|
format_id = '0'
|
||||||
if api_result := self._download_json(
|
if api_result := self._download_json(
|
||||||
|
@ -42,9 +51,9 @@ class AniGamerIE(InfoExtractor):
|
||||||
(self.url_result(
|
(self.url_result(
|
||||||
smuggle_url(f'https://ani.gamer.com.tw/animeVideo.php?sn={ep["videoSn"]}', {
|
smuggle_url(f'https://ani.gamer.com.tw/animeVideo.php?sn={ep["videoSn"]}', {
|
||||||
'extract_playlist': False,
|
'extract_playlist': False,
|
||||||
}),
|
'device_id': device_id,
|
||||||
AniGamerIE,
|
}), ie=AniGamerIE,
|
||||||
video_id=ep['videoSn'], thumbnail=ep['cover']) for ep in traverse_obj(
|
video_id=ep['videoSn'], thumbnail=ep.get('cover')) for ep in traverse_obj(
|
||||||
api_result,
|
api_result,
|
||||||
# This (the first ellipsis) extracts episodes of all languages,
|
# This (the first ellipsis) extracts episodes of all languages,
|
||||||
# maybe just extract episodes of the current language?
|
# maybe just extract episodes of the current language?
|
||||||
|
@ -69,6 +78,12 @@ class AniGamerIE(InfoExtractor):
|
||||||
error_code = traverse_obj(m3u8_info, ('error', 'code'))
|
error_code = traverse_obj(m3u8_info, ('error', 'code'))
|
||||||
if error_code == 1011:
|
if error_code == 1011:
|
||||||
self.raise_geo_restricted()
|
self.raise_geo_restricted()
|
||||||
|
elif error_code == 1007:
|
||||||
|
if unsmuggled_data.pop('device_id', None):
|
||||||
|
return self.url_result(
|
||||||
|
smuggle_url(f'https://ani.gamer.com.tw/animeVideo.php?sn={video_id}',
|
||||||
|
unsmuggled_data), ie=AniGamerIE, video_id=video_id)
|
||||||
|
raise ExtractorError('Invalid device id!')
|
||||||
# TODO: handle more error codes
|
# TODO: handle more error codes
|
||||||
src = m3u8_info['src']
|
src = m3u8_info['src']
|
||||||
return {
|
return {
|
||||||
|
|
Loading…
Add table
Reference in a new issue