aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor
diff options
context:
space:
mode:
Diffstat (limited to 'youtube_dl/extractor')
-rw-r--r--youtube_dl/extractor/__init__.py1
-rw-r--r--youtube_dl/extractor/canalc2.py28
-rw-r--r--youtube_dl/extractor/savefrom.py37
-rw-r--r--youtube_dl/extractor/spankwire.py65
4 files changed, 95 insertions, 36 deletions
diff --git a/youtube_dl/extractor/__init__.py b/youtube_dl/extractor/__init__.py
index 6377f8b4c..ad90a0b91 100644
--- a/youtube_dl/extractor/__init__.py
+++ b/youtube_dl/extractor/__init__.py
@@ -186,6 +186,7 @@ from .rutube import (
RutubeMovieIE,
RutubePersonIE,
)
+from .savefrom import SaveFromIE
from .servingsys import ServingSysIE
from .sina import SinaIE
from .slashdot import SlashdotIE
diff --git a/youtube_dl/extractor/canalc2.py b/youtube_dl/extractor/canalc2.py
index 3d8d7f9d2..c4fefefe4 100644
--- a/youtube_dl/extractor/canalc2.py
+++ b/youtube_dl/extractor/canalc2.py
@@ -1,4 +1,6 @@
# coding: utf-8
+from __future__ import unicode_literals
+
import re
from .common import InfoExtractor
@@ -9,11 +11,12 @@ class Canalc2IE(InfoExtractor):
_VALID_URL = r'http://.*?\.canalc2\.tv/video\.asp\?.*?idVideo=(?P<id>\d+)'
_TEST = {
- u'url': u'http://www.canalc2.tv/video.asp?idVideo=12163&voir=oui',
- u'file': u'12163.mp4',
- u'md5': u'060158428b650f896c542dfbb3d6487f',
- u'info_dict': {
- u'title': u'Terrasses du Numérique'
+ 'url': 'http://www.canalc2.tv/video.asp?idVideo=12163&voir=oui',
+ 'md5': '060158428b650f896c542dfbb3d6487f',
+ 'info_dict': {
+ 'id': '12163',
+ 'ext': 'mp4',
+ 'title': 'Terrasses du Numérique'
}
}
@@ -28,10 +31,11 @@ class Canalc2IE(InfoExtractor):
video_url = 'http://vod-flash.u-strasbg.fr:8080/' + file_name
title = self._html_search_regex(
- r'class="evenement8">(.*?)</a>', webpage, u'title')
-
- return {'id': video_id,
- 'ext': 'mp4',
- 'url': video_url,
- 'title': title,
- }
+ r'class="evenement8">(.*?)</a>', webpage, 'title')
+
+ return {
+ 'id': video_id,
+ 'ext': 'mp4',
+ 'url': video_url,
+ 'title': title,
+ }
diff --git a/youtube_dl/extractor/savefrom.py b/youtube_dl/extractor/savefrom.py
new file mode 100644
index 000000000..198a08c1c
--- /dev/null
+++ b/youtube_dl/extractor/savefrom.py
@@ -0,0 +1,37 @@
+# coding: utf-8
+from __future__ import unicode_literals
+
+import os.path
+import re
+
+from .common import InfoExtractor
+
+
+class SaveFromIE(InfoExtractor):
+ IE_NAME = 'savefrom.net'
+ _VALID_URL = r'https?://[^.]+\.savefrom\.net/\#url=(?P<url>.*)$'
+
+ _TEST = {
+ 'url': 'http://en.savefrom.net/#url=http://youtube.com/watch?v=UlVRAPW2WJY&utm_source=youtube.com&utm_medium=short_domains&utm_campaign=ssyoutube.com',
+ 'info_dict': {
+ 'id': 'UlVRAPW2WJY',
+ 'ext': 'mp4',
+ 'title': 'About Team Radical MMA | MMA Fighting',
+ 'upload_date': '20120816',
+ 'uploader': 'Howcast',
+ 'uploader_id': 'Howcast',
+ 'description': 'md5:4f0aac94361a12e1ce57d74f85265175',
+ },
+ 'params': {
+ 'skip_download': True
+ }
+ }
+
+ def _real_extract(self, url):
+ mobj = re.match(self._VALID_URL, url)
+ video_id = os.path.splitext(url.split('/')[-1])[0]
+ return {
+ '_type': 'url',
+ 'id': video_id,
+ 'url': mobj.group('url'),
+ }
diff --git a/youtube_dl/extractor/spankwire.py b/youtube_dl/extractor/spankwire.py
index 3362b3db8..2007a0013 100644
--- a/youtube_dl/extractor/spankwire.py
+++ b/youtube_dl/extractor/spankwire.py
@@ -1,6 +1,5 @@
from __future__ import unicode_literals
-import os
import re
from .common import InfoExtractor
@@ -8,23 +7,27 @@ from ..utils import (
compat_urllib_parse_urlparse,
compat_urllib_request,
compat_urllib_parse,
+ unified_strdate,
+ str_to_int,
+ int_or_none,
)
-from ..aes import (
- aes_decrypt_text
-)
+from ..aes import aes_decrypt_text
class SpankwireIE(InfoExtractor):
- _VALID_URL = r'^(?:https?://)?(?:www\.)?(?P<url>spankwire\.com/[^/]*/video(?P<videoid>[0-9]+)/?)'
+ _VALID_URL = r'https?://(?:www\.)?(?P<url>spankwire\.com/[^/]*/video(?P<videoid>[0-9]+)/?)'
_TEST = {
'url': 'http://www.spankwire.com/Buckcherry-s-X-Rated-Music-Video-Crazy-Bitch/video103545/',
- 'file': '103545.mp4',
- 'md5': '1b3f55e345500552dbc252a3e9c1af43',
+ 'md5': '8bbfde12b101204b39e4b9fe7eb67095',
'info_dict': {
- "uploader": "oreusz",
- "title": "Buckcherry`s X Rated Music Video Crazy Bitch",
- "description": "Crazy Bitch X rated music video.",
- "age_limit": 18,
+ 'id': '103545',
+ 'ext': 'mp4',
+ 'title': 'Buckcherry`s X Rated Music Video Crazy Bitch',
+ 'description': 'Crazy Bitch X rated music video.',
+ 'uploader': 'oreusz',
+ 'uploader_id': '124697',
+ 'upload_date': '20070508',
+ 'age_limit': 18,
}
}
@@ -37,13 +40,26 @@ class SpankwireIE(InfoExtractor):
req.add_header('Cookie', 'age_verified=1')
webpage = self._download_webpage(req, video_id)
- video_title = self._html_search_regex(r'<h1>([^<]+)', webpage, 'title')
- video_uploader = self._html_search_regex(
- r'by:\s*<a [^>]*>(.+?)</a>', webpage, 'uploader', fatal=False)
- thumbnail = self._html_search_regex(
- r'flashvars\.image_url = "([^"]+)', webpage, 'thumbnail', fatal=False)
+ title = self._html_search_regex(r'<h1>([^<]+)', webpage, 'title')
description = self._html_search_regex(
r'<div\s+id="descriptionContent">([^<]+)<', webpage, 'description', fatal=False)
+ thumbnail = self._html_search_regex(
+ r'flashvars\.image_url = "([^"]+)', webpage, 'thumbnail', fatal=False)
+
+ uploader = self._html_search_regex(
+ r'by:\s*<a [^>]*>(.+?)</a>', webpage, 'uploader', fatal=False)
+ uploader_id = self._html_search_regex(
+ r'by:\s*<a href="/Profile\.aspx\?.*?UserId=(\d+).*?"', webpage, 'uploader id', fatal=False)
+ upload_date = self._html_search_regex(r'</a> on (.+?) at \d+:\d+', webpage, 'upload date', fatal=False)
+ if upload_date:
+ upload_date = unified_strdate(upload_date)
+
+ view_count = self._html_search_regex(
+ r'<div id="viewsCounter"><span>([^<]+)</span> views</div>', webpage, 'view count', fatal=False)
+ if view_count:
+ view_count = str_to_int(view_count)
+ comment_count = int_or_none(self._html_search_regex(
+ r'<span id="spCommentCount">\s*(\d+)</span> Comments</div>', webpage, 'comment count', fatal=False))
video_urls = list(map(compat_urllib_parse.unquote , re.findall(r'flashvars\.quality_[0-9]{3}p = "([^"]+)', webpage)))
if webpage.find('flashvars\.encrypted = "true"') != -1:
@@ -53,16 +69,13 @@ class SpankwireIE(InfoExtractor):
formats = []
for video_url in video_urls:
path = compat_urllib_parse_urlparse(video_url).path
- extension = os.path.splitext(path)[1][1:]
format = path.split('/')[4].split('_')[:2]
resolution, bitrate_str = format
format = "-".join(format)
- height = int(resolution.rstrip('P'))
- tbr = int(bitrate_str.rstrip('K'))
-
+ height = int(resolution.rstrip('Pp'))
+ tbr = int(bitrate_str.rstrip('Kk'))
formats.append({
'url': video_url,
- 'ext': extension,
'resolution': resolution,
'format': format,
'tbr': tbr,
@@ -75,10 +88,14 @@ class SpankwireIE(InfoExtractor):
return {
'id': video_id,
- 'uploader': video_uploader,
- 'title': video_title,
- 'thumbnail': thumbnail,
+ 'title': title,
'description': description,
+ 'thumbnail': thumbnail,
+ 'uploader': uploader,
+ 'uploader_id': uploader_id,
+ 'upload_date': upload_date,
+ 'view_count': view_count,
+ 'comment_count': comment_count,
'formats': formats,
'age_limit': age_limit,
}