diff options
Diffstat (limited to 'mastodon')
-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 079fc85..3d707ed 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py | |||
@@ -1201,9 +1201,16 @@ class Mastodon: | |||
1201 | instance = self.instance() | 1201 | instance = self.instance() |
1202 | if "streaming_api" in instance["urls"] and instance["urls"]["streaming_api"] != self.api_base_url: | 1202 | if "streaming_api" in instance["urls"] and instance["urls"]["streaming_api"] != self.api_base_url: |
1203 | # This is probably a websockets URL, which is really for the browser, but requests can't handle it | 1203 | # This is probably a websockets URL, which is really for the browser, but requests can't handle it |
1204 | # So we do this below to turn it into an HTTPS URL | 1204 | # So we do this below to turn it into an HTTPS or HTTP URL |
1205 | parse = urlparse(instance["urls"]["streaming_api"]) | 1205 | parse = urlparse(instance["urls"]["streaming_api"]) |
1206 | url = "https://" + parse.netloc | 1206 | if parse.scheme == 'wss': |
1207 | url = "https://" + parse.netloc | ||
1208 | elif parse.scheme == 'ws': | ||
1209 | url = "http://" + parse.netloc | ||
1210 | else: | ||
1211 | raise MastodonAPIError( | ||
1212 | "Could not parse streaming api location returned from server: {}.".format( | ||
1213 | instance["urls"]["streaming_api"])) | ||
1207 | else: | 1214 | else: |
1208 | url = self.api_base_url | 1215 | url = self.api_base_url |
1209 | 1216 | ||