Fixed pyflakes and pep8 warnings
parent
dd06c95e43
commit
7ed806d241
|
@ -11,6 +11,7 @@ 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
|
||||||
|
|
||||||
|
|
||||||
class GroovesharkHtmlParser(compat_html_parser.HTMLParser):
|
class GroovesharkHtmlParser(compat_html_parser.HTMLParser):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._current_object = None
|
self._current_object = None
|
||||||
|
@ -20,7 +21,7 @@ class GroovesharkHtmlParser(compat_html_parser.HTMLParser):
|
||||||
def handle_starttag(self, tag, attrs):
|
def handle_starttag(self, tag, attrs):
|
||||||
attrs = dict((k, v) for k, v in attrs)
|
attrs = dict((k, v) for k, v in attrs)
|
||||||
if tag == 'object':
|
if tag == 'object':
|
||||||
self._current_object = { 'attrs': attrs, 'params': [] }
|
self._current_object = {'attrs': attrs, 'params': []}
|
||||||
elif tag == 'param':
|
elif tag == 'param':
|
||||||
self._current_object['params'].append(attrs)
|
self._current_object['params'].append(attrs)
|
||||||
|
|
||||||
|
@ -36,6 +37,7 @@ class GroovesharkHtmlParser(compat_html_parser.HTMLParser):
|
||||||
p.close()
|
p.close()
|
||||||
return p.objects
|
return p.objects
|
||||||
|
|
||||||
|
|
||||||
class GroovesharkIE(InfoExtractor):
|
class GroovesharkIE(InfoExtractor):
|
||||||
_VALID_URL = r'https?://(www\.)?grooveshark\.com/#!/s/([^/]+)/([^/]+)'
|
_VALID_URL = r'https?://(www\.)?grooveshark\.com/#!/s/([^/]+)/([^/]+)'
|
||||||
_TEST = {
|
_TEST = {
|
||||||
|
@ -154,12 +156,12 @@ class GroovesharkIE(InfoExtractor):
|
||||||
headers = {
|
headers = {
|
||||||
'Content-Length': len(post_data),
|
'Content-Length': len(post_data),
|
||||||
'Content-Type': 'application/x-www-form-urlencoded'
|
'Content-Type': 'application/x-www-form-urlencoded'
|
||||||
}
|
}
|
||||||
|
|
||||||
if 'swf_referer' in locals():
|
if 'swf_referer' in locals():
|
||||||
headers['Referer'] = swf_referer
|
headers['Referer'] = swf_referer
|
||||||
|
|
||||||
req = compat_urllib_request.Request(streamurl, post_data, headers)
|
req = compat_urllib_request.Request(stream_url, post_data, headers)
|
||||||
|
|
||||||
info_dict = {
|
info_dict = {
|
||||||
'id': token,
|
'id': token,
|
||||||
|
@ -170,11 +172,13 @@ class GroovesharkIE(InfoExtractor):
|
||||||
'format': 'mp3 audio',
|
'format': 'mp3 audio',
|
||||||
'duration': duration,
|
'duration': duration,
|
||||||
|
|
||||||
|
# various ways of supporting the download request.
|
||||||
|
# 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,
|
'headers': headers,
|
||||||
'request': req
|
'request': req
|
||||||
}
|
}
|
||||||
|
|
||||||
if 'swf_referer' in locals():
|
if 'swf_referer' in locals():
|
||||||
info_dict['http_referer'] = swf_referer
|
info_dict['http_referer'] = swf_referer
|
||||||
|
@ -197,4 +201,3 @@ class GroovesharkIE(InfoExtractor):
|
||||||
if fatal:
|
if fatal:
|
||||||
raise ee
|
raise ee
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue