ipv4 enforce in order to skip timeout for ipv6 search

This commit is contained in:
Reeverflow
2026-03-06 11:36:14 +01:00
parent f83d21d8f6
commit b63d70078a
6 changed files with 22 additions and 13 deletions

View File

@@ -67,6 +67,12 @@
<artifactId>spring-boot-starter-webmvc-test</artifactId> <artifactId>spring-boot-starter-webmvc-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.jetbrains</groupId>
<artifactId>annotations</artifactId>
<version>26.1.0</version>
<scope>compile</scope>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@@ -8,6 +8,7 @@ import com.example.video_downloader.services.PlaylistService;
import com.example.video_downloader.services.VideoService; import com.example.video_downloader.services.VideoService;
import com.example.video_downloader.services.YTDLPService; import com.example.video_downloader.services.YTDLPService;
import lombok.Data; import lombok.Data;
import org.jetbrains.annotations.NotNull;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity; import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@@ -58,13 +59,13 @@ public class VideoController {
} }
@PostMapping(path = "/fire") @PostMapping(path = "/fire")
public int getJobDone(@RequestBody Trigger trigger) throws IOException, InterruptedException { public int getJobDone(@RequestBody @NotNull Trigger trigger) throws IOException, InterruptedException {
int statusCode = 200; int statusCode = 200;
if(trigger.input) { if(trigger.input) {
ytdlpService.processPlaylist(); ytdlpService.processPlaylist();
System.out.println("Hello!");
ytdlpService.validateVideos(); ytdlpService.validateVideos();
System.out.println("Hello!");
} }
return statusCode; return statusCode;

View File

@@ -4,7 +4,6 @@ import jakarta.persistence.*;
import lombok.Data; import lombok.Data;
import lombok.ToString; import lombok.ToString;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@Data @Data

View File

@@ -5,6 +5,7 @@ import lombok.Data;
import lombok.ToString; import lombok.ToString;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
@Data @Data
@@ -18,8 +19,8 @@ public class Video {
private String url; private String url;
private String name; private String name;
private String ytdl; private String uploadDate;
private String ytMetaData; private String duration;
@Enumerated(EnumType.STRING) @Enumerated(EnumType.STRING)
private StatusEnum status; private StatusEnum status;

View File

@@ -10,8 +10,8 @@ import org.springframework.stereotype.Service;
import org.springframework.web.client.HttpClientErrorException; import org.springframework.web.client.HttpClientErrorException;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Date;
@Service @Service
public class YTDLPService { public class YTDLPService {
@@ -31,9 +31,9 @@ public class YTDLPService {
public void processPlaylist() throws IOException, InterruptedException { public void processPlaylist() throws IOException, InterruptedException {
List<Playlist> playlists = playlistRepository.findByStatus(StatusEnum.NEW); List<Playlist> playlists = playlistRepository.findByStatus(StatusEnum.NEW);
System.out.println("Am I slow?");
for(Playlist playlist : playlists) { for(Playlist playlist : playlists) {
String urls = processService.execute("yt-dlp", "--flat-playlist", "--print", "webpage_url", playlist.getUrl()); String urls = processService.execute("yt-dlp", "--force-ipv4", "--flat-playlist", "--print", "webpage_url", playlist.getUrl());
for(String url : urls.split("\\n")){ for(String url : urls.split("\\n")){
Video video = new Video(); Video video = new Video();
video.setUrl(url); video.setUrl(url);
@@ -52,8 +52,10 @@ public class YTDLPService {
for(Video video : response) { for(Video video : response) {
String data = processVideo(video.getUrl()); String data = processVideo(video.getUrl());
String[] parts = data.trim().split(", "); String[] parts = data.trim().split(", ");
video.setName(parts[0]); video.setName(parts[0]);
video.setCreator(parts[1]); video.setCreator(parts[1]);
video.setUploadDate(parts[2]);
video.setDuration(parts[3]);
videoRepository.save(video); videoRepository.save(video);
} }
} }
@@ -68,12 +70,12 @@ public class YTDLPService {
// } // }
public String processVideo(String url) throws HttpClientErrorException, InterruptedException, IOException { public String processVideo(String url) throws HttpClientErrorException, InterruptedException, IOException {
String result = processService.execute("yt-dlp", "--skip-download", "--print", "%(title)s, %(uploader)s, %(upload_date)s, %(duration_string)s", url); String result = processService.execute("yt-dlp", "--force-ipv4", "--skip-download", "--print", "%(title)s, %(uploader)s, %(upload_date)s, %(duration_string)s", url);
return result; return result;
} }
public void downloadVideo(String url, Long id) throws HttpClientErrorException, InterruptedException, IOException { public void downloadVideo(String url, Long id) throws HttpClientErrorException, InterruptedException, IOException {
String outputPath = "downloads/" + id + ".%(ext)s"; String outputPath = "downloads/" + id + ".%(ext)s";
String result = processService.execute("yt-dlp", "--print", "%(title)s, %(uploader)s, %(upload_date)s, %(duration_string)s", outputPath, url); String result = processService.execute("yt-dlp", "--force-ipv4", "--print", "%(title)s, %(uploader)s, %(upload_date)s, %(duration_string)s", outputPath, url);
System.out.println(result); System.out.println(result);
} }

View File

@@ -1,5 +1,5 @@
spring.application.name=video_downloader spring.application.name=video_downloader
spring.datasource.url = jdbc:postgresql://localhost:5432/videos spring.datasource.url = jdbc:postgresql://127.0.0.1:5432/videos
spring.datasource.username = postgres spring.datasource.username = postgres
spring.datasource.password = 5995 spring.datasource.password = 5995
spring.jpa.hibernate.ddl-auto = create-drop spring.jpa.hibernate.ddl-auto = create-drop