diff --git a/resources/data/settings.json b/resources/data/settings.json index 670347d..40fb303 100644 --- a/resources/data/settings.json +++ b/resources/data/settings.json @@ -2,46 +2,30 @@ "stream_url": { "user_agent": "Mozilla/5.0" }, + "streams": { + "public": {"low": "android_low", "moderate": "android"}, + "premium": {"low": "premium_low", "moderate": "premium", "medium": "premium_medium", "high": "premium_high"} + }, "networks": { "di": { "domain": "di.fm", - "display_name": "DigitallyImported", - "streams": { - "public": {"low": "android_low", "moderate": "android"}, - "premium": {"low": "premium_low", "moderate": "premium", "medium": "premium_medium", "high": "premium_high"} - } + "display_name": "DigitallyImported" }, "radiotunes": { "domain": "radiotunes.com", - "display_name": "RadioTunes", - "streams": { - "public": {"low": "android_low", "moderate": "android"}, - "premium": {"low": "premium_low", "moderate": "premium", "medium": "premium_medium", "high": "premium_high"} - } + "display_name": "RadioTunes" }, "rockradio": { "domain": "rockradio.com", - "display_name": "RockRadio", - "streams": { - "public": {"low": "android_low", "moderate": "android"}, - "premium": {"low": "premium_low", "moderate": "premium", "medium": "premium_medium", "high": "premium_high"} - } + "display_name": "RockRadio" }, "jazzradio": { "domain": "jazzradio.com", - "display_name": "JazzRadio", - "streams": { - "public": {"low": "android_low", "moderate": "android"}, - "premium": {"low": "premium_low", "moderate": "premium", "medium": "premium_medium", "high": "premium_high"} - } + "display_name": "JazzRadio" }, "classicalradio": { "domain": "classicalradio.com", - "display_name": "ClassicalRadio", - "streams": { - "public": {"low": "android_low", "moderate": "android"}, - "premium": {"low": "premium_low", "moderate": "premium", "medium": "premium_medium", "high": "premium_high"} - } + "display_name": "ClassicalRadio" } }, "network_order": ["di", "radiotunes", "rockradio", "jazzradio", "classicalradio"] diff --git a/resources/lib/audioaddict/settings.py b/resources/lib/audioaddict/settings.py index ac560ef..1765870 100644 --- a/resources/lib/audioaddict/settings.py +++ b/resources/lib/audioaddict/settings.py @@ -32,7 +32,8 @@ def user_agent(self): def get_network(self, network_key): return NetworkSettings(network_key, - self._settings['networks'][network_key]) + self._settings['networks'][network_key], + self._settings['streams']) @property def networks(self): @@ -45,8 +46,10 @@ def networks(self): class NetworkSettings(object): - def __init__(self, key, network): + def __init__(self, key, network, streams): self._network = network + self._streams = streams + self.key = key @property @@ -62,11 +65,9 @@ def referer(self): return "http://www.%s/" % self.domain def get_stream_key(self, quality_key, premium=False): - streams = self._network['streams'] - if premium: - stream_key = streams['premium'][quality_key] + stream_key = self._streams['premium'][quality_key] else: - stream_key = streams['public'][quality_key] + stream_key = self._streams['public'][quality_key] return stream_key