M README.md +3 -3
@@ 20,20 20,20 @@ Mopidy-Multisonic to your Mopidy configu
```
[multisonic]
providers =
- PROVIDER_NAME: PROTOCOL://USERNAME:PASSWORD@TARGET
+ PROVIDER_NAME: PROTOCOL://USERNAME:PASSWORD@TARGET?[option1=value1&option2=value2]
[ANOTHER]
```
```
[multisonic]
providers =
- banalisation: https://mr_banal:azerty@music.banalserver.com
+ banalisation: https://mr_banal:azerty@music.banalserver.com?max_bit_rate=320
```
```
[multisonic]
providers =
- banalisation: https://mr_banal:azerty@music.banalserver.com
+ banalisation: https://mr_banal:azerty@music.banalserver.com?max_bit_rate=320
decadence: http://h4ck3r:1213@toot.com
```
M mopidy_multisonic/backend.py +16 -2
@@ 10,21 10,35 @@ from . import playback
from . import httpclient
from . import uri_parser
+def parse_raw_options(raw_options):
+ if not raw_options:
+ return {}
+
+ options = {}
+ for raw_option in raw_options.split("&"):
+ key, value = raw_option.split("=")
+ options[key] = value
+
+ return options
def load_http_client_config(provider):
- match = re.match(r'^([^:]+):(?: )?([^:]+)://([^:]+):([^@]+)@(.+)', provider)
+ match = re.match(r'^([^:]+):(?: )?([^:]+)://([^:]+):([^@]+)@([^?]+)(\?([^=]+=[^&]+)+)?', provider)
name=match.group(1)
protocol=match.group(2)
username=match.group(3)
password=match.group(4)
url=match.group(5)
+ raw_options=match.group(7)
+
+ options = parse_raw_options(raw_options)
return httpclient.HttpClientConfig(
name=name,
url=protocol + "://" + url,
username=username,
- password=password
+ password=password,
+ max_bit_rate=options.get("max_bit_rate")
)
def load_http_client_configs(config):
M mopidy_multisonic/httpclient.py +5 -0
@@ 10,6 10,7 @@ HttpClientConfig = namedtuple(
'url',
'username',
'password',
+ 'max_bit_rate',
]
)
@@ 89,6 90,10 @@ def get_stream(client_config, id):
params = {
"id": id,
}
+
+ if client_config.max_bit_rate:
+ params["maxBitRate"] = client_config.max_bit_rate,
+
return get_request(client_config, "/rest/stream", params)
def get_search(client_config, query):