Compare commits

1 Commits

Author SHA1 Message Date
890aedd380 typescript generator 2026-02-09 07:00:20 +01:00
8 changed files with 36 additions and 65 deletions

1
.gitignore vendored
View File

@@ -31,4 +31,3 @@ build/
### VS Code ###
.vscode/
After this video, you will speak with confidence \[3yMHLJbXfFc].webm

View File

@@ -1,8 +0,0 @@
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"]

22
pom.xml
View File

@@ -75,7 +75,29 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>cz.habarta.typescript-generator</groupId>
<artifactId>typescript-generator-maven-plugin</artifactId>
<version>3.2.1263</version>
<executions>
<execution>
<id>generate</id>
<goals>
<goal>generate</goal>
</goals>
<phase>process-classes</phase>
</execution>
</executions>
<configuration>
<jsonLibrary>jackson2</jsonLibrary>
<classes>
<class>com.example.video_downloader.dto.SaveNewVideoRequest</class>
</classes>
<outputKind>module</outputKind>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@@ -2,16 +2,11 @@ package com.example.video_downloader.controllers;
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.services.VideoService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.server.ResponseStatusException;
import java.util.List;
import java.util.Optional;
@RestController
@RequestMapping(path="/video")
@@ -36,15 +31,4 @@ public class VideoController {
return response;
}
@GetMapping(path = "/all")
public ResponseEntity<List<Video>> getAllVideos(){
return ResponseEntity.ok(videoService.getVideos());
}
@GetMapping(path = "/{id}")
public ResponseEntity<Video> getVideoById(@PathVariable Long id){
return ResponseEntity.ok(videoService.getVideoById(id));
}
}

View File

@@ -1,26 +0,0 @@
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 {
execute("yt-dlp", "");
}
public void execute(String... command) throws InterruptedException, IOException {
ProcessBuilder builder = new ProcessBuilder(command);
builder.redirectOutput(ProcessBuilder.Redirect.INHERIT);
builder.redirectError(ProcessBuilder.Redirect.INHERIT);
Process process = builder.start();
process.waitFor();
}
}

View File

@@ -7,9 +7,6 @@ import com.example.video_downloader.repositories.VideoRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional;
@Service
public class VideoService {
@@ -25,14 +22,4 @@ public class VideoService {
return video;
}
public List<Video> getVideos(){
return videoRepository.findAll();
}
public Video getVideoById(Long id){
return videoRepository.findById(id)
.orElseThrow(() -> new RuntimeException("Video not found with id: " + id));
}
}

View File

@@ -0,0 +1,13 @@
package com.example.video_downloader;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class VideoDownloaderApplicationTests {
@Test
void contextLoads() {
}
}

BIN
yt-dlp

Binary file not shown.