refactor: simplify filename generation by removing unnecessary relative path computation (closes #916, closes #917)
This commit is contained in:
parent
58c317f7cd
commit
1915bdfc46
1 changed files with 1 additions and 10 deletions
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})
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue