Browse Source

Edit formats

doc-issue-template
MrS0m30n3 8 years ago
parent
commit
48d1f8ea2b
4 changed files with 32 additions and 22 deletions
  1. 25
      youtube_dl_gui/formats.py
  2. 17
      youtube_dl_gui/mainframe.py
  3. 8
      youtube_dl_gui/optionsframe.py
  4. 4
      youtube_dl_gui/optionsmanager.py

25
youtube_dl_gui/formats.py

@ -10,11 +10,13 @@ OUTPUT_FORMATS = tdict([
(3, "Custom")
])
DEFAULT_VIDEO_FORMATS = [
DEFAULT_FORMATS = tdict([
("0", "default")
]
])
NON_DEFAULT_VIDEO_FORMATS = [
VIDEO_FORMATS = tdict([
("17", "3gp [176x144]"),
("36", "3gp [320x240]"),
("5", "flv [400x240]"),
@ -55,6 +57,19 @@ NON_DEFAULT_VIDEO_FORMATS = [
("141", "m4a 256k (DASH AUDIO)"),
("171", "webm 48k (DASH AUDIO)"),
("172", "webm 256k (DASH AUDIO)")
]
])
AUDIO_FORMATS = tdict([
("mp3", "mp3"),
("wav", "wav"),
("aac", "aac"),
("m4a", "m4a"),
("vorbis", "vorbis"),
("opus", "opus")
])
VIDEO_FORMATS = tdict(DEFAULT_VIDEO_FORMATS + NON_DEFAULT_VIDEO_FORMATS)
FORMATS = DEFAULT_FORMATS.copy()
FORMATS.update(VIDEO_FORMATS)
FORMATS.update(AUDIO_FORMATS)

17
youtube_dl_gui/mainframe.py

@ -50,8 +50,8 @@ from .utils import (
)
from .formats import (
DEFAULT_VIDEO_FORMATS,
VIDEO_FORMATS
DEFAULT_FORMATS,
FORMATS
)
from .info import (
@ -265,7 +265,7 @@ class MainFrame(wx.Frame):
self._folder_icon = self._create_static_bitmap(self._bitmaps["folder"])
self._path_combobox = ExtComboBox(self._panel, 5, style=wx.CB_READONLY)
self._videoformat_combobox = ExtComboBox(self._panel, choices=list(VIDEO_FORMATS.values()), style=wx.CB_READONLY)
self._videoformat_combobox = ExtComboBox(self._panel, style=wx.CB_READONLY)
self._download_text = self._create_statictext(self.DOWNLOAD_LIST_LABEL)
self._status_list = ListCtrl(self.STATUSLIST_COLUMNS,
@ -431,18 +431,15 @@ class MainFrame(wx.Frame):
self._buttons["pause"].SetBitmap(self._bitmaps["pause"], wx.TOP)
def _update_videoformat_combobox(self):
video_formats = []
for _, label in DEFAULT_VIDEO_FORMATS:
video_formats.append(label)
video_formats = list(DEFAULT_FORMATS.values())
for vformat in self.opt_manager.options["selected_video_formats"]:
video_formats.append(VIDEO_FORMATS[vformat])
video_formats.append(FORMATS[vformat])
self._videoformat_combobox.Clear()
self._videoformat_combobox.AppendItems(video_formats)
current_index = self._videoformat_combobox.FindString(VIDEO_FORMATS[self.opt_manager.options["video_format"]])
current_index = self._videoformat_combobox.FindString(FORMATS[self.opt_manager.options["video_format"]])
if current_index == wx.NOT_FOUND:
self._videoformat_combobox.SetSelection(0)
@ -452,7 +449,7 @@ class MainFrame(wx.Frame):
self._update_videoformat(None)
def _update_videoformat(self, event):
self.opt_manager.options["video_format"] = VIDEO_FORMATS[self._videoformat_combobox.GetValue()]
self.opt_manager.options["video_format"] = FORMATS[self._videoformat_combobox.GetValue()]
def _update_savepath(self, event):
self.opt_manager.options["save_path"] = self._path_combobox.GetValue()

8
youtube_dl_gui/optionsframe.py

@ -28,9 +28,9 @@ from .utils import (
)
from .formats import (
NON_DEFAULT_VIDEO_FORMATS,
OUTPUT_FORMATS,
VIDEO_FORMATS
VIDEO_FORMATS,
FORMATS
)
#TODO Bind events
#TODO Adjust layout
@ -335,10 +335,8 @@ class FormatsTab(TabPanel):
def __init__(self, *args, **kwargs):
super(FormatsTab, self).__init__(*args, **kwargs)
video_formats = [item[1] for item in NON_DEFAULT_VIDEO_FORMATS]
self.video_formats_label = self.crt_statictext("Video formats")
self.video_formats_checklistbox = self.crt_checklistbox(video_formats)
self.video_formats_checklistbox = self.crt_checklistbox(list(VIDEO_FORMATS.values()))
self.audio_formats_label = self.crt_statictext("Audio formats")
self.audio_formats_checklistbox = self.crt_checklistbox(self.AUDIO_FORMATS)

4
youtube_dl_gui/optionsmanager.py

@ -18,7 +18,7 @@ from .utils import (
from .formats import (
OUTPUT_FORMATS,
VIDEO_FORMATS
FORMATS
)
@ -323,7 +323,7 @@ class OptionsManager(object):
# Check if each key has a valid value
rules_dict = {
'video_format': VIDEO_FORMATS.keys(),
'video_format': FORMATS.keys(),
'second_video_format': VALID_VIDEO_FORMAT,
'audio_format': VALID_AUDIO_FORMAT,
'audio_quality': VALID_AUDIO_QUALITY,

Loading…
Cancel
Save