示例#1
0
def export(data_novel):
    getify.cover_generator(data_novel['cover_url'], data_novel['series'], data_novel['title'], data_novel['author'])

    chapter = 1

    download_url = data_novel['first_chapter_url']
    file_list = []
    end = False
    while (True):
        filename = storage_dir + os.sep + "tmp" + os.sep + str(chapter) + ".xhtml"
        filenameOut = storage_dir + os.sep + "tmp"+os.sep+'ch-{:0>3}'.format(chapter)
        try:
            getify.download(download_url, filename)
        except HTTPError as e:
            # Return code error (e.g. 404, 501, ...)
            print('URL: {}, HTTPError: {} - {}'.format(download_url, e.code, e.reason))
        except URLError as e:
            # Not an HTTP-specific error (e.g. connection refused)
            print('URL: {}, URLError: {}'.format(download_url, e.reason))
        else:
            raw = open(filename, "r", encoding="utf8")
            soup = BeautifulSoup(raw, 'lxml')
            button_next = soup.find_all('a', string=re.compile('Next >'), href=True)
            if (not button_next):
                end = True
            else:
                download_url = button_next[0]['href']
            getify.clean(filename, filenameOut, "Chapter #{:100}".format(chapter))
            file_list.append(filenameOut + ".xhtml")
        if (not end):
            chapter += 1
        else:
            break
    getify.generate(file_list, data_novel['title'], data_novel['author'], 'ch-', data_novel['series'], None, None)
示例#2
0
def button_press():
    try:
        #Getting Information
        generate_button.configure(state = "disabled")
        s_chapter = starting_chapter.get()
        reset = str(s_chapter)
        e_chapter = ending_chapter.get()
        cleanup = delete_chapters.get()
        booknr = book_number.get()
        name = novel.get()

        #Getting relevant novel Information
        raw_info = []
        for i in db:
            if name in i[0]:
                raw_info.append(i)
        raw_info = raw_info[0]
        if raw_info[5] == 0:
            link = raw_info[1]
        else:
            link = raw_info[1] + str(booknr) + "-chapter-"

        #Generating list with download links
        bulk_list = []
        for s_chapter in range(s_chapter, e_chapter + 1):
            bulk_list.append(link + str(s_chapter))
        s_chapter = reset

        getify.cover_generator(raw_info[4], s_chapter, str(e_chapter))

        if not path.exists(raw_info[0]):
            os.makedirs(raw_info[0])

        #Calls function's for downloading, cleanup and managing
        #a list of file name's for cleanup, ToC and packing
        y = int(s_chapter)
        file_list = []
        for x in range(len(bulk_list)):
            if path.exists(_get_xhtml_path(raw_info, s_chapter)):
                print(_get_xhtml_path(raw_info, s_chapter), " already exists")
            else:
                try:
                    getify.download(bulk_list[x], str(s_chapter) + ".xhtml")
                    file_list.append(_get_xhtml_path(raw_info, s_chapter))
                except HTTPError as e:
                    # Return code error (e.g. 404, 501, ...)
                    print('URL: {}, HTTPError: {} - {}'.format(bulk_list[x], e.code, e.reason))
                except URLError as e:
                    # Not an HTTP-specific error (e.g. connection refused)
                    print('URL: {}, URLError: {}'.format(bulk_list[x], e.reason))
                else:
                    getify.clean(str(s_chapter) + ".xhtml", _get_xhtml_path(raw_info, s_chapter), name)
            s_chapter = int(s_chapter) + 1

        getify.generate(file_list, raw_info[0], raw_info[3], raw_info[2], reset, str(e_chapter), cleanup=cleanup)

    finally:
        generate_button.configure(state = "enabled")
def button_press():
    #Getting Information
    generate_button.configure(state="disabled")
    s_chapter = starting_chapter.get()
    reset = str(s_chapter)
    e_chapter = ending_chapter.get()
    booknr = book_number.get()
    name = novel.get()

    #Getting relevant novel Information
    raw_info = []
    for i in db:
        if name in i[0]:
            raw_info.append(i)
    raw_info = raw_info[0]
    if raw_info[5] == 0:
        link = raw_info[1]
    else:
        link = raw_info[1] + str(booknr) + "-chapter-"

    #Generating list with download links
    bulk_list = []
    for s_chapter in range(s_chapter, e_chapter + 1):
        bulk_list.append(link + str(s_chapter))
    s_chapter = reset

    getify.cover_generator(raw_info[4], s_chapter, str(e_chapter))

    #Calls function's for downloading, cleanup and managing
    #a list of file name's for cleanup, ToC and packing
    y = int(s_chapter)
    file_list = []
    for x in range(len(bulk_list)):
        getify.download(bulk_list[x], str(s_chapter) + ".xhtml")
        getify.clean(
            str(s_chapter) + ".xhtml", raw_info[2] + str(s_chapter),
            '<div itemprop="articleBody"', '''<div class="code-block''')
        file_list.append(raw_info[2] + str(s_chapter) + ".xhtml")
        s_chapter = int(s_chapter) + 1

    getify.generate(file_list, raw_info[0], raw_info[3], raw_info[2], reset,
                    str(e_chapter))
    generate_button.configure(state="enabled")