Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@
/build/
/dist/
/MANIFEST
.vscode
2 changes: 2 additions & 0 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,8 @@ The following configuration values are available:
- ``tunein/enabled``: If the TuneIn extension should be enabled or not. Defaults to true.
- ``tunein/filter``: Limit the search results. ``station``, ``program`` or leave blank to disable filtering. Defaults to blank.
- ``tunein/timeout``: Milliseconds before giving up waiting for results. Defaults to ``5000``.
- ``tunein/formats``: List of formats supported by local Mopidy installation. Streams that are aren't available in any compatible
format are not returned by search. Defaults to ``*`` (all formats).


Project resources
Expand Down
1 change: 1 addition & 0 deletions mopidy_tunein/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ def get_config_schema(self):
schema["filter"] = config.String(
optional=True, choices=("station", "program")
)
schema["formats"] = config.List(optional=True)
return schema

def setup(self, registry):
Expand Down
2 changes: 2 additions & 0 deletions mopidy_tunein/actor.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,15 @@ def __init__(self, config, audio):
self._session = get_requests_session(config["proxy"])
self._timeout = config["tunein"]["timeout"]
self._filter = config["tunein"]["filter"]
self._formats = config["tunein"]["formats"]

self._scanner = scan.Scanner(
timeout=config["tunein"]["timeout"], proxy_config=config["proxy"]
)
self.tunein = tunein.TuneIn(
config["tunein"]["timeout"],
config["tunein"]["filter"],
config["tunein"]["formats"],
self._session,
)
self.library = TuneInLibrary(self)
Expand Down
1 change: 1 addition & 0 deletions mopidy_tunein/ext.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
enabled = true
filter =
timeout = 5000
formats = *
5 changes: 3 additions & 2 deletions mopidy_tunein/tunein.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ class TuneIn:
ID_STREAM = "stream"
ID_UNKNOWN = "unknown"

def __init__(self, timeout, filter_=None, session=None):
def __init__(self, timeout, filter_=None, formats="*", session=None):
self._base_uri = "https://opml.radiotime.com/%s"
self._session = session or requests.Session()
self._timeout = timeout / 1000.0
Expand All @@ -197,6 +197,7 @@ def __init__(self, timeout, filter_=None, session=None):
else:
self._filter = ""
self._stations = {}
self._formats = f"&formats={','.join(formats)}" if formats else ""

def reload(self):
self._stations.clear()
Expand Down Expand Up @@ -368,7 +369,7 @@ def search(self, query):
logger.debug("Empty search query")
return []
logger.debug(f"Searching TuneIn for '{query}'")
args = f"&query={query}{self._filter}"
args = f"&query={query}{self._filter}{self._formats}"
search_results = self._tunein("Search.ashx", args)
results = []
for item in self._flatten(search_results):
Expand Down
1 change: 1 addition & 0 deletions tests/test_extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ def test_get_config_schema(self):

self.assertIn("timeout", schema)
self.assertIn("filter", schema)
self.assertIn("formats", schema)