0
0
Fork 0

Fixed pyflakes and pep8 warnings

main
Keith Beckman 2014-05-20 02:55:21 -04:00
parent dd06c95e43
commit 7ed806d241
1 changed files with 24 additions and 21 deletions

View File

@ -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