]> jfr.im git - yt-dlp.git/blame - yt_dlp/extractor/wakanim.py
[test/download] Fallback test to `bv`
[yt-dlp.git] / yt_dlp / extractor / wakanim.py
CommitLineData
845333ac
S
1# coding: utf-8
2from __future__ import unicode_literals
3
dc88e9be 4from urllib.parse import unquote
5
845333ac
S
6from .common import InfoExtractor
7from ..utils import (
8 merge_dicts,
9 urljoin,
10)
11
12
13class WakanimIE(InfoExtractor):
14 _VALID_URL = r'https://(?:www\.)?wakanim\.tv/[^/]+/v2/catalogue/episode/(?P<id>\d+)'
30cd1a5f 15 _TESTS = [{
845333ac
S
16 'url': 'https://www.wakanim.tv/de/v2/catalogue/episode/2997/the-asterisk-war-omu-staffel-1-episode-02-omu',
17 'info_dict': {
18 'id': '2997',
19 'ext': 'mp4',
20 'title': 'Episode 02',
21 'description': 'md5:2927701ea2f7e901de8bfa8d39b2852d',
22 'series': 'The Asterisk War (OmU.)',
23 'season_number': 1,
24 'episode': 'Episode 02',
25 'episode_number': 2,
26 },
27 'params': {
845333ac
S
28 'skip_download': True,
29 },
30cd1a5f
RA
30 }, {
31 # DRM Protected
32 'url': 'https://www.wakanim.tv/de/v2/catalogue/episode/7843/sword-art-online-alicization-omu-arc-2-folge-15-omu',
33 'only_matching': True,
34 }]
bd1c7923 35 _GEO_BYPASS = False
845333ac
S
36
37 def _real_extract(self, url):
38 video_id = self._match_id(url)
39
40 webpage = self._download_webpage(url, video_id)
41
bd1c7923 42 if 'Geoblocking' in webpage:
43 if '/de/' in url:
44 self.raise_geo_restricted(countries=['DE', 'AT', 'CH'])
45 else:
46 self.raise_geo_restricted(countries=['RU'])
47
dc88e9be 48 manifest_url = urljoin(url, self._search_regex(
49 r'file\s*:\s*(["\'])(?P<url>(?:(?!\1).)+)\1', webpage, 'manifest url',
845333ac 50 group='url'))
a06916d9 51 if not self.get_param('allow_unplayable_formats'):
06869367 52 # https://docs.microsoft.com/en-us/azure/media-services/previous/media-services-content-protection-overview#streaming-urls
53 encryption = self._search_regex(
54 r'encryption%3D(c(?:enc|bc(?:s-aapl)?))',
dc88e9be 55 manifest_url, 'encryption', default=None)
06869367 56 if encryption in ('cenc', 'cbcs-aapl'):
88acdbc2 57 self.report_drm(video_id)
845333ac 58
dc88e9be 59 if 'format=mpd-time-cmaf' in unquote(manifest_url):
60 formats = self._extract_mpd_formats(
61 manifest_url, video_id, mpd_id='dash')
62 else:
63 formats = self._extract_m3u8_formats(
64 manifest_url, video_id, 'mp4', entry_protocol='m3u8_native',
65 m3u8_id='hls')
845333ac
S
66
67 info = self._search_json_ld(webpage, video_id, default={})
68
69 title = self._search_regex(
70 (r'<h1[^>]+\bclass=["\']episode_h1[^>]+\btitle=(["\'])(?P<title>(?:(?!\1).)+)\1',
71 r'<span[^>]+\bclass=["\']episode_title["\'][^>]*>(?P<title>[^<]+)'),
72 webpage, 'title', default=None, group='title')
73
74 return merge_dicts(info, {
75 'id': video_id,
76 'title': title,
77 'formats': formats,
78 })