Exemplo n.º 1
0
Arquivo: test.py Projeto: skxu/spice
def main():
    creds = spice.load_auth_from_file('auth')
    print(creds)
    results = spice.search('Re:Zero Kara Hajimeru Isekai Seikatsu',
                           spice.get_medium('anime'), creds)
    print(results[0].title)
    souma = spice.search_id(1, spice.get_medium('manga'), creds)
    print(souma.raw_data)
    print(souma.title)
    print(souma.chapters)
    print(souma.volumes)
    re_zero_data = spice.get_blank(spice.get_medium('anime'))
    re_zero_data.episodes = 0
    re_zero_data.status = spice.get_status('reading')
    re_zero_data.score = 8
    re_zero_data.tags = ['this the first time a show that made me cringe']

    shokugeki_data = spice.get_blank(spice.get_medium('manga'))
    shokugeki_data.chapters = 13
    shokugeki_data.volumes = 1
    shokugeki_data.status = 1
    shokugeki_data.score = 8
    spice.update(shokugeki_data, 45757, spice.get_medium('manga'), creds)

    anime_list = spice.get_list(spice.get_medium('ANIME'), 'Utagai-', creds)
    print(anime_list.avg_score())
    print(anime_list.median_score())
    print(anime_list.mode_score())
    print(anime_list.extremes())
    print(anime_list.p_stddev())
    print(anime_list.p_var())
    print(anime_list.get_num_status(1))
    print(anime_list.get_total())
    print(anime_list.get_days())
    print(anime_list.exists(11734))
    print(len(anime_list.get_ids()))
    print(len(anime_list.get_titles()))
    print(anime_list.get_status(1))
    print(anime_list.get_score(10))
    print(anime_list.exists_as_status(11734, 1))
    print(anime_list.score_diff())
    anime_list2 = spice.get_list(spice.get_medium('ANIME'), 'Pickleplatter',
                                 creds)
    print("Similarity coefficient: {}".format(
        anime_list.compatibility(anime_list2)))
Exemplo n.º 2
0
def main():
    creds = spice.load_auth_from_file('auth')
    print(creds)
    results = spice.search('Spice and Wolf', spice.get_medium('anime'))
    print(results[0].title)
    saw_novel = spice.search_id(9115, spice.get_medium('manga'))
    print(saw_novel.raw_data)
    print(saw_novel.title)
    print(saw_novel.chapters)
    print(saw_novel.volumes)

    saw_data = spice.get_blank(spice.get_medium('anime'))
    saw_data.episodes = 10
    saw_data.status = spice.get_status('watching')
    saw_data.score = 9
    saw_data.tags = ['holo is the best']
    spice.update(saw_data, 2966, spice.get_medium('anime'))

    #shokugeki_data = spice.get_blank(spice.get_medium('manga'))
    #shokugeki_data.chapters = 13
    #shokugeki_data.volumes = 1
    #shokugeki_data.status = 1
    #shokugeki_data.score = 8
    #spice.update(shokugeki_data, 45757, spice.get_medium('manga'))

    anime_list = spice.get_list(spice.get_medium('ANIME'))
    print(anime_list.avg_score())
    #print(anime_list.median_score())
    #print(anime_list.mode_score())
    #print(anime_list.extremes())
    #print(anime_list.p_stddev())
    print(anime_list.p_var())
    print(anime_list.get_num_status(spice.get_status_num('reading')))
    #print(anime_list.get_total())
    #print(anime_list.get_days())
    #print(anime_list.exists(11734))
    #print(len(anime_list.get_ids()))
    #print(len(anime_list.get_titles()))
    #print(anime_list.get_status(1))
    #print(anime_list.get_score(10))
    #print(anime_list.exists_as_status(11734, 1))
    #print(anime_list.score_diff())
    anime_list2 = spice.get_list(spice.get_medium('ANIME'), 'Pickleplatter')
    print("Similarity coefficient: {}".format(
        anime_list.compatibility(anime_list2)))
