mirror of
https://github.com/alexta69/metube.git
synced 2026-03-18 22:43:51 +00:00
refactor: simplify filename generation by removing unnecessary relative path computation (closes #916, closes #917)
This commit is contained in:
11
app/ytdl.py
11
app/ytdl.py
@@ -214,16 +214,7 @@ class Download:
|
|||||||
filepath = d['info_dict']['filepath']
|
filepath = d['info_dict']['filepath']
|
||||||
if '__finaldir' in d['info_dict']:
|
if '__finaldir' in d['info_dict']:
|
||||||
finaldir = d['info_dict']['__finaldir']
|
finaldir = d['info_dict']['__finaldir']
|
||||||
# Compute relative path from temp dir to preserve
|
filename = os.path.join(finaldir, os.path.basename(filepath))
|
||||||
# subdirectory structure from the output template.
|
|
||||||
try:
|
|
||||||
rel_path = os.path.relpath(filepath, self.temp_dir)
|
|
||||||
except ValueError:
|
|
||||||
rel_path = os.path.basename(filepath)
|
|
||||||
if rel_path.startswith('..'):
|
|
||||||
# filepath is not under temp_dir, fall back to basename
|
|
||||||
rel_path = os.path.basename(filepath)
|
|
||||||
filename = os.path.join(finaldir, rel_path)
|
|
||||||
else:
|
else:
|
||||||
filename = filepath
|
filename = filepath
|
||||||
self.status_queue.put({'status': 'finished', 'filename': filename})
|
self.status_queue.put({'status': 'finished', 'filename': filename})
|
||||||
|
|||||||
Reference in New Issue
Block a user