-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):
# More robust than regular expressions
-class ChannelParser(HTMLParser):
+class ChannelParser(compat_html_parser.HTMLParser):
"""
<meta name="ustream:channel_id" content="1234">
"""
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):
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))
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)