This commit is contained in:
lukas 2021-06-06 11:49:42 +02:00
parent e3c7fe514b
commit f0bc0c29dd

View File

@ -28,27 +28,27 @@ type TVShowTMDB struct {
} }
type tmdbVidResult struct { type tmdbVidResult struct {
PosterPath string `json:"poster_path"` PosterPath *string `json:"poster_path"`
Adult bool `json:"adult"` Adult bool `json:"adult"`
Overview string `json:"overview"` Overview string `json:"overview"`
ReleaseDate string `json:"release_date"` ReleaseDate string `json:"release_date"`
GenreIds []int `json:"genre_ids"` GenreIds []int `json:"genre_ids"`
Id int `json:"id"` Id int `json:"id"`
OriginalTitle string `json:"original_title"` OriginalTitle string `json:"original_title"`
OriginalLanguage string `json:"original_language"` OriginalLanguage string `json:"original_language"`
Title string `json:"title"` Title string `json:"title"`
BackdropPath string `json:"backdrop_path"` BackdropPath *string `json:"backdrop_path"`
Popularity int `json:"popularity"` Popularity int `json:"popularity"`
VoteCount int `json:"vote_count"` VoteCount int `json:"vote_count"`
Video bool `json:"video"` Video bool `json:"video"`
VoteAverage int `json:"vote_average"` VoteAverage int `json:"vote_average"`
} }
type tmdbTvResult struct { type tmdbTvResult struct {
PosterPath string `json:"poster_path"` PosterPath *string `json:"poster_path"`
Popularity int `json:"popularity"` Popularity int `json:"popularity"`
Id int `json:"id"` Id int `json:"id"`
BackdropPath string `json:"backdrop_path"` BackdropPath *string `json:"backdrop_path"`
VoteAverage int `json:"vote_average"` VoteAverage int `json:"vote_average"`
Overview string `json:"overview"` Overview string `json:"overview"`
FirstAirDate string `json:"first_air_date"` FirstAirDate string `json:"first_air_date"`
@ -111,10 +111,16 @@ func SearchVideo(MovieName string, year int) *VideoTMDB {
// continue label // continue label
cont: cont:
thumbnail := fetchPoster(tmdbVid.PosterPath) var thumbnail = ""
if tmdbVid.PosterPath != nil {
pic := fetchPoster(*tmdbVid.PosterPath)
if pic != nil {
thumbnail = *pic
}
}
result := VideoTMDB{ result := VideoTMDB{
Thumbnail: *thumbnail, Thumbnail: thumbnail,
Overview: tmdbVid.Overview, Overview: tmdbVid.Overview,
Title: tmdbVid.Title, Title: tmdbVid.Title,
GenreIds: tmdbVid.GenreIds, GenreIds: tmdbVid.GenreIds,
@ -155,9 +161,11 @@ func SearchTVShow(Name string) *TVShowTMDB {
GenreIds: t.Results[0].GenreIds, GenreIds: t.Results[0].GenreIds,
} }
thumbnail := fetchPoster(t.Results[0].PosterPath) if t.Results[0].PosterPath != nil {
if thumbnail != nil { pic := fetchPoster(*t.Results[0].PosterPath)
res.Thumbnail = *thumbnail if pic != nil {
res.Thumbnail = *pic
}
} }
return &res return &res