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.

42 lines
1.7 KiB

10 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import remove_start
  5. class Ir90TvIE(InfoExtractor):
  6. _VALID_URL = r'https?://(?:www\.)?90tv\.ir/video/(?P<id>[0-9]+)/.*'
  7. _TESTS = [{
  8. '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',
  9. 'md5': '411dbd94891381960cb9e13daa47a869',
  10. 'info_dict': {
  11. 'id': '95719',
  12. 'ext': 'mp4',
  13. 'title': 'شایعات نقل و انتقالات مهم فوتبال اروپا 94/02/18',
  14. 'thumbnail': r're:^https?://.*\.jpg$',
  15. }
  16. }, {
  17. 'url': 'http://www.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',
  18. 'only_matching': True,
  19. }]
  20. def _real_extract(self, url):
  21. video_id = self._match_id(url)
  22. webpage = self._download_webpage(url, video_id)
  23. title = remove_start(self._html_search_regex(
  24. r'<title>([^<]+)</title>', webpage, 'title'), '90tv.ir :: ')
  25. video_url = self._search_regex(
  26. r'<source[^>]+src="([^"]+)"', webpage, 'video url')
  27. thumbnail = self._search_regex(r'poster="([^"]+)"', webpage, 'thumbnail url', fatal=False)
  28. return {
  29. 'url': video_url,
  30. 'id': video_id,
  31. 'title': title,
  32. 'video_url': video_url,
  33. 'thumbnail': thumbnail,
  34. }