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.

64 lines
1.9 KiB

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