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.

50 lines
1.5 KiB

  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. ExtractorError,
  6. NO_DEFAULT,
  7. remove_start
  8. )
  9. class OdaTVIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?odatv\.com/(?:mob|vid)_video\.php\?.*\bid=(?P<id>[^&]+)'
  11. _TESTS = [{
  12. 'url': 'http://odatv.com/vid_video.php?id=8E388',
  13. 'md5': 'dc61d052f205c9bf2da3545691485154',
  14. 'info_dict': {
  15. 'id': '8E388',
  16. 'ext': 'mp4',
  17. 'title': 'Artık Davutoğlu ile devam edemeyiz'
  18. }
  19. }, {
  20. # mobile URL
  21. 'url': 'http://odatv.com/mob_video.php?id=8E388',
  22. 'only_matching': True,
  23. }, {
  24. # no video
  25. 'url': 'http://odatv.com/mob_video.php?id=8E900',
  26. 'only_matching': True,
  27. }]
  28. def _real_extract(self, url):
  29. video_id = self._match_id(url)
  30. webpage = self._download_webpage(url, video_id)
  31. no_video = 'NO VIDEO!' in webpage
  32. video_url = self._search_regex(
  33. r'mp4\s*:\s*(["\'])(?P<url>http.+?)\1', webpage, 'video url',
  34. default=None if no_video else NO_DEFAULT, group='url')
  35. if no_video:
  36. raise ExtractorError('Video %s does not exist' % video_id, expected=True)
  37. return {
  38. 'id': video_id,
  39. 'url': video_url,
  40. 'title': remove_start(self._og_search_title(webpage), 'Video: '),
  41. 'thumbnail': self._og_search_thumbnail(webpage),
  42. }