]>
Commit | Line | Data |
---|---|---|
db40364b MTP |
1 | # coding: utf-8 |
2 | from __future__ import unicode_literals | |
3 | from .common import InfoExtractor | |
4 | from ..utils import ( | |
5 | ExtractorError, | |
6 | ) | |
7 | import re | |
8 | ||
9 | ||
10 | class Varzesh3IE(InfoExtractor): | |
11 | _VALID_URL = r'(?P<url>(https?://(?:www\.)?video\.varzesh3\.com)/(?P<id>.+))' | |
a7fce980 | 12 | _TEST ={ |
db40364b MTP |
13 | 'url': 'http://video.varzesh3.com/germany/bundesliga/5-%D9%88%D8%A7%DA%A9%D9%86%D8%B4-%D8%A8%D8%B1%D8%AA%D8%B1-%D8%AF%D8%B1%D9%88%D8%A7%D8%B2%D9%87%E2%80%8C%D8%A8%D8%A7%D9%86%D8%A7%D9%86%D8%9B%D9%87%D9%81%D8%AA%D9%87-26-%D8%A8%D9%88%D9%86%D8%AF%D8%B3/', |
14 | 'md5': '2a933874cb7dce4366075281eb49e855', | |
15 | 'info_dict': { | |
16 | 'url': 'http://dl1.video.varzesh3.com/video/clip94/1/video/namayeshi/saves_week26.mp4', | |
17 | 'id': '76337', | |
18 | 'ext': 'mp4', | |
8896b614 | 19 | 'title': '۵ واکنش برتر دروازهبانان؛هفته ۲۶ بوندسلیگا', |
db40364b | 20 | 'thumbnail': 'http://video.varzesh3.com/wp-content/uploads/230315_saves_week26.jpg', |
2315fb5e | 21 | 'description': 'فصل ۲۰۱۵-۲۰۱۴', |
db40364b | 22 | } |
a7fce980 | 23 | } |
db40364b MTP |
24 | |
25 | def _real_extract(self, url): | |
26 | video_id = self._match_id(url) | |
27 | webpage = self._download_webpage(url, video_id) | |
28 | ||
29 | if not 'shortlink' in webpage: | |
30 | raise ExtractorError('URL has no videos or there is a problem.') | |
31 | ||
32 | title = self._html_search_regex(r'meta[^>]+property="og:title"[^>]+content="([^"]+)"', webpage, 'title') | |
33 | video_link = self._html_search_regex(r'source[^>]+src="([^"]+)"', webpage, 'video_link') | |
34 | vid_id = self._html_search_regex(r"link[^>]+rel='canonical'[^>]+href='\/\?p=([^']+)'\/>", webpage, 'vid_id') | |
35 | try: | |
36 | description = self._html_search_regex(r'<div class="matn">(.*?)</div>', webpage, 'description', flags=re.DOTALL) | |
37 | except: | |
38 | description = title | |
39 | thumbnail = self._html_search_regex(r'link[^>]+rel="image_src"[^>]+href="([^"]+)"', webpage, 'thumbnail') | |
40 | ||
41 | return { | |
42 | 'url': video_link, | |
43 | 'id': vid_id, | |
44 | 'title': title, | |
45 | 'ext': video_link.split(".")[-1], | |
46 | 'description': description, | |
47 | 'thumbnail': thumbnail, | |
48 | } |