Browse Source

Fixed errors found by travisci:

py26: re.split can't take flags. use inline flags or re.compile
py27: info_dict must be serializable. remove request object
py335, py34: no urlparse module. use utils.compat_urlparse
Keith Beckman 11 years ago
parent
commit
ee1a7032d5
1 changed files with 8 additions and 6 deletions
  1. 8 6
      youtube_dl/extractor/grooveshark.py

+ 8 - 6
youtube_dl/extractor/grooveshark.py

@@ -4,13 +4,18 @@ from __future__ import unicode_literals
 import time
 import time
 import math
 import math
 import re
 import re
-from urlparse import urlparse, urlunparse, urldefrag
+
 from urllib import quote, urlencode
 from urllib import quote, urlencode
 from os.path import basename
 from os.path import basename
 
 
 from .common import InfoExtractor
 from .common import InfoExtractor
 from ..utils import ExtractorError, compat_urllib_request, compat_html_parser
 from ..utils import ExtractorError, compat_urllib_request, compat_html_parser
 
 
+from ..utils import compat_urlparse
+urlparse = compat_urlparse.urlparse
+urlunparse = compat_urlparse.urlunparse
+urldefrag = compat_urlparse.urldefrag
+
 
 
 class GroovesharkHtmlParser(compat_html_parser.HTMLParser):
 class GroovesharkHtmlParser(compat_html_parser.HTMLParser):
     def __init__(self):
     def __init__(self):
@@ -78,7 +83,7 @@ class GroovesharkIE(InfoExtractor):
         return urlunparse((uri.scheme, uri.netloc, obj['attrs']['data'], None, None, None))
         return urlunparse((uri.scheme, uri.netloc, obj['attrs']['data'], None, None, None))
 
 
     def _transform_bootstrap(self, js):
     def _transform_bootstrap(self, js):
-        return re.split('^\s*try\s*{', js, flags=re.M)[0] \
+        return re.split('(?m)^\s*try\s*{', js)[0] \
                  .split(' = ', 1)[1].strip().rstrip(';')
                  .split(' = ', 1)[1].strip().rstrip(';')
 
 
     def _transform_meta(self, js):
     def _transform_meta(self, js):
@@ -161,8 +166,6 @@ class GroovesharkIE(InfoExtractor):
         if 'swf_referer' in locals():
         if 'swf_referer' in locals():
             headers['Referer'] = swf_referer
             headers['Referer'] = swf_referer
 
 
-        req = compat_urllib_request.Request(stream_url, post_data, headers)
-
         info_dict = {
         info_dict = {
             'id': token,
             'id': token,
             'title': meta['song']['Name'],
             'title': meta['song']['Name'],
@@ -176,8 +179,7 @@ class GroovesharkIE(InfoExtractor):
             # remove keys unnecessary to the eventual post implementation
             # remove keys unnecessary to the eventual post implementation
             'post_data': post_data,
             'post_data': post_data,
             'post_dict': post_dict,
             'post_dict': post_dict,
-            'headers': headers,
-            'request': req
+            'headers': headers
         }
         }
 
 
         if 'swf_referer' in locals():
         if 'swf_referer' in locals():