From 5e9e6e635092ed68a43a6ed606c4654f676882ec Mon Sep 17 00:00:00 2001 From: gkiviv Date: Tue, 3 Dec 2024 19:07:45 +0200 Subject: [PATCH] bugfix when downloading films --- downloader/downloader.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/downloader/downloader.go b/downloader/downloader.go index 72c0543..8ab3f40 100644 --- a/downloader/downloader.go +++ b/downloader/downloader.go @@ -2,6 +2,7 @@ package downloader import ( "encoding/json" + "errors" "fmt" "io" "net/http" @@ -17,7 +18,7 @@ type ContentPageData struct { type Data struct { MainContent MainContent `json:"mainContent"` - SeasonList SeasonList `json:"seasonList"` + SeasonList SeasonList `json:"seasonList"` } type MainContent struct { @@ -152,7 +153,12 @@ func GetContentPageData(contentId string) *ContentPageData { err = json.Unmarshal(bytes, &data) if err != nil { - panic(err) + var unmarshalTypeError *json.UnmarshalTypeError + if errors.As(err, &unmarshalTypeError) { + data.Data.SeasonList = SeasonList{} + } else { + panic(err) + } } return &data