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.

72 lines
2.6 KiB

10 years ago
  1. # coding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..compat import compat_urlparse
  5. from ..utils import (
  6. remove_start,
  7. sanitized_Request,
  8. )
  9. class EinthusanIE(InfoExtractor):
  10. _VALID_URL = r'https?://(?:www\.)?einthusan\.com/movies/watch.php\?([^#]*?)id=(?P<id>[0-9]+)'
  11. _TESTS = [
  12. {
  13. 'url': 'http://www.einthusan.com/movies/watch.php?id=2447',
  14. 'md5': 'd71379996ff5b7f217eca034c34e3461',
  15. 'info_dict': {
  16. 'id': '2447',
  17. 'ext': 'mp4',
  18. 'title': 'Ek Villain',
  19. 'thumbnail': r're:^https?://.*\.jpg$',
  20. 'description': 'md5:9d29fc91a7abadd4591fb862fa560d93',
  21. }
  22. },
  23. {
  24. 'url': 'http://www.einthusan.com/movies/watch.php?id=1671',
  25. 'md5': 'b16a6fd3c67c06eb7c79c8a8615f4213',
  26. 'info_dict': {
  27. 'id': '1671',
  28. 'ext': 'mp4',
  29. 'title': 'Soodhu Kavvuum',
  30. 'thumbnail': r're:^https?://.*\.jpg$',
  31. 'description': 'md5:b40f2bf7320b4f9414f3780817b2af8c',
  32. }
  33. },
  34. ]
  35. def _real_extract(self, url):
  36. video_id = self._match_id(url)
  37. request = sanitized_Request(url)
  38. request.add_header('User-Agent', 'Mozilla/5.0 (Windows NT 5.2; WOW64; rv:43.0) Gecko/20100101 Firefox/43.0')
  39. webpage = self._download_webpage(request, video_id)
  40. title = self._html_search_regex(
  41. r'<h1><a[^>]+class=["\']movie-title["\'][^>]*>(.+?)</a></h1>',
  42. webpage, 'title')
  43. video_id = self._search_regex(
  44. r'data-movieid=["\'](\d+)', webpage, 'video id', default=video_id)
  45. m3u8_url = self._download_webpage(
  46. 'http://cdn.einthusan.com/geturl/%s/hd/London,Washington,Toronto,Dallas,San,Sydney/'
  47. % video_id, video_id, headers={'Referer': url})
  48. formats = self._extract_m3u8_formats(
  49. m3u8_url, video_id, ext='mp4', entry_protocol='m3u8_native')
  50. description = self._html_search_meta('description', webpage)
  51. thumbnail = self._html_search_regex(
  52. r'''<a class="movie-cover-wrapper".*?><img src=["'](.*?)["'].*?/></a>''',
  53. webpage, "thumbnail url", fatal=False)
  54. if thumbnail is not None:
  55. thumbnail = compat_urlparse.urljoin(url, remove_start(thumbnail, '..'))
  56. return {
  57. 'id': video_id,
  58. 'title': title,
  59. 'formats': formats,
  60. 'thumbnail': thumbnail,
  61. 'description': description,
  62. }