def start():
    if len(sys.argv) < 2:
        logger.error(
            'No show title specified in arguments so cancelling updating')
        sys.exit()
    else:
        # If we have custom settings file parameter use different arg index to
        # keep legacy method intact
        if len(sys.argv) > 2:
            show_title = sys.argv[2]
        elif len(sys.argv) == 2:
            show_title = sys.argv[1]

        logger.info('Updating single show: %s' % (show_title))

    if ANILIST_SKIP_UPDATE == 'true':
        logger.warning(
            'AniList skip list update enabled in settings, will match but NOT update your list'
        )

    # Wait a few a seconds to make sure Plex has processed watched states
    sleep(5.0)

    # Anilist
    anilist_username = anilist_settings['username']
    anilist.custom_mappings = custom_mappings
    anilist.ANILIST_ACCESS_TOKEN = ANILIST_ACCESS_TOKEN
    anilist.ANILIST_SKIP_UPDATE = ANILIST_SKIP_UPDATE
    anilist_series = anilist.process_user_list(anilist_username)

    # Plex
    if anilist_series is None:
        logger.error(
            'Unable to retrieve AniList list, check your username and access token'
        )
    elif not anilist_series:
        logger.error('No items found on your AniList list to process')
    else:
        plexmodule.plex_settings = plex_settings
        plex_anime_series = plexmodule.get_anime_shows_filter(show_title)

        if (plex_anime_series is None):
            logger.error('Found no Plex shows for processing')
            plex_series_watched = None
        else:
            plex_series_watched = plexmodule.get_watched_shows(
                plex_anime_series)

        if (plex_series_watched is None):
            logger.error('Found no watched shows on Plex for processing')
        else:
            anilist.match_to_plex(anilist_series, plex_anime_series,
                                  plex_series_watched)

        logger.info('Plex to AniList sync finished')
Esempio n. 2
0
def start():
    logger.info(f"PlexAniSync - version: {__version__}")
    logger.info(f"Updating single show: {show_title}")

    anilist.CUSTOM_MAPPINGS = read_custom_mappings()

    if graphql.ANILIST_SKIP_UPDATE:
        logger.warning(
            "AniList skip list update enabled in settings, will match but NOT update your list"
        )

    anilist.clean_failed_matches_file()

    # Anilist
    anilist_username = anilist_settings["username"]
    anilist_series = anilist.process_user_list(anilist_username)

    # Plex
    if anilist_series is None:
        logger.error(
            "Unable to retrieve AniList list, check your username and access token"
        )
    elif not anilist_series:
        logger.error("No items found on your AniList list to process")
    else:
        # Wait a few a seconds to make sure Plex has processed watched states
        sleep(5.0)
        plexmodule.plex_settings = plex_settings
        plex_anime_series = plexmodule.get_anime_shows_filter(show_title)

        if plex_anime_series is None:
            logger.error("Found no Plex shows for processing")
            plex_series_watched = None
        else:
            plex_series_watched = plexmodule.get_watched_shows(
                plex_anime_series)

        if plex_series_watched is None:
            logger.error("Found no watched shows on Plex for processing")
        else:
            anilist.match_to_plex(anilist_series, plex_series_watched)

        logger.info("Plex to AniList sync finished")
Esempio n. 3
0
def start():
    if len(sys.argv) < 2:
        logger.error(
            'No show title specified in arguments so cancelling updating')
        sys.exit()
    else:
        show_title = sys.argv[1]
        logger.info('Updating single show: %s' % (show_title))

    if ANILIST_SKIP_UPDATE == 'true':
        logger.warning(
            'AniList skip list update enabled in settings, will match but NOT update your list')

    # Wait a few a seconds to make sure Plex has processed watched states
    sleep(5.0)

    # Anilist
    anilist_username = anilist_settings['username']
    anilist.custom_mappings = custom_mappings
    anilist.ANILIST_ACCESS_TOKEN = ANILIST_ACCESS_TOKEN
    anilist.ANILIST_SKIP_UPDATE = ANILIST_SKIP_UPDATE
    anilist_series = anilist.process_user_list(anilist_username)

    # Plex
    if not anilist_series:
        logger.error(
            'Unable to retrieve AniList list, check your username and access token')
    else:
        plexmodule.plex_settings = plex_settings
        plex_anime_series = plexmodule.get_anime_shows_filter(show_title)
        plex_series_watched = plexmodule.get_watched_shows(plex_anime_series)
        anilist.match_to_plex(
            anilist_series,
            plex_anime_series,
            plex_series_watched)

        logger.info('Plex to AniList sync finished')