diff options
-rw-r--r-- | mastodon/Mastodon.py | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index b4d4aa3..d2d634e 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -1299,9 +1299,16 @@ class Mastodon: | |||
1299 | instance = self.instance() | 1299 | instance = self.instance() |
1300 | if "streaming_api" in instance["urls"] and instance["urls"]["streaming_api"] != self.api_base_url: | 1300 | if "streaming_api" in instance["urls"] and instance["urls"]["streaming_api"] != self.api_base_url: |
1301 | # This is probably a websockets URL, which is really for the browser, but requests can't handle it | 1301 | # This is probably a websockets URL, which is really for the browser, but requests can't handle it |
1302 | # So we do this below to turn it into an HTTPS URL | 1302 | # So we do this below to turn it into an HTTPS or HTTP URL |
1303 | parse = urlparse(instance["urls"]["streaming_api"]) | 1303 | parse = urlparse(instance["urls"]["streaming_api"]) |
1304 | url = "https://" + parse.netloc | 1304 | if parse.scheme == 'wss': |
1305 | url = "https://" + parse.netloc | ||
1306 | elif parse.scheme == 'ws': | ||
1307 | url = "http://" + parse.netloc | ||
1308 | else: | ||
1309 | raise MastodonAPIError( | ||
1310 | "Could not parse streaming api location returned from server: {}.".format( | ||
1311 | instance["urls"]["streaming_api"])) | ||
1305 | else: | 1312 | else: |
1306 | url = self.api_base_url | 1313 | url = self.api_base_url |
1307 | 1314 | ||