From e8e054b22582744669d626631487e015bf5688ab Mon Sep 17 00:00:00 2001 From: MrS0m30n3 Date: Thu, 6 Mar 2014 00:49:11 +0200 Subject: [PATCH] fixed subprocess unicode error --- youtube_dl_gui/DownloadThread.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/youtube_dl_gui/DownloadThread.py b/youtube_dl_gui/DownloadThread.py index 495dc8a..85b26d3 100644 --- a/youtube_dl_gui/DownloadThread.py +++ b/youtube_dl_gui/DownloadThread.py @@ -1,5 +1,6 @@ #! /usr/bin/env python +import sys import subprocess from os import name from time import sleep @@ -99,7 +100,7 @@ class ProcessWrapper(Thread): self.start() def run(self): - self.proc = subprocess.Popen(self.options + [self.url], stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=self.info) + self.proc = subprocess.Popen(self.get_cmd(), stdout=subprocess.PIPE, stderr=subprocess.PIPE, startupinfo=self.info) # while subprocess is alive and NOT the current thread while self.proc_is_alive(): # read output @@ -145,8 +146,19 @@ class ProcessWrapper(Thread): return ['ignore'] if data[0] == "[download]" and data[1] == "100%": return ['ignore'] + if data[0] == "[download]" and len(data[1]) > 10: + return ['ignore'] + if data[0] == "[download]" and data[1] == "Resuming": + return ['ignore'] return data + def get_cmd(self): + data = self.options + [self.url] + if OS_TYPE == 'nt': + enc = sys.getfilesystemencoding() + data = [x.encode(enc, 'ignore') for x in data] + return data + def string_to_array(self, string): return string.split(' ')