PEP8
Small bug fixes
This commit is contained in:
@@ -6,7 +6,7 @@ import os
|
||||
from mopidy import config, ext
|
||||
|
||||
|
||||
__version__ = '0.1.0'
|
||||
__version__ = '0.1.1'
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
@@ -33,4 +33,3 @@ class Extension(ext.Extension):
|
||||
def setup(self, registry):
|
||||
from .backend import RadioNetBackend
|
||||
registry.add('backend', RadioNetBackend)
|
||||
|
||||
|
||||
@@ -1,8 +1,13 @@
|
||||
import pykka
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import time
|
||||
|
||||
from mopidy import backend
|
||||
|
||||
import pykka
|
||||
|
||||
import mopidy_radionet
|
||||
|
||||
from .library import RadioNetLibraryProvider
|
||||
from .radionet import RadioNetClient
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import pykka
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import re
|
||||
|
||||
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__)
|
||||
|
||||
@@ -26,9 +28,8 @@ class RadioNetLibraryProvider(backend.LibraryProvider):
|
||||
album = Album(
|
||||
artists=[artist],
|
||||
images=[radio_data.image],
|
||||
name=radio_data.description + " / " + radio_data.continent +
|
||||
" / " +
|
||||
radio_data.country + " - " + radio_data.city,
|
||||
name=radio_data.description + ' / ' + radio_data.continent +
|
||||
' / ' + radio_data.country + ' - ' + radio_data.city,
|
||||
uri='radionet:station:%s' % (identifier))
|
||||
|
||||
track = Track(
|
||||
@@ -54,17 +55,17 @@ class RadioNetLibraryProvider(backend.LibraryProvider):
|
||||
directories.append(
|
||||
self.ref_directory(
|
||||
"radionet:category:favstations", "My stations")
|
||||
)
|
||||
)
|
||||
if self.backend.radionet.local_stations:
|
||||
directories.append(
|
||||
self.ref_directory(
|
||||
"radionet:category:localstations", "Local stations")
|
||||
)
|
||||
)
|
||||
if self.backend.radionet.top_stations:
|
||||
directories.append(
|
||||
self.ref_directory(
|
||||
"radionet:category:top100", "Top 100")
|
||||
)
|
||||
)
|
||||
elif variant == 'category' and identifier:
|
||||
if identifier == "favstations":
|
||||
for station in self.backend.radionet.fav_stations:
|
||||
@@ -93,14 +94,14 @@ class RadioNetLibraryProvider(backend.LibraryProvider):
|
||||
result.append(self.station_to_track(station))
|
||||
|
||||
return SearchResult(
|
||||
tracks=result
|
||||
)
|
||||
tracks=result
|
||||
)
|
||||
|
||||
def station_to_ref(self, station):
|
||||
return Ref.track(
|
||||
uri='radionet:station:%s' % (station.id),
|
||||
name=station.name,
|
||||
)
|
||||
)
|
||||
|
||||
def station_to_track(self, station):
|
||||
ref = self.station_to_ref(station)
|
||||
@@ -113,4 +114,4 @@ class RadioNetLibraryProvider(backend.LibraryProvider):
|
||||
result = re.findall(r'^radionet:([a-z]+):?([a-z0-9]+|\d+)?$', uri)
|
||||
if result:
|
||||
return result[0]
|
||||
return None, None
|
||||
return None, None
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
#!/usr/bin/env python2
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from __future__ import unicode_literals
|
||||
|
||||
import logging
|
||||
import requests
|
||||
import re
|
||||
import time
|
||||
|
||||
from mopidy import httpclient
|
||||
|
||||
import requests
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
@@ -90,7 +90,7 @@ class RadioNetClient(object):
|
||||
logger.debug('Radio.net: Check auth.')
|
||||
api_sufix = 'user/account'
|
||||
response = self.session.post(self.api_base_url + api_sufix,
|
||||
params=url_params)
|
||||
params=url_params)
|
||||
|
||||
if response.status_code is not 200:
|
||||
logger.error('Radio.net: Auth error.')
|
||||
@@ -123,7 +123,7 @@ class RadioNetClient(object):
|
||||
'password': password,
|
||||
}
|
||||
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:
|
||||
logger.error('Radio.net: Login error. ' + response.text)
|
||||
@@ -141,7 +141,7 @@ class RadioNetClient(object):
|
||||
}
|
||||
api_sufix = 'user/logout'
|
||||
response = self.session.post(self.api_base_url + api_sufix,
|
||||
params=url_params)
|
||||
params=url_params)
|
||||
|
||||
if response.status_code is not 200:
|
||||
logger.error('Radio.net: Error logout.')
|
||||
@@ -165,7 +165,7 @@ class RadioNetClient(object):
|
||||
api_sufix = 'user/bookmarks'
|
||||
|
||||
response = self.session.post(self.api_base_url + api_sufix,
|
||||
params=url_params)
|
||||
params=url_params)
|
||||
|
||||
if response.status_code is not 200:
|
||||
logger.error('Radio.net: ' + response.text)
|
||||
@@ -179,7 +179,7 @@ class RadioNetClient(object):
|
||||
|
||||
for stream in stream_json:
|
||||
if int(stream['bitRate']) >= bitrate and \
|
||||
stream['streamStatus'] == 'VALID':
|
||||
stream['streamStatus'] == 'VALID':
|
||||
stream_url = stream['streamUrl']
|
||||
break
|
||||
|
||||
@@ -208,10 +208,10 @@ class RadioNetClient(object):
|
||||
'station': station_id,
|
||||
}
|
||||
response = self.session.post(self.api_base_url + api_sufix,
|
||||
params=url_params)
|
||||
params=url_params)
|
||||
if response.status_code is not 200:
|
||||
logger.error('Radio.net: Error on get station by id ' +
|
||||
str(station_id) + ". Error: " + response.text)
|
||||
str(station_id) + ". Error: " + response.text)
|
||||
return False
|
||||
else:
|
||||
logger.debug('Radio.net: Done get top stations list')
|
||||
@@ -234,6 +234,8 @@ class RadioNetClient(object):
|
||||
return tmpStation
|
||||
|
||||
def get_local_stations(self):
|
||||
self.local_stations = []
|
||||
|
||||
api_sufix = 'search/localstations'
|
||||
|
||||
url_params = {
|
||||
@@ -244,11 +246,11 @@ class RadioNetClient(object):
|
||||
}
|
||||
|
||||
response = self.session.post(self.api_base_url + api_sufix,
|
||||
params=url_params)
|
||||
params=url_params)
|
||||
|
||||
if response.status_code is not 200:
|
||||
logger.error('Radio.net: Get local stations error. ' +
|
||||
response.text)
|
||||
response.text)
|
||||
else:
|
||||
logger.debug('Radio.net: Done get local stations list')
|
||||
json = response.json()
|
||||
@@ -262,6 +264,7 @@ class RadioNetClient(object):
|
||||
' local stations.')
|
||||
|
||||
def get_top_stations(self):
|
||||
self.top_stations = []
|
||||
api_sufix = 'search/topstations'
|
||||
|
||||
url_params = {
|
||||
@@ -272,7 +275,7 @@ class RadioNetClient(object):
|
||||
}
|
||||
|
||||
response = self.session.post(self.api_base_url + api_sufix,
|
||||
params=url_params)
|
||||
params=url_params)
|
||||
|
||||
if response.status_code is not 200:
|
||||
logger.error('Radio.net: Get top stations error. ' + response.text)
|
||||
@@ -300,7 +303,7 @@ class RadioNetClient(object):
|
||||
'pageindex': page_index,
|
||||
}
|
||||
response = self.session.post(self.api_base_url + api_sufix,
|
||||
params=url_params)
|
||||
params=url_params)
|
||||
|
||||
if response.status_code is not 200:
|
||||
logger.error('Radio.net: Search error ' + response.text)
|
||||
@@ -317,4 +320,4 @@ class RadioNetClient(object):
|
||||
self.do_search(query_string, page_index + 1)
|
||||
else:
|
||||
logger.info('Radio.net: Found ' +
|
||||
str(len(self.search_results)) + ' stations.')
|
||||
str(len(self.search_results)) + ' stations.')
|
||||
|
||||
Reference in New Issue
Block a user