mirror of
https://github.com/yt-dlp/yt-dlp
synced 2025-01-15 03:41:33 +01:00
[ie/anigamer] rename to bahamut
This commit is contained in:
parent
f8e15176cb
commit
ce031318fd
3 changed files with 32 additions and 23 deletions
|
@ -1868,8 +1868,8 @@ 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
|
#### bahamut
|
||||||
* `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"`
|
* `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. `"bahamut: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
|
||||||
|
|
||||||
|
|
|
@ -127,7 +127,6 @@ from .americastestkitchen import (
|
||||||
)
|
)
|
||||||
from .anchorfm import AnchorFMEpisodeIE
|
from .anchorfm import AnchorFMEpisodeIE
|
||||||
from .angel import AngelIE
|
from .angel import AngelIE
|
||||||
from .anigamer import AniGamerIE
|
|
||||||
from .antenna import (
|
from .antenna import (
|
||||||
Ant1NewsGrArticleIE,
|
Ant1NewsGrArticleIE,
|
||||||
Ant1NewsGrEmbedIE,
|
Ant1NewsGrEmbedIE,
|
||||||
|
@ -197,6 +196,7 @@ from .awaan import (
|
||||||
)
|
)
|
||||||
from .axs import AxsIE
|
from .axs import AxsIE
|
||||||
from .azmedien import AZMedienIE
|
from .azmedien import AZMedienIE
|
||||||
|
from .bahamut import BahamutIE
|
||||||
from .baidu import BaiduVideoIE
|
from .baidu import BaiduVideoIE
|
||||||
from .banbye import (
|
from .banbye import (
|
||||||
BanByeChannelIE,
|
BanByeChannelIE,
|
||||||
|
|
|
@ -9,16 +9,17 @@ from ..utils import (
|
||||||
from ..utils.traversal import traverse_obj
|
from ..utils.traversal import traverse_obj
|
||||||
|
|
||||||
|
|
||||||
class AniGamerIE(InfoExtractor):
|
class BahamutIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://ani\.gamer\.com\.tw/animeVideo\.php\?sn=(?P<id>\d+)'
|
_VALID_URL = r'https?://ani\.gamer\.com\.tw/animeVideo\.php\?sn=(?P<id>\d+)'
|
||||||
|
|
||||||
|
# see anime_player.js
|
||||||
RATING_TO_AGE_LIMIT = {
|
RATING_TO_AGE_LIMIT = {
|
||||||
1: 0,
|
1: 0,
|
||||||
2: 6,
|
2: 6,
|
||||||
3: 12,
|
3: 12,
|
||||||
4: 15,
|
4: 15,
|
||||||
# Seems like there's no age limit for '5'
|
5: 18,
|
||||||
6: 18,
|
6: 18, # age-gated, needs login
|
||||||
}
|
}
|
||||||
|
|
||||||
def _real_extract(self, url):
|
def _real_extract(self, url):
|
||||||
|
@ -31,8 +32,9 @@ class AniGamerIE(InfoExtractor):
|
||||||
'https://ani.gamer.com.tw/ajax/getdeviceid.php', video_id,
|
'https://ani.gamer.com.tw/ajax/getdeviceid.php', video_id,
|
||||||
'Downloading device ID', 'Failed to download device ID',
|
'Downloading device ID', 'Failed to download device ID',
|
||||||
headers=self.geo_verification_headers())['deviceid'])
|
headers=self.geo_verification_headers())['deviceid'])
|
||||||
|
|
||||||
|
# TODO: extract metadata from webpage
|
||||||
metadata = {}
|
metadata = {}
|
||||||
# format_id = '0'
|
|
||||||
if api_result := self._download_json(
|
if api_result := self._download_json(
|
||||||
'https://api.gamer.com.tw/anime/v1/video.php', video_id,
|
'https://api.gamer.com.tw/anime/v1/video.php', video_id,
|
||||||
'Downloading video info', 'Failed to download video info',
|
'Downloading video info', 'Failed to download video info',
|
||||||
|
@ -52,7 +54,7 @@ class AniGamerIE(InfoExtractor):
|
||||||
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,
|
'device_id': device_id,
|
||||||
}), ie=AniGamerIE,
|
}), ie=BahamutIE,
|
||||||
video_id=ep['videoSn'], thumbnail=ep.get('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,
|
||||||
|
@ -68,23 +70,30 @@ class AniGamerIE(InfoExtractor):
|
||||||
'duration': ('duration', {float_or_none}, {lambda x: x * 60}),
|
'duration': ('duration', {float_or_none}, {lambda x: x * 60}),
|
||||||
'age_limit': ('rating', {lambda x: self.RATING_TO_AGE_LIMIT.get(x)}),
|
'age_limit': ('rating', {lambda x: self.RATING_TO_AGE_LIMIT.get(x)}),
|
||||||
})))
|
})))
|
||||||
# format_id = traverse_obj(api_result, ('video', 'quality'), default=format_id)
|
|
||||||
|
|
||||||
m3u8_info = self._download_json('https://ani.gamer.com.tw/ajax/m3u8.php', video_id, query={
|
m3u8_info, urlh = self._download_json_handle(
|
||||||
'sn': video_id,
|
'https://ani.gamer.com.tw/ajax/m3u8.php', video_id,
|
||||||
'device': device_id,
|
note='Downloading m3u8 URL', errnote='Failed to download m3u8 URL', query={
|
||||||
}, headers=self.geo_verification_headers(), expected_status=400)
|
'sn': video_id,
|
||||||
|
'device': device_id,
|
||||||
|
}, headers=self.geo_verification_headers(), expected_status=400)
|
||||||
|
|
||||||
|
if urlh.status == 400:
|
||||||
|
# TODO: handle more error codes, search for /case \d+{4}:/g in anime_player.js
|
||||||
|
error_code = traverse_obj(m3u8_info, ('error', 'code'))
|
||||||
|
if error_code == 1011:
|
||||||
|
self.raise_geo_restricted()
|
||||||
|
elif error_code == 1007:
|
||||||
|
if unsmuggled_data.pop('device_id', None) is not None:
|
||||||
|
return self.url_result(
|
||||||
|
smuggle_url(f'https://ani.gamer.com.tw/animeVideo.php?sn={video_id}',
|
||||||
|
unsmuggled_data), ie=BahamutIE, video_id=video_id)
|
||||||
|
raise ExtractorError('Invalid device id!')
|
||||||
|
elif error_code == 1017:
|
||||||
|
self.raise_login_required()
|
||||||
|
raise ExtractorError(traverse_obj(m3u8_info, ('error', 'message'))
|
||||||
|
or 'Failed to download m3u8 URL')
|
||||||
|
|
||||||
error_code = traverse_obj(m3u8_info, ('error', 'code'))
|
|
||||||
if error_code == 1011:
|
|
||||||
self.raise_geo_restricted()
|
|
||||||
elif error_code == 1007:
|
|
||||||
if unsmuggled_data.pop('device_id', None) is not 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
|
|
||||||
src = m3u8_info['src']
|
src = m3u8_info['src']
|
||||||
return {
|
return {
|
||||||
**metadata,
|
**metadata,
|
Loading…
Reference in a new issue