From afbff59d49ae8b2f58e73be9cf22ba2b310e6249 Mon Sep 17 00:00:00 2001 From: Reeverflow Date: Sun, 22 Feb 2026 18:37:53 +0100 Subject: [PATCH] - Database: Update -> Drop and Create - Removed PostConstruct from services - Extended Video with MANYTOONE Playlist - Extended Video with ONETOONE creator - Extended Playlist with MANYTOMANY with videos - Created Creator - Extended Creator with OneToMany to videos - VideoController now listens to POST on /fire, expects RequestBody input:true --- .../controllers/VideoController.java | 20 +++++++++++++++++++ .../dto/SaveNewPlaylistRequest.java | 3 +-- .../dto/SaveNewVideoRequest.java | 1 - .../video_downloader/entity/Creator.java | 20 +++++++++++++++++++ .../video_downloader/entity/Playlist.java | 11 +++++++--- .../video_downloader/entity/Video.java | 6 ++++++ .../services/YTDLPService.java | 4 +++- src/main/resources/application.properties | 2 +- 8 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 src/main/java/com/example/video_downloader/entity/Creator.java diff --git a/src/main/java/com/example/video_downloader/controllers/VideoController.java b/src/main/java/com/example/video_downloader/controllers/VideoController.java index 7f41ace..7e8b109 100644 --- a/src/main/java/com/example/video_downloader/controllers/VideoController.java +++ b/src/main/java/com/example/video_downloader/controllers/VideoController.java @@ -6,11 +6,13 @@ import com.example.video_downloader.entity.Playlist; import com.example.video_downloader.entity.Video; import com.example.video_downloader.services.PlaylistService; import com.example.video_downloader.services.VideoService; +import com.example.video_downloader.services.YTDLPService; import lombok.Data; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.http.ResponseEntity; import org.springframework.web.bind.annotation.*; +import java.io.IOException; import java.util.List; @RestController @@ -24,11 +26,19 @@ public class VideoController { @Autowired private PlaylistService playlistService; + @Autowired + private YTDLPService ytdlpService; + @Data private static class Response { private Long id; } + @Data + private static class Trigger { + private boolean input; + } + @PostMapping(path = "/videos") public Response saveNewVideo(@RequestBody SaveNewVideoRequest request){ @@ -56,4 +66,14 @@ public class VideoController { return ResponseEntity.ok(videoService.getVideoById(id)); } + + @PostMapping(path = "/fire") + public int getJobDone(@RequestBody Trigger trigger) throws IOException, InterruptedException { + int statusCode = 200; + if(trigger.input) { + ytdlpService.validateVideos(); + } + return statusCode; + + } } diff --git a/src/main/java/com/example/video_downloader/dto/SaveNewPlaylistRequest.java b/src/main/java/com/example/video_downloader/dto/SaveNewPlaylistRequest.java index 3d2ae2e..6768aa8 100644 --- a/src/main/java/com/example/video_downloader/dto/SaveNewPlaylistRequest.java +++ b/src/main/java/com/example/video_downloader/dto/SaveNewPlaylistRequest.java @@ -4,7 +4,6 @@ import lombok.Data; @Data public class SaveNewPlaylistRequest { - private String playlist_name; + private String playlistName; private String url; - } diff --git a/src/main/java/com/example/video_downloader/dto/SaveNewVideoRequest.java b/src/main/java/com/example/video_downloader/dto/SaveNewVideoRequest.java index ccde4d8..bfdf986 100644 --- a/src/main/java/com/example/video_downloader/dto/SaveNewVideoRequest.java +++ b/src/main/java/com/example/video_downloader/dto/SaveNewVideoRequest.java @@ -5,5 +5,4 @@ import lombok.Data; @Data public class SaveNewVideoRequest { private String url; - } diff --git a/src/main/java/com/example/video_downloader/entity/Creator.java b/src/main/java/com/example/video_downloader/entity/Creator.java new file mode 100644 index 0000000..6357207 --- /dev/null +++ b/src/main/java/com/example/video_downloader/entity/Creator.java @@ -0,0 +1,20 @@ +package com.example.video_downloader.entity; + +import jakarta.persistence.*; +import lombok.Data; + +import java.util.List; + +@Data +@Entity +public class Creator { + @Id + @GeneratedValue + private Long id; + + private String name; + private String url; + + @OneToMany(mappedBy = "creator") + private List