def write_to_epub(novelids, login, session): for novelid in novelids: e = Epub() e.summary = get_summary(novelid, session) e.intro = get_intro(novelid, session) e.author, e.name, contents = get_contents(novelid, login, session) e.init() pic_con = get_pic(novelid, e.filename, session) e.write_pic(pic_con) e.write_coverandintro() e.write_chapters(contents) for chapter in contents: if chapter[0]: text = get_all_text(chapter[2], session) print(chapter[1][0], " ", chapter[1][1]) e.write_text(chapter[1], text) e.packet()