From e26514bb839756ed7f14711d193b5ebb3777c6b8 Mon Sep 17 00:00:00 2001 From: Fredrik Tolf Date: Sat, 11 May 2013 21:21:14 +0200 Subject: [PATCH] Added a simple reader shell. --- automanga | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 60 insertions(+) create mode 100755 automanga diff --git a/automanga b/automanga new file mode 100755 index 0000000..e80db3f --- /dev/null +++ b/automanga @@ -0,0 +1,60 @@ +#!/usr/bin/python + +import sys, getopt +import manga.lib, manga.reader +import glib, gobject, gtk + +gobject.threads_init() +gtk.gdk.threads_init() + +def usage(out): + out.write("usage: automanga [-h] [DIR]\n") + out.write(" automanga [-h] -l LIBRARY ID\n") + out.write(" automanga [-h] -s LIBRARY NAME\n") + +libname = None +search = False +opts, args = getopt.getopt(sys.argv[1:], "hl:s") +for o, a in opts: + if o == "-h": + usage(sys.stdout) + sys.exit(0) + elif o == "-l": + libname = a + elif o == "-s": + search = True + +if search: + if len(args) < 2: + usage(sys.stderr) + sys.exit(1) + try: + lib = manga.lib.libraries[args[0]] + except KeyError: + sys.stderr.write("automanga: no such library: %s\n" % args[0]) + sys.exit(1) + for manga in lib.byname(args[1]): + sys.stdout.write("\"%s\": %s\n" % (manga.name, manga.id)) + sys.exit(0) + +if libname is not None: + if len(args) < 1: + usage(sys.stderr) + sys.exit(1) + try: + lib = manga.lib.libraries[libname] + except KeyError: + sys.stderr.write("automanga: no such library: %s\n" % libname) + sys.exit(1) + try: + mng = lib.byid(args[0]) + except KeyError: + sys.stderr.write("automanga: no such manga: %s\n" % args[0]) + sys.exit(1) +else: + sys.stderr.write("automanga: local manga not yet implemented\n") + sys.exit(1) + +reader = manga.reader.reader(mng) +reader.show() +gtk.main() -- 2.11.0