Basic movie page layout created

This commit is contained in:
2025-02-24 10:21:31 +11:00
parent 8fa20e05c0
commit e2d66fc26d
6 changed files with 65 additions and 42 deletions

View File

@@ -1,23 +0,0 @@
package tmdb
import (
"fmt"
"net/url"
"path"
)
func FormatRuntime(minutes int) string {
hours := minutes / 60
mins := minutes % 60
return fmt.Sprintf("%dh %02dm", hours, mins)
}
func GetPoster(image *Image, size, imgpath string) string {
base, err := url.Parse(image.SecureBaseURL)
if err != nil {
return ""
}
fullPath := path.Join(base.Path, size, imgpath)
base.Path = fullPath
return base.String()
}

35
tmdb/movie_functions.go Normal file
View File

@@ -0,0 +1,35 @@
package tmdb
import (
"fmt"
"net/url"
"path"
)
func (movie *Movie) FRuntime() string {
hours := movie.Runtime / 60
mins := movie.Runtime % 60
return fmt.Sprintf("%dh %02dm", hours, mins)
}
func (movie *Movie) GetPoster(image *Image, size string) string {
base, err := url.Parse(image.SecureBaseURL)
if err != nil {
return ""
}
fullPath := path.Join(base.Path, size, movie.Poster)
base.Path = fullPath
return base.String()
}
func (movie *Movie) ReleaseYear() string {
return movie.ReleaseDate[:4]
}
func (movie *Movie) FGenres() string {
genres := ""
for _, genre := range movie.Genres {
genres += genre.Name + ", "
}
return genres[:len(genres)-2]
}