primesharetv.py 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. # encoding: utf-8
  2. from __future__ import unicode_literals
  3. from .common import InfoExtractor
  4. from ..utils import (
  5. int_or_none,
  6. parse_filesize,
  7. unified_strdate,
  8. urlencode_postdata,
  9. )
  10. from ..compat import (
  11. compat_urllib_request,
  12. )
  13. class PrimesharetvIE(InfoExtractor):
  14. _VALID_URL = r'https?://(?:www\.)?primeshare\.tv/download/(?P<id>.*)(?:.*)'
  15. def _real_extract(self, url):
  16. video_id = self._match_id(url)
  17. webpage = self._download_webpage(url, video_id)
  18. self._sleep(9, video_id)
  19. hashtoken = self._search_regex(r' name="hash" value="(.*?)" ', webpage, 'hash token')
  20. data = urlencode_postdata({
  21. 'hash': hashtoken,
  22. })
  23. headers = {
  24. 'Referer': url,
  25. 'Content-Type': 'application/x-www-form-urlencoded',
  26. }
  27. video_page_request = compat_urllib_request.Request(url, data, headers=headers)
  28. video_page = self._download_webpage(video_page_request, None, False, '')
  29. video_url = self._html_search_regex(
  30. r'url: \'(http://l\.primeshare\.tv[^\']+)\',', video_page, 'video url')
  31. title = self._html_search_regex(
  32. r'<h1>Watch&nbsp;[^\(]+\(([^/)]+)\)&nbsp;', video_page, 'title')
  33. return {
  34. 'id': video_id,
  35. 'url': video_url,
  36. 'title': title,
  37. 'ext': 'mp4',
  38. }