def download_range_test(self): dc = DownloadController() dc.setSeriesUrl(self.mangatraders_series_url) r = dc.downloadChapterRange(0, 1) self.assertFalse(False in r)
def nogui(args): #test if we have all needed args if args.url is None: print("--url option is needed in nogui mode!") sys.exit(2) if args.range is None and args.list is False: print("--range (or --list) option is needed in nogui mode!") sys.exit(2) dc = DownloadController() print("Downloading gallery info for: %s" % (args.url, )) if not dc.setSeriesUrl(args.url): print("Wrong url! Exiting...") sys.exit(2) chapter_list = dc.getChaptersList() # -l --list option, print chapters and exit if args.list: print("Printing list of chapters...") for i in range(len(chapter_list)): print("%i - %s" % (i, chapter_list[i][0])) print("Exiting...") sys.exit(0) # test -r --range option if args.range is None or len(args.range)!=2: print("Incorrect range argument, exiting...") sys.exit(2) if args.range[1]<0: args.range[1] = len(chapter_list) else: args.range[1] = args.range[1]+1 try: c_range = chapter_list[args.range[0]:args.range[1]] except Exception as e: print("Bad range! %s" % (e,)) print("Exiting...") sys.exit(2) if len(c_range)==0: print("Nothing to download, exiting...") sys.exit(0) # downloading print("Starting download of %i chapters..." % (len(c_range),)) print("from: %s" % (c_range[0][0],)) print("to: %s" % (c_range[-1][0],)) dc.downloadChapterRange(args.range[0], args.range[1]-1) print("Download Finished!!!") # Print failed downloads print("\nChapters with failed downloads:") for i, r in enumerate(dc.results): if r is False: print(chapter_list[i+args.range[0]][0]) sys.exit(0)