コード例 #1
0
ファイル: auto.py プロジェクト: siimsaar/py-project
def look_for_torrents(forced=False, sse_id="b"):
    if int(app.conf.automation_status) == 1 or forced is True:
        if forced is False:
            global l_t_check
            l_t_check = app.datetime.now().strftime("%d/%m/%Y, %H:%M:%S")
        logging.info("Checking for releases in torrents")
        todays_date = app.datetime.now()
        schd_albums = app.QueueAlbum.query.all()
        for query in schd_albums:
            date = app.datetime.strptime(query.date, "%d %B %Y")
            if date <= todays_date:
                if int(query.status) == 0:
                    app.download(query.album_name)
        data = ({"album": "C_T", "date": "C_T"})
        app.pushtoListener(data)
コード例 #2
0
ファイル: auto.py プロジェクト: siimsaar/Heedfouns
def look_for_torrents(forced=False, sse_id="b"):
    if int(app.conf.automation_status) == 1 or forced is True:
        if forced is False:
            global l_t_check
            l_t_check = app.datetime.now().strftime("%d/%m/%Y, %H:%M:%S")
        logging.info("Checking for releases in torrents")
        todays_date = app.datetime.now()
        schd_albums = app.QueueAlbum.query.all()
        for query in schd_albums:
            date = app.datetime.strptime(query.date, "%d %B %Y")
            if date <= todays_date:
                if int(query.status) == 0:
                    app.download(query.album_name)
        data = ({"album": "C_T", "date": "C_T"})
        app.pushtoListener(data)
コード例 #3
0
def processtask(page, data):
    print(now() + ' [Processing task] ', page.name, file=sys.stderr)
    try:
        text = download(page.url, page.ua, page.referer, page.cookie,
                        page.method, page.postdata)
    except Exception as e:
        print(page.id, page.name, type(e).__name__, file=sys.stderr)
        page.update_check(type(e).__name__)
        return
    if not data:
        data.append(text)
        page.update_check('First check')
    else:
        # print(text.splitlines(True),file=sys.stderr)
        if data[0] != text:  # page changed!
            if page.watch_type == 'change' or (page.watch_type == 'keyword'
                                               and page.keyword in text and
                                               not page.keyword in data[0]):
                notify = gendiff(data[0], text,
                                 page.notify_content) + '\n\n' + page.url
                send_mail(page.name + ' - subscribe to anything', notify,
                          page.email())
            data[0] = text
            page.update_check('Changed')
        else:
            page.update_check('Not changed')
コード例 #4
0
def processtask(page,data):
    print(now()+' [Processing task] ',page.name,file=sys.stderr)
    try:
        text=download(page.url,page.ua,page.referer,page.cookie,page.method,page.postdata)
    except Exception as e:
        print(page.id,page.name,type(e).__name__,file=sys.stderr)
        page.update_check(type(e).__name__)
        return
    if not data:
        data.append(text)
        page.update_check('First check')
    else:
        #print(text.splitlines(True),file=sys.stderr)
        if data[0]!=text: #page changed!
            if page.watch_type=='change':
                notify=gendiff(data[0],text,page.notify_content)+'\n\n'+page.url
                send_mail(
                    page.name+' - subscribe to anything',
                    notify,
                    page.email()
                )
            elif page.watch_type=='keyword':
                pass
            data[0]=text
            page.update_check('Changed')
        else:
            page.update_check('Not changed')
コード例 #5
0
def test(id):
    page=Page.query.get(id)
    if not page or page.user!=current_user:
        return redirect(url_for('manage.index'))
    try:
        text=download(page.url,page.ua,page.referer,page.cookie,page.method,page.postdata)
    except Exception as e:
        text=type(e).__name__
    return Response(text,mimetype='text/plain')
コード例 #6
0
def test(id):
    page = Page.query.get(id)
    if not page or page.user != current_user:
        return redirect(url_for('manage.index'))
    try:
        text = download(page.url, page.ua, page.referer, page.cookie, page.method, page.postdata)
    except Exception as e:
        text = type(e).__name__
    return render_template('test.html', text=text)
コード例 #7
0
def test(id):
    page = Page.query.get(id)
    if not page or page.user != current_user:
        return redirect(url_for('manage.index'))
    try:
        text = download(page.url, page.ua, page.referer, page.cookie,
                        page.method, page.postdata)
    except Exception as e:
        text = type(e).__name__
    return Response(text, mimetype='text/plain')
コード例 #8
0
def main():
    if app.arguments.format == 'all':

        # Whitelist and blacklist
        whitelist: List[str] = []
        blacklist: List[str] = []

        # Populate lists if configured in settings
        if 'all' in app.settings['formats']:
            if 'whitelist' in app.settings['formats']['all']:
                whitelist = app.settings['formats']['all']['whitelist']

            if 'blacklist' in app.settings['formats']['all']:
                blacklist = app.settings['formats']['all']['blacklist']

        # If not input, download JSON data form API and
        # use it as input value for the other formats.
        if app.arguments.input is None:
            app.arguments.input = app.download(app.arguments.video, 'json')

        # Download all formats. Ignore 'all' and 'json'.
        for format_name in app.settings['formats']:
            if format_name not in ['all', 'json']:

                if (whitelist and format_name not in whitelist) or (
                        blacklist and format_name in blacklist):
                    if app.arguments.verbose:
                        print('Skipping {format_name}'.format(
                            format_name=format_name))
                    continue
                else:
                    app.download(app.arguments.video, format_name)

    else:
        app.download(app.arguments.video, app.arguments.format)

    if app.arguments.verbose:
        print('Done')
コード例 #9
0
def download(to, verbose):
    "Download all frac schedules"

    set_verbosity(verbose)
    click.echo(
        click.style(
            "\n" + f"Downloading frac schedules to: {os.path.abspath(to)}",
            fg="cyan",
            bold=True,
        ))

    with DownloadLog.context(DOWNLOADLOGPATH) as dlog:
        for path, filename, status in app.download(to):
            click.secho(
                f"{filename:<60} {status:<25}",
                fg="green" if status == "success" else "red",
            )
            dlog.add(os.path.abspath(os.path.join(path, filename)))
コード例 #10
0
def get_single_video(vid, form):
    app.arguments.video = vid
    app.arguments.format = form
    app.download(app.arguments.video, app.arguments.format)
    return