Ir90Tv Add new extractor
[youtube-dl] / youtube_dl / extractor / ir90tv.py
1 # coding: utf-8
2 from __future__ import unicode_literals
3
4 from .common import InfoExtractor
5
6
7 class Ir90TvIE(InfoExtractor):
8     _VALID_URL = r'https?://(?:www\.)?90tv\.ir/video/(?P<id>[0-9]+)/.*'
9     _TEST = {
10         'url': 'http://90tv.ir/video/95719/%D8%B4%D8%A7%DB%8C%D8%B9%D8%A7%D8%AA-%D9%86%D9%82%D9%84-%D9%88-%D8%A7%D9%86%D8%AA%D9%82%D8%A7%D9%84%D8%A7%D8%AA-%D9%85%D9%87%D9%85-%D9%81%D9%88%D8%AA%D8%A8%D8%A7%D9%84-%D8%A7%D8%B1%D9%88%D9%BE%D8%A7-940218',
11         'md5': '411dbd94891381960cb9e13daa47a869',
12         'info_dict': {
13             'id': '95719',
14             'ext': 'mp4',
15             'title': 'شایعات نقل و انتقالات مهم فوتبال اروپا 94/02/18',
16             'thumbnail': 're:^https?://.*\.jpg$',
17         }
18     }
19
20     def _real_extract(self, url):
21         video_id = self._match_id(url)
22         webpage = self._download_webpage(url, video_id)
23
24         # TODO more code goes here, for example ...
25         title = self._html_search_regex(
26             r'<title>\n90tv.ir :: (.*?)</title>', webpage, 'title')
27
28         video_url = self._search_regex(
29             r'<source[^>]+src="([^"]+)"', webpage, 'video url')
30
31         thumbnail = self._search_regex(r'poster="([^"]+)"', webpage, 'thumbnail url')
32         print thumbnail
33
34
35         return {
36             'url': video_url,
37             'id': video_id,
38             'title': title,
39             'video_url' : video_url,
40             'thumbnail' : thumbnail,
41         }