Added test for dump.com
[youtube-dl] / youtube_dl / extractor / dump.py
1 # encoding: utf-8
2 from __future__ import unicode_literals
3
4 import re
5
6 from .common import InfoExtractor
7 from ..utils import (
8     ExtractorError,
9 )
10
11 class DumpIE(InfoExtractor):
12     _VALID_URL = r'^https?://(?:www\.)?dump\.com/(?P<id>[a-zA-Z0-9]+)/'
13
14     _TEST = {
15         u'url': u'http://www.dump.com/oneus/',
16         u'file': u'oneus.flv',
17         u'md5': u'ad71704d1e67dfd9e81e3e8b42d69d99',
18         u'info_dict': {
19             u"title": u"He's one of us.",
20         },
21     }
22
23     def _real_extract(self, url):
24         m = re.match(self._VALID_URL, url)
25         video_id = m.group('id')
26
27         # Note: There is an easier-to-parse configuration at
28         # http://www.aparat.com/video/video/config/videohash/%video_id
29         # but the URL in there does not work
30
31         webpage = self._download_webpage(url, video_id)
32
33         try:
34             video_url = re.findall(r'file","(.+?.flv)"', webpage)[-1]
35         except IndexError:
36             raise ExtractorError(u'No video URL found')
37
38         thumb = re.findall('<meta property="og:image" content="(.+?)"',webpage)[0]
39
40         title = self._search_regex(r'<b>([^"]+)</b>', webpage, u'title')
41
42         return {
43             'id': video_id,
44             'title': title,
45             'url': video_url,
46             'ext': 'flv',
47             'thumbnail': thumb,
48         }