Ejemplo n.º 1
0
def new():
    if request.method == 'GET':
        return render_template(
            'serie/new.html', title='New Serie', edit=True,
            serie=Serie(), menuItems=menu.make(), fansubs=Fansub.select())
    elif request.method == 'POST':
        fansub = Fansub.get(Fansub.id == request.form.get('fansub'))
        serie = Serie(
            title=request.form.get('title'),
            lastChapter=request.form.get('lastChapter', 0),
            totalChapters=request.form.get('totalChapters'),
            onGoing=request.form.get('onGoing', False),
            scrapCode='',
            scrapParam='',
            fansub=fansub)

        serie.save()

        count = 1
        for paramTemplate in fansub.paramTemplate:
            ScrapParam.create(
                name=paramTemplate.name,
                dataType=paramTemplate.dataType,
                value=paramTemplate.value,
                serie=serie,
                paramNo=count)
            count += 1

        return redirect(url_for('.update', id=serie.id))
Ejemplo n.º 2
0
def new():
    if request.method == 'GET':
        return render_template(
            'fansub/new.html', title='New Fansub', edit=True,
            fansub=Fansub(), menuItems=menu.make())
    elif request.method == 'POST':
        Fansub.create(
            name=request.form.get('name'),
            url=request.form.get('url'),
            baseUrl=request.form.get('baseUrl'))

        return redirect(url_for('.list'))
Ejemplo n.º 3
0
def checkNewChapters():
    logger.debug('checkNewChapters() running')
    fansubs = Fansub.select()
    for fs in fansubs:
        scr = Scraper(fs)
        series = Serie.select().where(
            Serie.onGoing == 1,
            Serie.active == 1,
            Serie.fansub == fs)
        for s in series:
            try:
                logger.debug('Scraping %s - %s' % (fs, s))
                scr.next(s)
            except ConnectionError as err:
                logger.error('%s/%s Connection Error: \n%s' % (fs, s, err))
            except ReadTimeout as err:
                logger.error('%s/%s Read Timeout: \n%s' % (fs, s, err))
Ejemplo n.º 4
0
def update(id):
    if request.method == 'GET':
        s = Serie.get(Serie.id == id)
        return render_template(
            'serie/view.html', title=s.title, edit=True,
            serie=s, menuItems=menu.make())
    elif request.method == 'POST':
        serie = Serie.get(Serie.id == id)

        serie.title = request.form.get('title')
        serie.lastChapter = request.form.get('lastChapter')
        serie.totalChapters = request.form.get('totalChapters')
        serie.onGoing = request.form.get('onGoing', False)

        serie.fansub = Fansub.get(Fansub.id == request.form.get('fansub'))

        for param in serie.params:
            param.value = request.form.get(param.name)
            param.save()

        serie.save()

        return redirect(url_for('.view', id=serie.id))
Ejemplo n.º 5
0
def list():
    fansubs = Fansub.select()
    return render_template(
        'fansub/list.html', title='Fansubs',
        fansubs=fansubs, menuItems=menu.make())