mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add support for file URLs as command line arguents
This commit is contained in:
parent
03b5ad536b
commit
d41cc01560
@ -601,12 +601,12 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
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 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
||||
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 @@ Name=calibre
|
||||
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…
x
Reference in New Issue
Block a user