Compare commits

..

5 Commits

Author SHA1 Message Date
Christopher Schreiner
4585602504
chore: remove debug print 2023-12-05 22:59:16 +01:00
Christopher Schreiner
caf8f843d8
fix: remove extractor args and add base class
extractor args not needed
add base class
2023-12-05 22:48:25 +01:00
Christopher Schreiner
895b350673
feat(#6643): add test for season download 2023-12-05 19:35:55 +01:00
Christopher Schreiner
dd58743d1d
fix: linting 2023-12-05 19:22:16 +01:00
Christopher Schreiner
245ed7ad06
feat: add season download 2023-12-05 19:18:07 +01:00
2 changed files with 67 additions and 22 deletions

View File

@ -47,7 +47,7 @@ from .acast import (
ACastChannelIE,
)
from .acfun import AcFunVideoIE, AcFunBangumiIE
from .adn import ADNIE
from .adn import ADNIE, ADNSeasonIE
from .adobeconnect import AdobeConnectIE
from .adobetv import (
AdobeTVEmbedIE,

View File

@ -25,8 +25,31 @@ from ..utils import (
)
class ADNIE(InfoExtractor):
class ADNBaseIE(InfoExtractor):
IE_DESC = 'Animation Digital Network'
_NETRC_MACHINE = 'animationdigitalnetwork'
_BASE = 'animationdigitalnetwork.fr'
_API_BASE_URL = 'https://gw.api.' + _BASE + '/'
_PLAYER_BASE_URL = _API_BASE_URL + 'player/'
_HEADERS = {}
_LOGIN_ERR_MESSAGE = 'Unable to log in'
_RSA_KEY = (0x9B42B08905199A5CCE2026274399CA560ECB209EE9878A708B1C0812E1BB8CB5D1FB7441861147C1A1F2F3A0476DD63A9CAC20D3E983613346850AA6CB38F16DC7D720FD7D86FC6E5B3D5BBC72E14CD0BF9E869F2CEA2CCAD648F1DCE38F1FF916CEFB2D339B64AA0264372344BC775E265E8A852F88144AB0BD9AA06C1A4ABB, 65537)
_POS_ALIGN_MAP = {
'start': 1,
'end': 3,
}
_LINE_ALIGN_MAP = {
'middle': 8,
'end': 4,
}
def _get_distribution_language(self, url):
if 'network.de' in url:
return 'de'
return 'fr'
class ADNIE(ADNBaseIE):
_VALID_URL = r'https?://(?:www\.)?(?:animation|anime)digitalnetwork\.(fr|de)/video/[^/]+/(?P<id>\d+)'
_TESTS = [{
'url': 'https://animationdigitalnetwork.fr/video/fruits-basket/9841-episode-1-a-ce-soir',
@ -47,7 +70,7 @@ class ADNIE(InfoExtractor):
'thumbnail': str,
'season': 'Season 1',
},
'skip': 'Only available in region (FR, ...)',
'skip': 'Only available in French end German speaking Europe',
}, {
'url': 'http://animedigitalnetwork.fr/video/blue-exorcist-kyoto-saga/7778-episode-1-debut-des-hostilites',
'only_matching': True,
@ -59,25 +82,9 @@ class ADNIE(InfoExtractor):
'episode_number': 1,
'duration': 1429,
},
# 'skip': 'Only available in DE, AT, CH, LU, LI',
# 'skip': 'Only available in French end German speaking Europe',
}]
_NETRC_MACHINE = 'animationdigitalnetwork'
_BASE = 'animationdigitalnetwork.fr'
_API_BASE_URL = 'https://gw.api.' + _BASE + '/'
_PLAYER_BASE_URL = _API_BASE_URL + 'player/'
_HEADERS = {}
_LOGIN_ERR_MESSAGE = 'Unable to log in'
_RSA_KEY = (0x9B42B08905199A5CCE2026274399CA560ECB209EE9878A708B1C0812E1BB8CB5D1FB7441861147C1A1F2F3A0476DD63A9CAC20D3E983613346850AA6CB38F16DC7D720FD7D86FC6E5B3D5BBC72E14CD0BF9E869F2CEA2CCAD648F1DCE38F1FF916CEFB2D339B64AA0264372344BC775E265E8A852F88144AB0BD9AA06C1A4ABB, 65537)
_POS_ALIGN_MAP = {
'start': 1,
'end': 3,
}
_LINE_ALIGN_MAP = {
'middle': 8,
'end': 4,
}
def _get_subtitles(self, sub_url, video_id):
if not sub_url:
return None
@ -176,7 +183,6 @@ Format: Marked,Start,End,Style,Name,MarginL,MarginR,MarginV,Effect,Text'''
user.get('refreshTokenUrl') or (self._PLAYER_BASE_URL + 'refresh/token'),
video_id, 'Downloading access token', headers={
'X-Player-Refresh-Token': user['refreshToken'],
'X-Target-Distribution': ('de' if 'network.de' in url else 'fr')
}, data=b'')['token']
links_url = try_get(options, lambda x: x['video']['url']) or (video_base_url + 'link')
@ -199,7 +205,7 @@ Format: Marked,Start,End,Style,Name,MarginL,MarginR,MarginV,Effect,Text'''
links_data = self._download_json(
links_url, video_id, 'Downloading links JSON metadata', headers={
'X-Player-Token': authorization,
'X-Target-Distribution': ('de' if 'network.de' in url else 'fr')
'X-Target-Distribution': self._get_distribution_language(url),
}, query={
'freeWithAds': 'true',
'adaptive': 'false',
@ -273,3 +279,42 @@ Format: Marked,Start,End,Style,Name,MarginL,MarginR,MarginV,Effect,Text'''
'average_rating': float_or_none(video.get('rating') or metas.get('rating')),
'comment_count': int_or_none(video.get('commentsCount')),
}
class ADNSeasonIE(ADNIE):
_VALID_URL = r'https?://(?:www\.)?(?:animation|anime)digitalnetwork\.(fr|de)/video/(?P<id>[^/]+)/?$'
_TESTS = [{
'url': 'https://animationdigitalnetwork.fr/video/tokyo-mew-mew-new',
'playlist_count': 12,
'info_dict': {
'id': 911,
'title': 'Tokyo Mew Mew New',
},
# 'skip': 'Only available in French end German speaking Europe',
}]
def _real_extract(self, url):
video_show_slug = self._match_id(url)
video_base_url = self._API_BASE_URL + 'show/%s/' % video_show_slug
show = self._download_json(
video_base_url, video_show_slug,
'Downloading show JSON metadata',
headers=self._HEADERS)['show']
show_id = show['id']
lang = self._get_distribution_language(url)
episodes = self._download_json(
self._API_BASE_URL + 'video/show/%s' % show_id, video_show_slug,
'Downloading episode list', headers={
'X-Target-Distribution': lang,
}, query={
'order': 'asc',
'limit': '-1',
})
entries = []
for episode in episodes['videos']:
entries.append(self.url_result(
'https://animationdigitalnetwork.%s/video/%s/%s' % (lang, video_show_slug, episode['id']),
ie=ADNIE.ie_key(),
video_id=episode['id']
))
return self.playlist_result(entries, show_id, show['title'])