Exemplo n.º 3
0
def test_spice():
    creds = spice.init_auth(os.environ['USERNAME'], os.environ['PASSWORD'])
    results = spice.search('Re:Zero Kara Hajimeru Isekai Seikatsu', 
            spice.get_medium('anime'), creds)
    print(results[0].title)
    souma = spice.search_id(1, spice.get_medium('manga'), creds)
    print(souma.raw_data)
    print(souma.title)
    print(souma.chapters)
    print(souma.volumes)
    re_zero_data = spice.get_blank(spice.get_medium('anime'))
    re_zero_data.episodes = 0
    re_zero_data.status = spice.get_status('reading')
    re_zero_data.score = 8
    re_zero_data.tags = ['this the first time a show that made me cringe']

    shokugeki_data = spice.get_blank(spice.get_medium('manga'))
    shokugeki_data.chapters = 13
    shokugeki_data.volumes = 1
    shokugeki_data.status = 1
    shokugeki_data.score = 8
    spice.update(shokugeki_data, 45757, spice.get_medium('manga'), creds)

    anime_list = spice.get_list(spice.get_medium('ANIME'), 'Utagai-', creds)
    print(anime_list.avg_score())
    print(anime_list.median_score())
    print(anime_list.mode_score())
    print(anime_list.extremes())
    print(anime_list.p_stddev())
    print(anime_list.p_var())
    print(anime_list.get_num_status(1))
    print(anime_list.get_total())
    print(anime_list.get_days())
    print(anime_list.exists(11734))
    print(len(anime_list.get_ids()))
    print(len(anime_list.get_titles()))
    print(anime_list.get_status(1))
    print(anime_list.get_score(10))
    print(anime_list.exists_as_status(11734, 1))
    print(anime_list.score_diff())
    anime_list2 = spice.get_list(spice.get_medium('ANIME'), 'Pickleplatter', creds)
    print("Similarity coefficient: {}".format(anime_list.compatibility(anime_list2)))
Exemplo n.º 4
0
def update_mal_entry(list_item, plex_title, plex_watched_episode_count,
                     force_update):
    mal_watched_episode_count = int(list_item.episodes)
    mal_show_id = int(list_item.id)
    print(mal_watched_episode_count, mal_show_id)
    if mal_show_id > 0:
        if mal_watched_episode_count < plex_watched_episode_count or force_update:
            anime_new = spice.get_blank(spice.get_medium('anime'))
            anime_new.episodes = plex_watched_episode_count
            new_status = 'watching'

            # If full watched set status to completed, needs additional lookup as total episodes
            # are not exposed in list (mal or spice limitation)
            lookup_show = spice.search_id(mal_show_id,
                                          spice.get_medium('anime'),
                                          mal_credentials)
            if lookup_show:
                if lookup_show.episodes:
                    mal_total_episodes = int(lookup_show.episodes)

                    if plex_watched_episode_count >= mal_total_episodes:
                        new_status = 'completed'

                anime_new.status = spice.get_status(new_status)

            logger.warning(
                '[PLEX -> MAL] Watch count for {} on Plex is {} and MAL is {}, updating MAL watch count to {} and status to {}'
                .format(plex_title, plex_watched_episode_count,
                        mal_watched_episode_count, plex_watched_episode_count,
                        new_status))
            spice.update(anime_new, mal_show_id, spice.get_medium('anime'),
                         mal_credentials)
        else:
            logger.warning(
                '[PLEX -> MAL] Watch count for {} on Plex was equal or higher on MAL so skipping update'
                .format(plex_title))
        pass
