aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Ngo <ngoke@onid.oregonstate.edu>2011-11-08 00:03:35 -0800
committerKevin Ngo <ngoke@onid.oregonstate.edu>2011-11-08 00:03:35 -0800
commit40306424b1fa34284060740e0d8dd0c2859054b2 (patch)
tree7c958f92189a69cfe821240d2f497b46fee1b112
parentecb3bfe543ada5e4433522efc05c49a71da8b03f (diff)
downloadyoutube-dl-40306424b1fa34284060740e0d8dd0c2859054b2.tar.xz
work on soundcloud information extractor...need to talk to youtube-dl guys
-rwxr-xr-xyoutube-dl56
1 files changed, 55 insertions, 1 deletions
diff --git a/youtube-dl b/youtube-dl
index cb31d13c9..263ae6540 100755
--- a/youtube-dl
+++ b/youtube-dl
@@ -3484,9 +3484,63 @@ class XVideosIE(InfoExtractor):
class SoundcloudIE(InformationExtractor):
"""Information extractor for soundcloud.com"""
- _VALID_URL = r'^(?:https?://)?(?:www\.)?soundcloud\.com/([\w\d-]+)/(\w\d-]+)'
+ _VALID_URL = r'^(?:https?://)?(?:www\.)?soundcloud\.com/([\w\d-]+)/([\w\d-]+)'
IE_NAME = u'soundcloud'
+ def __init__(self, downloader=None):
+ InfoExtractor.__init__(self, downloader)
+
+ def report_webpage(self, video_id):
+ """Report information extraction."""
+ self._downloader.to_screen(u'[%s] %s: Downloading webpage' % (self.IE_NAME, video_id))
+
+ def report_extraction(self, video_id):
+ """Report information extraction."""
+ self._downloader.to_screen(u'[%s] %s: Extracting information' % (self.IE_NAME, video_id))
+
+ def _real_initialize(self):
+ return
+
+ def _real_extract(self, url):
+ htmlParser = HTMLParser.HTMLParser()
+
+ mobj = re.match(self._VALID_URL, url)
+ if mobj is None:
+ self._downloader.trouble(u'ERROR: invalid URL: %s' % url)
+ return
+
+ # extract uploader
+ uploader = mobj.group(3).decode('utf-8')
+ # extract simple title (uploader + slug of song title)
+ slug_title = mobj.group(4).decode('utf-8')
+ simple_title = uploader + '-' + slug_title
+
+ self.report_webpage('%s/%s' % (uploader, slug_title))
+
+ request = urllib2.Request('http://soundcloud.com/%s/%s' % (uploader, slug_title))
+ try:
+ webpage = urllib2.urlopen(request).read()
+ except (urllib2.URLError, httplib.HTTPException, socket.error), err:
+ self._downloader.trouble(u'ERROR: unable to download video webpage: %s' % str(err))
+ return
+
+ self.report_extraction('%s/%s' % (uploader, slug_title))
+
+ # extract video_id (soundcloud uid of song)
+ mobj = re.search
+
+ try:
+ self._download.process_info({
+ 'id': video_id,
+ 'url': video_url,
+ 'uploader': uploader,
+ 'upload_date': u'NA',
+ 'title': video_title,
+ 'stitle': simple_title,
+ 'ext': u'mp3',
+ 'format': u'NA',
+ 'player_url': None,
+ })
class PostProcessor(object):
"""Post Processor class.