PEP8
Small bug fixes
This commit is contained in:
@@ -6,7 +6,7 @@ import os
|
|||||||
from mopidy import config, ext
|
from mopidy import config, ext
|
||||||
|
|
||||||
|
|
||||||
__version__ = '0.1.0'
|
__version__ = '0.1.1'
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
@@ -33,4 +33,3 @@ class Extension(ext.Extension):
|
|||||||
def setup(self, registry):
|
def setup(self, registry):
|
||||||
from .backend import RadioNetBackend
|
from .backend import RadioNetBackend
|
||||||
registry.add('backend', RadioNetBackend)
|
registry.add('backend', RadioNetBackend)
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,13 @@
|
|||||||
import pykka
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from mopidy import backend
|
from mopidy import backend
|
||||||
|
|
||||||
|
import pykka
|
||||||
|
|
||||||
import mopidy_radionet
|
import mopidy_radionet
|
||||||
|
|
||||||
from .library import RadioNetLibraryProvider
|
from .library import RadioNetLibraryProvider
|
||||||
from .radionet import RadioNetClient
|
from .radionet import RadioNetClient
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
import pykka
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from mopidy import backend
|
from mopidy import backend
|
||||||
from mopidy.models import Album, Artist, Ref, Track, SearchResult
|
from mopidy.models import Album, Artist, Ref, SearchResult, Track
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -26,9 +28,8 @@ class RadioNetLibraryProvider(backend.LibraryProvider):
|
|||||||
album = Album(
|
album = Album(
|
||||||
artists=[artist],
|
artists=[artist],
|
||||||
images=[radio_data.image],
|
images=[radio_data.image],
|
||||||
name=radio_data.description + " / " + radio_data.continent +
|
name=radio_data.description + ' / ' + radio_data.continent +
|
||||||
" / " +
|
' / ' + radio_data.country + ' - ' + radio_data.city,
|
||||||
radio_data.country + " - " + radio_data.city,
|
|
||||||
uri='radionet:station:%s' % (identifier))
|
uri='radionet:station:%s' % (identifier))
|
||||||
|
|
||||||
track = Track(
|
track = Track(
|
||||||
@@ -54,17 +55,17 @@ class RadioNetLibraryProvider(backend.LibraryProvider):
|
|||||||
directories.append(
|
directories.append(
|
||||||
self.ref_directory(
|
self.ref_directory(
|
||||||
"radionet:category:favstations", "My stations")
|
"radionet:category:favstations", "My stations")
|
||||||
)
|
)
|
||||||
if self.backend.radionet.local_stations:
|
if self.backend.radionet.local_stations:
|
||||||
directories.append(
|
directories.append(
|
||||||
self.ref_directory(
|
self.ref_directory(
|
||||||
"radionet:category:localstations", "Local stations")
|
"radionet:category:localstations", "Local stations")
|
||||||
)
|
)
|
||||||
if self.backend.radionet.top_stations:
|
if self.backend.radionet.top_stations:
|
||||||
directories.append(
|
directories.append(
|
||||||
self.ref_directory(
|
self.ref_directory(
|
||||||
"radionet:category:top100", "Top 100")
|
"radionet:category:top100", "Top 100")
|
||||||
)
|
)
|
||||||
elif variant == 'category' and identifier:
|
elif variant == 'category' and identifier:
|
||||||
if identifier == "favstations":
|
if identifier == "favstations":
|
||||||
for station in self.backend.radionet.fav_stations:
|
for station in self.backend.radionet.fav_stations:
|
||||||
@@ -93,14 +94,14 @@ class RadioNetLibraryProvider(backend.LibraryProvider):
|
|||||||
result.append(self.station_to_track(station))
|
result.append(self.station_to_track(station))
|
||||||
|
|
||||||
return SearchResult(
|
return SearchResult(
|
||||||
tracks=result
|
tracks=result
|
||||||
)
|
)
|
||||||
|
|
||||||
def station_to_ref(self, station):
|
def station_to_ref(self, station):
|
||||||
return Ref.track(
|
return Ref.track(
|
||||||
uri='radionet:station:%s' % (station.id),
|
uri='radionet:station:%s' % (station.id),
|
||||||
name=station.name,
|
name=station.name,
|
||||||
)
|
)
|
||||||
|
|
||||||
def station_to_track(self, station):
|
def station_to_track(self, station):
|
||||||
ref = self.station_to_ref(station)
|
ref = self.station_to_ref(station)
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
#!/usr/bin/env python2
|
#!/usr/bin/env python2
|
||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
|
|
||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
import logging
|
import logging
|
||||||
import requests
|
|
||||||
import re
|
import re
|
||||||
import time
|
import time
|
||||||
|
|
||||||
from mopidy import httpclient
|
from mopidy import httpclient
|
||||||
|
|
||||||
|
import requests
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -90,7 +90,7 @@ class RadioNetClient(object):
|
|||||||
logger.debug('Radio.net: Check auth.')
|
logger.debug('Radio.net: Check auth.')
|
||||||
api_sufix = 'user/account'
|
api_sufix = 'user/account'
|
||||||
response = self.session.post(self.api_base_url + api_sufix,
|
response = self.session.post(self.api_base_url + api_sufix,
|
||||||
params=url_params)
|
params=url_params)
|
||||||
|
|
||||||
if response.status_code is not 200:
|
if response.status_code is not 200:
|
||||||
logger.error('Radio.net: Auth error.')
|
logger.error('Radio.net: Auth error.')
|
||||||
@@ -123,7 +123,7 @@ class RadioNetClient(object):
|
|||||||
'password': password,
|
'password': password,
|
||||||
}
|
}
|
||||||
response = self.session.post(self.api_base_url + api_sufix,
|
response = self.session.post(self.api_base_url + api_sufix,
|
||||||
params=url_params, data=payload)
|
params=url_params, data=payload)
|
||||||
|
|
||||||
if response.status_code is not 200:
|
if response.status_code is not 200:
|
||||||
logger.error('Radio.net: Login error. ' + response.text)
|
logger.error('Radio.net: Login error. ' + response.text)
|
||||||
@@ -141,7 +141,7 @@ class RadioNetClient(object):
|
|||||||
}
|
}
|
||||||
api_sufix = 'user/logout'
|
api_sufix = 'user/logout'
|
||||||
response = self.session.post(self.api_base_url + api_sufix,
|
response = self.session.post(self.api_base_url + api_sufix,
|
||||||
params=url_params)
|
params=url_params)
|
||||||
|
|
||||||
if response.status_code is not 200:
|
if response.status_code is not 200:
|
||||||
logger.error('Radio.net: Error logout.')
|
logger.error('Radio.net: Error logout.')
|
||||||
@@ -165,7 +165,7 @@ class RadioNetClient(object):
|
|||||||
api_sufix = 'user/bookmarks'
|
api_sufix = 'user/bookmarks'
|
||||||
|
|
||||||
response = self.session.post(self.api_base_url + api_sufix,
|
response = self.session.post(self.api_base_url + api_sufix,
|
||||||
params=url_params)
|
params=url_params)
|
||||||
|
|
||||||
if response.status_code is not 200:
|
if response.status_code is not 200:
|
||||||
logger.error('Radio.net: ' + response.text)
|
logger.error('Radio.net: ' + response.text)
|
||||||
@@ -179,7 +179,7 @@ class RadioNetClient(object):
|
|||||||
|
|
||||||
for stream in stream_json:
|
for stream in stream_json:
|
||||||
if int(stream['bitRate']) >= bitrate and \
|
if int(stream['bitRate']) >= bitrate and \
|
||||||
stream['streamStatus'] == 'VALID':
|
stream['streamStatus'] == 'VALID':
|
||||||
stream_url = stream['streamUrl']
|
stream_url = stream['streamUrl']
|
||||||
break
|
break
|
||||||
|
|
||||||
@@ -208,10 +208,10 @@ class RadioNetClient(object):
|
|||||||
'station': station_id,
|
'station': station_id,
|
||||||
}
|
}
|
||||||
response = self.session.post(self.api_base_url + api_sufix,
|
response = self.session.post(self.api_base_url + api_sufix,
|
||||||
params=url_params)
|
params=url_params)
|
||||||
if response.status_code is not 200:
|
if response.status_code is not 200:
|
||||||
logger.error('Radio.net: Error on get station by id ' +
|
logger.error('Radio.net: Error on get station by id ' +
|
||||||
str(station_id) + ". Error: " + response.text)
|
str(station_id) + ". Error: " + response.text)
|
||||||
return False
|
return False
|
||||||
else:
|
else:
|
||||||
logger.debug('Radio.net: Done get top stations list')
|
logger.debug('Radio.net: Done get top stations list')
|
||||||
@@ -234,6 +234,8 @@ class RadioNetClient(object):
|
|||||||
return tmpStation
|
return tmpStation
|
||||||
|
|
||||||
def get_local_stations(self):
|
def get_local_stations(self):
|
||||||
|
self.local_stations = []
|
||||||
|
|
||||||
api_sufix = 'search/localstations'
|
api_sufix = 'search/localstations'
|
||||||
|
|
||||||
url_params = {
|
url_params = {
|
||||||
@@ -244,11 +246,11 @@ class RadioNetClient(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
response = self.session.post(self.api_base_url + api_sufix,
|
response = self.session.post(self.api_base_url + api_sufix,
|
||||||
params=url_params)
|
params=url_params)
|
||||||
|
|
||||||
if response.status_code is not 200:
|
if response.status_code is not 200:
|
||||||
logger.error('Radio.net: Get local stations error. ' +
|
logger.error('Radio.net: Get local stations error. ' +
|
||||||
response.text)
|
response.text)
|
||||||
else:
|
else:
|
||||||
logger.debug('Radio.net: Done get local stations list')
|
logger.debug('Radio.net: Done get local stations list')
|
||||||
json = response.json()
|
json = response.json()
|
||||||
@@ -262,6 +264,7 @@ class RadioNetClient(object):
|
|||||||
' local stations.')
|
' local stations.')
|
||||||
|
|
||||||
def get_top_stations(self):
|
def get_top_stations(self):
|
||||||
|
self.top_stations = []
|
||||||
api_sufix = 'search/topstations'
|
api_sufix = 'search/topstations'
|
||||||
|
|
||||||
url_params = {
|
url_params = {
|
||||||
@@ -272,7 +275,7 @@ class RadioNetClient(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
response = self.session.post(self.api_base_url + api_sufix,
|
response = self.session.post(self.api_base_url + api_sufix,
|
||||||
params=url_params)
|
params=url_params)
|
||||||
|
|
||||||
if response.status_code is not 200:
|
if response.status_code is not 200:
|
||||||
logger.error('Radio.net: Get top stations error. ' + response.text)
|
logger.error('Radio.net: Get top stations error. ' + response.text)
|
||||||
@@ -300,7 +303,7 @@ class RadioNetClient(object):
|
|||||||
'pageindex': page_index,
|
'pageindex': page_index,
|
||||||
}
|
}
|
||||||
response = self.session.post(self.api_base_url + api_sufix,
|
response = self.session.post(self.api_base_url + api_sufix,
|
||||||
params=url_params)
|
params=url_params)
|
||||||
|
|
||||||
if response.status_code is not 200:
|
if response.status_code is not 200:
|
||||||
logger.error('Radio.net: Search error ' + response.text)
|
logger.error('Radio.net: Search error ' + response.text)
|
||||||
|
|||||||
4
setup.py
4
setup.py
@@ -14,9 +14,9 @@ def get_version(filename):
|
|||||||
setup(
|
setup(
|
||||||
name='Mopidy-RadioNet',
|
name='Mopidy-RadioNet',
|
||||||
version=get_version('mopidy_radionet/__init__.py'),
|
version=get_version('mopidy_radionet/__init__.py'),
|
||||||
url='https://github.com/blakberrymamba/mopidy-radionet',
|
url='https://github.com/blackberrymamba/mopidy-radionet',
|
||||||
license='Apache License, Version 2.0',
|
license='Apache License, Version 2.0',
|
||||||
author='blakberrymamba',
|
author='blackberrymamba',
|
||||||
author_email='mariusz@typedef.pl',
|
author_email='mariusz@typedef.pl',
|
||||||
description='Mopidy extension for radio.net',
|
description='Mopidy extension for radio.net',
|
||||||
long_description=open('README.rst').read(),
|
long_description=open('README.rst').read(),
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from mopidy_radionet import Extension
|
from mopidy_radionet import Extension
|
||||||
|
|
||||||
|
|
||||||
@@ -20,5 +21,3 @@ def test_get_config_schema():
|
|||||||
assert 'password' in schema
|
assert 'password' in schema
|
||||||
assert 'language' in schema
|
assert 'language' in schema
|
||||||
assert 'min_bitrate' in schema
|
assert 'min_bitrate' in schema
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -16,8 +16,8 @@ class RadioNetClientTest(unittest.TestCase):
|
|||||||
|
|
||||||
def test_login(self):
|
def test_login(self):
|
||||||
radionet = RadioNetClient()
|
radionet = RadioNetClient()
|
||||||
radionet.login(self.username,self.password)
|
radionet.login(self.username, self.password)
|
||||||
self.assertEqual(radionet.user_login,self.username)
|
self.assertEqual(radionet.user_login, self.username)
|
||||||
|
|
||||||
def test_get_bookmarks(self):
|
def test_get_bookmarks(self):
|
||||||
radionet = RadioNetClient()
|
radionet = RadioNetClient()
|
||||||
@@ -50,8 +50,6 @@ class RadioNetClientTest(unittest.TestCase):
|
|||||||
radionet.do_search("radio ram")
|
radionet.do_search("radio ram")
|
||||||
self.assertGreater(len(radionet.search_results), 0)
|
self.assertGreater(len(radionet.search_results), 0)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
unittest.main()
|
||||||
unittest.main()
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user