|
|
@ -1,59 +1,65 @@
|
|
|
|
# encoding: utf-8
|
|
|
|
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
from __future__ import unicode_literals
|
|
|
|
|
|
|
|
|
|
|
|
import re
|
|
|
|
import re
|
|
|
|
|
|
|
|
|
|
|
|
from .common import InfoExtractor
|
|
|
|
from .common import InfoExtractor
|
|
|
|
from ..utils import (
|
|
|
|
|
|
|
|
ExtractorError,
|
|
|
|
|
|
|
|
int_or_none,
|
|
|
|
|
|
|
|
parse_filesize,
|
|
|
|
|
|
|
|
unified_strdate,
|
|
|
|
|
|
|
|
urlencode_postdata,
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
from ..compat import (
|
|
|
|
from ..compat import (
|
|
|
|
|
|
|
|
compat_urllib_parse,
|
|
|
|
compat_urllib_request,
|
|
|
|
compat_urllib_request,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
from ..utils import ExtractorError
|
|
|
|
|
|
|
|
|
|
|
|
class PrimesharetvIE(InfoExtractor):
|
|
|
|
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?primeshare\.tv/download/(?P<id>.*)(?:.*)'
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
_TESTS = [
|
|
|
|
class PrimeShareTVIE(InfoExtractor):
|
|
|
|
{
|
|
|
|
_VALID_URL = r'https?://(?:www\.)?primeshare\.tv/download/(?P<id>[\da-zA-Z]+)'
|
|
|
|
'url': 'http://primeshare.tv/download/238790B611',
|
|
|
|
|
|
|
|
'md5': 'bb41f9f6c0dd434c729f04ce5b677192',
|
|
|
|
_TEST = {
|
|
|
|
'info_dict': {
|
|
|
|
'url': 'http://primeshare.tv/download/238790B611',
|
|
|
|
'id': '238790B611',
|
|
|
|
'md5': 'b92d9bf5461137c36228009f31533fbc',
|
|
|
|
'ext': 'mp4',
|
|
|
|
'info_dict': {
|
|
|
|
"title": "Public Domain - 1960s Commercial - Crest Toothpaste-YKsuFona [...]",
|
|
|
|
'id': '238790B611',
|
|
|
|
"duration": 10,
|
|
|
|
'ext': 'mp4',
|
|
|
|
},
|
|
|
|
'title': 'Public Domain - 1960s Commercial - Crest Toothpaste-YKsuFona',
|
|
|
|
}
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def _real_extract(self, url):
|
|
|
|
def _real_extract(self, url):
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
video_id = self._match_id(url)
|
|
|
|
|
|
|
|
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
webpage = self._download_webpage(url, video_id)
|
|
|
|
if re.search(r'<h1>File not exist</h1>', webpage) is not None:
|
|
|
|
|
|
|
|
raise ExtractorError('The file does not exist', expected=True)
|
|
|
|
if '>File not exist<' in webpage:
|
|
|
|
hashtoken = self._search_regex(r' name="hash" value="(.*?)" ', webpage, 'hash token')
|
|
|
|
raise ExtractorError('Video %s does not exist' % video_id, expected=True)
|
|
|
|
|
|
|
|
|
|
|
|
self._sleep(9, video_id)
|
|
|
|
fields = dict(re.findall(r'''(?x)<input\s+
|
|
|
|
|
|
|
|
type="hidden"\s+
|
|
|
|
data = urlencode_postdata({
|
|
|
|
name="([^"]+)"\s+
|
|
|
|
'hash': hashtoken,
|
|
|
|
(?:id="[^"]+"\s+)?
|
|
|
|
})
|
|
|
|
value="([^"]*)"
|
|
|
|
|
|
|
|
''', webpage))
|
|
|
|
|
|
|
|
|
|
|
|
headers = {
|
|
|
|
headers = {
|
|
|
|
'Referer': url,
|
|
|
|
'Referer': url,
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
video_page_request = compat_urllib_request.Request(url, data, headers=headers)
|
|
|
|
|
|
|
|
video_page = self._download_webpage(video_page_request, None, False, '')
|
|
|
|
wait_time = int(self._search_regex(
|
|
|
|
video_url = self._html_search_regex(
|
|
|
|
r'var\s+cWaitTime\s*=\s*(\d+)',
|
|
|
|
r'url: \'(http://[a-z0-9]+\.primeshare\.tv:443/file/get/[^\']+)\',', video_page, 'video url')
|
|
|
|
webpage, 'wait time', default=7)) + 1
|
|
|
|
|
|
|
|
self._sleep(wait_time, video_id)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
req = compat_urllib_request.Request(
|
|
|
|
|
|
|
|
url, compat_urllib_parse.urlencode(fields), headers)
|
|
|
|
|
|
|
|
video_page = self._download_webpage(
|
|
|
|
|
|
|
|
req, video_id, 'Downloading video page')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
video_url = self._search_regex(
|
|
|
|
|
|
|
|
r"url\s*:\s*'([^']+\.primeshare\.tv(?::443)?/file/[^']+)'",
|
|
|
|
|
|
|
|
video_page, 'video url')
|
|
|
|
|
|
|
|
|
|
|
|
title = self._html_search_regex(
|
|
|
|
title = self._html_search_regex(
|
|
|
|
r'<h1>Watch [^\(]+\(([^/)]+)\) ', video_page, 'title')
|
|
|
|
r'<h1>Watch\s*(?: )?\s*\((.+?)(?:\s*\[\.\.\.\])?\)\s*(?: )?\s*<strong>',
|
|
|
|
|
|
|
|
video_page, 'title')
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
'id': video_id,
|
|
|
|
'id': video_id,
|
|
|
@ -61,8 +67,3 @@ class PrimesharetvIE(InfoExtractor):
|
|
|
|
'title': title,
|
|
|
|
'title': title,
|
|
|
|
'ext': 'mp4',
|
|
|
|
'ext': 'mp4',
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
def _debug_print(self, txt):
|
|
|
|
|
|
|
|
if self._downloader.params.get('verbose'):
|
|
|
|
|
|
|
|
self.to_screen('[debug] %s' % txt)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|