From cb8f0bbb7df6314cfad497bf37da6656528cb8e4 Mon Sep 17 00:00:00 2001 From: MrS0m30n3 Date: Tue, 8 Nov 2016 23:11:43 +0200 Subject: [PATCH] Fix filenames extraction with multiple whitespaces --- youtube_dl_gui/downloaders.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/youtube_dl_gui/downloaders.py b/youtube_dl_gui/downloaders.py index 48df60d..0d731af 100644 --- a/youtube_dl_gui/downloaders.py +++ b/youtube_dl_gui/downloaders.py @@ -371,7 +371,11 @@ def extract_data(stdout): if not stdout: return data_dictionary - stdout = [string for string in stdout.split(' ') if string != ''] + # We want to keep the spaces in order to extract filenames with + # multiple whitespaces correctly. We also keep a copy of the old + # 'stdout' for backward compatibility with the old code + stdout_with_spaces = stdout.split(' ') + stdout = stdout.split() stdout[0] = stdout[0].lstrip('\r') @@ -380,7 +384,7 @@ def extract_data(stdout): # Get path, filename & extension if stdout[1] == 'Destination:': - path, filename, extension = extract_filename(' '.join(stdout[2:])) + path, filename, extension = extract_filename(' '.join(stdout_with_spaces[2:])) data_dictionary['path'] = path data_dictionary['filename'] = filename @@ -430,7 +434,7 @@ def extract_data(stdout): # Get final extension after merging process if stdout[1] == 'Merging': - path, filename, extension = extract_filename(' '.join(stdout[4:])) + path, filename, extension = extract_filename(' '.join(stdout_with_spaces[4:])) data_dictionary['path'] = path data_dictionary['filename'] = filename