diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index c0b79fa..613735c 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -54,7 +54,7 @@ had to install to develop the app. In general, the requirements are: #### Specific Requirements for Various Distros/OSes * **NixOS:** use the `shell.nix` which will also run the `poetry install` -* **Arch Linux:** `pacman -S libnm-glib libnotify python-gobject` +* **Arch Linux:** `pacman -S libnm-glib libnotify python-gobject gobject-introspection` * **macOS (Homebrew):** `brew install mp3 gobject-introspection pkg-config pygobject3 gtk+3 adwaita-icon-theme` ### Installing diff --git a/sublime_music/adapters/subsonic/adapter.py b/sublime_music/adapters/subsonic/adapter.py index 4dbe3d1..7ef9601 100644 --- a/sublime_music/adapters/subsonic/adapter.py +++ b/sublime_music/adapters/subsonic/adapter.py @@ -444,18 +444,41 @@ class SubsonicAdapter(Adapter): logging.info("Using mock data") result = self._get_mock_data() else: - result = requests.get( - url, - params=params, - verify=self.verify_cert, - timeout=timeout, - ) + if url.startswith("http://") or url.startswith("https://"): + result = requests.get( + url, + params=params, + verify=self.verify_cert, + timeout=timeout, + ) + else: + # if user creates a serverconf address w/o protocol, we'll + # attempt to fix it and store it in hostname + # TODO (#305) #hostname currently preprends https:// if + # protocol isn't defined this might be able to be taken out + try: + logging.info("Hostname: %r has no protocol", self.hostname) + result = requests.get( + "https://" + url, + params=params, + verify=self.verify_cert, + timeout=timeout, + ) + self.hostname = "https://" + url.split("/")[0] + except Exception: + result = requests.get( + "http://" + url, + params=params, + verify=self.verify_cert, + timeout=timeout, + ) + + self.hostname = "http://" + url.split("/")[0] if result.status_code != 200: raise ServerError( result.status_code, f"{url} returned status={result.status_code}." ) - # Any time that a server request succeeds, then we win. self._server_available.value = True self._last_ping_timestamp.value = datetime.now().timestamp()