mirror of
git://github.com/kovidgoyal/calibre.git
synced 2026-02-17 17:34:28 +01:00
Add support for file URLs as command line arguents
This commit is contained in:
parent
03b5ad536b
commit
d41cc01560
2 changed files with 13 additions and 2 deletions
|
|
@ -601,12 +601,12 @@ def refresh_all(self):
|
|||
self.tags_view.recount()
|
||||
|
||||
def handle_cli_args(self, args):
|
||||
from urllib.parse import unquote, urlparse, parse_qs
|
||||
if isinstance(args, string_or_bytes):
|
||||
args = [args]
|
||||
files, urls = [], []
|
||||
for p in args:
|
||||
if p.startswith('calibre://'):
|
||||
from urllib.parse import unquote, urlparse, parse_qs
|
||||
try:
|
||||
purl = urlparse(p)
|
||||
if purl.scheme == 'calibre':
|
||||
|
|
@ -617,6 +617,17 @@ def handle_cli_args(self, args):
|
|||
except Exception:
|
||||
prints('Ignoring malformed URL:', p, file=sys.stderr)
|
||||
continue
|
||||
elif p.startswith('file://'):
|
||||
try:
|
||||
purl = urlparse(p)
|
||||
if purl.scheme == 'file':
|
||||
path = unquote(purl.path)
|
||||
a = os.path.abspath(path)
|
||||
if not os.path.isdir(a) and os.access(a, os.R_OK):
|
||||
files.append(a)
|
||||
except Exception:
|
||||
prints('Ignoring malformed URL:', p, file=sys.stderr)
|
||||
continue
|
||||
else:
|
||||
a = os.path.abspath(p)
|
||||
if not os.path.isdir(a) and os.access(a, os.R_OK):
|
||||
|
|
|
|||
|
|
@ -1129,7 +1129,7 @@ def opts_and_exts(name, op, exts, cover_opts=('--cover',), opf_opts=(),
|
|||
GenericName=E-book library management
|
||||
Comment=E-book library management: Convert, view, share, catalogue all your e-books
|
||||
TryExec=calibre
|
||||
Exec=calibre --detach %F
|
||||
Exec=calibre --detach %U
|
||||
Icon=calibre-gui
|
||||
Categories=Office;
|
||||
X-GNOME-UsesNotifications=true
|
||||
|
|
|
|||
Loading…
Reference in a new issue