Esempio n. 1
0
def update_library():
    " Update Kinobot's database. "
    kino_log(KINOLOG)
    create_db_tables()
    radarr_list = get_radarr_list()
    episode_list = get_episodes()
    clean_tables()
    logger.info("Updating Kinobot's database: MOVIES")
    check_missing_movies(radarr_list)
    force_update(radarr_list)
    update_paths(radarr_list)
    logger.info("Updating Kinobot's database: EPISODES")
    update_episode_table(episode_list)
    remove_empty()
    update_dar_from_table("episodes")
Esempio n. 2
0
def collect(count):
    """
    Collect 'requests' from Kinobot's last <n> posts.
    """
    kino_log(KINOLOG_COMMENTS)

    create_request_db()

    logging.info(f"About to scan {count} posts")
    posts = (FB.get("me/posts", limit=count)["data"] +
             FB_TV.get("me/posts", limit=count)["data"])
    count_ = 0
    for i in posts:
        new_comments = add_comments(str(i["id"]))
        if new_comments:
            count_ = new_comments + count_

    logging.info(f"Total new comments added: {count_}")
Esempio n. 3
0
def collect(count):
    """
    Collect 'requests' from Kinobot's last <n> posts.
    """
    kino_log(KINOLOG_COMMENTS)
    kinobot = GraphAPI(FACEBOOK)
    kinobot_tv = GraphAPI(FACEBOOK_TV)

    create_request_db()

    logging.info(f"About to scan {count} posts")

    count_ = 0
    for type_ in (kinobot, kinobot_tv):
        for post in type_.get("me/posts", limit=count)["data"]:
            new_comments = add_comments(type_, str(post["id"]))
            if new_comments:
                count_ = new_comments + count_

    logging.info(f"Total new comments added: {count_}")
Esempio n. 4
0
def testing():
    " Find a valid request for tests. "
    kino_log(KINOLOG + ".test")
    post(test=True)
    post("episodes", test=True)
Esempio n. 5
0
def publish():
    " Find a valid request and post it to Facebook. "
    kino_log(KINOLOG)
    post("episodes")
    post()
Esempio n. 6
0
from kinobot.utils import kino_log

CRON = "*/30 * * * *"

logger = logging.getLogger(__name__)


def post_request():
    post("episodes", TEST)
    post_id = post(test=TEST)

    logger.info(f"Waiting 10 minutes to verify Facebook reacts for {post_id}")

    time.sleep(600)

    if get_reacts_count(post_id) < 15:
        logger.info("Ignored post")
        post(test=TEST)


if __name__ == "__main__":
    kino_log(kinobot.KINOLOG)

    logger.info(f"Log location: {kinobot.KINOLOG}")
    logger.info(f"Cron: {CRON}")

    sched = BlockingScheduler()
    sched.add_job(post_request, CronTrigger.from_crontab(CRON))

    sched.start()