mirror of
https://github.com/dev-claw/vripper-project.git
synced 2026-08-19 08:35:41 +02:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
335cbf70b4 | ||
|
|
e25d306f1d | ||
|
|
f395338a9d | ||
|
|
58a40682cc | ||
|
|
ccc4032bb0 |
@@ -1,5 +1,24 @@
|
||||
# Changelog
|
||||
|
||||
## [3.3.4] - 2021-03-18
|
||||
|
||||
### Changed
|
||||
|
||||
- Bug fixes
|
||||
|
||||
## [3.3.3] - 2021-03-13
|
||||
|
||||
### Changed
|
||||
|
||||
- Remove unnecessary event logs
|
||||
|
||||
## [3.3.2] - 2021-03-11
|
||||
|
||||
### Changed
|
||||
|
||||
- Fix a bug with event logs
|
||||
- Change event names and add some icons
|
||||
|
||||
## [3.3.1] - 2021-02-18
|
||||
|
||||
### Added
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>tn.mnlr</groupId>
|
||||
<artifactId>vripper</artifactId>
|
||||
<version>3.3.2</version>
|
||||
<version>3.3.4</version>
|
||||
<packaging>pom</packaging>
|
||||
<parent>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
|
||||
Generated
-2486
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vripper-electron",
|
||||
"version": "3.3.2",
|
||||
"version": "3.3.4",
|
||||
"description": "A ripper for vipergirls.to built using web technolgies",
|
||||
"main": "main.js",
|
||||
"author": "death-claw <53543762+death-claw@users.noreply.github.com>",
|
||||
|
||||
+10
-11
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>tn.mnlr</groupId>
|
||||
<artifactId>vripper</artifactId>
|
||||
<version>3.3.2</version>
|
||||
<version>3.3.4</version>
|
||||
</parent>
|
||||
<artifactId>vripper-electron</artifactId>
|
||||
<name>vripper-electron</name>
|
||||
@@ -39,34 +39,33 @@
|
||||
<plugin>
|
||||
<groupId>com.github.eirslett</groupId>
|
||||
<artifactId>frontend-maven-plugin</artifactId>
|
||||
<version>1.3</version>
|
||||
<version>1.11.2</version>
|
||||
<configuration>
|
||||
<nodeVersion>v12.2.0</nodeVersion>
|
||||
<npmVersion>6.9.0</npmVersion>
|
||||
<nodeVersion>v14.16.0</nodeVersion>
|
||||
<yarnVersion>v1.22.10</yarnVersion>
|
||||
<workingDirectory>build-dir</workingDirectory>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>install node and npm</id>
|
||||
<id>install node and yarn</id>
|
||||
<goals>
|
||||
<goal>install-node-and-npm</goal>
|
||||
<goal>install-node-and-yarn</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>npm install</id>
|
||||
<id>yarn install</id>
|
||||
<goals>
|
||||
<goal>npm</goal>
|
||||
<goal>yarn</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>npm run build</id>
|
||||
<id>yarn run build</id>
|
||||
<goals>
|
||||
<goal>npm</goal>
|
||||
<goal>yarn</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<arguments>run dist</arguments>
|
||||
</configuration>
|
||||
<phase>generate-resources</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>tn.mnlr</groupId>
|
||||
<artifactId>vripper</artifactId>
|
||||
<version>3.3.2</version>
|
||||
<version>3.3.4</version>
|
||||
</parent>
|
||||
<artifactId>vripper-server</artifactId>
|
||||
<name>vripper-server</name>
|
||||
|
||||
@@ -40,6 +40,8 @@ public class Event {
|
||||
METADATA,
|
||||
SCAN,
|
||||
DOWNLOAD,
|
||||
|
||||
// Below are deprecated events
|
||||
METADATA_CACHE_MISS,
|
||||
QUEUED_CACHE_MISS
|
||||
}
|
||||
|
||||
@@ -14,9 +14,18 @@ public class Metadata {
|
||||
|
||||
private Long postIdRef;
|
||||
|
||||
private String PostId;
|
||||
private String postId;
|
||||
|
||||
private String postedBy;
|
||||
|
||||
private List<String> resolvedNames = Collections.emptyList();
|
||||
|
||||
public static Metadata from(Metadata metadata) {
|
||||
Metadata copy = new Metadata();
|
||||
copy.postIdRef = metadata.postIdRef;
|
||||
copy.postId = metadata.postId;
|
||||
copy.postedBy = metadata.postedBy;
|
||||
copy.resolvedNames = List.copyOf(metadata.resolvedNames);
|
||||
return copy;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,23 +10,19 @@ import org.apache.http.client.HttpClient;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.apache.http.util.EntityUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.w3c.dom.Document;
|
||||
import org.w3c.dom.Node;
|
||||
import tn.mnlr.vripper.Utils;
|
||||
import tn.mnlr.vripper.exception.DownloadException;
|
||||
import tn.mnlr.vripper.exception.PostParseException;
|
||||
import tn.mnlr.vripper.jpa.domain.Event;
|
||||
import tn.mnlr.vripper.jpa.domain.Metadata;
|
||||
import tn.mnlr.vripper.jpa.domain.Post;
|
||||
import tn.mnlr.vripper.jpa.repositories.IEventRepository;
|
||||
import tn.mnlr.vripper.services.domain.tasks.MetadataRunnable;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -43,16 +39,13 @@ public class MetadataService {
|
||||
private final XpathService xpathService;
|
||||
private final Map<String, MetadataRunnable> fetchingMetadata = new ConcurrentHashMap<>();
|
||||
private final ThreadPoolService threadPoolService;
|
||||
private final IEventRepository eventRepository;
|
||||
|
||||
@Autowired
|
||||
public MetadataService(ConnectionService cm, VGAuthService VGAuthService, HtmlProcessorService htmlProcessorService, XpathService xpathService, ThreadPoolService threadPoolService, IEventRepository eventRepository) {
|
||||
public MetadataService(ConnectionService cm, VGAuthService VGAuthService, HtmlProcessorService htmlProcessorService, XpathService xpathService, ThreadPoolService threadPoolService) {
|
||||
this.cm = cm;
|
||||
this.VGAuthService = VGAuthService;
|
||||
this.htmlProcessorService = htmlProcessorService;
|
||||
this.xpathService = xpathService;
|
||||
this.threadPoolService = threadPoolService;
|
||||
this.eventRepository = eventRepository;
|
||||
|
||||
CacheLoader<Key, Metadata> loader = new CacheLoader<>() {
|
||||
@Override
|
||||
@@ -65,30 +58,9 @@ public class MetadataService {
|
||||
.build(loader);
|
||||
}
|
||||
|
||||
public Metadata get(Post post) {
|
||||
Metadata metadata = new Metadata();
|
||||
public Metadata get(Post post) throws ExecutionException {
|
||||
Key key = new Key(post.getPostId(), post.getThreadId(), post.getUrl());
|
||||
Metadata cachedMetadata = cache.getIfPresent(key);
|
||||
if (cachedMetadata == null) {
|
||||
Event event = new Event(Event.Type.METADATA_CACHE_MISS, Event.Status.PROCESSING, LocalDateTime.now(), "Loading metadata for " + post.getUrl());
|
||||
eventRepository.save(event);
|
||||
try {
|
||||
cachedMetadata = cache.get(key);
|
||||
event.setStatus(Event.Status.DONE);
|
||||
eventRepository.update(event);
|
||||
} catch (Exception e) {
|
||||
String error = "Failed to load metadata for " + post.getUrl();
|
||||
log.error(error, e);
|
||||
event.setStatus(Event.Status.ERROR);
|
||||
event.setMessage(error + "\n" + Utils.throwableToString(e));
|
||||
eventRepository.update(event);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
metadata.setPostedBy(cachedMetadata.getPostedBy());
|
||||
metadata.setPostId(cachedMetadata.getPostId());
|
||||
metadata.setResolvedNames(List.copyOf(cachedMetadata.getResolvedNames()));
|
||||
return metadata;
|
||||
return Metadata.from(cache.get(key));
|
||||
}
|
||||
|
||||
public void startFetchingMetadata(Post post) {
|
||||
|
||||
@@ -7,23 +7,17 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.lang.NonNull;
|
||||
import org.springframework.stereotype.Service;
|
||||
import tn.mnlr.vripper.Utils;
|
||||
import tn.mnlr.vripper.jpa.domain.Event;
|
||||
import tn.mnlr.vripper.jpa.domain.Post;
|
||||
import tn.mnlr.vripper.jpa.domain.Queued;
|
||||
import tn.mnlr.vripper.jpa.repositories.IEventRepository;
|
||||
import tn.mnlr.vripper.services.domain.ApiThreadParser;
|
||||
import tn.mnlr.vripper.services.domain.MultiPostItem;
|
||||
import tn.mnlr.vripper.services.domain.MultiPostScanParser;
|
||||
import tn.mnlr.vripper.services.domain.MultiPostScanResult;
|
||||
import tn.mnlr.vripper.services.domain.tasks.AddPostRunnable;
|
||||
import tn.mnlr.vripper.services.domain.tasks.AddQueuedRunnable;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import static tn.mnlr.vripper.jpa.domain.Event.Status.DONE;
|
||||
import static tn.mnlr.vripper.jpa.domain.Event.Status.PROCESSING;
|
||||
|
||||
@Service
|
||||
@Slf4j
|
||||
public class PostService {
|
||||
@@ -31,20 +25,18 @@ public class PostService {
|
||||
private final DataService dataService;
|
||||
private final ThreadPoolService threadPoolService;
|
||||
private final MetadataService metadataService;
|
||||
private final IEventRepository eventRepository;
|
||||
private final LoadingCache<Queued, List<MultiPostItem>> cache;
|
||||
private final LoadingCache<Queued, MultiPostScanResult> cache;
|
||||
|
||||
@Autowired
|
||||
public PostService(DataService dataService, ThreadPoolService threadPoolService, MetadataService metadataService, IEventRepository eventRepository) {
|
||||
public PostService(DataService dataService, ThreadPoolService threadPoolService, MetadataService metadataService) {
|
||||
this.dataService = dataService;
|
||||
this.threadPoolService = threadPoolService;
|
||||
this.metadataService = metadataService;
|
||||
this.eventRepository = eventRepository;
|
||||
|
||||
CacheLoader<Queued, List<MultiPostItem>> loader = new CacheLoader<>() {
|
||||
CacheLoader<Queued, MultiPostScanResult> loader = new CacheLoader<>() {
|
||||
@Override
|
||||
public List<MultiPostItem> load(@NonNull Queued multiPostItem) throws Exception {
|
||||
return new ApiThreadParser(multiPostItem).parse();
|
||||
public MultiPostScanResult load(@NonNull Queued multiPostItem) throws Exception {
|
||||
return new MultiPostScanParser(multiPostItem).parse();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -67,27 +59,8 @@ public class PostService {
|
||||
}
|
||||
}
|
||||
|
||||
public List<MultiPostItem> get(Queued queued) {
|
||||
List<MultiPostItem> multiPostItems;
|
||||
multiPostItems = cache.getIfPresent(queued);
|
||||
if (multiPostItems == null) {
|
||||
Event event = new Event(Event.Type.QUEUED_CACHE_MISS, PROCESSING, LocalDateTime.now(), "Loading posts from " + queued.getLink());
|
||||
eventRepository.save(event);
|
||||
try {
|
||||
multiPostItems = cache.get(queued);
|
||||
event.setStatus(DONE);
|
||||
event.setMessage("Loaded " + multiPostItems.size() + " posts from " + queued.getLink());
|
||||
eventRepository.update(event);
|
||||
} catch (Exception e) {
|
||||
String error = String.format("Failed to parse link %s", queued.getLink());
|
||||
log.error(error, e);
|
||||
event.setStatus(Event.Status.ERROR);
|
||||
event.setMessage(error + "\n" + Utils.throwableToString(e));
|
||||
eventRepository.update(event);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return multiPostItems;
|
||||
public MultiPostScanResult get(Queued queued) throws ExecutionException {
|
||||
return cache.get(queued);
|
||||
}
|
||||
|
||||
public void remove(String threadId) {
|
||||
|
||||
@@ -268,6 +268,10 @@ public class SettingsService {
|
||||
if (settings.getMaxEventLog() < 100 || settings.getMaxEventLog() > 10_000) {
|
||||
throw new ValidationException(String.format("Invalid maximum event log record settings, values must be in [%d,%d]", 100, 10_000));
|
||||
}
|
||||
|
||||
if (!settings.getVThanks() && settings.getLeaveThanksOnStart() != null && settings.getLeaveThanksOnStart()) {
|
||||
throw new ValidationException("Invalid value, leave thanks must be checked");
|
||||
}
|
||||
}
|
||||
|
||||
public Theme getTheme() {
|
||||
|
||||
+10
-4
@@ -1,6 +1,5 @@
|
||||
package tn.mnlr.vripper.services.domain;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
import tn.mnlr.vripper.SpringContext;
|
||||
@@ -12,14 +11,14 @@ import java.util.*;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class ApiThreadHandler extends DefaultHandler {
|
||||
public class MultiPostScanHandler extends DefaultHandler {
|
||||
|
||||
private final Queued queued;
|
||||
private final Collection<Host> supportedHosts;
|
||||
private final SettingsService settingsService;
|
||||
private final Map<Host, AtomicInteger> hostMap = new HashMap<>();
|
||||
@Getter
|
||||
private final List<MultiPostItem> posts = new ArrayList<>();
|
||||
private String error;
|
||||
private List<String> previews = new ArrayList<>();
|
||||
private String threadTitle;
|
||||
private String postId;
|
||||
@@ -28,12 +27,16 @@ public class ApiThreadHandler extends DefaultHandler {
|
||||
private int postCounter;
|
||||
private int previewCounter = 0;
|
||||
|
||||
public ApiThreadHandler(Queued queued) {
|
||||
public MultiPostScanHandler(Queued queued) {
|
||||
this.queued = queued;
|
||||
supportedHosts = SpringContext.getBeansOfType(Host.class).values();
|
||||
settingsService = SpringContext.getBean(SettingsService.class);
|
||||
}
|
||||
|
||||
public MultiPostScanResult getScanResult() {
|
||||
return new MultiPostScanResult(posts, error);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startDocument() {
|
||||
}
|
||||
@@ -42,6 +45,9 @@ public class ApiThreadHandler extends DefaultHandler {
|
||||
public void startElement(String uri, String localName, String qName, Attributes attributes) {
|
||||
|
||||
switch (qName.toLowerCase()) {
|
||||
case "error":
|
||||
error = attributes.getValue("details");
|
||||
break;
|
||||
case "thread":
|
||||
threadTitle = attributes.getValue("title").trim();
|
||||
break;
|
||||
+9
-9
@@ -18,11 +18,10 @@ import tn.mnlr.vripper.services.VGAuthService;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import java.io.BufferedInputStream;
|
||||
import java.net.URISyntaxException;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@Slf4j
|
||||
public class ApiThreadParser {
|
||||
public class MultiPostScanParser {
|
||||
|
||||
private static final SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||
private final Queued queued;
|
||||
@@ -30,14 +29,14 @@ public class ApiThreadParser {
|
||||
private final VGAuthService VGAuthService;
|
||||
private final SettingsService settingsService;
|
||||
|
||||
public ApiThreadParser(Queued queued) {
|
||||
public MultiPostScanParser(Queued queued) {
|
||||
this.queued = queued;
|
||||
cm = SpringContext.getBean(ConnectionService.class);
|
||||
VGAuthService = SpringContext.getBean(VGAuthService.class);
|
||||
settingsService = SpringContext.getBean(SettingsService.class);
|
||||
}
|
||||
|
||||
public List<MultiPostItem> parse() throws PostParseException {
|
||||
public MultiPostScanResult parse() throws PostParseException {
|
||||
|
||||
log.debug(String.format("Parsing thread %s", queued));
|
||||
HttpGet httpGet;
|
||||
@@ -49,10 +48,10 @@ public class ApiThreadParser {
|
||||
throw new PostParseException(e);
|
||||
}
|
||||
|
||||
ApiThreadHandler apiThreadHandler = new ApiThreadHandler(queued);
|
||||
MultiPostScanHandler multiPostScanHandler = new MultiPostScanHandler(queued);
|
||||
AtomicReference<Throwable> thr = new AtomicReference<>();
|
||||
log.debug(String.format("Requesting %s", httpGet));
|
||||
List<MultiPostItem> posts = Failsafe.with(cm.getRetryPolicy())
|
||||
MultiPostScanResult multiPostScanResult = Failsafe.with(cm.getRetryPolicy())
|
||||
.onFailure(e -> thr.set(e.getFailure()))
|
||||
.get(() -> {
|
||||
HttpClient connection = cm.getClient().build();
|
||||
@@ -62,8 +61,9 @@ public class ApiThreadParser {
|
||||
}
|
||||
|
||||
try {
|
||||
factory.newSAXParser().parse(new BufferedInputStream(response.getEntity().getContent()), apiThreadHandler);
|
||||
return apiThreadHandler.getPosts();
|
||||
// System.out.println(EntityUtils.toString(response.getEntity()));
|
||||
factory.newSAXParser().parse(new BufferedInputStream(response.getEntity().getContent()), multiPostScanHandler);
|
||||
return multiPostScanHandler.getScanResult();
|
||||
} catch (Exception e) {
|
||||
throw new PostParseException(String.format("Failed to parse thread %s", queued), e);
|
||||
} finally {
|
||||
@@ -75,6 +75,6 @@ public class ApiThreadParser {
|
||||
log.error(String.format("parsing failed for thread %s", queued), thr.get());
|
||||
throw new PostParseException(thr.get());
|
||||
}
|
||||
return posts;
|
||||
return multiPostScanResult;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package tn.mnlr.vripper.services.domain;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
public class MultiPostScanResult {
|
||||
private final List<MultiPostItem> posts;
|
||||
private final String error;
|
||||
|
||||
public MultiPostScanResult(List<MultiPostItem> posts, String error) {
|
||||
this.posts = posts;
|
||||
this.error = error;
|
||||
}
|
||||
}
|
||||
+4
-4
@@ -16,7 +16,7 @@ import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Slf4j
|
||||
class ApiPostHandler extends DefaultHandler {
|
||||
class PostScanHandler extends DefaultHandler {
|
||||
|
||||
private final Collection<Host> supportedHosts;
|
||||
|
||||
@@ -32,7 +32,7 @@ class ApiPostHandler extends DefaultHandler {
|
||||
|
||||
private Post parsedPost;
|
||||
|
||||
ApiPostHandler(String threadId, String postId) {
|
||||
PostScanHandler(String threadId, String postId) {
|
||||
this.threadId = threadId;
|
||||
this.postId = postId;
|
||||
supportedHosts = SpringContext.getBeansOfType(Host.class).values();
|
||||
@@ -41,8 +41,8 @@ class ApiPostHandler extends DefaultHandler {
|
||||
}
|
||||
|
||||
|
||||
public ApiPost getParsedPost() {
|
||||
return new ApiPost(parsedPost, images);
|
||||
public PostScanResult getParsedPost() {
|
||||
return new PostScanResult(parsedPost, images);
|
||||
}
|
||||
|
||||
@Override
|
||||
+8
-8
@@ -19,7 +19,7 @@ import java.net.URISyntaxException;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
@Slf4j
|
||||
public class ApiPostParser {
|
||||
public class PostScanParser {
|
||||
|
||||
private static final SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ApiPostParser {
|
||||
private final VGAuthService VGAuthService;
|
||||
private final SettingsService settingsService;
|
||||
|
||||
public ApiPostParser(String threadId, String postId) {
|
||||
public PostScanParser(String threadId, String postId) {
|
||||
this.threadId = threadId;
|
||||
this.postId = postId;
|
||||
cm = SpringContext.getBean(ConnectionService.class);
|
||||
@@ -37,7 +37,7 @@ public class ApiPostParser {
|
||||
settingsService = SpringContext.getBean(SettingsService.class);
|
||||
}
|
||||
|
||||
public ApiPost parse() throws PostParseException {
|
||||
public PostScanResult parse() throws PostParseException {
|
||||
|
||||
log.debug(String.format("Parsing post %s", postId));
|
||||
HttpGet httpGet;
|
||||
@@ -50,9 +50,9 @@ public class ApiPostParser {
|
||||
}
|
||||
|
||||
AtomicReference<Throwable> thr = new AtomicReference<>();
|
||||
ApiPostHandler apiPostHandler = new ApiPostHandler(threadId, postId);
|
||||
PostScanHandler postScanHandler = new PostScanHandler(threadId, postId);
|
||||
log.debug(String.format("Requesting %s", httpGet));
|
||||
ApiPost post = getPost(httpGet, apiPostHandler, thr);
|
||||
PostScanResult post = getPost(httpGet, postScanHandler, thr);
|
||||
if (thr.get() != null) {
|
||||
log.error(String.format("parsing failed for thread %s, post %s", threadId, postId), thr.get());
|
||||
throw new PostParseException(thr.get());
|
||||
@@ -60,7 +60,7 @@ public class ApiPostParser {
|
||||
return post;
|
||||
}
|
||||
|
||||
private ApiPost getPost(HttpGet httpGet, ApiPostHandler apiPostHandler, AtomicReference<Throwable> thr) {
|
||||
private PostScanResult getPost(HttpGet httpGet, PostScanHandler postScanHandler, AtomicReference<Throwable> thr) {
|
||||
return Failsafe.with(cm.getRetryPolicy())
|
||||
.onFailure(e -> thr.set(e.getFailure()))
|
||||
.get(() -> {
|
||||
@@ -70,9 +70,9 @@ public class ApiPostParser {
|
||||
throw new DownloadException(String.format("Unexpected response code '%d' for %s", response.getStatusLine().getStatusCode(), httpGet));
|
||||
}
|
||||
|
||||
factory.newSAXParser().parse(response.getEntity().getContent(), apiPostHandler);
|
||||
factory.newSAXParser().parse(response.getEntity().getContent(), postScanHandler);
|
||||
EntityUtils.consumeQuietly(response.getEntity());
|
||||
return apiPostHandler.getParsedPost();
|
||||
return postScanHandler.getParsedPost();
|
||||
}
|
||||
});
|
||||
}
|
||||
+2
-2
@@ -7,14 +7,14 @@ import tn.mnlr.vripper.jpa.domain.Post;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
|
||||
public class ApiPost {
|
||||
public class PostScanResult {
|
||||
|
||||
private final Post post;
|
||||
|
||||
@Getter
|
||||
private final Set<Image> images;
|
||||
|
||||
public ApiPost(Post post, Set<Image> images) {
|
||||
public PostScanResult(Post post, Set<Image> images) {
|
||||
this.post = post;
|
||||
this.images = images;
|
||||
}
|
||||
+10
-10
@@ -14,8 +14,8 @@ import tn.mnlr.vripper.services.DataService;
|
||||
import tn.mnlr.vripper.services.MetadataService;
|
||||
import tn.mnlr.vripper.services.SettingsService;
|
||||
import tn.mnlr.vripper.services.VGAuthService;
|
||||
import tn.mnlr.vripper.services.domain.ApiPost;
|
||||
import tn.mnlr.vripper.services.domain.ApiPostParser;
|
||||
import tn.mnlr.vripper.services.domain.PostScanParser;
|
||||
import tn.mnlr.vripper.services.domain.PostScanResult;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Set;
|
||||
@@ -46,7 +46,7 @@ public class AddPostRunnable implements Runnable {
|
||||
this.pendingQueue = SpringContext.getBean(PendingQueue.class);
|
||||
this.VGAuthService = SpringContext.getBean(VGAuthService.class);
|
||||
this.eventRepository = SpringContext.getBean(IEventRepository.class);
|
||||
link = settingsService.getSettings().getVProxy() + String.format("/%s?%s", threadId, (postId != null ? "p=" + postId : ""));
|
||||
link = settingsService.getSettings().getVProxy() + String.format("/threads/%s?%s", threadId, (postId != null ? "p=" + postId : ""));
|
||||
event = new Event(Event.Type.POST, Event.Status.PENDING, LocalDateTime.now(), String.format("Processing %s", link));
|
||||
eventRepository.save(event);
|
||||
}
|
||||
@@ -65,11 +65,11 @@ public class AddPostRunnable implements Runnable {
|
||||
return;
|
||||
}
|
||||
|
||||
ApiPostParser apiPostParser = new ApiPostParser(threadId, postId);
|
||||
PostScanParser postScanParser = new PostScanParser(threadId, postId);
|
||||
|
||||
ApiPost apiPost;
|
||||
PostScanResult postScanResult;
|
||||
try {
|
||||
apiPost = apiPostParser.parse();
|
||||
postScanResult = postScanParser.parse();
|
||||
} catch (PostParseException e) {
|
||||
String error = String.format("parsing failed for gallery %s", link);
|
||||
log.error(error, e);
|
||||
@@ -78,7 +78,7 @@ public class AddPostRunnable implements Runnable {
|
||||
eventRepository.update(event);
|
||||
return;
|
||||
}
|
||||
if (apiPost.getPost().isEmpty()) {
|
||||
if (postScanResult.getPost().isEmpty()) {
|
||||
String error = String.format("Gallery %s contains no galleries", link);
|
||||
log.error(error);
|
||||
event.setMessage(error);
|
||||
@@ -86,7 +86,7 @@ public class AddPostRunnable implements Runnable {
|
||||
eventRepository.update(event);
|
||||
return;
|
||||
}
|
||||
if (apiPost.getImages().isEmpty()) {
|
||||
if (postScanResult.getImages().isEmpty()) {
|
||||
String error = String.format("Gallery %s contains no images to download", link);
|
||||
log.error(error);
|
||||
event.setMessage(error);
|
||||
@@ -95,8 +95,8 @@ public class AddPostRunnable implements Runnable {
|
||||
return;
|
||||
}
|
||||
|
||||
Post post = apiPost.getPost().get();
|
||||
Set<Image> images = apiPost.getImages();
|
||||
Post post = postScanResult.getPost().get();
|
||||
Set<Image> images = postScanResult.getImages();
|
||||
|
||||
dataService.newPost(post, images);
|
||||
|
||||
|
||||
+18
-7
@@ -9,10 +9,9 @@ import tn.mnlr.vripper.jpa.repositories.IEventRepository;
|
||||
import tn.mnlr.vripper.services.DataService;
|
||||
import tn.mnlr.vripper.services.PostService;
|
||||
import tn.mnlr.vripper.services.ThreadPoolService;
|
||||
import tn.mnlr.vripper.services.domain.MultiPostItem;
|
||||
import tn.mnlr.vripper.services.domain.MultiPostScanResult;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
import static tn.mnlr.vripper.jpa.domain.Event.Status.ERROR;
|
||||
import static tn.mnlr.vripper.jpa.domain.Event.Status.PROCESSING;
|
||||
@@ -42,18 +41,30 @@ public class AddQueuedRunnable implements Runnable {
|
||||
try {
|
||||
event.setStatus(PROCESSING);
|
||||
eventRepository.update(event);
|
||||
List<MultiPostItem> multiPostItems = postService.get(queued);
|
||||
if (multiPostItems == null) {
|
||||
MultiPostScanResult multiPostScanResult = postService.get(queued);
|
||||
if (multiPostScanResult == null) {
|
||||
String message = String.format("Fetching multi-post link %s failed", queued.getLink());
|
||||
event.setStatus(ERROR);
|
||||
event.setMessage(message);
|
||||
eventRepository.update(event);
|
||||
return;
|
||||
} else if (multiPostScanResult.getError() != null) {
|
||||
String message = "Nothing found for " + queued.getLink() + "\n" + multiPostScanResult.getError();
|
||||
event.setStatus(ERROR);
|
||||
event.setMessage(message);
|
||||
eventRepository.update(event);
|
||||
return;
|
||||
} else if (multiPostScanResult.getPosts().isEmpty()) {
|
||||
String message = "Nothing found for " + queued.getLink();
|
||||
event.setStatus(ERROR);
|
||||
event.setMessage(message);
|
||||
eventRepository.update(event);
|
||||
return;
|
||||
}
|
||||
queued.setTotal(multiPostItems.size());
|
||||
queued.setTotal(multiPostScanResult.getPosts().size());
|
||||
queued.done();
|
||||
if (multiPostItems.size() == 1) {
|
||||
threadPoolService.getGeneralExecutor().submit(new AddPostRunnable(multiPostItems.get(0).getPostId(), multiPostItems.get(0).getThreadId()));
|
||||
if (multiPostScanResult.getPosts().size() == 1) {
|
||||
threadPoolService.getGeneralExecutor().submit(new AddPostRunnable(multiPostScanResult.getPosts().get(0).getPostId(), multiPostScanResult.getPosts().get(0).getThreadId()));
|
||||
event.setStatus(Event.Status.DONE);
|
||||
event.setMessage(String.format("Link %s is added to download queue", queued.getLink()));
|
||||
} else {
|
||||
|
||||
+4
-4
@@ -53,25 +53,25 @@ public class LeaveThanksRunnable implements Runnable {
|
||||
event.setStatus(Event.Status.PROCESSING);
|
||||
eventRepository.update(event);
|
||||
if (!settingsService.getSettings().getVLogin()) {
|
||||
event.setMessage(String.format("Will not leave a thanks for %s\nAuthentication with ViperGirls option is disabled", post.getUrl()));
|
||||
event.setMessage(String.format("Will not send a like for %s\nAuthentication with ViperGirls option is disabled", post.getUrl()));
|
||||
event.setStatus(Event.Status.DONE);
|
||||
eventRepository.update(event);
|
||||
return;
|
||||
}
|
||||
if (!settingsService.getSettings().getVThanks()) {
|
||||
event.setMessage(String.format("Will not leave a thanks for %s\nLeave thanks option is disabled", post.getUrl()));
|
||||
event.setMessage(String.format("Will not send a like for %s\nLeave thanks option is disabled", post.getUrl()));
|
||||
event.setStatus(Event.Status.DONE);
|
||||
eventRepository.update(event);
|
||||
return;
|
||||
}
|
||||
if (!authenticated) {
|
||||
event.setMessage(String.format("Will not leave a thanks for %s\nYou are not authenticated", post.getUrl()));
|
||||
event.setMessage(String.format("Will not send a like for %s\nYou are not authenticated", post.getUrl()));
|
||||
event.setStatus(Event.Status.ERROR);
|
||||
eventRepository.update(event);
|
||||
return;
|
||||
}
|
||||
if (post.isThanked()) {
|
||||
event.setMessage(String.format("Will not leave a thanks for %s\nAlready left a thanks", post.getUrl()));
|
||||
event.setMessage(String.format("Will not send a like for %s\nAlready left a thanks", post.getUrl()));
|
||||
event.setStatus(Event.Status.DONE);
|
||||
eventRepository.update(event);
|
||||
return;
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ public class LinkScanRunnable implements Runnable {
|
||||
settingsService = SpringContext.getBean(SettingsService.class);
|
||||
postService = SpringContext.getBean(PostService.class);
|
||||
eventRepository = SpringContext.getBean(EventRepository.class);
|
||||
event = new Event(Event.Type.SCAN, Event.Status.PENDING, LocalDateTime.now(), "Links scan:\n\t" + String.join("\n\t", urlList));
|
||||
event = new Event(Event.Type.SCAN, Event.Status.PENDING, LocalDateTime.now(), "Links to scan:\n\t" + String.join("\n\t", urlList));
|
||||
eventRepository.save(event);
|
||||
}
|
||||
|
||||
|
||||
+17
-11
@@ -9,8 +9,12 @@ import tn.mnlr.vripper.download.DownloadService;
|
||||
import tn.mnlr.vripper.jpa.domain.Metadata;
|
||||
import tn.mnlr.vripper.jpa.domain.Post;
|
||||
import tn.mnlr.vripper.jpa.domain.Queued;
|
||||
import tn.mnlr.vripper.services.*;
|
||||
import tn.mnlr.vripper.services.DataService;
|
||||
import tn.mnlr.vripper.services.PathService;
|
||||
import tn.mnlr.vripper.services.PostService;
|
||||
import tn.mnlr.vripper.services.ThreadPoolService;
|
||||
import tn.mnlr.vripper.services.domain.MultiPostItem;
|
||||
import tn.mnlr.vripper.services.domain.MultiPostScanResult;
|
||||
import tn.mnlr.vripper.services.domain.tasks.AddPostRunnable;
|
||||
import tn.mnlr.vripper.services.domain.tasks.LinkScanRunnable;
|
||||
import tn.mnlr.vripper.web.restendpoints.domain.*;
|
||||
@@ -35,16 +39,14 @@ public class PostRestEndpoint {
|
||||
private final DownloadService downloadService;
|
||||
private final PostService postService;
|
||||
private final ThreadPoolService threadPoolService;
|
||||
private final SettingsService settingsService;
|
||||
|
||||
@Autowired
|
||||
public PostRestEndpoint(DataService dataService, PathService pathService, DownloadService downloadService, PostService postService, ThreadPoolService threadPoolService, SettingsService settingsService) {
|
||||
public PostRestEndpoint(DataService dataService, PathService pathService, DownloadService downloadService, PostService postService, ThreadPoolService threadPoolService) {
|
||||
this.dataService = dataService;
|
||||
this.pathService = pathService;
|
||||
this.downloadService = downloadService;
|
||||
this.postService = postService;
|
||||
this.threadPoolService = threadPoolService;
|
||||
this.settingsService = settingsService;
|
||||
}
|
||||
|
||||
@PostMapping("/post")
|
||||
@@ -204,13 +206,17 @@ public class PostRestEndpoint {
|
||||
@ResponseStatus(value = HttpStatus.OK)
|
||||
public List<MultiPostItem> grab(@PathVariable("threadId") @NonNull String threadId) {
|
||||
synchronized (LOCK) {
|
||||
Queued queued = dataService.findQueuedByThreadId(threadId).orElseThrow(() -> new NotFoundException(String.format("Unable to find links for threadId = %s", threadId)));
|
||||
List<MultiPostItem> multiPostItems = postService.get(queued);
|
||||
if (multiPostItems == null) {
|
||||
log.error(String.format("Failed to get links for threadId = %s", threadId));
|
||||
throw new ServerErrorException(String.format("Failed to get links for threadId = %s", threadId));
|
||||
} else {
|
||||
return multiPostItems;
|
||||
try {
|
||||
Queued queued = dataService.findQueuedByThreadId(threadId).orElseThrow(() -> new NotFoundException(String.format("Unable to find links for threadId = %s", threadId)));
|
||||
MultiPostScanResult multiPostScanResult = postService.get(queued);
|
||||
if (multiPostScanResult == null) {
|
||||
log.error(String.format("Failed to get links for threadId = %s", threadId));
|
||||
throw new ServerErrorException(String.format("Failed to get links for threadId = %s", threadId));
|
||||
} else {
|
||||
return multiPostScanResult.getPosts();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServerErrorException(String.format("Failed to get links for threadId = %s, %s", threadId, e.getMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Generated
-13960
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "vripper-ui",
|
||||
"version": "3.3.2",
|
||||
"version": "3.3.4",
|
||||
"scripts": {
|
||||
"ng": "ng",
|
||||
"start": "ng serve",
|
||||
|
||||
+19
-21
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<groupId>tn.mnlr</groupId>
|
||||
<artifactId>vripper</artifactId>
|
||||
<version>3.3.2</version>
|
||||
<version>3.3.4</version>
|
||||
</parent>
|
||||
<artifactId>vripper-ui</artifactId>
|
||||
<name>vripper-ui</name>
|
||||
@@ -33,34 +33,33 @@
|
||||
<plugin>
|
||||
<groupId>com.github.eirslett</groupId>
|
||||
<artifactId>frontend-maven-plugin</artifactId>
|
||||
<version>1.3</version>
|
||||
<version>1.11.2</version>
|
||||
<configuration>
|
||||
<nodeVersion>v12.2.0</nodeVersion>
|
||||
<npmVersion>6.9.0</npmVersion>
|
||||
<nodeVersion>v14.16.0</nodeVersion>
|
||||
<yarnVersion>v1.22.10</yarnVersion>
|
||||
<workingDirectory>build-dir</workingDirectory>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>install node and npm</id>
|
||||
<id>install node and yarn</id>
|
||||
<goals>
|
||||
<goal>install-node-and-npm</goal>
|
||||
<goal>install-node-and-yarn</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>npm install</id>
|
||||
<id>yarn install</id>
|
||||
<goals>
|
||||
<goal>npm</goal>
|
||||
<goal>yarn</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>npm run build</id>
|
||||
<id>yarn run build</id>
|
||||
<goals>
|
||||
<goal>npm</goal>
|
||||
<goal>yarn</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<arguments>run build-web</arguments>
|
||||
</configuration>
|
||||
<phase>generate-resources</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
@@ -77,34 +76,33 @@
|
||||
<plugin>
|
||||
<groupId>com.github.eirslett</groupId>
|
||||
<artifactId>frontend-maven-plugin</artifactId>
|
||||
<version>1.3</version>
|
||||
<version>1.11.2</version>
|
||||
<configuration>
|
||||
<nodeVersion>v12.2.0</nodeVersion>
|
||||
<npmVersion>6.9.0</npmVersion>
|
||||
<nodeVersion>v14.16.0</nodeVersion>
|
||||
<yarnVersion>v1.22.10</yarnVersion>
|
||||
<workingDirectory>build-dir</workingDirectory>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>install node and npm</id>
|
||||
<id>install node and yarn</id>
|
||||
<goals>
|
||||
<goal>install-node-and-npm</goal>
|
||||
<goal>install-node-and-yarn</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>npm install</id>
|
||||
<id>yarn install</id>
|
||||
<goals>
|
||||
<goal>npm</goal>
|
||||
<goal>yarn</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>npm run build</id>
|
||||
<id>yarn run build</id>
|
||||
<goals>
|
||||
<goal>npm</goal>
|
||||
<goal>yarn</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<arguments>run build-electron</arguments>
|
||||
</configuration>
|
||||
<phase>generate-resources</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
@@ -161,16 +161,17 @@
|
||||
</mat-form-field>
|
||||
|
||||
<section class="input">
|
||||
<mat-checkbox color="primary" formControlName="vThanks" name="vThanks">Leave thanks</mat-checkbox>
|
||||
<mat-icon matTooltip="Automatically leave a thanks to the poster"
|
||||
<mat-checkbox color="primary" formControlName="vThanks" name="vThanks">Send a like to poster
|
||||
</mat-checkbox>
|
||||
<mat-icon matTooltip="Automatically send a like to the poster"
|
||||
svgIcon="help-circle-outline"></mat-icon>
|
||||
</section>
|
||||
<section class="input">
|
||||
<mat-checkbox color="primary" formControlName="leaveThanksOnStart" name="leaveThanksOnStart">Leave
|
||||
thanks when download starts
|
||||
<mat-checkbox color="primary" formControlName="leaveThanksOnStart" name="leaveThanksOnStart">Send a like
|
||||
when download starts
|
||||
</mat-checkbox>
|
||||
<mat-icon
|
||||
matTooltip="Leave a thanks only when the download starts, if unchecked, leave a thanks once a gallery is added to the download queue"
|
||||
matTooltip="Send a like only when the download starts, if unchecked, send a like once a gallery is added to the download queue"
|
||||
svgIcon="help-circle-outline"></mat-icon>
|
||||
</section>
|
||||
</section>
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import {finalize} from 'rxjs/operators';
|
||||
import {AppService} from '../services/app.service';
|
||||
import {ClipboardService} from '../services/clipboard.service';
|
||||
import {ChangeDetectionStrategy, Component, NgZone, OnInit} from '@angular/core';
|
||||
import {ChangeDetectionStrategy, Component, NgZone, OnDestroy, OnInit} from '@angular/core';
|
||||
import {HttpClient} from '@angular/common/http';
|
||||
import {FormControl, FormGroup} from '@angular/forms';
|
||||
import {MatSnackBar} from '@angular/material/snack-bar';
|
||||
import {ServerService} from '../services/server-service';
|
||||
import {ElectronService} from 'ngx-electron';
|
||||
import {Settings} from '../domain/settings.model';
|
||||
import {EMPTY, Observable} from 'rxjs';
|
||||
import {EMPTY, Observable, Subscription} from 'rxjs';
|
||||
import OpenDialogReturnValue = Electron.OpenDialogReturnValue;
|
||||
|
||||
@Component({
|
||||
@@ -17,12 +17,14 @@ import OpenDialogReturnValue = Electron.OpenDialogReturnValue;
|
||||
styleUrls: ['./settings.component.scss'],
|
||||
changeDetection: ChangeDetectionStrategy.OnPush
|
||||
})
|
||||
export class SettingsComponent implements OnInit {
|
||||
export class SettingsComponent implements OnInit, OnDestroy {
|
||||
loading = false;
|
||||
darkTheme = false;
|
||||
|
||||
mirrors: Observable<string[]> = EMPTY;
|
||||
|
||||
subscriptions: Subscription[] = [];
|
||||
|
||||
viperGirlsSettingsForm = new FormGroup({
|
||||
vLogin: new FormControl(false),
|
||||
vUsername: new FormControl(''),
|
||||
@@ -66,6 +68,15 @@ export class SettingsComponent implements OnInit {
|
||||
private appService: AppService,
|
||||
private zone: NgZone
|
||||
) {
|
||||
this.subscriptions.push(this.viperGirlsSettingsForm.get('vThanks').valueChanges.subscribe(c => {
|
||||
const formControl: FormControl = this.viperGirlsSettingsForm.get('leaveThanksOnStart') as FormControl;
|
||||
if (!c) {
|
||||
formControl.setValue(false);
|
||||
formControl.disable();
|
||||
} else {
|
||||
formControl.enable();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
updateTheme() {
|
||||
@@ -93,6 +104,10 @@ export class SettingsComponent implements OnInit {
|
||||
});
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.subscriptions.forEach(s => s.unsubscribe());
|
||||
}
|
||||
|
||||
browse() {
|
||||
this.electronService.remote.dialog
|
||||
.showOpenDialog(this.electronService.remote.getCurrentWindow(), {
|
||||
|
||||
@@ -2,5 +2,5 @@ export const environment = {
|
||||
production: true,
|
||||
localhost: `${window.location.protocol}//${window.location.host}`,
|
||||
ws: `${window.location.protocol === 'http:' ? 'ws:' : 'wss:'}//${window.location.host}`,
|
||||
version: '3.3.2'
|
||||
version: '3.3.4'
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@ export const environment = {
|
||||
production: false,
|
||||
localhost: 'http://localhost:8080',
|
||||
ws: 'ws://localhost:8080',
|
||||
version: '3.3.2'
|
||||
version: '3.3.4'
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user