diff options
author | James Taylor <user234683@users.noreply.github.com> | 2020-02-06 22:17:58 -0800 |
---|---|---|
committer | James Taylor <user234683@users.noreply.github.com> | 2020-02-06 22:17:58 -0800 |
commit | 6f28d959f00e517ba5c36e486041f7fdaa329e6d (patch) | |
tree | 6082bf55f667acc4aada88c2c69919f26c9ef4e6 | |
parent | d86384c4ec7bdd54b5a8ca5c4860f3e54bfdbd57 (diff) | |
download | yt-local-6f28d959f00e517ba5c36e486041f7fdaa329e6d.tar.lz yt-local-6f28d959f00e517ba5c36e486041f7fdaa329e6d.tar.xz yt-local-6f28d959f00e517ba5c36e486041f7fdaa329e6d.zip |
Fix FileNotFound error when trying to download search plugin when the working directory is not the directory of the program
-rw-r--r-- | settings.py | 1 | ||||
-rw-r--r-- | youtube/search.py | 3 |
2 files changed, 3 insertions, 1 deletions
diff --git a/settings.py b/settings.py index bd6710c..5407922 100644 --- a/settings.py +++ b/settings.py @@ -147,6 +147,7 @@ For security reasons, enabling this is not recommended.''', }), ]) +program_directory = os.path.dirname(os.path.realpath(__file__)) acceptable_targets = settings_info.keys() | {'enable_comments', 'enable_related_videos'} diff --git a/youtube/search.py b/youtube/search.py index 0f6bbc4..34df76f 100644 --- a/youtube/search.py +++ b/youtube/search.py @@ -8,6 +8,7 @@ import base64 import mimetypes from flask import request import flask +import os # Sort: 1 # Upload date: 2 @@ -106,6 +107,6 @@ def get_search_page(): @yt_app.route('/opensearch.xml') def get_search_engine_xml(): - with open("youtube/opensearch.xml", 'rb') as f: + with open(os.path.join(settings.program_directory, 'youtube/opensearch.xml'), 'rb') as f: content = f.read().replace(b'$port_number', str(settings.port_number).encode()) return flask.Response(content, mimetype='application/xml') |