Browse Source

Unicode support

doc-issue-template
MrS0m30n3 10 years ago
parent
commit
1a86e62aa2
4 changed files with 29 additions and 14 deletions
  1. 2
      SIGNALS.txt
  2. 24
      youtube_dl_gui/DownloadThread.py
  3. 4
      youtube_dl_gui/OptionsHandler.py
  4. 13
      youtube_dl_gui/YoutubeDLGUI.py

2
SIGNALS.txt

@ -27,6 +27,8 @@ SIGNALS
['[ffmpeg]', ..., index]: Post-Processing for url, index
['ignore'] Do nothing
EXAMPLES
========

24
youtube_dl_gui/DownloadThread.py

@ -104,13 +104,13 @@ class ProcessWrapper(Thread):
while self.proc_is_alive():
# read output
output = self.read()
if self.err:
CallAfter(Publisher.sendMessage, PUBLISHER_TOPIC, ['error', self.index])
else:
if output != '':
data = self.proc_output(output)
if output != '':
data = self.proc_output(output)
data = self.check_data(data)
if self.err:
CallAfter(Publisher.sendMessage, PUBLISHER_TOPIC, ['error', self.index])
else:
CallAfter(Publisher.sendMessage, PUBLISHER_TOPIC, data)
if not self.err and not self.stopped:
CallAfter(Publisher.sendMessage, PUBLISHER_TOPIC, ['finish', self.index])
@ -135,6 +135,18 @@ class ProcessWrapper(Thread):
data.append(self.index)
return data
def check_data(self, data):
''' check data for exceptions '''
if len(data) > 3:
if data[1] == "UnicodeWarning:":
self.err = False
return ['ignore']
if data[0] == "[download]" and data[1] == "Destination:":
return ['ignore']
if data[0] == "[download]" and data[1] == "100%":
return ['ignore']
return data
def string_to_array(self, string):
return string.split(' ')

4
youtube_dl_gui/OptionsHandler.py

@ -73,7 +73,7 @@ class OptionsHandler():
self.keepVideo = opts[4] in ['True']
self.audioQuality = int(opts[5])
self.proxy = opts[6]
self.savePath = opts[7]
self.savePath = opts[7].decode('utf8')
self.autoUpdate = opts[8] in ['True']
self.videoFormat = opts[9]
self.userAgent = opts[10]
@ -104,7 +104,7 @@ class OptionsHandler():
f.write('KeepVideo='+str(self.keepVideo)+'\n')
f.write('AudioQuality='+str(self.audioQuality)+'\n')
f.write('Proxy='+str(self.proxy)+'\n')
f.write('SavePath='+str(self.savePath)+'\n')
f.write('SavePath='+self.savePath.encode('utf-8')+'\n')
f.write('AutoUpdate='+str(self.autoUpdate)+'\n')
f.write('VideoFormat='+str(self.videoFormat)+'\n')
f.write('UserAgent='+str(self.userAgent)+'\n')

13
youtube_dl_gui/YoutubeDLGUI.py

@ -152,16 +152,17 @@ class MainFrame(wx.Frame):
self.statusList._write_data(index, 5, 'Pre-Processing')
elif msg.data[0] == '[download]':
index = msg.data.pop()
if (len(msg.data[1]) <= 6 and msg.data[1] != '100%'):
self.statusList._write_data(index, 1, msg.data[3])
self.statusList._write_data(index, 2, msg.data[1])
self.statusList._write_data(index, 3, msg.data[7])
self.statusList._write_data(index, 4, msg.data[5])
self.statusList._write_data(index, 5, 'Downloading')
self.statusList._write_data(index, 1, msg.data[3])
self.statusList._write_data(index, 2, msg.data[1])
self.statusList._write_data(index, 3, msg.data[7])
self.statusList._write_data(index, 4, msg.data[5])
self.statusList._write_data(index, 5, 'Downloading')
elif msg.data[0] == '[ffmpeg]':
index = msg.data.pop()
self.statusList._write_data(index, 4, '')
self.statusList._write_data(index, 5, 'Converting to Audio')
else: # ['ignore'] or anything else
pass # do nothing
def update_handler(self, msg):
if msg.data == 'finish':

Loading…
Cancel
Save