varzesh3.py 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. from .common import InfoExtractor
  2. from ..utils import (
  3. clean_html,
  4. parse_qs,
  5. remove_start,
  6. )
  7. class Varzesh3IE(InfoExtractor):
  8. _WORKING = False
  9. _VALID_URL = r'https?://(?:www\.)?video\.varzesh3\.com/(?:[^/]+/)+(?P<id>[^/]+)/?'
  10. _TESTS = [{
  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. 'id': '76337',
  15. 'ext': 'mp4',
  16. 'title': '۵ واکنش برتر دروازه‌بانان؛هفته ۲۶ بوندسلیگا',
  17. 'description': 'فصل ۲۰۱۵-۲۰۱۴',
  18. 'thumbnail': r're:^https?://.*\.jpg$',
  19. },
  20. 'skip': 'HTTP 404 Error',
  21. }, {
  22. 'url': 'http://video.varzesh3.com/video/112785/%D8%AF%D9%84%D9%87-%D8%B9%D9%84%DB%8C%D8%9B-%D8%B3%D8%AA%D8%A7%D8%B1%D9%87-%D9%86%D9%88%D8%B8%D9%87%D9%88%D8%B1-%D9%84%DB%8C%DA%AF-%D8%A8%D8%B1%D8%AA%D8%B1-%D8%AC%D8%B2%DB%8C%D8%B1%D9%87',
  23. 'md5': '841b7cd3afbc76e61708d94e53a4a4e7',
  24. 'info_dict': {
  25. 'id': '112785',
  26. 'ext': 'mp4',
  27. 'title': 'دله علی؛ ستاره نوظهور لیگ برتر جزیره',
  28. 'description': 'فوتبال 120',
  29. },
  30. 'expected_warnings': ['description'],
  31. }]
  32. def _real_extract(self, url):
  33. display_id = self._match_id(url)
  34. webpage = self._download_webpage(url, display_id)
  35. video_url = self._search_regex(
  36. r'<source[^>]+src="([^"]+)"', webpage, 'video url')
  37. title = remove_start(self._html_extract_title(webpage), 'ویدیو ورزش 3 | ')
  38. description = self._html_search_regex(
  39. r'(?s)<div class="matn">(.+?)</div>',
  40. webpage, 'description', default=None)
  41. if description is None:
  42. description = clean_html(self._html_search_meta('description', webpage))
  43. thumbnail = self._og_search_thumbnail(webpage, default=None)
  44. if thumbnail is None:
  45. fb_sharer_url = self._search_regex(
  46. r'<a[^>]+href="(https?://www\.facebook\.com/sharer/sharer\.php?[^"]+)"',
  47. webpage, 'facebook sharer URL', fatal=False)
  48. sharer_params = parse_qs(fb_sharer_url)
  49. thumbnail = sharer_params.get('p[images][0]', [None])[0]
  50. video_id = self._search_regex(
  51. r"<link[^>]+rel='(?:canonical|shortlink)'[^>]+href='/\?p=([^']+)'",
  52. webpage, display_id, default=None)
  53. if video_id is None:
  54. video_id = self._search_regex(
  55. r'var\s+VideoId\s*=\s*(\d+);', webpage, 'video id',
  56. default=display_id)
  57. return {
  58. 'url': video_url,
  59. 'id': video_id,
  60. 'title': title,
  61. 'description': description,
  62. 'thumbnail': thumbnail,
  63. }