aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/primesharetv.py
blob: 967125abc4883fdbf73e0920267162add6c2e089 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
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',
        }