diff --git a/pom.xml b/pom.xml
index e209aff..4822144 100644
--- a/pom.xml
+++ b/pom.xml
@@ -9,8 +9,8 @@
org.springframework.boot
spring-boot-starter-parent
- 2.4.1
-
+ 2.4.5
+
vripper-server
diff --git a/vripper-electron/pre-build.js b/vripper-electron/pre-build.js
index ec379c4..829a524 100644
--- a/vripper-electron/pre-build.js
+++ b/vripper-electron/pre-build.js
@@ -18,7 +18,7 @@ fs.writeFileSync('./build/vripper-ui/index.html', $.html());
console.log('Building runtime environment');
rimraf.sync('java-runtime');
-execSync('jlink --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules java.base,java.desktop,java.instrument,java.management,java.naming,java.prefs,java.rmi,java.scripting,java.security.jgss,java.sql,jdk.httpserver,jdk.unsupported,jdk.crypto.ec --output java-runtime');
+execSync('jlink --no-header-files --no-man-pages --compress=2 --strip-debug --add-modules java.base,java.desktop,java.instrument,java.management,java.security.jgss,java.sql,jdk.unsupported,jdk.crypto.ec --output java-runtime');
if (process.platform === 'linux') {
console.log('Stripping libjvm.so');
execSync('strip -p --strip-unneeded java-runtime/lib/server/libjvm.so');
diff --git a/vripper-server/src/main/java/tn/mnlr/vripper/EventListenerBean.java b/vripper-server/src/main/java/tn/mnlr/vripper/EventListenerBean.java
index bf2afc1..e084d67 100644
--- a/vripper-server/src/main/java/tn/mnlr/vripper/EventListenerBean.java
+++ b/vripper-server/src/main/java/tn/mnlr/vripper/EventListenerBean.java
@@ -5,23 +5,23 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;
-import tn.mnlr.vripper.services.DataService;
+import tn.mnlr.vripper.jpa.repositories.IPostRepository;
@Component
public class EventListenerBean {
@Getter private static boolean init = false;
- private final DataService dataService;
+ private final IPostRepository postRepository;
@Autowired
- public EventListenerBean(DataService dataService) {
- this.dataService = dataService;
+ public EventListenerBean(IPostRepository postRepository) {
+ this.postRepository = postRepository;
}
@EventListener
public void onApplicationEvent(ContextRefreshedEvent event) {
- dataService.setDownloadingToStopped();
+ postRepository.setDownloadingToStopped();
init = true;
}
}
diff --git a/vripper-server/src/main/java/tn/mnlr/vripper/event/Event.java b/vripper-server/src/main/java/tn/mnlr/vripper/event/Event.java
index 420cb07..494cd9f 100644
--- a/vripper-server/src/main/java/tn/mnlr/vripper/event/Event.java
+++ b/vripper-server/src/main/java/tn/mnlr/vripper/event/Event.java
@@ -14,7 +14,7 @@ public class Event {
}
public static Event wrap(Kind kind, T data) {
- return new Event(kind, data);
+ return new Event<>(kind, data);
}
public enum Kind {
diff --git a/vripper-server/src/main/java/tn/mnlr/vripper/event/EventBus.java b/vripper-server/src/main/java/tn/mnlr/vripper/event/EventBus.java
index 393d9d5..0f1634d 100644
--- a/vripper-server/src/main/java/tn/mnlr/vripper/event/EventBus.java
+++ b/vripper-server/src/main/java/tn/mnlr/vripper/event/EventBus.java
@@ -10,13 +10,13 @@ import javax.annotation.PreDestroy;
public class EventBus {
public static final Sinks.EmitFailureHandler RETRY = (signalType, emitResult) -> true;
- private final Sinks.Many sink = Sinks.many().multicast().onBackpressureBuffer();
+ private final Sinks.Many> sink = Sinks.many().multicast().onBackpressureBuffer();
- public void publishEvent(Event event) {
+ public void publishEvent(Event> event) {
sink.emitNext(event, RETRY);
}
- public Flux flux() {
+ public Flux> flux() {
return sink.asFlux();
}
diff --git a/vripper-server/src/main/java/tn/mnlr/vripper/host/ImageBamHost.java b/vripper-server/src/main/java/tn/mnlr/vripper/host/ImageBamHost.java
index 1c91552..04741eb 100644
--- a/vripper-server/src/main/java/tn/mnlr/vripper/host/ImageBamHost.java
+++ b/vripper-server/src/main/java/tn/mnlr/vripper/host/ImageBamHost.java
@@ -20,6 +20,7 @@ public class ImageBamHost extends Host {
private static final String host = "imagebam.com";
private static final String IMG_XPATH = "//img[contains(@class,'main-image')]";
+ private static final String CONTINUE_XPATH = "//*[contains(text(), 'Continue')]";
private final HostService hostService;
private final XpathService xpathService;
@@ -47,6 +48,17 @@ public class ImageBamHost extends Host {
HostService.Response response = hostService.getResponse(url, context);
Document doc = response.getDocument();
+ try {
+ log.debug(String.format("Looking for xpath expression %s in %s", CONTINUE_XPATH, url));
+ if (xpathService.getAsNode(doc, CONTINUE_XPATH) != null) {
+ // Button detected. No need to actually click it, just make the call again.
+ response = hostService.getResponse(url, context);
+ doc = response.getDocument();
+ }
+ } catch (XpathException e) {
+ throw new HostException(e);
+ }
+
Node imgNode;
try {
log.debug(String.format("Looking for xpath expression %s in %s", IMG_XPATH, url));
diff --git a/vripper-server/src/main/java/tn/mnlr/vripper/services/DataService.java b/vripper-server/src/main/java/tn/mnlr/vripper/services/DataService.java
index 7173589..fb6921a 100644
--- a/vripper-server/src/main/java/tn/mnlr/vripper/services/DataService.java
+++ b/vripper-server/src/main/java/tn/mnlr/vripper/services/DataService.java
@@ -70,10 +70,6 @@ public class DataService {
});
}
- public void setDownloadingToStopped() {
- postRepository.setDownloadingToStopped();
- }
-
public synchronized void afterJobFinish(Image image, Post post) {
if (image.getStatus().equals(Status.COMPLETE)) {
post.setDone(post.getDone() + 1);
@@ -88,6 +84,22 @@ public class DataService {
postRepository.updateDone(done, id);
}
+ public void updatePostStatus(Status status, Long id) {
+ postRepository.updateStatus(status, id);
+ }
+
+ public void updatePostThanks(boolean thanked, Long id) {
+ postRepository.updateThanked(thanked, id);
+ }
+
+ public void updatePostTitle(String title, Long id) {
+ postRepository.updateTitle(title, id);
+ }
+
+ public void updatePostDownloadDirectory(String postFolderName, Long id) {
+ postRepository.updateFolderName(postFolderName, id);
+ }
+
public void finishPost(@NonNull Post post) {
if (!imageRepository.findByPostIdAndIsError(post.getPostId()).isEmpty()) {
post.setStatus(Status.ERROR);
@@ -203,22 +215,6 @@ public class DataService {
imageRepository.updateTotal(total, id);
}
- public void updatePostStatus(Status status, Long id) {
- postRepository.updateStatus(status, id);
- }
-
- public void updateDownloadDirectory(String postFolderName, Long id) {
- postRepository.updateFolderName(postFolderName, id);
- }
-
- public void updatePostTitle(String title, Long id) {
- postRepository.updateTitle(title, id);
- }
-
- public void updatePostThanked(boolean thanked, Long id) {
- postRepository.updateThanked(thanked, id);
- }
-
public Optional findEventById(Long id) {
return eventRepository.findById(id);
}
diff --git a/vripper-server/src/main/java/tn/mnlr/vripper/services/PathService.java b/vripper-server/src/main/java/tn/mnlr/vripper/services/PathService.java
index 4efbaaa..8184028 100644
--- a/vripper-server/src/main/java/tn/mnlr/vripper/services/PathService.java
+++ b/vripper-server/src/main/java/tn/mnlr/vripper/services/PathService.java
@@ -50,7 +50,7 @@ public class PathService {
downloadDirectory = makeDir(downloadDirectory);
post.setDownloadDirectory(
downloadDirectory.getAbsolutePath().replace(settings.getDownloadPath(), ""));
- dataService.updateDownloadDirectory(post.getDownloadDirectory(), post.getId());
+ dataService.updatePostDownloadDirectory(post.getDownloadDirectory(), post.getId());
}
public final void rename(@NonNull String postId, @NonNull String altName, Settings settings)
@@ -78,7 +78,7 @@ public class PathService {
StandardCopyOption.ATOMIC_MOVE);
post.setDownloadDirectory(
newDownloadDirectory.getAbsolutePath().replace(settings.getDownloadPath(), ""));
- dataService.updateDownloadDirectory(post.getDownloadDirectory(), post.getId());
+ dataService.updatePostDownloadDirectory(post.getDownloadDirectory(), post.getId());
post.setTitle(altName);
dataService.updatePostTitle(post.getTitle(), post.getId());
diff --git a/vripper-server/src/main/java/tn/mnlr/vripper/services/domain/tasks/LeaveThanksRunnable.java b/vripper-server/src/main/java/tn/mnlr/vripper/services/domain/tasks/LeaveThanksRunnable.java
index 6bf9fee..489a329 100644
--- a/vripper-server/src/main/java/tn/mnlr/vripper/services/domain/tasks/LeaveThanksRunnable.java
+++ b/vripper-server/src/main/java/tn/mnlr/vripper/services/domain/tasks/LeaveThanksRunnable.java
@@ -117,7 +117,7 @@ public class LeaveThanksRunnable implements Runnable {
try (CloseableHttpResponse response = client.execute(postThanks, context)) {
if (response.getStatusLine().getStatusCode() / 100 == 2) {
post.setThanked(true);
- dataService.updatePostThanked(post.isThanked(), post.getId());
+ dataService.updatePostThanks(post.isThanked(), post.getId());
}
EntityUtils.consumeQuietly(response.getEntity());
}
diff --git a/vripper-server/src/main/java/tn/mnlr/vripper/web/wsendpoints/DataBroadcast.java b/vripper-server/src/main/java/tn/mnlr/vripper/web/wsendpoints/DataBroadcast.java
index 9d9ce99..fd157ee 100644
--- a/vripper-server/src/main/java/tn/mnlr/vripper/web/wsendpoints/DataBroadcast.java
+++ b/vripper-server/src/main/java/tn/mnlr/vripper/web/wsendpoints/DataBroadcast.java
@@ -9,8 +9,6 @@ import tn.mnlr.vripper.event.Event;
import tn.mnlr.vripper.event.EventBus;
import tn.mnlr.vripper.jpa.domain.Image;
import tn.mnlr.vripper.services.DataService;
-import tn.mnlr.vripper.services.DownloadSpeedService;
-import tn.mnlr.vripper.services.GlobalStateService;
import tn.mnlr.vripper.services.domain.DownloadSpeed;
import tn.mnlr.vripper.services.domain.GlobalState;
@@ -34,12 +32,7 @@ public class DataBroadcast {
private Disposable disposable;
@Autowired
- public DataBroadcast(
- SimpMessagingTemplate template,
- GlobalStateService globalStateService,
- DownloadSpeedService downloadSpeedService,
- DataService dataService,
- EventBus eventBus) {
+ public DataBroadcast(SimpMessagingTemplate template, DataService dataService, EventBus eventBus) {
this.template = template;
this.dataService = dataService;
this.eventBus = eventBus;
@@ -54,7 +47,7 @@ public class DataBroadcast {
.buffer(Duration.of(500, ChronoUnit.MILLIS))
.subscribe(
data -> {
- Map> eventMap =
+ Map>> eventMap =
data.stream().collect(Collectors.groupingBy(Event::getKind));
eventMap.forEach(