add runtime
This commit is contained in:
parent
841f56659b
commit
07387154f1
|
@ -46,6 +46,7 @@ type Movie struct {
|
||||||
Title string
|
Title string
|
||||||
EnglishTitle string
|
EnglishTitle string
|
||||||
Year int
|
Year int
|
||||||
|
RunTime int
|
||||||
Directors []string
|
Directors []string
|
||||||
Summary string
|
Summary string
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import (
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
"text/template"
|
"text/template"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -14,6 +15,7 @@ emdb: {{ .IMDBID }}
|
||||||
englishTitle: {{ .EnglishTitle }}
|
englishTitle: {{ .EnglishTitle }}
|
||||||
title: {{ .Title }}
|
title: {{ .Title }}
|
||||||
year: {{ .Year }}
|
year: {{ .Year }}
|
||||||
|
runtime: {{ .Runtime }}
|
||||||
directors: {{ .DirectorsYAML }}
|
directors: {{ .DirectorsYAML }}
|
||||||
inCollection: no
|
inCollection: no
|
||||||
watchedOn:
|
watchedOn:
|
||||||
|
@ -43,12 +45,20 @@ func Export(movie Movie) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
runtime := time.Duration(movie.RunTime) * time.Minute
|
||||||
|
runtimeStr, _, ok := strings.Cut(runtime.String(), "m")
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("could not parse runtime format %s", runtime)
|
||||||
|
}
|
||||||
|
runtimeStr = fmt.Sprintf("%sm", runtimeStr)
|
||||||
|
|
||||||
data := struct {
|
data := struct {
|
||||||
TMDBID string
|
TMDBID string
|
||||||
IMDBID string
|
IMDBID string
|
||||||
EnglishTitle string
|
EnglishTitle string
|
||||||
Title string
|
Title string
|
||||||
Year int
|
Year int
|
||||||
|
Runtime string
|
||||||
DirectorsYAML string
|
DirectorsYAML string
|
||||||
Directors string
|
Directors string
|
||||||
Summary string
|
Summary string
|
||||||
|
@ -58,6 +68,7 @@ func Export(movie Movie) error {
|
||||||
EnglishTitle: movie.EnglishTitle,
|
EnglishTitle: movie.EnglishTitle,
|
||||||
Title: movie.Title,
|
Title: movie.Title,
|
||||||
Year: movie.Year,
|
Year: movie.Year,
|
||||||
|
Runtime: runtimeStr,
|
||||||
DirectorsYAML: strings.Join(movie.Directors, ", "),
|
DirectorsYAML: strings.Join(movie.Directors, ", "),
|
||||||
Directors: fmt.Sprintf("[[%s]]", strings.Join(movie.Directors, "]], [[")),
|
Directors: fmt.Sprintf("[[%s]]", strings.Join(movie.Directors, "]], [[")),
|
||||||
Summary: movie.Summary,
|
Summary: movie.Summary,
|
||||||
|
|
|
@ -67,6 +67,7 @@ func (t TMDB) GetMovie(id int64) (Movie, error) {
|
||||||
TMDBID: fmt.Sprintf("%d", result.ID),
|
TMDBID: fmt.Sprintf("%d", result.ID),
|
||||||
IMDBID: result.IMDbID,
|
IMDBID: result.IMDbID,
|
||||||
Year: year,
|
Year: year,
|
||||||
|
RunTime: result.Runtime,
|
||||||
Directors: directors,
|
Directors: directors,
|
||||||
Summary: result.Overview,
|
Summary: result.Overview,
|
||||||
}, nil
|
}, nil
|
||||||
|
|
Loading…
Reference in New Issue