implement command update-title
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 4s

This commit is contained in:
Thomas Peetz
2026-10-12 17:37:06 +02:00
parent f5e9cbc423
commit 4c603a8eff
8 changed files with 145 additions and 31 deletions
+14 -1
View File
@@ -1,8 +1,11 @@
package cmd
import (
"fmt"
"kontor-api-gin/internal/api"
"kontor-api-gin/internal/config"
"kontor-api-gin/internal/helpers"
"kontor-api-gin/internal/models"
"log/slog"
"github.com/spf13/cobra"
@@ -23,7 +26,17 @@ var updateTitleCmd = &cobra.Command{
api.GetJSON(client, token, localServer, "media/lofis", &api.Medialofis)
for _, lofi := range api.Medialofis {
if lofi.Review {
slog.Info("get title for Url", "url", lofi.WebLink)
title, err := helpers.GetVideoTitle(lofi.WebLink)
var updated models.MediaLoFiDTO
if err != nil {
slog.Info("get title for Url", "url", lofi.WebLink, "error", err.Error())
} else {
slog.Info("get title for Url", "url", lofi.WebLink, "title", title)
lofi.Title = title
lofi.Review = false
api.PostJSON(client, localServer, token, config.Config.ApiVersion, fmt.Sprintf("media/lofis/%s", lofi.ID), lofi, &updated)
slog.Info("MediaLoi updated", "MediaLoFi", updated)
}
}
}
},