diff options
author | Jeff Crouse <jefftimesten@gmail.com> | 2012-11-12 16:17:55 -0500 |
---|---|---|
committer | Jeff Crouse <jefftimesten@gmail.com> | 2012-11-12 16:17:55 -0500 |
commit | 110d4f4c9170c1180cf25fd14976df30744455b7 (patch) | |
tree | dbf518f89a736e3b413e5ea7faeb3a264901c25a /youtube_dl | |
parent | 0526e4f55a822cb629ca06bb02d695eac2ef4a60 (diff) | |
download | hypervideo-pre-110d4f4c9170c1180cf25fd14976df30744455b7.tar.lz hypervideo-pre-110d4f4c9170c1180cf25fd14976df30744455b7.tar.xz hypervideo-pre-110d4f4c9170c1180cf25fd14976df30744455b7.zip |
Added Pornotube support (for Laborers of Love)
Diffstat (limited to 'youtube_dl')
-rw-r--r-- | youtube_dl/InfoExtractors.py | 81 | ||||
-rw-r--r-- | youtube_dl/__init__.py | 1 |
2 files changed, 82 insertions, 0 deletions
diff --git a/youtube_dl/InfoExtractors.py b/youtube_dl/InfoExtractors.py index cfaef2904..acbd3fcee 100644 --- a/youtube_dl/InfoExtractors.py +++ b/youtube_dl/InfoExtractors.py @@ -94,6 +94,8 @@ class InfoExtractor(object): pass + + class YoutubeIE(InfoExtractor): """Information extractor for youtube.com.""" @@ -3368,3 +3370,82 @@ class GooglePlusIE(InfoExtractor): 'format': u'NA', 'player_url': None, }] + + +class PornotubeIE(InfoExtractor): + """Information extractor for pornotube.com.""" + + _VALID_URL = r'^(?:https?://)?(?:\w+\.)?pornotube\.com(/c/(?P<channel>[0-9]+))?(/m/(?P<videoid>[0-9]+))(/(?P<title>.+))$' + IE_NAME = u'pornotube' + VIDEO_URL_RE = r'url: "(?P<url>http://video[0-9].pornotube.com/.+\.flv)",' + VIDEO_UPLOADED_RE = r'<div class="video_added_by">Added (?P<date>[0-9\/]+) by' + + + def __init__(self, downloader=None): + InfoExtractor.__init__(self, downloader) + + def report_extract_entry(self, url): + """Report downloading extry""" + self._downloader.to_screen(u'[pornotube] Downloading entry: %s' % url.decode('utf-8')) + + def report_date(self, upload_date): + """Report finding uploaded date""" + self._downloader.to_screen(u'[pornotube] Entry date: %s' % upload_date) + + def report_webpage(self, url): + """Report downloading page""" + self._downloader.to_screen(u'[pornotube] Downloaded page: %s' % url) + + def report_title(self, video_title): + """Report downloading extry""" + self._downloader.to_screen(u'[pornotube] Title: %s' % video_title.decode('utf-8')) + + def _real_extract(self, url): + mobj = re.match(self._VALID_URL, url) + if mobj is None: + self._downloader.trouble(u'ERROR: invalid URL: %s' % url) + return + + video_id = mobj.group('videoid').decode('utf-8') + video_title = mobj.group('title').decode('utf-8') + self.report_title(video_title); + + # Get webpage content + try: + webpage = urllib2.urlopen(url).read() + except (urllib2.URLError, httplib.HTTPException, socket.error), err: + self._downloader.trouble(u'ERROR: unable to download video webpage: %s' % err) + return + self.report_webpage(url) + + # Get the video URL + result = re.search(self.VIDEO_URL_RE, webpage) + if result is None: + self._downloader.trouble(u'ERROR: unable to extract video url') + return + video_url = urllib.unquote(result.group('url').decode('utf-8')) + self.report_extract_entry(video_url) + + #Get the uploaded date + result = re.search(self.VIDEO_UPLOADED_RE, webpage) + if result is None: + self._downloader.trouble(u'ERROR: unable to extract video title') + return + upload_date = result.group('date').decode('utf-8') + self.report_date(upload_date); + + + info = {'id': video_id, + 'url': video_url, + 'uploader': None, + 'upload_date': upload_date, + 'title': video_title, + 'ext': 'flv', + 'format': 'flv', + 'thumbnail': None, + 'description': None, + 'player_url': None} + + return [info] + + diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index 3aa7bde12..3b893c62f 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -361,6 +361,7 @@ def gen_extractors(): YoukuIE(), XNXXIE(), GooglePlusIE(), + PornotubeIE(), GenericIE() ] |