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