sct / overseerr

Request management and media discovery tool for the Plex ecosystem
https://overseerr.dev
MIT License
3.54k stars 412 forks source link

AvalailbilitySync method mediaExistsInPlex() not full working #3857

Open cedricdu78 opened 1 month ago

cedricdu78 commented 1 month ago

Description

Method mediaExistsInPlex not find all series or movies removed with ratingKey.

Desired Behavior

In plexapi.ts

  public async getAllTmdbIds(): Promise<Number[]> {

    const settings = getSettings();
    const tmdbIds : Number[] = []

    for (const library in settings.plex.libraries) {
      const response = await this.getLibraryContents(settings.plex.libraries[library].id, {
        size: 5000,
        offset: 0,
      });

      for (const entry in response.items) {
        const tmdbString = response.items[entry].Guid?.find((guid) =>
          guid.id.startsWith('tmdb')
        );

        if (tmdbString) {
          tmdbIds.push(Number(tmdbString.id.split('//')[1]))
        } else {
          logger.error(`Failed to fetch tmdbId : ${JSON.stringify(response.items[entry])}`, { label: 'Plex API' });
        }
      }
    }

    return tmdbIds
  }

In run()

      this.plexMediaCache = await this.plexClient?.getAllTmdbIds();

In mediaExistsInPlex()

    const existsInPlex = this.plexMediaCache.indexOf(media.tmdbId) > -1;

    if (! existsInPlex) {
      return { existsInPlex };
    }

Additional Context

No response

Code of Conduct