Added an IE 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     def _real_extract(self, url):
15         m = re.match(self._VALID_URL, url)
16         video_id = m.group('id')
17
18         # Note: There is an easier-to-parse configuration at
19         # http://www.aparat.com/video/video/config/videohash/%video_id
20         # but the URL in there does not work
21
22         webpage = self._download_webpage(url, video_id)
23
24         try:
25             video_url = re.findall(r'file","(.+?.flv)"', webpage)[-1]
26         except IndexError:
27             raise ExtractorError(u'No video URL found')
28
29         thumb = re.findall('<meta property="og:image" content="(.+?)"',webpage)[0]
30
31         title = self._search_regex(r'<b>([^"]+)</b>', webpage, u'title')
32
33         return {
34             'id': video_id,
35             'title': title,
36             'url': video_url,
37             'ext': 'flv',
38             'thumbnail': thumb,
39         }