Exemplo n.º 1
0
def Novel(novelname):
    
    chapterlist = ''
    noveldata = {}
    novelname = unquote(novelname)

    try:
        noveldata = pickle.load(open('./novel/' + novelname + '/info.dat', "rb"))
    except:
        return "咦,这里也没有!"
    try:
        lastread = noveldata['lastread']
    except:
        lastread = -1
    
    if request.method == 'POST':
        return usrlib.Get_New_Chapter_List(noveldata)

    try:
        chapter_name = pickle.load(open('./novel/' + novelname + '/chapter_name.dat', "rb"))
    except:
        return "咦,这里也没有!"

    html = open('./webui/book.html',encoding='utf8').read()
    try:
        string = noveldata['image']
    except:
        string = '/img/default.jpg'
    html = html.replace('#image',string)
    try:
        string = noveldata['description']
        string = usrlib.escape(string,1)
    except:
        string = ''
    html = html.replace('#description',string)
    try:
        string = noveldata['author']
    except:
        string = ''
    html = html.replace('#author',string)
    try:
        string = noveldata['category']
    except:
        string = ''
    html = html.replace('#category',string)
    try:
        string = noveldata['status']
    except:
        string = ''
    html = html.replace('#status',string)
    try:
        string = noveldata['update']
    except:
        string = ''
    html = html.replace('#update',string)
    try:
        string = noveldata['website']
    except:
        string = ''
    html = html.replace('#resourceid',string)
    try:
        string = noveldata['homepage']
    except:
        string = ''
    html = html.replace('#resource',string)
    
    i=0
    for item in chapter_name:
        if i == lastread:
            chapterlist += '<a class="list-group-item col-lg-4" id="chapterlink" href="' + '/' + novelname + '/' + repr(i) + '">' + item + '<span class="badge">书签</span></a>'
        else:
            chapterlist += '<a class="list-group-item col-lg-4" id="chapterlink" href="' + '/' + novelname + '/' + repr(i) + '">' + item + '</a>'
        i=i+1
    html = html.replace('#novelname',novelname)
    html = html.replace('#chapterlist',chapterlist)
    return html
Exemplo n.º 2
0
def Novel(novelname):

    chapterlist = ''
    noveldata = {}
    novelname = unquote(novelname)

    try:
        noveldata = pickle.load(
            open('./novel/' + novelname + '/info.dat', "rb"))
    except:
        return "咦,这里也没有!"
    try:
        lastread = noveldata['lastread']
    except:
        lastread = -1

    if request.method == 'POST':
        return usrlib.Get_New_Chapter_List(noveldata)

    try:
        chapter_name = pickle.load(
            open('./novel/' + novelname + '/chapter_name.dat', "rb"))
    except:
        return "咦,这里也没有!"

    html = open('./webui/book.html', encoding='utf8').read()
    try:
        string = noveldata['image']
    except:
        string = '/img/default.jpg'
    html = html.replace('#image', string)
    try:
        string = noveldata['description']
        string = usrlib.escape(string, 1)
    except:
        string = ''
    html = html.replace('#description', string)
    try:
        string = noveldata['author']
    except:
        string = ''
    html = html.replace('#author', string)
    try:
        string = noveldata['category']
    except:
        string = ''
    html = html.replace('#category', string)
    try:
        string = noveldata['status']
    except:
        string = ''
    html = html.replace('#status', string)
    try:
        string = noveldata['update']
    except:
        string = ''
    html = html.replace('#update', string)
    try:
        string = noveldata['website']
    except:
        string = ''
    html = html.replace('#resourceid', string)
    try:
        string = noveldata['homepage']
    except:
        string = ''
    html = html.replace('#resource', string)

    i = 0
    for item in chapter_name:
        if i == lastread:
            chapterlist += '<a class="list-group-item col-lg-4" id="chapterlink" href="' + '/' + novelname + '/' + repr(
                i) + '">' + item + '<span class="badge">书签</span></a>'
        else:
            chapterlist += '<a class="list-group-item col-lg-4" id="chapterlink" href="' + '/' + novelname + '/' + repr(
                i) + '">' + item + '</a>'
        i = i + 1
    html = html.replace('#novelname', novelname)
    html = html.replace('#chapterlist', chapterlist)
    return html
