Beispiel #1
0
 def get_chapter(self, chapter_url: str) -> Chapter:
     """Returns `Chapter` object from database whose `url` is `chapter_url`, 
     otherwise `None`"""
     chapter = None
     try:
         chapter = self.__database.select_chapter(chapter_url)
     except sql.OperationalError as ex:
         plog(["No Chapter"], chapter_url)
     return chapter
    def add_to_library(self):
        """Add Current Instance Of Novel To Database"""
        novel = self.repo.get_novel(self.novel.url, offline=True)
        if novel is None:
            self.repo.save_novel(self.novel)
            self.repo.save_meta(self.novel.url, self.novel.meta)
            self.repo.save_chapters(self.novel.url, self.novel.chapters)

            plog(["added to library"], self.ids.title.text)
        else:
            plog(["in library"], self.ids.title.text)
Beispiel #3
0
    def on_start(self, repository: Repository):
        plog(["on start"], "library_page")
        self.repo = repository
        Clock.schedule_interval(lambda dt: self.update_library(), 1 * 60)

        # load saved novels in database
        novels = self.repo.get_novels()
        if novels:
            for novel in novels:
                threading.Thread(target=self.download_thumbnail,
                                 args=(novel.thumbnail, )).start()
            self.update_library()
    def update_chapters(self, url: str):
        """Update Chapters Of Novel"""
        new_chapters, num_new_chapter = self.repo.update_chapters(url)

        if new_chapters:
            dict_chapters = [{
                "text": chapter.title,
                "url": chapter.url
            } for chapter in new_chapters]
            self.ids.chapter_list.data = dict_chapters

        plog(["# Of New Chapters"], num_new_chapter)
Beispiel #5
0
 def update_library(self):
     self.novellist.data = []
     novels = self.repo.get_novels()
     for novel in novels:
         self.novellist.data.append({
             "url":
             novel.url,
             "title":
             novel.title,
             "thumbnail":
             str(thumbnail_path(novel.thumbnail))
         })
     plog(["loaded", str(len(novels))], 'novels')
Beispiel #6
0
    def start_search(self):
        if not self.__searching:
            self.__searching = True
            plog(['searching'], self.search_input.text)
            self.search_list_recycle.data.clear()

            with requests.Session() as session:
                thread = threading.Thread(target=self.search_work,
                                          args=(self.search_input.text,
                                                Website.BOXNOVELCOM))
                thread.start()
        else:
            plog(["already searching"], self.search_input.text)
    def read_chapter(self, chapter_url):
        # check first if chapter has content in database
        chapter = self.repo.get_chapter()

        if chapter:
            # chapter in database
            if not chapter.has_read:
                # chapter not yet read
                self.repo.update_chapter_has_read(chapter.url, True)

            if not chapter.content:
                # check if chapter has not content
                # get content from web
                content = self.repo.get_chapter_content(chapter_url)
                self.repo.update_chapter_content(chapter_url, content)
                chapter.content = content
            if chapter.content:
                # makes sure that chapter has content
                self.manager.get_screen("reader_page").update_content(
                    chapter.content)
                self.manager.current = "reader_page"
            else:
                plog(["missing", "content"], chapter_url)
 def read(self):
     plog(["reading"], self.text)
     self.parent.parent.parent.parent.read_chapter(self.url)
Beispiel #9
0
 def browse(self):
     plog(['browsing'], self.text)
     self.parent.parent.parent.parent.goto_info_page(self.url)
Beispiel #10
0
 def search_work(self, keyword: str, website: Website):
     novels = self.repo.search(keyword, website)
     if novels:
         plog(["# Of Searched"], len(novels))
         self.update_search_list(novels)
     self.__searching = False