aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/extractor/ustream.py
diff options
context:
space:
mode:
Diffstat (limited to 'youtube_dl/extractor/ustream.py')
-rw-r--r--youtube_dl/extractor/ustream.py22
1 files changed, 9 insertions, 13 deletions
diff --git a/youtube_dl/extractor/ustream.py b/youtube_dl/extractor/ustream.py
index 16cdcc765..f69b27d44 100644
--- a/youtube_dl/extractor/ustream.py
+++ b/youtube_dl/extractor/ustream.py
@@ -1,9 +1,11 @@
-from HTMLParser import HTMLParser
import json
import re
-from urlparse import urljoin
from .common import InfoExtractor
+from ..utils import (
+ compat_urlparse,
+ compat_html_parser,
+)
class UstreamIE(InfoExtractor):
@@ -49,7 +51,7 @@ class UstreamIE(InfoExtractor):
# More robust than regular expressions
-class ChannelParser(HTMLParser):
+class ChannelParser(compat_html_parser.HTMLParser):
"""
<meta name="ustream:channel_id" content="1234">
"""
@@ -65,13 +67,13 @@ class ChannelParser(HTMLParser):
if value.isdigit():
self.channel_id = value
-class SocialstreamParser(HTMLParser):
+class SocialstreamParser(compat_html_parser.HTMLParser):
"""
<li class="content123 video" data-content-id="123" data-length="1452"
data-href="/recorded/123" data-og-url="/recorded/123">
"""
def __init__(self):
- HTMLParser.__init__(self)
+ compat_html_parser.HTMLParser.__init__(self)
self.content_ids = []
def handle_starttag(self, tag, attrs):
@@ -88,8 +90,6 @@ class UstreamChannelIE(InfoExtractor):
def _real_extract(self, url):
m = re.match(self._VALID_URL, url)
slug = m.group('slug')
- # Slugs can be non-ascii, but youtube-dl can't handle non-ascii command lines,
- # so if we got this far it's probably percent encoded and we needn't worry.
p = ChannelParser()
p.feed(self._download_webpage(url, slug))
@@ -100,16 +100,12 @@ class UstreamChannelIE(InfoExtractor):
BASE = 'http://www.ustream.tv'
next_url = '/ajax/socialstream/videos/%s/1.json' % channel_id
while next_url:
- reply = json.loads(self._download_webpage(urljoin(BASE, next_url), channel_id))
+ reply = json.loads(self._download_webpage(compat_urlparse.urljoin(BASE, next_url), channel_id))
p.feed(reply['data'])
next_url = reply['nextUrl']
p.close()
video_ids = p.content_ids
- # From YoutubeChannelIE
-
- self._downloader.to_screen(u'[ustream] Channel %s: Found %i videos' % (channel_id, len(video_ids)))
-
urls = ['http://www.ustream.tv/recorded/' + vid for vid in video_ids]
url_entries = [self.url_result(eurl, 'Ustream') for eurl in urls]
- return [self.playlist_result(url_entries, channel_id)]
+ return self.playlist_result(url_entries, channel_id)