Compare commits
5 Commits
cd6cc9812a
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df838920b6 | ||
|
|
68b7143fb2 | ||
|
|
c8993a67d1 | ||
|
|
31906f2010 | ||
|
|
41cb2eb470 |
8
Dockerfile
Normal file
8
Dockerfile
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
FROM eclipse-temurin:21-jdk
|
||||||
|
|
||||||
|
WORKDIR /app
|
||||||
|
|
||||||
|
COPY yt-dlp /app
|
||||||
|
COPY target/video_downloader-0.0.1-SNAPSHOT.jar /app
|
||||||
|
|
||||||
|
CMD ["java", "-jar", "/app/video_downloader-0.0.1-SNAPSHOT.jar"]
|
||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.example.video_downloader.controllers;
|
package com.example.video_downloader.controllers;
|
||||||
|
|
||||||
import com.example.video_downloader.dto.SaveNewVideoRequest;
|
import com.example.video_downloader.dto.SaveNewVideoRequest;
|
||||||
|
import com.example.video_downloader.entity.Video;
|
||||||
import com.example.video_downloader.repositories.VideoRepository;
|
import com.example.video_downloader.repositories.VideoRepository;
|
||||||
import com.example.video_downloader.services.VideoService;
|
import com.example.video_downloader.services.VideoService;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
@@ -8,7 +9,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping(path = "/video" )
|
@RequestMapping(path="/video")
|
||||||
@CrossOrigin(origins = "http://localhost:3000")
|
@CrossOrigin(origins = "http://localhost:3000")
|
||||||
public class VideoController {
|
public class VideoController {
|
||||||
|
|
||||||
@@ -20,12 +21,12 @@ public class VideoController {
|
|||||||
private Long id;
|
private Long id;
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping(path = "/video")
|
@PostMapping(path = "/videos")
|
||||||
public Response saveNewVideo(@RequestBody SaveNewVideoRequest request){
|
public Response saveNewVideo(@RequestBody SaveNewVideoRequest request){
|
||||||
|
|
||||||
videoService.saveNewVideo(request);
|
|
||||||
Response response = new Response();
|
Response response = new Response();
|
||||||
response.setId(videoService.saveNewVideo(request).getId());
|
Video video = videoService.saveNewVideo(request);
|
||||||
|
response.setId(video.getId());
|
||||||
|
|
||||||
return response;
|
return response;
|
||||||
|
|
||||||
|
|||||||
@@ -14,8 +14,11 @@ public class Video {
|
|||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
private String url;
|
private String url;
|
||||||
private String ytld;
|
private String ytdl;
|
||||||
private String ytMetaData;
|
private String ytMetaData;
|
||||||
|
|
||||||
|
@Enumerated(EnumType.STRING)
|
||||||
private StatusEnum status;
|
private StatusEnum status;
|
||||||
|
|
||||||
private String fullPath;
|
private String fullPath;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.example.video_downloader.services;
|
||||||
|
|
||||||
|
import jakarta.annotation.PostConstruct;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class ProcessService {
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() throws InterruptedException, IOException {
|
||||||
|
System.out.println("Init...");
|
||||||
|
|
||||||
|
ProcessBuilder builder = new ProcessBuilder("/app/yt-dlp");
|
||||||
|
Process process = builder.start();
|
||||||
|
process.waitFor();
|
||||||
|
String text = new String(process.getInputStream().readAllBytes(), StandardCharsets.UTF_8);
|
||||||
|
String text2 = new String(process.getErrorStream().readAllBytes(), StandardCharsets.UTF_8);
|
||||||
|
|
||||||
|
System.out.println(text);
|
||||||
|
System.out.println(text2);
|
||||||
|
|
||||||
|
System.out.println("Marker...");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -1 +1,5 @@
|
|||||||
spring.application.name=video_downloader
|
spring.application.name=video_downloader
|
||||||
|
spring.datasource.url = jdbc:postgresql://localhost:5432/videos
|
||||||
|
spring.datasource.username = postgres
|
||||||
|
spring.datasource.password = 5995
|
||||||
|
spring.jpa.hibernate.ddl-auto = update
|
||||||
Reference in New Issue
Block a user