Skip to content

Commit

Permalink
[Primesharetv] Handle file not existing properly.
Browse files Browse the repository at this point in the history
  • Loading branch information
jbuchbinder authored and dstftw committed Mar 17, 2015
1 parent af69cab commit 13047f4
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions youtube_dl/extractor/primesharetv.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
# encoding: utf-8
from __future__ import unicode_literals

import re

from .common import InfoExtractor
from ..utils import (
ExtractorError,
int_or_none,
parse_filesize,
unified_strdate,
Expand Down Expand Up @@ -31,10 +34,12 @@ class PrimesharetvIE(InfoExtractor):
def _real_extract(self, url):
video_id = self._match_id(url)
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)
hashtoken = self._search_regex(r' name="hash" value="(.*?)" ', webpage, 'hash token')

self._sleep(9, video_id)

hashtoken = self._search_regex(r' name="hash" value="(.*?)" ', webpage, 'hash token')
data = urlencode_postdata({
'hash': hashtoken,
})
Expand All @@ -44,7 +49,6 @@ def _real_extract(self, url):
}
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://[a-z0-9]+\.primeshare\.tv:443/file/get/[^\']+)\',', video_page, 'video url')

Expand All @@ -57,3 +61,8 @@ def _real_extract(self, url):
'title': title,
'ext': 'mp4',
}

def _debug_print(self, txt):
if self._downloader.params.get('verbose'):
self.to_screen('[debug] %s' % txt)

0 comments on commit 13047f4

Please sign in to comment.