ipv4 enforce in order to skip timeout for ipv6 search
This commit is contained in:
6
pom.xml
6
pom.xml
@@ -67,6 +67,12 @@
|
||||
<artifactId>spring-boot-starter-webmvc-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.jetbrains</groupId>
|
||||
<artifactId>annotations</artifactId>
|
||||
<version>26.1.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -8,6 +8,7 @@ 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.jetbrains.annotations.NotNull;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
@@ -58,13 +59,13 @@ public class VideoController {
|
||||
}
|
||||
|
||||
@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;
|
||||
if(trigger.input) {
|
||||
ytdlpService.processPlaylist();
|
||||
System.out.println("Hello!");
|
||||
ytdlpService.validateVideos();
|
||||
System.out.println("Hello!");
|
||||
}
|
||||
return statusCode;
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import jakarta.persistence.*;
|
||||
import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
|
||||
@@ -5,6 +5,7 @@ import lombok.Data;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@@ -18,8 +19,8 @@ public class Video {
|
||||
|
||||
private String url;
|
||||
private String name;
|
||||
private String ytdl;
|
||||
private String ytMetaData;
|
||||
private String uploadDate;
|
||||
private String duration;
|
||||
|
||||
@Enumerated(EnumType.STRING)
|
||||
private StatusEnum status;
|
||||
|
||||
@@ -10,8 +10,8 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.client.HttpClientErrorException;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Date;
|
||||
|
||||
@Service
|
||||
public class YTDLPService {
|
||||
@@ -31,9 +31,9 @@ public class YTDLPService {
|
||||
|
||||
public void processPlaylist() throws IOException, InterruptedException {
|
||||
List<Playlist> playlists = playlistRepository.findByStatus(StatusEnum.NEW);
|
||||
|
||||
System.out.println("Am I slow?");
|
||||
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")){
|
||||
Video video = new Video();
|
||||
video.setUrl(url);
|
||||
@@ -54,6 +54,8 @@ public class YTDLPService {
|
||||
String[] parts = data.trim().split(", ");
|
||||
video.setName(parts[0]);
|
||||
video.setCreator(parts[1]);
|
||||
video.setUploadDate(parts[2]);
|
||||
video.setDuration(parts[3]);
|
||||
videoRepository.save(video);
|
||||
}
|
||||
}
|
||||
@@ -68,12 +70,12 @@ public class YTDLPService {
|
||||
// }
|
||||
|
||||
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;
|
||||
}
|
||||
public void downloadVideo(String url, Long id) throws HttpClientErrorException, InterruptedException, IOException {
|
||||
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);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
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.password = 5995
|
||||
spring.jpa.hibernate.ddl-auto = create-drop
|
||||
Reference in New Issue
Block a user