MCPcopy Create free account
hub / github.com/RickDB/PlexMALSync / update_mal_entry

Function update_mal_entry

PlexMALSync.py:216–258  ·  view source on GitHub ↗
(
        list_item,
        plex_title,
        plex_watched_episode_count,
        force_update)

Source from the content-addressed store, hash-verified

214
215# update an existing match
216def update_mal_entry(
217 list_item,
218 plex_title,
219 plex_watched_episode_count,
220 force_update):
221 mal_watched_episode_count = int(list_item.episodes)
222 mal_show_id = int(list_item.id)
223 print(mal_watched_episode_count, mal_show_id)
224 if mal_show_id > 0:
225 if mal_watched_episode_count < plex_watched_episode_count or force_update:
226 anime_new = spice.get_blank(spice.get_medium('anime'))
227 anime_new.episodes = plex_watched_episode_count
228 new_status = 'watching'
229
230 # If full watched set status to completed, needs additional lookup as total episodes
231 # are not exposed in list (mal or spice limitation)
232 lookup_show = spice.search_id(
233 mal_show_id, spice.get_medium('anime'), mal_credentials)
234 if lookup_show:
235 if lookup_show.episodes:
236 mal_total_episodes = int(lookup_show.episodes)
237
238 if plex_watched_episode_count >= mal_total_episodes:
239 new_status = 'completed'
240
241 anime_new.status = spice.get_status(new_status)
242
243 logger.warning(
244 '[PLEX -> MAL] Watch count for {} on Plex is {} and MAL is {}, updating MAL watch count to {} and status to {}' .format(
245 plex_title,
246 plex_watched_episode_count,
247 mal_watched_episode_count,
248 plex_watched_episode_count,
249 new_status))
250 spice.update(
251 anime_new,
252 mal_show_id,
253 spice.get_medium('anime'),
254 mal_credentials)
255 else:
256 logger.warning(
257 '[PLEX -> MAL] Watch count for {} on Plex was equal or higher on MAL so skipping update' .format(plex_title))
258 pass
259
260
261def add_mal_entry(list_item, on_mal_list):

Callers 1

send_watched_to_malFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected