match provider by prefix

This commit is contained in:
Roy Olav Purser 2021-07-23 17:38:59 +02:00
parent f739418141
commit ab34a21f2c
Signed by: roypur
GPG Key ID: E14D26A036F21656

View File

@ -139,9 +139,9 @@ class UpstreamHandler():
if self.provider in providers.keys():
self.valid = True
path = handler.request.path
if self.provider == "nextcloud":
if self.provider.startswith("nextcloud"):
path = path.removesuffix("/").removesuffix("download").removesuffix("/")
elif self.provider == "youtube":
elif self.provider.startswith("youtube"):
path = path.removeprefix("/")
self.upstream = providers[self.provider] + path
proxy_list = proxies.get(self.provider)
@ -215,7 +215,7 @@ class MainHandler(tornado.web.RequestHandler):
async def handle_render(self, handler):
if template_script is not None and template_html is not None:
provider_data = None
if handler.provider == "nextcloud":
if handler.provider.startswith("nextcloud"):
provider_data = await stream_providers.get_nextcloud(handler.upstream, handler.proxy, logger)
else:
provider_data = await stream_providers.get_any(handler.upstream, handler.proxy, logger)