Compare commits
5 Commits
main
...
5b6862f678
| Author | SHA1 | Date | |
|---|---|---|---|
|
5b6862f678
|
|||
|
aef8980786
|
|||
|
2baa79c3a9
|
|||
|
95ca3d1a65
|
|||
|
973e588947
|
@ -1,5 +1,5 @@
|
|||||||
services:
|
services:
|
||||||
composer_backend:
|
hls-proxy:
|
||||||
build:
|
build:
|
||||||
context: .
|
context: .
|
||||||
dockerfile: Dockerfile.dev
|
dockerfile: Dockerfile.dev
|
||||||
|
|||||||
2
pom.xml
2
pom.xml
@ -35,7 +35,7 @@
|
|||||||
<apache-tika.version>3.2.3</apache-tika.version>
|
<apache-tika.version>3.2.3</apache-tika.version>
|
||||||
<springdoc-openapi.version>2.8.5</springdoc-openapi.version>
|
<springdoc-openapi.version>2.8.5</springdoc-openapi.version>
|
||||||
<jaffree.version>2024.08.29</jaffree.version>
|
<jaffree.version>2024.08.29</jaffree.version>
|
||||||
<yt-dlp-java.version>2.0.8</yt-dlp-java.version>
|
<yt-dlp-java.version>2.0.7</yt-dlp-java.version>
|
||||||
<record-builder.version>51</record-builder.version>
|
<record-builder.version>51</record-builder.version>
|
||||||
</properties>
|
</properties>
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|||||||
@ -38,7 +38,6 @@ public class TrackController {
|
|||||||
@ModelAttribute AddLocalTrackRequest request) throws ImportTrackException {
|
@ModelAttribute AddLocalTrackRequest request) throws ImportTrackException {
|
||||||
var params = AddLocalTrackParamsBuilder.builder()
|
var params = AddLocalTrackParamsBuilder.builder()
|
||||||
.blob(new MultipartBlob(request.source()))
|
.blob(new MultipartBlob(request.source()))
|
||||||
.includeProgressHistory(true)
|
|
||||||
.build();
|
.build();
|
||||||
TrackResponse response = trackService.addLocalTrack(user, playlistId, params);
|
TrackResponse response = trackService.addLocalTrack(user, playlistId, params);
|
||||||
return ResponseEntity.ok(response);
|
return ResponseEntity.ok(response);
|
||||||
|
|||||||
@ -31,7 +31,7 @@ public abstract class BaseTrackProgress {
|
|||||||
return id;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getTimestamp() {
|
public Long getTimestamp() {
|
||||||
return timestamp;
|
return timestamp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -4,19 +4,17 @@ public class PlaylistProgress extends BaseTrackProgress {
|
|||||||
private String ytdlnStdout;
|
private String ytdlnStdout;
|
||||||
private int overallProgress;
|
private int overallProgress;
|
||||||
private int trackCount;
|
private int trackCount;
|
||||||
private String playlistTitle;
|
|
||||||
private ProgressStatus status;
|
private ProgressStatus status;
|
||||||
|
|
||||||
PlaylistProgress() {
|
PlaylistProgress() {
|
||||||
super(0, 0, 0);
|
super(0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlaylistProgress(long playlistId, long trackSourceId, long userId, int trackCount, String playlistTitle) {
|
public PlaylistProgress(long playlistId, long trackSourceId, long userId, int trackCount) {
|
||||||
super(playlistId, trackSourceId, userId);
|
super(playlistId, trackSourceId, userId);
|
||||||
this.setType(ProgressEntryType.PLAYLIST);
|
this.setType(ProgressEntryType.PLAYLIST);
|
||||||
this.status = ProgressStatus.LOADING;
|
this.status = ProgressStatus.LOADING;
|
||||||
this.trackCount = trackCount;
|
this.trackCount = trackCount;
|
||||||
this.playlistTitle = playlistTitle;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getYtdlnStdout() {
|
public String getYtdlnStdout() {
|
||||||
@ -47,8 +45,4 @@ public class PlaylistProgress extends BaseTrackProgress {
|
|||||||
return trackCount;
|
return trackCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPlaylistTitle() {
|
|
||||||
return playlistTitle;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -7,7 +7,6 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
@ -137,14 +136,8 @@ public class YoutubeTrackService {
|
|||||||
ytDlpRequest.setOption("audio-format", "best");
|
ytDlpRequest.setOption("audio-format", "best");
|
||||||
ytDlpRequest.setOption("no-overwrites");
|
ytDlpRequest.setOption("no-overwrites");
|
||||||
|
|
||||||
String playlistTitle = videoInfos.stream()
|
|
||||||
.map(VideoInfo::getExtraProperties)
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.map(v -> String.valueOf(v.getOrDefault("playlist_title", ""))).findFirst()
|
|
||||||
.orElse("");
|
|
||||||
|
|
||||||
PlaylistProgress playlistProgress = new PlaylistProgress(playlistId, trackSource.getId(), userId,
|
PlaylistProgress playlistProgress = new PlaylistProgress(playlistId, trackSource.getId(), userId,
|
||||||
videoInfos.size(), playlistTitle);
|
videoInfos.size());
|
||||||
redisProgressService.saveProgress(playlistProgress);
|
redisProgressService.saveProgress(playlistProgress);
|
||||||
|
|
||||||
var response = YtDlp.execute(ytDlpRequest, (downloadProgress, ignored) -> {
|
var response = YtDlp.execute(ytDlpRequest, (downloadProgress, ignored) -> {
|
||||||
@ -156,8 +149,7 @@ public class YoutubeTrackService {
|
|||||||
}, stdoutLine -> {
|
}, stdoutLine -> {
|
||||||
redisProgressService.<PlaylistProgress>updateTrackProgressField(playlistId, trackSource.getId(), userId,
|
redisProgressService.<PlaylistProgress>updateTrackProgressField(playlistId, trackSource.getId(), userId,
|
||||||
progress -> {
|
progress -> {
|
||||||
String previousStdout = progress.getYtdlnStdout() == null ? "" : progress.getYtdlnStdout();
|
progress.setYtdlnStdout(String.join("\n", progress.getYtdlnStdout(), stdoutLine));
|
||||||
progress.setYtdlnStdout(previousStdout + stdoutLine);
|
|
||||||
});
|
});
|
||||||
}, null);
|
}, null);
|
||||||
redisProgressService.<PlaylistProgress>updateTrackProgressField(playlistId, trackSource.getId(), userId,
|
redisProgressService.<PlaylistProgress>updateTrackProgressField(playlistId, trackSource.getId(), userId,
|
||||||
@ -169,7 +161,7 @@ public class YoutubeTrackService {
|
|||||||
|
|
||||||
try (Stream<Path> pathStream = Files.walk(temporaryFolder)) {
|
try (Stream<Path> pathStream = Files.walk(temporaryFolder)) {
|
||||||
List<Path> downloadedFiles = Files.walk(temporaryFolder).toList();
|
List<Path> downloadedFiles = Files.walk(temporaryFolder).toList();
|
||||||
logger.info("downloaded file count {}", downloadedFiles.size() - 2);
|
logger.info("downloaded file count {}", downloadedFiles.size());
|
||||||
|
|
||||||
for (Path path : downloadedFiles) {
|
for (Path path : downloadedFiles) {
|
||||||
if (Files.isDirectory(path))
|
if (Files.isDirectory(path))
|
||||||
|
|||||||
Reference in New Issue
Block a user