up
This commit is contained in:
parent
2f868380a1
commit
2687a16e25
@ -871,7 +871,8 @@ func probe(ctx context.Context, file string) (*ffprobeOut, error) {
|
||||
|
||||
type mediaItemView struct {
|
||||
Title string
|
||||
Duration int64
|
||||
Duration int64 // en secondes
|
||||
DurationFmt string // ex: "3:45"
|
||||
Width, Height int
|
||||
ThumbURL string
|
||||
FilePath string
|
||||
@ -942,6 +943,8 @@ func PathMedia(db *gorm.DB) http.HandlerFunc {
|
||||
if err == nil {
|
||||
if d, err := strconv.ParseFloat(info.Format.Duration, 64); err == nil {
|
||||
view.Duration = int64(d)
|
||||
view.DurationFmt = fmt.Sprintf("%d:%02d", view.Duration/60, view.Duration%60)
|
||||
|
||||
}
|
||||
for _, s := range info.Streams {
|
||||
if s.CodecType == "video" {
|
||||
|
||||
@ -1,31 +1,4 @@
|
||||
<div class="breadcrumb mb-4">
|
||||
{{if .CurrentSub}}
|
||||
<a
|
||||
href="/api/paths/{{.PathID}}/media"
|
||||
hx-get="/api/paths/{{.PathID}}/media"
|
||||
hx-target="#content"
|
||||
hx-swap="innerHTML"
|
||||
>🔙 Racine</a>
|
||||
/ {{.CurrentSub}}
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<div class="dirs grid grid-cols-4 gap-4 mb-6">
|
||||
{{range .Dirs}}
|
||||
<div class="card p-3 rounded shadow">
|
||||
<a
|
||||
hx-get="/api/paths/{{$.PathID}}/media?sub={{urlquery .SubPath}}"
|
||||
hx-target="#content" hx-swap="innerHTML"
|
||||
>
|
||||
<i class="fas fa-folder fa-2x"></i>
|
||||
<div>{{.Name}}</div>
|
||||
</a>
|
||||
</div>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
<div class="media grid grid-cols-4 gap-4">
|
||||
{{if .MediaItems}}
|
||||
{{range .MediaItems}}
|
||||
<div class="card p-2 rounded shadow">
|
||||
<a
|
||||
@ -37,13 +10,10 @@
|
||||
<div class="mt-2">
|
||||
<h3 class="text-sm font-semibold truncate">{{.Title}}</h3>
|
||||
{{if .Duration}}
|
||||
<small>{{printf "%d:%02d" (div .Duration 60) (mod .Duration 60)}}</small>
|
||||
<small>{{.DurationFmt}}</small>
|
||||
{{end}}
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
{{end}}
|
||||
{{else}}
|
||||
<p>Aucun média dans ce dossier.</p>
|
||||
{{end}}
|
||||
</div>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user