Skip to content

Commit

Permalink
fix(server): better metadata agent detection (#52)
Browse files Browse the repository at this point in the history
* fix(server): detect metadata agents using show metadata instead of episode

* feat(server): set grandparentguid as fallback for metadata agent detection
  • Loading branch information
varoOP authored Nov 9, 2024
1 parent f256a7c commit f0915db
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
2 changes: 0 additions & 2 deletions internal/database/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,7 @@ func NewDB(dir string, log *zerolog.Logger) *DB {
}

if _, err = db.Handler.Exec(`PRAGMA journal_mode = wal;`); err != nil {
if err != nil {
db.log.Fatal().Err(err).Msg("unable to enable WAL mode")
}
}

return db
Expand Down
19 changes: 10 additions & 9 deletions internal/server/helpers.go
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
package server

import (
"github.com/pkg/errors"
"io"
"net/http"
"net/url"
"strings"

"github.com/pkg/errors"

"github.com/rs/zerolog/hlog"
"github.com/varoOP/shinkro/internal/domain"
"github.com/varoOP/shinkro/internal/tautulli"
Expand All @@ -16,16 +17,16 @@ import (
const InternalServerError string = "internal server error"

func isMetadataAgent(p *plex.PlexWebhook) (bool, string) {
if strings.Contains(p.Metadata.GUID.GUID, "agents.hama") {
return true, "hama"
agents := map[string]string{
"agents.hama": "hama",
"myanimelist": "mal",
"plex://": "plex",
}

if strings.Contains(p.Metadata.GUID.GUID, "myanimelist") {
return true, "mal"
}

if strings.Contains(p.Metadata.GUID.GUID, "plex://") {
return true, "plex"
for key, value := range agents {
if strings.Contains(p.Metadata.GUID.GUID, key) || strings.Contains(p.Metadata.GrandparentGUID, key) {
return true, value
}
}

return false, ""
Expand Down

0 comments on commit f0915db

Please sign in to comment.