예제 #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")
예제 #3
0
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")
예제 #4
0
rawMeta = driver.find_elements_by_css_selector(".mb5.ell")
meta = [test.text for test in rawMeta]
for x, y in enumerate(meta):
	if y.startswith("Author: "):
		info = y[len("Author: "):] + ", "
	if y.startswith("Translator: "):
		info += y[len("Translator: "):]

popup = driver.find_element_by_css_selector("a[href='#contentsModal']")
popup.click()
time.sleep(1)
chlistRaw = driver.find_elements_by_css_selector(".g_mod_content .g_mod_bd.content-list a" )
chlist = [{"link": category.get_attribute("href"), "text": category.text}
for category in chlistRaw]
driver.quit()

print ("There are currently " + str(len(chlist)) + " available")
startingChapter = int(input("What's the starting Chapter?: "))
endingChapter = int(input("What's the ending Chapter?: "))

chlistSelection = chlist[startingChapter - 1 : endingChapter]

file_list = []
for q in range(len(chlistSelection)):
	getify.download(chlistSelection[q]["link"], str(q))
	getify.clean(str(q))
	file_list.append(str(q) + "m" + ".xhtml")
	getify.update_progress(q/len(chlistSelection))
	
getify.generate(file_list, result[select - 1]["text"], info, chlistSelection, str(startingChapter), str(endingChapter))
end_chapter = e_chapter
e_chapter = int(e_chapter)

# Generates Link list
bulk_list = []
for s_chapter in range(s_chapter, e_chapter + 1):
    s_chapter_string = str(s_chapter)
    bulk_list.append(raw_info["link"] + s_chapter_string)

#Does the calls for downloadingand modifying
#and the progress bar... Don't forget the progress bar
array_length = len(bulk_list)
file_list = []
for x in range(array_length):
    x_chapter = str(x_chapter)
    getify.download(bulk_list[x], x_chapter + ".xhtml")
    getify.clean(x_chapter + ".xhtml", raw_info["ChapterName"] + x_chapter,
                 '<div itemprop="articleBody"', '''<div class='code-block''')
    file_list.append(raw_info["ChapterName"] + x_chapter + ".xhtml")
    x_chapter = int(x_chapter)
    x_chapter += 1
    getify.update_progress(x / array_length)

#Generates the eBook
print("")
print("Creating ePub...")
getify.generate(file_list, raw_info["NovelName"], raw_info["author"],
                raw_info["ChapterName"], f_chapter, end_chapter)

print("Success . . . Hopefully")