Exemplo n.º 3
0
def Chpater(novelname,chapter=None):
    noveldata ={}
    novelname = unquote(novelname)
    try:
        noveldata = pickle.load(open('./novel/' + novelname + '/info.dat', "rb"))
        chapter_name = pickle.load(open('./novel/' + novelname + '/chapter_name.dat', "rb"))
    except:
        return "咦,这里也没有!"

    if request.method == 'POST':

        if chapter is None:
            return '-1'

        text = usrlib.Get_Chapter(novelname,chapter)
        if  text == '未找到章节信息!':
            return json.dumps({"status":"404","message":text})
        elif text == '未找到章节!':
            return json.dumps({"status":"404","message":text})
        text = usrlib.escape(text,2)
        #rt = {"title": chapter_name[chapter], "description": text}
        try:
            lastread = noveldata['lastread']
        except:
            lastread = -1
        if chapter >= lastread:
            noveldata['lastread'] = chapter
            pickle.dump(noveldata, open('./novel/' + novelname + '/info.dat', "wb"))
        return json.dumps({"status":"OK","title": chapter_name[chapter], "description": text})
    else:
        reading_setting ={}
        try:
            reading_setting = pickle.load(open('./setting.dat', "rb"))
        except:
            reading_setting['continuously'] = 'true'
        continuously = reading_setting['continuously']

        if (0 <= chapter <= len(chapter_name)-1):
            chaptername=chapter_name[chapter]
            text = usrlib.Get_Chapter(novelname,chapter)
            text = usrlib.escape(text,2)
            html = open('./webui/chapter.html',encoding='utf8').read()
            html = html.replace('#novelname',novelname)
            html = html.replace('#chaptername',chaptername)
            html = html.replace('#NovelLink','/'+novelname+'/')
            html = html.replace('#text',text)
            html = html.replace('#chapter',repr(chapter))
            html = html.replace('#novelpage','/' + novelname + '/')
            if chapter<len(chapter_name)-1:
                html = html.replace('#next','/' + novelname + '/' + repr(chapter+1))
            else:
                html = html.replace('#next','/' + novelname + '/')
            if chapter>0:
                html = html.replace('#previous','/' + novelname + '/' + repr(chapter-1))
            else:
                html = html.replace('#previous','/' + novelname + '/')
            if continuously == 'true':
                html = html.replace('#script','/js/continuously.js')
                html = html.replace('#novelname',novelname)
                html = html.replace('#chapter',repr(chapter+1))
            else:
                html = html.replace('#script','/js/pager.js')
            try:
                lastread = noveldata['lastread']
            except:
                lastread = -1
            if chapter >= lastread:
                noveldata['lastread'] = chapter
                pickle.dump(noveldata, open('./novel/' + novelname + '/info.dat', "wb"))
            return html
        else:
            return Novel(novelname)
Exemplo n.º 4
0
def Chpater(novelname, chapter=None):
    noveldata = {}
    novelname = unquote(novelname)
    try:
        noveldata = pickle.load(
            open('./novel/' + novelname + '/info.dat', "rb"))
        chapter_name = pickle.load(
            open('./novel/' + novelname + '/chapter_name.dat', "rb"))
    except:
        return "咦,这里也没有!"

    if request.method == 'POST':

        if chapter is None:
            return '-1'

        text = usrlib.Get_Chapter(novelname, chapter)
        if text == '未找到章节信息!':
            return json.dumps({"status": "404", "message": text})
        elif text == '未找到章节!':
            return json.dumps({"status": "404", "message": text})
        text = usrlib.escape(text, 2)
        #rt = {"title": chapter_name[chapter], "description": text}
        try:
            lastread = noveldata['lastread']
        except:
            lastread = -1
        if chapter >= lastread:
            noveldata['lastread'] = chapter
            pickle.dump(noveldata,
                        open('./novel/' + novelname + '/info.dat', "wb"))
        return json.dumps({
            "status": "OK",
            "title": chapter_name[chapter],
            "description": text
        })
    else:
        reading_setting = {}
        try:
            reading_setting = pickle.load(open('./setting.dat', "rb"))
        except:
            reading_setting['continuously'] = 'true'
        continuously = reading_setting['continuously']

        if (0 <= chapter <= len(chapter_name) - 1):
            chaptername = chapter_name[chapter]
            text = usrlib.Get_Chapter(novelname, chapter)
            text = usrlib.escape(text, 2)
            html = open('./webui/chapter.html', encoding='utf8').read()
            html = html.replace('#novelname', novelname)
            html = html.replace('#chaptername', chaptername)
            html = html.replace('#NovelLink', '/' + novelname + '/')
            html = html.replace('#text', text)
            html = html.replace('#chapter', repr(chapter))
            html = html.replace('#novelpage', '/' + novelname + '/')
            if chapter < len(chapter_name) - 1:
                html = html.replace('#next',
                                    '/' + novelname + '/' + repr(chapter + 1))
            else:
                html = html.replace('#next', '/' + novelname + '/')
            if chapter > 0:
                html = html.replace('#previous',
                                    '/' + novelname + '/' + repr(chapter - 1))
            else:
                html = html.replace('#previous', '/' + novelname + '/')
            if continuously == 'true':
                html = html.replace('#script', '/js/continuously.js')
                html = html.replace('#novelname', novelname)
                html = html.replace('#chapter', repr(chapter + 1))
            else:
                html = html.replace('#script', '/js/pager.js')
            try:
                lastread = noveldata['lastread']
            except:
                lastread = -1
            if chapter >= lastread:
                noveldata['lastread'] = chapter
                pickle.dump(noveldata,
                            open('./novel/' + novelname + '/info.dat', "wb"))
            return html
        else:
            return Novel(novelname)