X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=blobdiff_plain;f=youtube_dl%2Fextractor%2Fjustintv.py;h=e9bde0c186a76e0546f97cdb08bf69e2b80b3e93;hb=72ca1d7f45488d746337cdf61a70ff25d9e8411b;hp=9c46baed56d27fbb6229db266ea6bc64555254b0;hpb=79e93125d0df50704ac32da5977c7d85e26b6976;p=youtube-dl diff --git a/youtube_dl/extractor/justintv.py b/youtube_dl/extractor/justintv.py index 9c46baed5..e9bde0c18 100644 --- a/youtube_dl/extractor/justintv.py +++ b/youtube_dl/extractor/justintv.py @@ -1,7 +1,6 @@ import json import os import re -import xml.etree.ElementTree from .common import InfoExtractor from ..utils import ( @@ -26,6 +25,17 @@ class JustinTVIE(InfoExtractor): """ _JUSTIN_PAGE_LIMIT = 100 IE_NAME = u'justin.tv' + _TEST = { + u'url': u'http://www.twitch.tv/thegamedevhub/b/296128360', + u'file': u'296128360.flv', + u'md5': u'ecaa8a790c22a40770901460af191c9a', + u'info_dict': { + u"upload_date": u"20110927", + u"uploader_id": 25114803, + u"uploader": u"thegamedevhub", + u"title": u"Beginner Series - Scripting With Python Pt.1" + } + } def report_download_page(self, channel, offset): """Report attempt to download a single page of videos.""" @@ -34,11 +44,11 @@ class JustinTVIE(InfoExtractor): # Return count of items, list of *valid* items def _parse_page(self, url, video_id): - webpage = self._download_webpage(url, video_id, - u'Downloading video info JSON', - u'unable to download video info JSON') + info_json = self._download_webpage(url, video_id, + u'Downloading video info JSON', + u'unable to download video info JSON') - response = json.loads(webpage) + response = json.loads(info_json) if type(response) != list: error_text = response.get('error', 'unknown error') raise ExtractorError(u'Justin.tv API: %s' % error_text) @@ -83,10 +93,9 @@ class JustinTVIE(InfoExtractor): archive_id = m.group(1) api = api_base + '/broadcast/by_chapter/%s.xml' % chapter_id - chapter_info_xml = self._download_webpage(api, chapter_id, + doc = self._download_xml(api, chapter_id, note=u'Downloading chapter information', errnote=u'Chapter information download failed') - doc = xml.etree.ElementTree.fromstring(chapter_info_xml) for a in doc.findall('.//archive'): if archive_id == a.find('./id').text: break