@@ -12,6 +12,7 @@ import (
12
12
"strings"
13
13
"time"
14
14
15
+ "github.com/iloveicedgreentea/go-plex/internal/common"
15
16
"github.com/iloveicedgreentea/go-plex/internal/config"
16
17
"github.com/iloveicedgreentea/go-plex/internal/logger"
17
18
"github.com/iloveicedgreentea/go-plex/internal/mqtt"
@@ -238,6 +239,10 @@ func buildAuthorWhitelist(preferredAuthors string, endpoint string) string {
238
239
return endpoint
239
240
}
240
241
242
+ func checkNameForSearch (searchTitle , MatchTitle string ) bool {
243
+ return common .InsensitiveContains (searchTitle , MatchTitle )
244
+ }
245
+
241
246
// searchCatalog will use ezbeq to search the catalog and then find the right match. tmdb data comes from plex, matched to ezbeq catalog
242
247
func (c * BeqClient ) searchCatalog (m * models.SearchRequest ) (models.BeqCatalog , error ) {
243
248
// url encode because of spaces and stuff
@@ -263,15 +268,28 @@ func (c *BeqClient) searchCatalog(m *models.SearchRequest) (models.BeqCatalog, e
263
268
264
269
// search through results and find match
265
270
for _ , val := range payload {
271
+ // if skipping TMDB, set the IDs to match
272
+ if config .GetBool ("jellyfin.skiptmdb" ) {
273
+ log .Debug ("Skipping TMDB search" )
274
+ val .MovieDbID = m .TMDB
275
+ }
266
276
log .Debugf ("Beq results: Title: %v -- Codec %v, ID: %v" , val .Title , val .AudioTypes , val .ID )
267
277
// if we find a match, return it. Much easier to match on tmdb since plex provides it also
268
278
if val .MovieDbID == m .TMDB && val .Year == m .Year && val .AudioTypes [0 ] == m .Codec {
279
+ // if tmdb is skipped, the title has to match
280
+ if config .GetBool ("jellyfin.skiptmdb" ) {
281
+ log .Debug ("Using title compare for search" )
282
+ if ! checkNameForSearch (val .Title , m .Title ) {
283
+ log .Errorf ("Title %s did not match %s" , val .Title , m .Title )
284
+ return models.BeqCatalog {}, errors .New ("beq profile was not found in catalog" )
285
+ }
286
+ }
269
287
// if it matches, check edition
270
288
if checkEdition (val , m .Edition ) {
271
289
log .Infof ("Found a match in catalog from author %s" , val .Author )
272
290
return val , nil
273
291
} else {
274
- log .Error ("Found a match but editions did not match entry. Not loading" )
292
+ log .Errorf ("Found a potential match but editions did not match entry. Not loading" )
275
293
}
276
294
}
277
295
}
@@ -302,9 +320,6 @@ func (c *BeqClient) LoadBeqProfile(m *models.SearchRequest) error {
302
320
return nil
303
321
}
304
322
305
- if m .TMDB == "" {
306
- return errors .New ("tmdb is empty. Can't find a match" )
307
- }
308
323
log .Debugf ("beq payload is %#v" , m )
309
324
310
325
// if no devices provided, error
@@ -322,6 +337,7 @@ func (c *BeqClient) LoadBeqProfile(m *models.SearchRequest) error {
322
337
323
338
// skip searching when resuming for speed
324
339
if ! m .SkipSearch {
340
+ // TODO: do the same for DD+ atmos
325
341
// if AtmosMaybe, check if its really truehd 7.1. If fails, its atmos
326
342
if m .Codec == "AtmosMaybe" {
327
343
m .Codec = "TrueHD 7.1"
0 commit comments