Add --mhtml flag to :download
And remove :download-whole command.
This commit is contained in:
parent
8cf0af004f
commit
d1f8d29c20
@ -19,7 +19,6 @@
|
|||||||
|<<download-open,download-open>>|Open the last/[count]th download.
|
|<<download-open,download-open>>|Open the last/[count]th download.
|
||||||
|<<download-remove,download-remove>>|Remove the last/[count]th download from the list.
|
|<<download-remove,download-remove>>|Remove the last/[count]th download from the list.
|
||||||
|<<download-retry,download-retry>>|Retry the first failed/[count]th download.
|
|<<download-retry,download-retry>>|Retry the first failed/[count]th download.
|
||||||
|<<download-whole,download-whole>>|Download the current page as a MHTML file, including all assets.
|
|
||||||
|<<forward,forward>>|Go forward in the history of the current tab.
|
|<<forward,forward>>|Go forward in the history of the current tab.
|
||||||
|<<fullscreen,fullscreen>>|Toggle fullscreen mode.
|
|<<fullscreen,fullscreen>>|Toggle fullscreen mode.
|
||||||
|<<help,help>>|Show help about a command or setting.
|
|<<help,help>>|Show help about a command or setting.
|
||||||
@ -146,7 +145,7 @@ Close the current window.
|
|||||||
|
|
||||||
[[download]]
|
[[download]]
|
||||||
=== download
|
=== download
|
||||||
Syntax: +:download [*--dest* 'DEST'] ['url'] ['dest-old']+
|
Syntax: +:download [*--mhtml*] [*--dest* 'DEST'] ['url'] ['dest-old']+
|
||||||
|
|
||||||
Download a given URL, or current page if no URL given.
|
Download a given URL, or current page if no URL given.
|
||||||
|
|
||||||
@ -157,6 +156,7 @@ The form `:download [url] [dest]` is deprecated, use `:download --dest [dest] [u
|
|||||||
* +'dest-old'+: (deprecated) Same as dest.
|
* +'dest-old'+: (deprecated) Same as dest.
|
||||||
|
|
||||||
==== optional arguments
|
==== optional arguments
|
||||||
|
* +*-m*+, +*--mhtml*+: Download the current page and all assets as mhtml file.
|
||||||
* +*-d*+, +*--dest*+: The file path to write the download to, or not given to ask.
|
* +*-d*+, +*--dest*+: The file path to write the download to, or not given to ask.
|
||||||
|
|
||||||
[[download-cancel]]
|
[[download-cancel]]
|
||||||
@ -203,15 +203,6 @@ Retry the first failed/[count]th download.
|
|||||||
==== count
|
==== count
|
||||||
The index of the download to cancel.
|
The index of the download to cancel.
|
||||||
|
|
||||||
[[download-whole]]
|
|
||||||
=== download-whole
|
|
||||||
Syntax: +:download-whole ['dest']+
|
|
||||||
|
|
||||||
Download the current page as a MHTML file, including all assets.
|
|
||||||
|
|
||||||
==== positional arguments
|
|
||||||
* +'dest'+: The file path to write the download to.
|
|
||||||
|
|
||||||
[[forward]]
|
[[forward]]
|
||||||
=== forward
|
=== forward
|
||||||
Syntax: +:forward [*--tab*] [*--bg*] [*--window*]+
|
Syntax: +:forward [*--tab*] [*--bg*] [*--window*]+
|
||||||
|
@ -1140,7 +1140,7 @@ class CommandDispatcher:
|
|||||||
cur.inspector.show()
|
cur.inspector.show()
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
@cmdutils.register(instance='command-dispatcher', scope='window')
|
||||||
def download(self, url=None, dest_old=None, *, dest=None):
|
def download(self, url=None, dest_old=None, *, mhtml=False, dest=None):
|
||||||
"""Download a given URL, or current page if no URL given.
|
"""Download a given URL, or current page if no URL given.
|
||||||
|
|
||||||
The form `:download [url] [dest]` is deprecated, use `:download --dest
|
The form `:download [url] [dest]` is deprecated, use `:download --dest
|
||||||
@ -1150,6 +1150,7 @@ class CommandDispatcher:
|
|||||||
url: The URL to download. If not given, download the current page.
|
url: The URL to download. If not given, download the current page.
|
||||||
dest_old: (deprecated) Same as dest.
|
dest_old: (deprecated) Same as dest.
|
||||||
dest: The file path to write the download to, or None to ask.
|
dest: The file path to write the download to, or None to ask.
|
||||||
|
mhtml: Download the current page and all assets as mhtml file.
|
||||||
"""
|
"""
|
||||||
if dest_old is not None:
|
if dest_old is not None:
|
||||||
message.warning('current', ":download [url] [dest] is deprecated -"
|
message.warning('current', ":download [url] [dest] is deprecated -"
|
||||||
@ -1162,15 +1163,20 @@ class CommandDispatcher:
|
|||||||
download_manager = objreg.get('download-manager', scope='window',
|
download_manager = objreg.get('download-manager', scope='window',
|
||||||
window=self._win_id)
|
window=self._win_id)
|
||||||
if url:
|
if url:
|
||||||
|
if mhtml:
|
||||||
|
raise cmdexc.CommandError("Can only download the current page"
|
||||||
|
" as mhtml.")
|
||||||
url = urlutils.qurl_from_user_input(url)
|
url = urlutils.qurl_from_user_input(url)
|
||||||
urlutils.raise_cmdexc_if_invalid(url)
|
urlutils.raise_cmdexc_if_invalid(url)
|
||||||
download_manager.get(url, filename=dest)
|
download_manager.get(url, filename=dest)
|
||||||
|
else:
|
||||||
|
if mhtml:
|
||||||
|
self._download_mhtml(dest)
|
||||||
else:
|
else:
|
||||||
page = self._current_widget().page()
|
page = self._current_widget().page()
|
||||||
download_manager.get(self._current_url(), page=page, filename=dest)
|
download_manager.get(self._current_url(), page=page, filename=dest)
|
||||||
|
|
||||||
@cmdutils.register(instance='command-dispatcher', scope='window')
|
def _download_mhtml(self, dest=None):
|
||||||
def download_whole(self, dest=None):
|
|
||||||
"""Download the current page as a MHTML file, including all assets.
|
"""Download the current page as a MHTML file, including all assets.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
Loading…
Reference in New Issue
Block a user