From aea606695af306ee2d3f31b3666c4ecb4aae84a6 Mon Sep 17 00:00:00 2001 From: MrS0m30n3 Date: Mon, 26 Sep 2016 18:57:25 +0300 Subject: [PATCH] Add 'get command' option to context menu --- TODO | 1 - youtube_dl_gui/mainframe.py | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/TODO b/TODO index 7c27cbd..137bf7e 100644 --- a/TODO +++ b/TODO @@ -5,7 +5,6 @@ NEW_LAYOUT * Create new button with two stages (like toggle) * Add more statistics (Average download speed, etc) * Adjust layout see #131 -* GUI command line builder like zenmap * Swap some of the Error messages with Info * Add clear list button ? * Icons theme selection (vote on github) diff --git a/youtube_dl_gui/mainframe.py b/youtube_dl_gui/mainframe.py index dfb16af..8f0b15f 100644 --- a/youtube_dl_gui/mainframe.py +++ b/youtube_dl_gui/mainframe.py @@ -35,6 +35,7 @@ from .downloadmanager import ( ) from .utils import ( + YOUTUBEDL_BIN, get_pixmaps_dir, get_config_path, get_icon_file, @@ -227,6 +228,7 @@ class MainFrame(wx.Frame): statuslist_menu_data = ( (_("Get url"), self._on_geturl), + (_("Get command"), self._on_getcmd) ) # Create options frame @@ -337,6 +339,23 @@ class MainFrame(wx.Frame): wx.TheClipboard.SetData(clipdata) wx.TheClipboard.Close() + def _on_getcmd(self, event): + selected = self._status_list.get_selected() + + if selected != -1: + object_id = self._status_list.GetItemData(selected) + download_item = self._download_list.get_item(object_id) + + cmd = [YOUTUBEDL_BIN] + download_item.options + [download_item.url] + cmd = " ".join(cmd) + + if not wx.TheClipboard.IsOpened(): + clipdata = wx.TextDataObject() + clipdata.SetText(cmd) + wx.TheClipboard.Open() + wx.TheClipboard.SetData(clipdata) + wx.TheClipboard.Close() + def _on_timer(self, event): msg = self.URL_REPORT_MSG.format(self.download_manager.active()) self._status_bar_write(msg)