From 4206d099540db08372d3099dd349cc4f01bcce16 Mon Sep 17 00:00:00 2001 From: Lucas BEE Date: Fri, 10 Apr 2020 17:47:35 +0200 Subject: [PATCH] Fix upsert of torrents We're missing some infos from the Torrents We ensure that we set them for now, we'll need to edit the polochon torrenters so that they put this info And add a DB constraint, a torrent shouldn't be able to be created without an imdbID --- backend/movies/movies.go | 1 + backend/shows/episodes.go | 3 +++ 2 files changed, 4 insertions(+) diff --git a/backend/movies/movies.go b/backend/movies/movies.go index f399a6f..9ab6d68 100644 --- a/backend/movies/movies.go +++ b/backend/movies/movies.go @@ -223,6 +223,7 @@ func (m *Movie) RefreshTorrents(env *web.Env, torrenters []polochon.Torrenter) e // Update them in database for _, t := range m.Movie.Torrents { + t.ImdbID = m.ImdbID err = models.UpsertMovieTorrent(env.Database, t) if err != nil { log.Error("error while adding torrent", err) diff --git a/backend/shows/episodes.go b/backend/shows/episodes.go index c9ac7f8..2273212 100644 --- a/backend/shows/episodes.go +++ b/backend/shows/episodes.go @@ -179,6 +179,9 @@ func RefreshTorrents(env *web.Env, showEpisode *polochon.ShowEpisode, torrenters // Upsert all the torrents we got for _, t := range showEpisode.Torrents { + t.ImdbID = showEpisode.ShowImdbID + t.Season = showEpisode.Season + t.Episode = showEpisode.Episode err = models.UpsertEpisodeTorrent(env.Database, t) if err != nil { log.Errorf("error while adding torrent : %s", err) -- 2.47.1