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()
|
self.tags_view.recount()
|
||||||
|
|
||||||
def handle_cli_args(self, args):
|
def handle_cli_args(self, args):
|
||||||
|
from urllib.parse import unquote, urlparse, parse_qs
|
||||||
if isinstance(args, string_or_bytes):
|
if isinstance(args, string_or_bytes):
|
||||||
args = [args]
|
args = [args]
|
||||||
files, urls = [], []
|
files, urls = [], []
|
||||||
for p in args:
|
for p in args:
|
||||||
if p.startswith('calibre://'):
|
if p.startswith('calibre://'):
|
||||||
from urllib.parse import unquote, urlparse, parse_qs
|
|
||||||
try:
|
try:
|
||||||
purl = urlparse(p)
|
purl = urlparse(p)
|
||||||
if purl.scheme == 'calibre':
|
if purl.scheme == 'calibre':
|
||||||
@ -617,6 +617,17 @@ class Main(MainWindow, MainWindowMixin, DeviceMixin, EmailMixin, # {{{
|
|||||||
except Exception:
|
except Exception:
|
||||||
prints('Ignoring malformed URL:', p, file=sys.stderr)
|
prints('Ignoring malformed URL:', p, file=sys.stderr)
|
||||||
continue
|
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:
|
else:
|
||||||
a = os.path.abspath(p)
|
a = os.path.abspath(p)
|
||||||
if not os.path.isdir(a) and os.access(a, os.R_OK):
|
if not os.path.isdir(a) and os.access(a, os.R_OK):
|
||||||
|
@ -1129,7 +1129,7 @@ Name=calibre
|
|||||||
GenericName=E-book library management
|
GenericName=E-book library management
|
||||||
Comment=E-book library management: Convert, view, share, catalogue all your e-books
|
Comment=E-book library management: Convert, view, share, catalogue all your e-books
|
||||||
TryExec=calibre
|
TryExec=calibre
|
||||||
Exec=calibre --detach %F
|
Exec=calibre --detach %U
|
||||||
Icon=calibre-gui
|
Icon=calibre-gui
|
||||||
Categories=Office;
|
Categories=Office;
|
||||||
X-GNOME-UsesNotifications=true
|
X-GNOME-UsesNotifications=true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user