Exemplo n.º 5
0
def send_watched_to_mal(mal_list, plex_title, plex_watched_episode_count):
    show_in_mal_list = False
    mal_watched_episode_count = 0
    mal_show_id = 0

    # check if show is already on MAL list
    for list_item in mal_list:
        #logger.debug('Comparing %s with %s' % (list_item.title, plex_title))
        mal_id = int(list_item.id)
        mal_title = list_item.title
        mal_title_english = ""

        if (list_item.english is not None):
            mal_title_english = list_item.english
            #logger.debug('Comparing original: %s | english: %s with %s' % (mal_title, mal_title_english, plex_title))
        else:
            #logger.debug('Comparing original: %s with %s' % (mal_title, plex_title))
            pass

        if (mal_title.lower() == plex_title.lower()
                or mal_title_english.lower() == plex_title.lower()):
            #logger.debug('%s [%s] was already in list => status = %s | watch count = %s' % (plex_title, list_item.id, spice.get_status(list_item.status), list_item.episodes))
            mal_watched_episode_count = int(list_item.episodes)
            mal_show_id = int(list_item.id)
            show_in_mal_list = True

            if (mal_watched_episode_count > 0 and mal_show_id > 0):
                if (mal_watched_episode_count < plex_watched_episode_count):
                    anime_new = spice.get_blank(spice.get_medium('anime'))
                    anime_new.episodes = plex_watched_episode_count
                    new_status = 'watching'

                    # if full watched set status to completed, needs additional
                    # lookup as total episodes are not exposed in list (mal or
                    # spice limitation)
                    lookup_show = spice.search_id(mal_id,
                                                  spice.get_medium('anime'),
                                                  mal_credentials)
                    if (lookup_show):
                        if (lookup_show.episodes is not None):
                            mal_total_episodes = int(lookup_show.episodes)

                            if (plex_watched_episode_count >=
                                    mal_total_episodes):
                                new_status = 'completed'

                    anime_new.status = spice.get_status(new_status)

                    logger.warn(
                        '[PLEX -> MAL] Watch count for %s on Plex is %s and MAL is %s, updating MAL watch count to %s and status to %s ]'
                        % (plex_title, plex_watched_episode_count,
                           mal_watched_episode_count,
                           plex_watched_episode_count, new_status))
                    spice.update(anime_new, mal_show_id,
                                 spice.get_medium('anime'), mal_credentials)
                else:
                    logger.warning(
                        '[PLEX -> MAL] Watch count for %s on Plex was equal or higher on MAL so skipping update'
                        % (plex_title))
                    pass

    # if not listed in list lookup on MAL
    if (not show_in_mal_list):
        found_result = False
        update_list = True
        on_mal_list = False
        logger.info(
            '[PLEX -> MAL] %s not in MAL list, searching for show on MAL' %
            (plex_title))

        mal_shows = spice.search(plex_title, spice.get_medium('anime'),
                                 mal_credentials)
        for mal_show in mal_shows:
            mal_title = mal_show.title.lower()
            mal_title_english = ''
            mal_show_id = int(mal_show.id)
            mal_total_episodes = int(mal_show.episodes)

            if (mal_show.english is not None):
                mal_title_english = mal_show.english.lower()
                #logger.debug('Comparing original: %s | english: %s with %s' % (mal_title, mal_title_english, plex_title.lower()))
            else:
                #logger.debug('Comparing original: %s with %s' % (mal_title, plex_title.lower()))
                pass

            if (mal_title == plex_title.lower()
                    or mal_title_english == plex_title.lower()):
                found_result = True

                # double check against MAL list using id to see if matches and
                # update is required
                for list_item in mal_list:
                    mal_list_id = int(list_item.id)
                    mal_list_watched_episode_count = int(list_item.episodes)

                    if (mal_list_id == mal_show_id):
                        on_mal_list = True
                        if (plex_watched_episode_count ==
                                mal_list_watched_episode_count):
                            logger.warning(
                                '[PLEX -> MAL] show was found in current MAL list using id lookup however watch count was identical so skipping update'
                            )
                            update_list = False
                        break

                if (update_list):
                    anime_new = spice.get_blank(spice.get_medium('anime'))
                    anime_new.episodes = plex_watched_episode_count

                    if (plex_watched_episode_count >= mal_total_episodes):
                        logger.warn(
                            '[PLEX -> MAL] Found match on MAL and setting state to completed as watch count equal or higher than total episodes'
                        )
                        anime_new.status = spice.get_status('completed')
                        if (on_mal_list):
                            spice.update(anime_new, mal_show.id,
                                         spice.get_medium('anime'),
                                         mal_credentials)
                        else:
                            spice.add(anime_new, mal_show.id,
                                      spice.get_medium('anime'),
                                      mal_credentials)
                    else:
                        logger.warn(
                            '[PLEX -> MAL] Found match on MAL and setting state to watching with watch count: %s'
                            % (plex_watched_episode_count))
                        anime_new.status = spice.get_status('watching')
                        if (on_mal_list):
                            spice.update(anime_new, mal_show.id,
                                         spice.get_medium('anime'),
                                         mal_credentials)
                        else:
                            spice.add(anime_new, mal_show.id,
                                      spice.get_medium('anime'),
                                      mal_credentials)
                break

        if (not found_result):
            logger.error('[PLEX -> MAL] Failed to find %s on MAL' %
                         (plex_title))
