diff --git a/README.md b/README.md index d2900f0..54094df 100644 --- a/README.md +++ b/README.md @@ -78,8 +78,9 @@ Example: ### Help output: ``` -usage: m2em.py [-h] [-af ADD_FEED] [-au] [-lc] [-Lc] [-lf] [-lu] [-cd] [-s] - [--send [SEND [SEND ...]]] [--convert [CONVERT [CONVERT ...]]] +usage: m2em.py [-h] [-af ADD_FEED] [-au] [-lm [LIST_MANGA]] [-lc] [-Lc] [-lf] + [-lu] [-cd] [-s] [--send [SEND [SEND ...]]] + [--convert [CONVERT [CONVERT ...]]] [--download [DOWNLOAD [DOWNLOAD ...]]] [-a ACTION] [-ss SWITCH_SEND] [-sc SWITCH_CHAPTER] [-dc DELETE_CHAPTER] [-du DELETE_USER] [-df DELETE_FEED] [--daemon] [-d] [-v] @@ -92,6 +93,9 @@ optional arguments: Add RSS Feed of Manga. Only Mangastream & MangaFox are supported -au, --add-user Adds new user + -lm [LIST_MANGA], --list-manga [LIST_MANGA] + Lists Manga saved in database. If a Manga is passed, + lists chapters to said Manga -lc, --list-chapters Lists the last 10 Chapters -Lc, --list-chapters-all Lists all Chapters @@ -162,6 +166,25 @@ EmailAdressPw = yourpassword ServerStartSSL = True ``` +## Examples + +If you want to check out the manga that are in the database: +``` +./m2em.py -lm +``` +You can use this out put to refine the search! +If you pass the manga name you get all chapters listed from that manga: +``` +./m2em.py -lm "Shokugeki no Souma" +Listing all chapters of Shokugeki no Souma: +ID MANGA CHAPTER CHAPTERNAME RSS ORIGIN SEND STATUS +=================================================================================================== +112 Shokugeki no Souma 240 Not Cute https://mangastream.com/rss SENT + +91 Shokugeki no Souma 238 The Queen's Tart https://mangastream.com/rss SENT + +78 Shokugeki no Souma 239 Her Fighting Style https://mangastream.com/rss SENT +``` To start a single run through the workers, you can simply execute the main program: diff --git a/bin/_version.py b/bin/_version.py index 37ac431..93e8096 100644 --- a/bin/_version.py +++ b/bin/_version.py @@ -1 +1 @@ -__version__ = "v0.3.0" \ No newline at end of file +__version__ = "v0.3.1" \ No newline at end of file diff --git a/bin/m2emHelper.py b/bin/m2emHelper.py index 2cebd02..0d20c54 100644 --- a/bin/m2emHelper.py +++ b/bin/m2emHelper.py @@ -938,4 +938,70 @@ def initialize_logger(output_dir, outputlevel): handler.setLevel(logging.INFO) formatter = logging.Formatter("%(asctime)s; %(levelname)s - %(message)s") handler.setFormatter(formatter) - logger.addHandler(handler) \ No newline at end of file + logger.addHandler(handler) + + + +''' +Function that gets feed data and display it nicely +Returns: N/A +''' +def printManga(config, args): + + + # Get database config + database = config["Database"] + + # Open Database + try: + conn = sqlite3.connect(database) + except Exception as e: + print("Could not connect to DB %s" % e) + + c = conn.cursor() + logging.debug("Succesfully Connected to DB %s" % database) + + + + if args.list_manga == "all": + # Get Data + __data = c.execute("SELECT manganame FROM chapter") + __tabledata = set(__data.fetchall()) + + + if __tabledata: + logging.info("Mangas with chapters in the database:") + for i in __tabledata: + logging.info("* %s"% i) + else: + __data = c.execute("SELECT * FROM chapter where manganame=(?)", (args.list_manga,)) + __tabledata = __data.fetchall() + + if len(__tabledata) == 0: + logging.error("No Manga with that Name found!") + else: + # Reverse List to get newest first + __tabledata.reverse() + + table = texttable.Texttable(max_width=120) + table.set_deco(texttable.Texttable.HEADER) + table.set_cols_align(["l", "l", "l", "l", "l", "l"]) + table.set_cols_dtype(['i', # int + 't', + 't', + 't', + 't', + 't']) # text + table.header (["ID", "MANGA", "CHAPTER", "CHAPTERNAME", "RSS ORIGIN", "SEND STATUS"]) + + + logging.info("Listing all chapters of %s:"% args.list_manga) + for row in __tabledata: + # Rename row[8] + if row[8] == 1: + sendstatus = "SENT" + else: + sendstatus = "NOT SENT" + table.add_row([row[0], row[11], row[10], row[5]+"\n", str(row[1]), sendstatus]) + logging.info(table.draw()) + diff --git a/m2em.py b/m2em.py index 1d875bc..c76bd76 100755 --- a/m2em.py +++ b/m2em.py @@ -49,6 +49,7 @@ def read_arguments(self): parser.add_argument("-af", "--add-feed", help="Add RSS Feed of Manga. Only Mangastream & MangaFox are supported") parser.add_argument("-au", "--add-user", help="Adds new user", action="store_true") + parser.add_argument("-lm", "--list-manga", help="Lists Manga saved in database. If a Manga is passed, lists chapters to said Manga",nargs="?",const='all') parser.add_argument("-lc", "--list-chapters", help="Lists the last 10 Chapters", action="store_true") parser.add_argument("-Lc", "--list-chapters-all", help="Lists all Chapters", @@ -95,6 +96,7 @@ def read_arguments(self): and self.args.switch_chapter is None \ and self.args.switch_send is None \ and self.args.add_user is False \ + and self.args.list_manga is None \ and not any([self.args.add_user, self.args.create_db, self.args.daemon, @@ -107,6 +109,8 @@ def read_arguments(self): self.args.send, self.args.start,]): logging.error("At least one argument is required!") + + logging.debug("Passed arguments: \n %s"% self.args) #Read Config def read_config(self): @@ -189,6 +193,15 @@ def list_chapters(self): pass + ''' + Catch -lm/--list-manga + ''' + def list_manga(self): + helper.printManga(self.config,self.args) + pass + + + ''' Catch --list-users ''' @@ -312,6 +325,10 @@ def run(self): self.list_chapters() return + if self.args.list_manga: + self.list_manga() + return + if self.args.add_user: self.add_user() return