def download(self, pathToConfigFile=None): if pathToConfigFile is not None: try: downloadSuccess = False jfw = JsonFileWrapper(pathToConfigFile) dataAsJson = jfw.getJson() if self._checkJsonInput(dataAsJson): self._log( "download {} from chapter {}".format( dataAsJson["name"], dataAsJson["chapter"]), "INFO") chapterAsString = dataAsJson["chapter"] name = dataAsJson["name"] url = dataAsJson["url"] lastDownloadedChapter = self._startDownloading( name, url, chapterAsString) if lastDownloadedChapter is not None and lastDownloadedChapter > int( dataAsJson["chapter"]): downloadSuccess = True if downloadSuccess: jfw.update("chapter", str(lastDownloadedChapter)) jfw.save() except IOError as e: self._log(e, "ERROR") else: self._log("config file path is not set !!", "ERROR")
def updateConfigFile(self, args): if self._argsAreValidForUpdate(args): try: jfw = JsonFileWrapper(self._getConfigFilePath(args.name)) actualChapter = jfw.getKey(JsonFileWrapper.CHAPTER) if actualChapter is not None: self._logger.info("class Main : update config for {}, set chapter from {} to {}".format(args.name, actualChapter, args.chapter)) jfw.update(JsonFileWrapper.CHAPTER, str(args.chapter)) jfw.save() self._logger.info("class Main :cleaning donwload directory") FileManager.getFileManager().cleanMangaDirectory(jfw.getKey(JsonFileWrapper.NAME), jfw.getKey(JsonFileWrapper.CHAPTER)) else: self._logger.error("class Main : can not set chapter {} for manga {} : actual chapter is {}"\ .format(args.chapter, args.name, actualChapter)) except IOError as e: self._logger.error("class Main : ioerror {}".format(e))
def updateConfigFile(self, args): if self._argsAreValidForUpdate(args): try: jfw = JsonFileWrapper(self._getConfigFilePath(args.name)) actualChapter = jfw.getKey(JsonFileWrapper.CHAPTER) if actualChapter is not None: self._logger.info( "class Main : update config for {}, set chapter from {} to {}" .format(args.name, actualChapter, args.chapter)) jfw.update(JsonFileWrapper.CHAPTER, str(args.chapter)) jfw.save() self._logger.info( "class Main :cleaning donwload directory") FileManager.getFileManager().cleanMangaDirectory( jfw.getKey(JsonFileWrapper.NAME), jfw.getKey(JsonFileWrapper.CHAPTER)) else: self._logger.error("class Main : can not set chapter {} for manga {} : actual chapter is {}"\ .format(args.chapter, args.name, actualChapter)) except IOError as e: self._logger.error("class Main : ioerror {}".format(e))
def download(self, pathToConfigFile=None): if pathToConfigFile is not None: try: downloadSuccess = False jfw = JsonFileWrapper(pathToConfigFile) dataAsJson = jfw.getJson() if self._checkJsonInput(dataAsJson): self._log("download {} from chapter {}".format(dataAsJson["name"], dataAsJson["chapter"]), "INFO") chapterAsString = dataAsJson["chapter"] name = dataAsJson["name"] url = dataAsJson["url"] lastDownloadedChapter = self._startDownloading(name, url, chapterAsString) if lastDownloadedChapter is not None and lastDownloadedChapter > int(dataAsJson["chapter"]): downloadSuccess = True if downloadSuccess: jfw.update("chapter", str(lastDownloadedChapter)) jfw.save() except IOError as e: self._log(e, "ERROR") else: self._log("config file path is not set !!", "ERROR")