Exemplo n.º 6
0
def send_watched_to_mal(plex_watched_shows, mal_list, mal_list_seasoned):
    for show, value in plex_watched_shows.items():
        plex_title = show.title
        plex_watched_episode_count, plex_watched_episode_season = value
        show_in_mal_list = False
        force_update = False
        #logger.debug('%s => watch count = %s' % (plex_title, watched_episode_count))

        if plex_watched_episode_count <= 0:
            continue

        # All shows with season > 1 were previously searched and are part of
        # the mal_list_seasoned object
        if plex_watched_episode_season > 1:
            force_update = True
            for anime, season, original_name, on_mal_list in mal_list_seasoned:
                if original_name.lower() == plex_title.lower():
                    try:
                        correct_item = [
                            value[0]
                            for index, value in enumerate(mal_list_seasoned)
                            if value[1] == plex_watched_episode_season
                            and value[2] == original_name
                        ][0]
                    except BaseException:
                        # Search failed to properly match seasons, e.g. Card Captor Sakura Clear Card is s4 on TVDB and s2 here
                        # assume most recent available season
                        # TODO: search by ID of the correct season
                        if force_update:
                            correct_item = spice.search_id(
                                int(mal_list_seasoned[-1][0].id),
                                spice.get_medium('anime'), mal_credentials)
                            on_mal_list = 'not_on_mal_list'
                        else:
                            break
                    # Trying to add before doens't really break anything and
                    # works for new series, since mal_list_seasoned includes
                    # things you haven't watched yet
                    add_mal_entry(correct_item, on_mal_list)
                    update_mal_entry(correct_item, plex_title,
                                     plex_watched_episode_count, force_update)
                    break
            continue

        # check if show is already on MAL list
        for list_item in mal_list:
            #logger.debug('Comparing %s with %s' % (list_item.title, plex_title))
            mal_title = list_item.title
            mal_title_english = ""
            if list_item.english is not None:
                mal_title_english = list_item.english
                #logger.debug('Comparing original: %s | english: %s with %s' % (mal_title, mal_title_english, plex_title))
            else:
                #logger.debug('Comparing original: %s with %s' % (mal_title, plex_title))
                pass

            if mal_title.lower() == plex_title.lower(
            ) or mal_title_english.lower() == plex_title.lower():
                show_status = spice.get_status(list_item.status)
                logger.debug(
                    '{} [{}] was already in list => status = {} | watch count = {}'
                    .format(plex_title, list_item.id, show_status,
                            list_item.episodes))
                show_in_mal_list = True
                update_mal_entry(list_item, plex_title,
                                 plex_watched_episode_count, force_update)

        # If not listed in list lookup on MAL
        if not show_in_mal_list:
            found_result = False
            update_list = True
            on_mal_list = False
            logger.info(
                '[PLEX -> MAL] {} not in MAL list, searching for show on MAL'.
                format(plex_title))

            potential_titles = [
                plex_title.lower(),
                guessit(plex_title)['title'].lower()
            ]
            for title in potential_titles:
                mal_shows = spice.search(title, spice.get_medium('anime'),
                                         mal_credentials)
                if len(mal_shows) >= 1:
                    break

            for mal_show in mal_shows:
                mal_title = mal_show.title.lower()
                mal_title_english = ''
                mal_show_id = int(mal_show.id)
                mal_total_episodes = int(mal_show.episodes)

                if mal_show.english:
                    mal_title_english = mal_show.english.lower()
                    #logger.debug('Comparing original: %s | english: %s with %s' % (mal_title, mal_title_english, plex_title.lower()))
                else:
                    #logger.debug('Comparing original: %s with %s' % (mal_title, plex_title.lower()))
                    pass

                if mal_title in potential_titles or mal_title_english in potential_titles:
                    found_result = True

                    # double check against MAL list using id to see if matches
                    # and update is required
                    for list_item in mal_list:
                        mal_list_id = int(list_item.id)
                        mal_list_watched_episode_count = int(
                            list_item.episodes)

                        if mal_list_id == mal_show_id:
                            on_mal_list = True
                            if plex_watched_episode_count == mal_list_watched_episode_count:
                                logger.warning(
                                    '[PLEX -> MAL] show was found in current MAL list using id lookup however watch count was identical so skipping update'
                                )
                                update_list = False
                            break

                    if update_list:
                        logger.warning(
                            '[PLEX -> MAL] Found match on MAL and setting state to watching with watch count: {}'
                            .format(plex_watched_episode_count))
                        anime_new = spice.get_blank(spice.get_medium('anime'))
                        anime_new.episodes = plex_watched_episode_count

                        if plex_watched_episode_count >= mal_total_episodes:
                            anime_new.status = spice.get_status('completed')
                            if on_mal_list:
                                spice.update(anime_new, mal_show.id,
                                             spice.get_medium('anime'),
                                             mal_credentials)
                            else:
                                spice.add(anime_new, mal_show.id,
                                          spice.get_medium('anime'),
                                          mal_credentials)
                        else:
                            anime_new.status = spice.get_status('watching')
                            if on_mal_list:
                                spice.update(anime_new, mal_show.id,
                                             spice.get_medium('anime'),
                                             mal_credentials)
                            else:
                                spice.add(anime_new, mal_show.id,
                                          spice.get_medium('anime'),
                                          mal_credentials)
                    break

            if not found_result:
                logger.error('[PLEX -> MAL] Failed to find {} on MAL'.format(
                    plex_title))
