]>
Commit | Line | Data |
---|---|---|
c792b501 S |
1 | from .common import InfoExtractor |
2 | from ..utils import ( | |
c792b501 | 3 | parse_duration, |
e897bd82 | 4 | unescapeHTML, |
c792b501 S |
5 | ) |
6 | ||
7 | ||
05d46129 YCH |
8 | class MovingImageIE(InfoExtractor): |
9 | _VALID_URL = r'https?://movingimage\.nls\.uk/film/(?P<id>\d+)' | |
c792b501 | 10 | _TEST = { |
05d46129 YCH |
11 | 'url': 'http://movingimage.nls.uk/film/3561', |
12 | 'md5': '4caa05c2b38453e6f862197571a7be2f', | |
c792b501 S |
13 | 'info_dict': { |
14 | 'id': '3561', | |
05d46129 | 15 | 'ext': 'mp4', |
c792b501 S |
16 | 'title': 'SHETLAND WOOL', |
17 | 'description': 'md5:c5afca6871ad59b4271e7704fe50ab04', | |
18 | 'duration': 900, | |
ec85ded8 | 19 | 'thumbnail': r're:^https?://.*\.jpg$', |
c792b501 | 20 | }, |
c792b501 S |
21 | } |
22 | ||
23 | def _real_extract(self, url): | |
24 | video_id = self._match_id(url) | |
25 | ||
26 | webpage = self._download_webpage(url, video_id) | |
27 | ||
05d46129 YCH |
28 | formats = self._extract_m3u8_formats( |
29 | self._html_search_regex(r'file\s*:\s*"([^"]+)"', webpage, 'm3u8 manifest URL'), | |
30 | video_id, ext='mp4', entry_protocol='m3u8_native') | |
c792b501 S |
31 | |
32 | def search_field(field_name, fatal=False): | |
33 | return self._search_regex( | |
34 | r'<span\s+class="field_title">%s:</span>\s*<span\s+class="field_content">([^<]+)</span>' % field_name, | |
35 | webpage, 'title', fatal=fatal) | |
36 | ||
37 | title = unescapeHTML(search_field('Title', fatal=True)).strip('()[]') | |
38 | description = unescapeHTML(search_field('Description')) | |
39 | duration = parse_duration(search_field('Running time')) | |
40 | thumbnail = self._search_regex( | |
05d46129 | 41 | r"image\s*:\s*'([^']+)'", webpage, 'thumbnail', fatal=False) |
c792b501 S |
42 | |
43 | return { | |
44 | 'id': video_id, | |
05d46129 | 45 | 'formats': formats, |
c792b501 S |
46 | 'title': title, |
47 | 'description': description, | |
48 | 'duration': duration, | |
49 | 'thumbnail': thumbnail, | |
50 | } |