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.

62 lines
1.9 KiB

  1. from __future__ import unicode_literals
  2. from .common import InfoExtractor
  3. from ..compat import (
  4. compat_urllib_parse,
  5. compat_urllib_request,
  6. )
  7. from ..utils import ExtractorError
  8. class PrimeShareTVIE(InfoExtractor):
  9. _VALID_URL = r'https?://(?:www\.)?primeshare\.tv/download/(?P<id>[\da-zA-Z]+)'
  10. _TEST = {
  11. 'url': 'http://primeshare.tv/download/238790B611',
  12. 'md5': 'b92d9bf5461137c36228009f31533fbc',
  13. 'info_dict': {
  14. 'id': '238790B611',
  15. 'ext': 'mp4',
  16. 'title': 'Public Domain - 1960s Commercial - Crest Toothpaste-YKsuFona',
  17. },
  18. }
  19. def _real_extract(self, url):
  20. video_id = self._match_id(url)
  21. webpage = self._download_webpage(url, video_id)
  22. if '>File not exist<' in webpage:
  23. raise ExtractorError('Video %s does not exist' % video_id, expected=True)
  24. fields = self._hidden_inputs(webpage)
  25. headers = {
  26. 'Referer': url,
  27. 'Content-Type': 'application/x-www-form-urlencoded',
  28. }
  29. wait_time = int(self._search_regex(
  30. r'var\s+cWaitTime\s*=\s*(\d+)',
  31. webpage, 'wait time', default=7)) + 1
  32. self._sleep(wait_time, video_id)
  33. req = compat_urllib_request.Request(
  34. url, compat_urllib_parse.urlencode(fields), headers)
  35. video_page = self._download_webpage(
  36. req, video_id, 'Downloading video page')
  37. video_url = self._search_regex(
  38. r"url\s*:\s*'([^']+\.primeshare\.tv(?::443)?/file/[^']+)'",
  39. video_page, 'video url')
  40. title = self._html_search_regex(
  41. r'<h1>Watch\s*(?:&nbsp;)?\s*\((.+?)(?:\s*\[\.\.\.\])?\)\s*(?:&nbsp;)?\s*<strong>',
  42. video_page, 'title')
  43. return {
  44. 'id': video_id,
  45. 'url': video_url,
  46. 'title': title,
  47. 'ext': 'mp4',
  48. }