Exemplo n.º 7
0
def send_watched_to_mal(watched_shows, mal_list):
    for key, value in watched_shows.items():
        plex_title = key
        watched_episode_count = value
        show_in_mal_list = False
        #print('%s => watch count = %s' % (plex_title, watched_episode_count))

        if(watched_episode_count <= 0):
            continue

        mal_watched_episode_count = 0
        mal_show_id = 0

        # check if show is already on MAL list
        for list_item in mal_list:
            #print('Comparing %s with %s' % (list_item.title, plex_title))
            mal_id = int(list_item.id)
            mal_title = list_item.title
            mal_title_english = ""

            if(list_item.english is not None):
                mal_title_english = list_item.english
                #print('Comparing original: %s | english: %s with %s' % (mal_title, mal_title_english, plex_title))
            else:
                #print('Comparing original: %s with %s' % (mal_title, plex_title))
                pass

            if(mal_title.lower() == plex_title.lower() or mal_title_english.lower() == plex_title.lower()):
                #print('%s [%s] was already in list => status = %s | watch count = %s' % (plex_title, list_item.id, spice.get_status(list_item.status), list_item.episodes))
                mal_watched_episode_count = int(list_item.episodes)
                mal_show_id = int(list_item.id)
                show_in_mal_list = True

                if(mal_watched_episode_count > 0 and mal_show_id > 0):
                    if(mal_watched_episode_count < watched_episode_count):
                        anime_new = spice.get_blank(spice.get_medium('anime'))
                        anime_new.episodes = watched_episode_count
                        new_status = 'watching'

                        # if full watched set status to completed, needs additional lookup as total episodes are not exposed in list (mal or spice limitation)
                        lookup_show = spice.search_id(
                            mal_id, spice.get_medium('anime'), mal_credentials)
                        if(lookup_show):
                            if(lookup_show.episodes is not None):
                                mal_total_episodes = int(lookup_show.episodes)

                                if(watched_episode_count >= mal_total_episodes):
                                    new_status = 'completed'

                        anime_new.status = spice.get_status(new_status)

                        print(Back.MAGENTA + '[PLEX -> MAL] Watch count for %s on Plex is %s and MAL is %s, gonna update MAL watch count to %s and status to %s ]' % (plex_title, watched_episode_count,
                                                                                                                                                                      mal_watched_episode_count, watched_episode_count, new_status))
                        spice.update(anime_new, mal_show_id,
                                     spice.get_medium('anime'), mal_credentials)
                    else:
                        print(
                            Back.GREEN + '[PLEX -> MAL] Watch count for %s on Plex was equal or higher on MAL so skipping update' % (plex_title))
                        pass

        # if not listed in list lookup on MAL
        if(not show_in_mal_list):
            found_result = False
            update_list = True
            on_mal_list = False
            print(
                Back.CYAN + '[PLEX -> MAL] %s not in MAL list, gonna search for show on MAL' % (plex_title))

            mal_shows = spice.search(
                plex_title, spice.get_medium('anime'), mal_credentials)
            for mal_show in mal_shows:
                mal_title = mal_show.title.lower()
                mal_title_english = ''
                mal_show_id = int(mal_show.id)
                mal_total_episodes = int(mal_show.episodes)

                if(mal_show.english is not None):
                    mal_title_english = mal_show.english.lower()
Exemplo n.º 8
0
                            if(watched_episode_count == mal_list_watched_episode_count):
                                print(
                                    Back.GREEN + '[PLEX -> MAL] show was found in current MAL list using id lookup however watch count was identical so skipping update')
                                update_list = False
                            break

                    if(update_list):
                        print(
                            Back.MAGENTA + '[PLEX -> MAL] Found match on MAL and setting state to watching with watch count: %s' % (watched_episode_count))
                        anime_new = spice.get_blank(spice.get_medium('anime'))
                        anime_new.episodes = watched_episode_count

                        if(watched_episode_count >= mal_total_episodes):
                            anime_new.status = spice.get_status('completed')
                            if(on_mal_list):
                                spice.update(anime_new, mal_show.id, spice.get_medium(
                                    'anime'), mal_credentials)
                            else:
                                spice.add(anime_new, mal_show.id, spice.get_medium(
                                    'anime'), mal_credentials)
                        else:
                            anime_new.status = spice.get_status('watching')
                            if(on_mal_list):
                                spice.update(anime_new, mal_show.id, spice.get_medium(
                                    'anime'), mal_credentials)
                            else:
                                spice.add(anime_new, mal_show.id, spice.get_medium(
                                    'anime'), mal_credentials)
                    break

            if(not found_result):
                print(Back.LIGHTRED_EX +