Merge pull request #252 from radiorabe/fix/pypo-tls-support

Use proper protocol in URL if port is set to 443
This commit is contained in:
Robb 2017-07-23 08:36:21 -04:00 committed by GitHub
commit c3bd93779b
1 changed files with 6 additions and 2 deletions

View File

@ -64,8 +64,12 @@ class PypoFile(Thread):
username = self._config.get(CONFIG_SECTION, 'api_key')
host = self._config.get(CONFIG_SECTION, 'base_url')
port = self._config.get(CONFIG_SECTION, 'base_port', 80)
url = "http://%s:%s/rest/media/%s/download" % (host, port, media_item["id"])
self.logger.error(url)
url = "%s://%s:%s/rest/media/%s/download" % (str(("http", "https")[int(port) == 443]),
host,
port,
media_item["id"])
self.logger.info(url)
with open(dst, "wb") as handle:
response = requests.get(url, auth=requests.auth.HTTPBasicAuth(username, ''), stream=True, verify=False)