[Primesharetv] Add primeshare.tv extractor, still need test data
authorJeff Buchbinder <jeff@ourexchange.net>
Wed, 4 Mar 2015 20:02:13 +0000 (15:02 -0500)
committerSergey M․ <dstftw@gmail.com>
Tue, 17 Mar 2015 14:33:16 +0000 (20:33 +0600)
youtube_dl/extractor/__init__.py
youtube_dl/extractor/primesharetv.py [new file with mode: 0644]

index 5316af2d10576e765f4f3b0f6a31559c15275f36..b028123658307d0bb970f6b4e9ee844d063c92d8 100644 (file)
@@ -381,6 +381,7 @@ from .pornhub import (
 )
 from .pornotube import PornotubeIE
 from .pornoxo import PornoXOIE
+from .primesharetv import PrimesharetvIE
 from .promptfile import PromptFileIE
 from .prosiebensat1 import ProSiebenSat1IE
 from .puls4 import Puls4IE
diff --git a/youtube_dl/extractor/primesharetv.py b/youtube_dl/extractor/primesharetv.py
new file mode 100644 (file)
index 0000000..967125a
--- /dev/null
@@ -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',
+        }