aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/movingimage.py
diff options
context:
space:
mode:
authorYen Chi Hsuan <yan12125@gmail.com>2016-09-01 16:58:16 +0800
committerYen Chi Hsuan <yan12125@gmail.com>2016-09-01 16:58:16 +0800
commit05d4612947d6dbfaedb8f2a00daa5f29d85f73df (patch)
tree56f6142438e6c569148a9707dfb665fbdad1be50 /youtube_dl/extractor/movingimage.py
parent746a695b362cb602625ed7357294bb18de133883 (diff)
[movingimage] Adapt to the new domain name and fix extraction
Closes #10466
Diffstat (limited to 'youtube_dl/extractor/movingimage.py')
-rw-r--r--youtube_dl/extractor/movingimage.py52
1 files changed, 52 insertions, 0 deletions
diff --git a/youtube_dl/extractor/movingimage.py b/youtube_dl/extractor/movingimage.py
new file mode 100644
index 000000000..bb789c32e
--- /dev/null
+++ b/youtube_dl/extractor/movingimage.py
@@ -0,0 +1,52 @@
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+from ..utils import (
+ unescapeHTML,
+ parse_duration,
+)
+
+
+class MovingImageIE(InfoExtractor):
+ _VALID_URL = r'https?://movingimage\.nls\.uk/film/(?P<id>\d+)'
+ _TEST = {
+ 'url': 'http://movingimage.nls.uk/film/3561',
+ 'md5': '4caa05c2b38453e6f862197571a7be2f',
+ 'info_dict': {
+ 'id': '3561',
+ 'ext': 'mp4',
+ 'title': 'SHETLAND WOOL',
+ 'description': 'md5:c5afca6871ad59b4271e7704fe50ab04',
+ 'duration': 900,
+ 'thumbnail': 're:^https?://.*\.jpg$',
+ },
+ }
+
+ def _real_extract(self, url):
+ video_id = self._match_id(url)
+
+ webpage = self._download_webpage(url, video_id)
+
+ formats = self._extract_m3u8_formats(
+ self._html_search_regex(r'file\s*:\s*"([^"]+)"', webpage, 'm3u8 manifest URL'),
+ video_id, ext='mp4', entry_protocol='m3u8_native')
+
+ def search_field(field_name, fatal=False):
+ return self._search_regex(
+ r'<span\s+class="field_title">%s:</span>\s*<span\s+class="field_content">([^<]+)</span>' % field_name,
+ webpage, 'title', fatal=fatal)
+
+ title = unescapeHTML(search_field('Title', fatal=True)).strip('()[]')
+ description = unescapeHTML(search_field('Description'))
+ duration = parse_duration(search_field('Running time'))
+ thumbnail = self._search_regex(
+ r"image\s*:\s*'([^']+)'", webpage, 'thumbnail', fatal=False)
+
+ return {
+ 'id': video_id,
+ 'formats': formats,
+ 'title': title,
+ 'description': description,
+ 'duration': duration,
+ 'thumbnail': thumbnail,
+ }