# -*- coding: utf-8 -*-
import datetime
-import httplib
import netrc
import os
import re
try:
self.report_lang()
compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.to_stderr(u'WARNING: unable to set language: %s' % compat_str(err))
return
if re.search(r'(?i)<form[^>]* name="loginForm"', login_results) is not None:
self._downloader.to_stderr(u'WARNING: unable to log in: bad username or password')
return
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.to_stderr(u'WARNING: unable to log in: %s' % compat_str(err))
return
try:
self.report_age_confirmation()
age_results = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to confirm age: %s' % compat_str(err))
return
request = compat_urllib_request.Request('http://www.youtube.com/watch?v=%s&gl=US&hl=en&has_verified=1' % video_id)
try:
video_webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download video webpage: %s' % compat_str(err))
return
video_info = parse_qs(video_info_webpage)
if 'token' in video_info:
break
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download video info webpage: %s' % compat_str(err))
return
if 'token' not in video_info:
request = compat_urllib_request.Request('http://video.google.com/timedtext?hl=en&type=list&v=%s' % video_id)
try:
srt_list = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
raise Trouble(u'WARNING: unable to download video subtitles: %s' % compat_str(err))
srt_lang_list = re.findall(r'name="([^"]*)"[^>]+lang_code="([\w\-]+)"', srt_list)
srt_lang_list = dict((l[1], l[0]) for l in srt_lang_list)
request = compat_urllib_request.Request('http://www.youtube.com/api/timedtext?lang=%s&name=%s&v=%s' % (srt_lang, srt_lang_list[srt_lang], video_id))
try:
srt_xml = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
raise Trouble(u'WARNING: unable to download video subtitles: %s' % compat_str(err))
if not srt_xml:
raise Trouble(u'WARNING: unable to download video subtitles')
try:
self.report_disclaimer()
disclaimer = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to retrieve disclaimer: %s' % compat_str(err))
return
try:
self.report_age_confirmation()
disclaimer = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to confirm age: %s' % compat_str(err))
return
try:
self.report_download_webpage(video_id)
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable retrieve video webpage: %s' % compat_str(err))
return
try:
self.report_download_webpage(video_id)
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable retrieve video webpage: %s' % compat_str(err))
return
try:
self.report_download_webpage(video_id)
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: Unable to retrieve video webpage: %s' % compat_str(err))
return
request = compat_urllib_request.Request('http://video.google.com/videosearch?q=%s+site:video.google.com&hl=en' % abs(int(video_id)))
try:
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: Unable to retrieve video webpage: %s' % compat_str(err))
return
mobj = re.search(r'<img class=thumbnail-img (?:.* )?src=(http.*)>', webpage)
try:
self.report_download_webpage(video_id)
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: Unable to retrieve video webpage: %s' % compat_str(err))
return
request = compat_urllib_request.Request(url)
try:
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: Unable to retrieve video webpage: %s' % compat_str(err))
return
try:
self.report_download_webpage(video_id)
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: Unable to retrieve video webpage: %s' % compat_str(err))
return
try:
self.report_download_webpage(video_id)
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: Unable to retrieve video webpage: %s' % compat_str(err))
return
try:
self.report_download_webpage(video_id)
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: Unable to retrieve video webpage: %s' % compat_str(err))
return
try:
self.report_download_webpage(url)
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: Unable to retrieve video webpage: %s' % compat_str(err))
return
except ValueError as err:
try:
self.report_download_webpage(video_id)
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: Unable to retrieve video webpage: %s' % compat_str(err))
return
except ValueError as err:
request = compat_urllib_request.Request(result_url)
try:
data = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download API page: %s' % compat_str(err))
return
api_response = json.loads(data)['data']
request = compat_urllib_request.Request(result_url)
try:
page = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download webpage: %s' % compat_str(err))
return
request = compat_urllib_request.Request(result_url)
try:
page = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download webpage: %s' % compat_str(err))
return
request = compat_urllib_request.Request(url)
try:
page = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download webpage: %s' % compat_str(err))
return
request = compat_urllib_request.Request(url)
try:
page = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download webpage: %s' % compat_str(err))
return
try:
page = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download webpage: %s' % compat_str(err))
return
page = compat_urllib_request.urlopen(request).read().decode('utf-8')
mobj = re.search(r'data-users-id="([^"]+)"', page)
page_base = page_base % mobj.group(1)
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download webpage: %s' % compat_str(err))
return
try:
page = compat_urllib_request.urlopen(request).read().decode('utf-8')
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download webpage: %s' % str(err))
return
try:
self.report_download_webpage(file_id)
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: Unable to retrieve file webpage: %s' % compat_str(err))
return
if re.search(r'<form(.*)name="login"(.*)</form>', login_results) is not None:
self._downloader.to_stderr(u'WARNING: unable to log in: bad username/password, or exceded login rate limit (~3/min). Check credentials or wait.')
return
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.to_stderr(u'WARNING: unable to log in: %s' % compat_str(err))
return
try:
page = compat_urllib_request.urlopen(request)
video_webpage = page.read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download video webpage: %s' % compat_str(err))
return
'ext': ext,
'urlhandle': urlh
}
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download video info webpage: %s' % compat_str(err))
return
if info is None: # Regular URL
try:
json_code = urlh.read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to read video info webpage: %s' % compat_str(err))
return
try:
self.report_download_webpage(video_id)
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: Unable to retrieve video webpage: %s' % compat_str(err))
return
try:
htmlHandle = compat_urllib_request.urlopen(req)
html = htmlHandle.read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download webpage: %s' % compat_str(err))
return
if dlNewest:
try:
urlHandle = compat_urllib_request.urlopen(playerUrl_raw)
playerUrl = urlHandle.geturl()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to find out player URL: ' + compat_str(err))
return
self.report_index_download(epTitle)
try:
indexXml = compat_urllib_request.urlopen(indexUrl).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download episode index: ' + compat_str(err))
return
self.report_config_download(epTitle)
try:
configXml = compat_urllib_request.urlopen(configReq).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download webpage: %s' % compat_str(err))
return
webPageBytes = webPage.read()
m = re.match(r'text/html; charset="?([^"]+)"?', webPage.headers['Content-Type'])
webPage = webPageBytes.decode(m.group(1) if m else 'utf-8')
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download webpage: ' + compat_str(err))
return
self.report_config_download(showName)
try:
configJSON = compat_urllib_request.urlopen(configUrl).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download configuration: ' + compat_str(err))
return
request = compat_urllib_request.Request(url)
try:
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download video webpage: %s' % compat_str(err))
return
xmlUrl = 'http://www.collegehumor.com/moogaloop/video:' + internal_video_id
try:
metaXml = compat_urllib_request.urlopen(xmlUrl).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download video info XML: %s' % compat_str(err))
return
request = compat_urllib_request.Request(r'http://www.xvideos.com/video' + video_id)
try:
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download video webpage: %s' % compat_str(err))
return
request = compat_urllib_request.Request('http://soundcloud.com/%s/%s' % (uploader, slug_title))
try:
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download video webpage: %s' % compat_str(err))
return
request = compat_urllib_request.Request(url)
try:
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download video webpage: %s' % compat_str(err))
return
try:
compat_urllib_request.urlopen(url)
return url
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
url = None
return None
try:
self.report_download_json(file_url)
jsonData = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: Unable to retrieve file: %s' % compat_str(err))
return
xmlUrl = baseUrl + video + '.xml'
try:
metaXml = compat_urllib_request.urlopen(xmlUrl).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download video info XML: %s' % compat_str(err))
return
mdoc = xml.etree.ElementTree.fromstring(metaXml)
self.report_download_webpage(info['id'])
try:
coursepage = compat_urllib_request.urlopen(url).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download course info page: ' + compat_str(err))
return
rootURL = 'http://openclassroom.stanford.edu/MainFolder/HomePage.php'
try:
rootpage = compat_urllib_request.urlopen(rootURL).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download course info page: ' + compat_str(err))
return
request = compat_urllib_request.Request(url)
try:
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download video webpage: %s' % compat_str(err))
return
request = compat_urllib_request.Request(videogen_url)
try:
metadataXml = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download video metadata: %s' % compat_str(err))
return
try:
self.report_download_webpage(video_id)
jsondata = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: Unable to retrieve video webpage: %s' % compat_str(err))
return
# Get webpage content
try:
webpage = compat_urllib_request.urlopen(url).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: unable to download video webpage: %s' % err)
return
request = compat_urllib_request.Request(post_url)
try:
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: Unable to retrieve entry webpage: %s' % compat_str(err))
return
request = compat_urllib_request.Request(video_page)
try:
webpage = compat_urllib_request.urlopen(request).read()
- except (compat_urllib_error.URLError, httplib.HTTPException, socket.error) as err:
+ except (compat_urllib_error.URLError, compat_http_client.HTTPException, socket.error) as err:
self._downloader.trouble(u'ERROR: Unable to retrieve video webpage: %s' % compat_str(err))
return
self.report_extract_vid_page(video_page)