Browse Source

Add "Restrict filenames" option under Options>Output

doc-issue-template
MrS0m30n3 11 years ago
parent
commit
5805aa38d8
3 changed files with 28 additions and 7 deletions
  1. 16
      youtube_dl_gui/OptionsHandler.py
  2. 15
      youtube_dl_gui/YoutubeDLGUI.py
  3. 4
      youtube_dl_gui/YoutubeDLInterpreter.py

16
youtube_dl_gui/OptionsHandler.py

@ -38,6 +38,7 @@ class OptionsHandler():
'keep_video': False, 'keep_video': False,
'audio_format': 'mp3', 'audio_format': 'mp3',
'audio_quality': 'mid', 'audio_quality': 'mid',
'restrict_filenames': False,
'output_format': 'title', 'output_format': 'title',
'output_template': '%(uploader)s/%(title)s.%(ext)s', 'output_template': '%(uploader)s/%(title)s.%(ext)s',
'playlist_start': 1, 'playlist_start': 1,
@ -50,8 +51,8 @@ class OptionsHandler():
'write_auto_subs': False, 'write_auto_subs': False,
'embed_subs': False, 'embed_subs': False,
'subs_lang': 'English', 'subs_lang': 'English',
'open_dl_dir': False,
'ignore_errors': True, 'ignore_errors': True,
'open_dl_dir': False,
'write_description': False, 'write_description': False,
'write_info': False, 'write_info': False,
'write_thumbnail': False, 'write_thumbnail': False,
@ -76,10 +77,21 @@ class OptionsHandler():
def set_settings_path(self): def set_settings_path(self):
self.settings_abs_path = fix_path(self.get_config_path()) + SETTINGS_FILENAME self.settings_abs_path = fix_path(self.get_config_path()) + SETTINGS_FILENAME
def settings_are_valid(self, settings_dictionary):
''' Check settings.json dictionary '''
for key in self.options:
if key not in settings_dictionary:
return False
return True
def load_from_file(self): def load_from_file(self):
with open(self.settings_abs_path, 'rb') as f: with open(self.settings_abs_path, 'rb') as f:
try: try:
self.options = json.load(f)
options = json.load(f)
if self.settings_are_valid(options):
self.options = options
else:
self.load_default()
except: except:
self.load_default() self.load_default()

15
youtube_dl_gui/YoutubeDLGUI.py

@ -734,10 +734,15 @@ class OutputPanel(wx.Panel):
self.optManager = optManager self.optManager = optManager
mainBoxSizer = wx.BoxSizer(wx.VERTICAL) mainBoxSizer = wx.BoxSizer(wx.VERTICAL)
restrictBox = wx.BoxSizer(wx.HORIZONTAL)
self.restrictFilenamesChk = wx.CheckBox(self, label='Restrict filenames (ASCII)')
restrictBox.Add(self.restrictFilenamesChk, flag = wx.LEFT, border=5)
mainBoxSizer.Add(restrictBox, flag = wx.TOP, border=15)
idBox = wx.BoxSizer(wx.HORIZONTAL) idBox = wx.BoxSizer(wx.HORIZONTAL)
self.idAsNameChk = wx.CheckBox(self, label='ID as Name') self.idAsNameChk = wx.CheckBox(self, label='ID as Name')
idBox.Add(self.idAsNameChk, flag = wx.LEFT, border=5) idBox.Add(self.idAsNameChk, flag = wx.LEFT, border=5)
mainBoxSizer.Add(idBox, flag = wx.TOP, border=15)
mainBoxSizer.Add(idBox, flag = wx.TOP, border=5+self.win_box_border)
titleBox = wx.BoxSizer(wx.HORIZONTAL) titleBox = wx.BoxSizer(wx.HORIZONTAL)
self.titleBoxChk = wx.CheckBox(self, label='Title as Name') self.titleBoxChk = wx.CheckBox(self, label='Title as Name')
@ -804,10 +809,12 @@ class OutputPanel(wx.Panel):
def load_options(self): def load_options(self):
self.group_load(self.optManager.options['output_format']) self.group_load(self.optManager.options['output_format'])
self.customTitleBox.SetValue(self.optManager.options['output_template']) self.customTitleBox.SetValue(self.optManager.options['output_template'])
self.restrictFilenamesChk.SetValue(self.optManager.options['restrict_filenames'])
def save_options(self): def save_options(self):
self.optManager.options['output_template'] = self.customTitleBox.GetValue() self.optManager.options['output_template'] = self.customTitleBox.GetValue()
self.optManager.options['output_format'] = self.get_output_format() self.optManager.options['output_format'] = self.get_output_format()
self.optManager.options['restrict_filenames'] = self.restrictFilenamesChk.GetValue()
class FilesystemPanel(wx.Panel): class FilesystemPanel(wx.Panel):
@ -836,10 +843,10 @@ class FilesystemPanel(wx.Panel):
self.win_box_border = 10 self.win_box_border = 10
def SetLeftBox(self, box): def SetLeftBox(self, box):
ignrBox = wx.BoxSizer(wx.HORIZONTAL)
ignoreBox = wx.BoxSizer(wx.HORIZONTAL)
self.ignoreErrorsChk = wx.CheckBox(self, label='Ignore Errors') self.ignoreErrorsChk = wx.CheckBox(self, label='Ignore Errors')
ignrBox.Add(self.ignoreErrorsChk, flag = wx.LEFT, border=5)
box.Add(ignrBox, flag = wx.TOP, border=15)
ignoreBox.Add(self.ignoreErrorsChk, flag = wx.LEFT, border=5)
box.Add(ignoreBox, flag = wx.TOP, border=15)
wrtDescBox = wx.BoxSizer(wx.HORIZONTAL) wrtDescBox = wx.BoxSizer(wx.HORIZONTAL)
self.writeDescriptionChk = wx.CheckBox(self, label='Write description to file') self.writeDescriptionChk = wx.CheckBox(self, label='Write description to file')

4
youtube_dl_gui/YoutubeDLInterpreter.py

@ -75,7 +75,7 @@ class YoutubeDLInterpreter():
def set_progress_opts(self): def set_progress_opts(self):
''' Do NOT change this option ''' ''' Do NOT change this option '''
self.opts.append('--newline') self.opts.append('--newline')
def set_playlist_opts(self): def set_playlist_opts(self):
if self.optManager.options['playlist_start'] != 1: if self.optManager.options['playlist_start'] != 1:
self.opts.append('--playlist-start') self.opts.append('--playlist-start')
@ -163,6 +163,8 @@ class YoutubeDLInterpreter():
self.opts.append(path + '%(title)s.%(ext)s') self.opts.append(path + '%(title)s.%(ext)s')
elif self.optManager.options['output_format'] == 'custom': elif self.optManager.options['output_format'] == 'custom':
self.opts.append(path + self.optManager.options['output_template']) self.opts.append(path + self.optManager.options['output_template'])
if self.optManager.options['restrict_filenames']:
self.opts.append('--restrict-filenames')
def set_audio_opts(self): def set_audio_opts(self):
if self.optManager.options['to_audio']: if self.optManager.options['to_audio']:

Loading…
Cancel
Save