diff --git a/README.md b/README.md
index 26e0087..4cece93 100644
--- a/README.md
+++ b/README.md
@@ -75,3 +75,4 @@ Build and push this container to ghcr
- [x] header on playlist page
- [x] Choose database directory
- [x] add extension to download
+- [ ] server-side watch progress
diff --git a/handlers/set_timestamp.go b/handlers/set_timestamp.go
new file mode 100644
index 0000000..a609ba9
--- /dev/null
+++ b/handlers/set_timestamp.go
@@ -0,0 +1,58 @@
+package handlers
+
+import (
+ "net/http"
+ "strconv"
+
+ "github.com/labstack/echo/v4"
+ "gorm.io/gorm"
+
+ "ytdlp-site/database"
+ "ytdlp-site/originals"
+)
+
+func SetTimestamp(c echo.Context) error {
+ // Parse the ID from the URL parameter
+ id, err := strconv.ParseUint(c.Param("id"), 10, 64)
+ if err != nil {
+ return c.JSON(http.StatusBadRequest, map[string]string{"error": "Invalid ID format"})
+ }
+
+ // Define a struct to receive the timestamp from JSON
+ type TimestampRequest struct {
+ Timestamp string `json:"timestamp"`
+ }
+
+ // Parse the request body
+ var req TimestampRequest
+ if err := c.Bind(&req); err != nil {
+ return c.JSON(http.StatusBadRequest, map[string]string{"error": "Invalid request body"})
+ }
+
+ // Validate that timestamp was provided
+ if req.Timestamp == "" {
+ return c.JSON(http.StatusBadRequest, map[string]string{"error": "Timestamp is required"})
+ }
+
+ // Get database connection
+ db := database.Get()
+
+ // Update the timestamp field with the value from the request
+ result := db.Model(&originals.Original{}).
+ Where("id = ?", id).
+ Update("timestamp", req.Timestamp)
+
+ // Handle database errors
+ if result.Error != nil {
+ log.Errorln(result.Error)
+ return c.JSON(http.StatusInternalServerError, map[string]string{"error": "Database error"})
+ }
+
+ // Check if record was found
+ if result.RowsAffected == 0 {
+ log.Errorln(gorm.ErrRecordNotFound)
+ return c.JSON(http.StatusNotFound, map[string]string{"error": "Record not found"})
+ }
+
+ return c.NoContent(http.StatusOK)
+}
diff --git a/main.go b/main.go
index 915b174..2ef4da7 100644
--- a/main.go
+++ b/main.go
@@ -144,6 +144,7 @@ func main() {
e.GET("/temp/:token", tempHandler)
e.POST("/video/:id/process", processHandler, handlers.AuthMiddleware)
e.POST("/video/:id/toggle_watched", handlers.ToggleWatched, handlers.AuthMiddleware)
+ e.POST("/video/:id/set_timestamp", handlers.SetTimestamp, handlers.AuthMiddleware)
e.POST("/delete_video/:id", deleteVideoHandler, handlers.AuthMiddleware)
e.POST("/delete_audio/:id", deleteAudioHandler, handlers.AuthMiddleware)
e.POST("/transcode_to_video/:id", transcodeToVideoHandler, handlers.AuthMiddleware)
diff --git a/originals/originals.go b/originals/originals.go
index 5226ca4..2d236ed 100644
--- a/originals/originals.go
+++ b/originals/originals.go
@@ -23,14 +23,15 @@ const (
type Original struct {
gorm.Model
- UserID uint
- URL string
- Title string
- Artist string
- Status Status
- Audio bool // video download requested
- Video bool // audio download requested
- Watched bool
+ UserID uint
+ URL string
+ Title string
+ Artist string
+ Status Status
+ Audio bool // video download requested
+ Video bool // audio download requested
+ Watched bool
+ Timestamp float64
Playlist bool // part of a playlist
PlaylistID uint // Playlist.ID (if part of a playlist)
diff --git a/templates/video.html b/templates/video.html
index c40a8d3..d8e5289 100644
--- a/templates/video.html
+++ b/templates/video.html
@@ -106,6 +106,7 @@
+
{{template "footer" .}}