aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRicardo Garcia <sarbalap+freshmeat@gmail.com>2010-01-06 10:49:38 +0100
committerRicardo Garcia <sarbalap+freshmeat@gmail.com>2010-10-31 11:25:05 +0100
commita04e80a481cf21b4d9ff02d7fee615ef2af83941 (patch)
tree73294dc1b8d9c2c7fd17a2cf934d3ee3fa04ca73
parentfe788f2c6f22224363484944254d17662bc5a394 (diff)
Add flexibility importing the "parse_qs" function (fixes issue #81)
-rwxr-xr-xyoutube-dl9
1 files changed, 7 insertions, 2 deletions
diff --git a/youtube-dl b/youtube-dl
index 07ef5dcfc..bdc33b57f 100755
--- a/youtube-dl
+++ b/youtube-dl
@@ -18,7 +18,12 @@ import sys
import time
import urllib
import urllib2
-import urlparse
+
+# parse_qs was moved from the cgi module to the urlparse module recently.
+try:
+ from urlparse import parse_qs
+except ImportError:
+ from cgi import parse_qs
std_headers = {
'User-Agent': 'Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.1.2) Gecko/20090729 Firefox/3.5.2',
@@ -729,7 +734,7 @@ class YoutubeIE(InfoExtractor):
try:
self.report_video_info_webpage_download(video_id)
video_info_webpage = urllib2.urlopen(request).read()
- video_info = urlparse.parse_qs(video_info_webpage)
+ video_info = parse_qs(video_info_webpage)
except (urllib2.URLError, httplib.HTTPException, socket.error), err:
self._downloader.trouble(u'ERROR: unable to download video info webpage: %s' % str(err))
return