You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
2.1 KiB

  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. class Varzesh3IE(InfoExtractor):
  9. _VALID_URL = r'(?P<url>(https?://(?:www\.)?video\.varzesh3\.com)/(?P<id>.+))'
  10. _TEST ={
  11. '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/',
  12. 'md5': '2a933874cb7dce4366075281eb49e855',
  13. 'info_dict': {
  14. 'url': 'http://dl1.video.varzesh3.com/video/clip94/1/video/namayeshi/saves_week26.mp4',
  15. 'id': '76337',
  16. 'ext': 'mp4',
  17. 'title': '۵ واکنش برتر دروازه‌بانان؛هفته ۲۶ بوندسلیگا',
  18. 'thumbnail': 'http://video.varzesh3.com/wp-content/uploads/230315_saves_week26.jpg',
  19. 'description': u'فصل ۲۰۱۵-۲۰۱۴',
  20. }
  21. }
  22. def _real_extract(self, url):
  23. video_id = self._match_id(url)
  24. webpage = self._download_webpage(url, video_id)
  25. if not 'shortlink' in webpage:
  26. raise ExtractorError('URL has no videos or there is a problem.')
  27. title = self._html_search_regex(r'meta[^>]+property="og:title"[^>]+content="([^"]+)"', webpage, 'title')
  28. video_link = self._html_search_regex(r'source[^>]+src="([^"]+)"', webpage, 'video_link')
  29. vid_id = self._html_search_regex(r"link[^>]+rel='canonical'[^>]+href='\/\?p=([^']+)'\/>", webpage, 'vid_id')
  30. try:
  31. description = self._html_search_regex(r'<div class="matn">(.*?)</div>', webpage, 'description', flags=re.DOTALL)
  32. except:
  33. description = title
  34. thumbnail = self._html_search_regex(r'link[^>]+rel="image_src"[^>]+href="([^"]+)"', webpage, 'thumbnail')
  35. return {
  36. 'url': video_link,
  37. 'id': vid_id,
  38. 'title': title,
  39. 'ext': video_link.split(".")[-1],
  40. 'description': description,
  41. 'thumbnail': thumbnail,
  42. }