Better comparison between plex and tmdb. Now also checks if plexTitle starts with tmdbTitle.
This commit is contained in:
@@ -8,17 +8,17 @@ const { Movie, Show, Person } = require('src/tmdb/types')
|
|||||||
const RedisCache = require('src/cache/redis')
|
const RedisCache = require('src/cache/redis')
|
||||||
const redisCache = new RedisCache()
|
const redisCache = new RedisCache()
|
||||||
|
|
||||||
// const { Movie, }
|
const sanitize = (string) => string.toLowerCase().replace(/[^\w\s]/gi, '')
|
||||||
// TODO? import class definitions to compare types ?
|
|
||||||
// what would typescript do?
|
|
||||||
|
|
||||||
const sanitize = (string) => string.toLowerCase()
|
|
||||||
|
|
||||||
const matchingTitleAndYear = (plex, tmdb) => {
|
const matchingTitleAndYear = (plex, tmdb) => {
|
||||||
let matchingTitle, matchingYear;
|
let matchingTitle, matchingYear;
|
||||||
|
|
||||||
if (plex['title'] != null && tmdb['title'] != null)
|
if (plex['title'] != null && tmdb['title'] != null) {
|
||||||
matchingTitle = sanitize(plex.title) == sanitize(tmdb.title);
|
const plexTitle = sanitize(plex.title)
|
||||||
|
const tmdbTitle = sanitize(tmdb.title)
|
||||||
|
matchingTitle = plexTitle == tmdbTitle;
|
||||||
|
matchingTitle = matchingTitle ? matchingTitle : plexTitle.startsWith(tmdbTitle)
|
||||||
|
}
|
||||||
else
|
else
|
||||||
matchingTitle = false;
|
matchingTitle = false;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user