]> jfr.im git - yt-dlp.git/blame - youtube_dl/extractor/criterion.py
Credit @atopuzov for hrti (#9482)
[yt-dlp.git] / youtube_dl / extractor / criterion.py
CommitLineData
159736c1 1# -*- coding: utf-8 -*-
4e415288 2from __future__ import unicode_literals
159736c1
YK
3
4import re
5
6from .common import InfoExtractor
4e415288 7
159736c1
YK
8
9class CriterionIE(InfoExtractor):
4e415288 10 _VALID_URL = r'https?://www\.criterion\.com/films/(?P<id>[0-9]+)-.+'
2d5a8b55 11 _TEST = {
4e415288
PH
12 'url': 'http://www.criterion.com/films/184-le-samourai',
13 'md5': 'bc51beba55685509883a9a7830919ec3',
14 'info_dict': {
15 'id': '184',
16 'ext': 'mp4',
17 'title': 'Le Samouraï',
18 'description': 'md5:a2b4b116326558149bef81f76dcbb93f',
2d5a8b55
YK
19 }
20 }
159736c1
YK
21
22 def _real_extract(self, url):
23 mobj = re.match(self._VALID_URL, url)
4e415288 24 video_id = mobj.group('id')
159736c1
YK
25 webpage = self._download_webpage(url, video_id)
26
4e415288
PH
27 final_url = self._search_regex(
28 r'so.addVariable\("videoURL", "(.+?)"\)\;', webpage, 'video url')
29 title = self._og_search_title(webpage)
36bb63fa 30 description = self._html_search_meta('description', webpage)
4e415288
PH
31 thumbnail = self._search_regex(
32 r'so.addVariable\("thumbnailURL", "(.+?)"\)\;',
33 webpage, 'thumbnail url')
159736c1 34
4e415288
PH
35 return {
36 'id': video_id,
37 'url': final_url,
38 'title': title,
39 'description': description,
40 'thumbnail': thumbnail,
41 }