Fix for temporary dir name

This commit is contained in:
2022-09-09 19:45:12 +03:00
parent c35a4e0ad2
commit 4ac6c1a8df

View File

@@ -90,19 +90,18 @@ def upload(key):
key = '/library/metadata/' + key key = '/library/metadata/' + key
item = plex.fetchItem(key) item = plex.fetchItem(key)
if request.method == 'POST': if request.method == 'POST':
# Create a temporary directory if it doesn't exist
if not path.exists('tmp'): if not path.exists('tmp'):
mkdir('tmp') mkdir('tmp')
# Fetch uploaded file # Fetch uploaded file
file = request.files['subtitles'] file = request.files['subtitles']
file.save('./temp/' + secure_filename(file.filename)) file.save('./tmp/' + secure_filename(file.filename))
# Upload file to Plex # Upload file to Plex
item.uploadSubtitles('./temp/' + secure_filename(file.filename)) item.uploadSubtitles('./tmp/' + secure_filename(file.filename))
# Remove temporary file # Remove temporary file
remove('./temp/' + secure_filename(file.filename)) remove('./tmp/' + secure_filename(file.filename))
return render_template('success.html') return render_template('success.html')