aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/primesharetv.py
diff options
context:
space:
mode:
authorJeff Buchbinder <jeff@ourexchange.net>2015-03-04 15:02:13 -0500
committerSergey M․ <dstftw@gmail.com>2015-03-17 20:33:16 +0600
commitd41a3fa1b47fc050e206bd16feed02b6a62e7d2d (patch)
tree3a0954b0ee6a2053eb992b1607638e504534bfb5 /youtube_dl/extractor/primesharetv.py
parent733be371af58ec63be5faa52ee24cab4dd85d388 (diff)
[Primesharetv] Add primeshare.tv extractor, still need test data
Diffstat (limited to 'youtube_dl/extractor/primesharetv.py')
-rw-r--r--youtube_dl/extractor/primesharetv.py46
1 files changed, 46 insertions, 0 deletions
diff --git a/youtube_dl/extractor/primesharetv.py b/youtube_dl/extractor/primesharetv.py
new file mode 100644
index 000000000..967125abc
--- /dev/null
+++ b/youtube_dl/extractor/primesharetv.py
@@ -0,0 +1,46 @@
+# encoding: utf-8
+from __future__ import unicode_literals
+
+from .common import InfoExtractor
+from ..utils import (
+ int_or_none,
+ parse_filesize,
+ unified_strdate,
+ urlencode_postdata,
+)
+from ..compat import (
+ compat_urllib_request,
+)
+
+class PrimesharetvIE(InfoExtractor):
+ _VALID_URL = r'https?://(?:www\.)?primeshare\.tv/download/(?P<id>.*)(?:.*)'
+
+ def _real_extract(self, url):
+ video_id = self._match_id(url)
+ webpage = self._download_webpage(url, video_id)
+
+ self._sleep(9, video_id)
+
+ hashtoken = self._search_regex(r' name="hash" value="(.*?)" ', webpage, 'hash token')
+ data = urlencode_postdata({
+ 'hash': hashtoken,
+ })
+ headers = {
+ 'Referer': url,
+ '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, '')
+
+ video_url = self._html_search_regex(
+ r'url: \'(http://l\.primeshare\.tv[^\']+)\',', video_page, 'video url')
+
+ title = self._html_search_regex(
+ r'<h1>Watch&nbsp;[^\(]+\(([^/)]+)\)&nbsp;', video_page, 'title')
+
+ return {
+ 'id': video_id,
+ 'url': video_url,
+ 'title': title,
+ 'ext': 'mp4',
+ }