Compare commits

...
2 Commits
Author SHA1 Message Date
death-claw eeb24ae7c1 v1.4.8 2019-08-13 14:39:41 +01:00
death-claw 9b9c5ac5c8 Add option to force image ordering 2019-08-13 14:34:46 +01:00
18 changed files with 46 additions and 22 deletions
+4
View File
@@ -1,5 +1,9 @@
# Changelog
## [1.4.8] - 2019-08-13
### Changed
- Add option to force image ordering
## [1.4.7] - 2019-08-13
### Changed
- Fixed a bug in image filename extensions
+1 -1
View File
@@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>tn.mnlr</groupId>
<artifactId>vripper</artifactId>
<version>1.4.7</version>
<version>1.4.8</version>
<packaging>pom</packaging>
<parent>
<groupId>org.springframework.boot</groupId>
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "vripper-electron",
"version": "1.4.7",
"version": "1.4.8",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "vripper-electron",
"version": "1.4.7",
"version": "1.4.8",
"description": "",
"main": "main.js",
"author": "",
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>tn.mnlr</groupId>
<artifactId>vripper</artifactId>
<version>1.4.7</version>
<version>1.4.8</version>
</parent>
<artifactId>vripper-electron</artifactId>
<name>vripper-electron</name>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>tn.mnlr</groupId>
<artifactId>vripper</artifactId>
<version>1.4.7</version>
<version>1.4.8</version>
</parent>
<artifactId>vripper-server</artifactId>
<name>vripper-server</name>
@@ -9,7 +9,6 @@ import tn.mnlr.vripper.host.Host;
import tn.mnlr.vripper.services.AppStateService;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicLong;
@Getter
@@ -30,6 +29,8 @@ public class Image {
private String url;
private int index;
private AtomicLong current = new AtomicLong(0);
private Status status;
private BehaviorProcessor<Image> imageStateProcessor;
@@ -37,12 +38,13 @@ public class Image {
@Setter
private long total = 0;
public Image(String url, String postId, String postName, Host host, AppStateService appStateService) {
public Image(String url, String postId, String postName, Host host, AppStateService appStateService, int index) {
this.url = url;
this.postId = postId;
this.postName = postName;
this.host = host;
this.appStateService = appStateService;
this.index = index;
status = Status.PENDING;
imageStateProcessor = BehaviorProcessor.create();
appStateService.getCurrentImages().put(this.url, this);
@@ -112,7 +112,7 @@ abstract public class Host {
downloadSpeedService.increase(read);
}
EntityUtils.consumeQuietly(response.getEntity());
checkImageTypeAndRename(outputFile, imageFileData.getImageName());
checkImageTypeAndRename(outputFile, imageFileData.getImageName(), image.getIndex());
}
}
} catch (Exception e) {
@@ -123,9 +123,8 @@ abstract public class Host {
}
}
private void checkImageTypeAndRename(File outputFile, String imageName) throws HostException {
try {
ImageInputStream iis = ImageIO.createImageInputStream(outputFile);
private void checkImageTypeAndRename(File outputFile, String imageName, int index) throws HostException {
try (ImageInputStream iis = ImageIO.createImageInputStream(outputFile)) {
Iterator<ImageReader> it = ImageIO.getImageReaders(iis);
if (!it.hasNext()) {
throw new HostException("Image file is not recognized!");
@@ -133,9 +132,9 @@ abstract public class Host {
ImageReader reader = it.next();
String formatName = reader.getFormatName();
if (formatName.toUpperCase().equals("JPEG")) {
formatName = "JPG";
formatName = "jpg";
}
String outImageName = imageName + "." + formatName.toUpperCase();
String outImageName = (appSettingsService.isForceOrder() ? String.format("%03d_", index) : "") + imageName + "." + formatName.toLowerCase();
outputFile.renameTo(new File(outputFile.getParent(), outImageName));
} catch (Exception e) {
throw new HostException("Failed to rename output file", e);
@@ -34,6 +34,7 @@ public class AppSettingsService {
private final String V_PASSWORD = "VPASSWORD";
private final String V_THANKS = "VTHANKS";
private final String DESKTOP_CLIPBOARD = "DESKTOP_CLIPBOARD";
private final String FORCE_ORDER = "FORCE_ORDER";
private String downloadPath;
private int maxThreads;
@@ -43,6 +44,7 @@ public class AppSettingsService {
private String vPassword;
private boolean vThanks;
private boolean desktopClipboard;
private boolean forceOrder;
public void setVPassword(String vPassword) {
if(vPassword.isEmpty()) {
@@ -62,6 +64,7 @@ public class AppSettingsService {
vPassword = prefs.get(V_PASSWORD, "");
vThanks = prefs.getBoolean(V_THANKS, false);
desktopClipboard = prefs.getBoolean(DESKTOP_CLIPBOARD, false);
forceOrder = prefs.getBoolean(FORCE_ORDER, false);
}
@PreDestroy
@@ -75,6 +78,7 @@ public class AppSettingsService {
prefs.put(V_PASSWORD, vPassword);
prefs.putBoolean(V_THANKS, vThanks);
prefs.putBoolean(DESKTOP_CLIPBOARD, desktopClipboard);
prefs.putBoolean(FORCE_ORDER, forceOrder);
try {
prefs.sync();
@@ -121,8 +125,10 @@ public class AppSettingsService {
private boolean vThanks;
@JsonProperty("desktopClipboard")
private boolean desktopClipboard;
@JsonProperty("forceOrder")
private boolean forceOrder;
public Settings(String downloadPath, int maxThreads, boolean autoStart, boolean vLogin, String vUsername, String vPassword, boolean vThanks, boolean desktopClipboard) {
public Settings(String downloadPath, int maxThreads, boolean autoStart, boolean vLogin, String vUsername, String vPassword, boolean vThanks, boolean desktopClipboard, boolean forceOrder) {
this.downloadPath = downloadPath;
this.maxThreads = maxThreads;
this.autoStart = autoStart;
@@ -131,6 +137,7 @@ public class AppSettingsService {
this.vPassword = vPassword;
this.vThanks = vThanks;
this.desktopClipboard = desktopClipboard;
this.forceOrder = forceOrder;
}
}
}
@@ -45,8 +45,8 @@ public class AppStateService {
}
}
public Image createImage(String pageUrl, String postId, String postName, Host host) {
return new Image(pageUrl, postId, postName, host, this);
public Image createImage(String pageUrl, String postId, String postName, Host host, int index) {
return new Image(pageUrl, postId, postName, host, this, index);
}
public Post createPost(String title, String url, List<Image> images, Map<String, String> metadata, String postId, String postCounter) {
@@ -180,7 +180,7 @@ public class PostParser {
}
if (foundHost != null) {
logger.info(String.format("Found supported host %s for %s", foundHost.getClass().getSimpleName(), imageHref));
imagesList.add(appStateService.createImage(imageHref.getTextContent(), postId, postTitle, foundHost));
imagesList.add(appStateService.createImage(imageHref.getTextContent(), postId, postTitle, foundHost, imagesList.size() + 1));
} else {
logger.warn(String.format("unsupported host for %s, skipping", imageHref));
continue;
@@ -7,8 +7,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;
import tn.mnlr.vripper.services.AppSettingsService;
import tn.mnlr.vripper.exception.ValidationException;
import tn.mnlr.vripper.services.AppSettingsService;
import tn.mnlr.vripper.services.VipergirlsAuthService;
@RestController
@@ -57,6 +57,7 @@ public class SettingsRestEndpoint {
this.settings.setVThanks(false);
}
this.settings.setDesktopClipboard(settings.isDesktopClipboard());
this.settings.setForceOrder(settings.isForceOrder());
this.settings.save();
@@ -76,7 +77,8 @@ public class SettingsRestEndpoint {
settings.getVUsername(),
settings.getVPassword(),
settings.isVThanks(),
settings.isDesktopClipboard()
settings.isDesktopClipboard(),
settings.isForceOrder()
);
}
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "vripper-ui",
"version": "1.4.7",
"version": "1.4.8",
"lockfileVersion": 1,
"requires": true,
"dependencies": {
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "vripper-ui",
"version": "1.4.7",
"version": "1.4.8",
"scripts": {
"ng": "ng",
"start": "ng serve",
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<groupId>tn.mnlr</groupId>
<artifactId>vripper</artifactId>
<version>1.4.7</version>
<version>1.4.8</version>
</parent>
<artifactId>vripper-ui</artifactId>
<name>vripper-ui</name>
@@ -35,6 +35,11 @@
/>
</mat-form-field>
<mat-checkbox color="primary" formControlName="forceOrder" name="forceOrder"
>Force image ordering (prepend incremental numbers)
</mat-checkbox
>
<mat-checkbox color="primary" formControlName="autoStart" name="autoStart"
>Auto start downloads</mat-checkbox
>
@@ -18,3 +18,7 @@
.container form section div > * {
width: 100%;
}
mat-checkbox {
display: block;
}
@@ -25,6 +25,7 @@ export class SettingsComponent implements OnInit {
downloadPath: new FormControl(''),
maxThreads: new FormControl(''),
autoStart: new FormControl(false),
forceOrder: new FormControl(false),
vLogin: new FormControl(false),
vUsername: new FormControl(''),
vPassword: new FormControl(''),