mirror of
https://github.com/jlengrand/RemarkablePocket.git
synced 2026-03-10 08:41:19 +00:00
Temporary fix
This commit is contained in:
@@ -52,7 +52,7 @@ from https://docs.docker.com/get-docker/. Then run the following command to star
|
||||
have not tested it on Windows yet):
|
||||
|
||||
```
|
||||
touch ~/.remarkable-pocket ~/.rmapi && mkdir -p ~/.rmapi-cache && docker run -it --env TZ=Europe/Amsterdam -p 65112:65112 -v ~/.remarkable-pocket:/root/.remarkable-pocket -v ~/.rmapi:/root/.rmapi -v ~/.rmapi-cache:/root/.cache/rmapi ghcr.io/nov1n/remarkable-pocket:0.2.1
|
||||
touch ~/.remarkable-pocket ~/.rmapi && mkdir -p ~/.rmapi-cache && docker run -it --env TZ=Europe/Amsterdam -p 65112:65112 -v ~/.remarkable-pocket:/root/.remarkable-pocket -v ~/.rmapi:/root/.rmapi -v ~/.rmapi-cache:/root/.cache/rmapi ghcr.io/nov1n/remarkable-pocket:0.2.2
|
||||
```
|
||||
|
||||
The first time you run the application, you will be asked to authorize Pocket and Remarkable Cloud. Once you have done
|
||||
|
||||
@@ -2,7 +2,7 @@ version: '3'
|
||||
|
||||
services:
|
||||
remarkable-pocket:
|
||||
image: ghcr.io/nov1n/remarkable-pocket:0.2.1
|
||||
image: ghcr.io/nov1n/remarkable-pocket:0.2.2
|
||||
restart: always
|
||||
ports:
|
||||
- 65112:65112
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<array>
|
||||
<string>/bin/sh</string>
|
||||
<string>-c</string>
|
||||
<string>while ! /usr/local/bin/docker version > /dev/null 2>&1; do sleep 5; done && /usr/local/bin/docker run --env TZ=Europe/Amsterdam -v ~/.remarkable-pocket:/root/.remarkable-pocket -v ~/.rmapi:/root/.rmapi -v ~/.rmapi-cache:/root/.cache/rmapi ghcr.io/nov1n/remarkable-pocket:0.2.1 1>>$HOME/.remarkable-pocket.log 2>&1</string>
|
||||
<string>while ! /usr/local/bin/docker version > /dev/null 2>&1; do sleep 5; done && /usr/local/bin/docker run --env TZ=Europe/Amsterdam -v ~/.remarkable-pocket:/root/.remarkable-pocket -v ~/.rmapi:/root/.rmapi -v ~/.rmapi-cache:/root/.cache/rmapi ghcr.io/nov1n/remarkable-pocket:0.2.2 1>>$HOME/.remarkable-pocket.log 2>&1</string>
|
||||
</array>
|
||||
<key>RunAtLoad</key>
|
||||
<true/>
|
||||
|
||||
@@ -58,22 +58,26 @@ final class MetadataProvider {
|
||||
|
||||
DocumentMetadata getMetadata(String name) {
|
||||
LOG.debug("Getting metadata for document: {}.", name);
|
||||
ZipFile zip;
|
||||
try {
|
||||
zip = new ZipFile(rmapi.download(name, workDir.toString()));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
String fileHash = zip.entries().nextElement().getName().split("\\.")[0];
|
||||
|
||||
try (InputStream lines = zip.getInputStream(zip.getEntry(fileHash + ".content"));
|
||||
InputStream epub = zip.getInputStream(zip.getEntry(fileHash + ".epub"))) {
|
||||
int pageCount = objectMapper.readValue(lines, Lines.class).pageCount();
|
||||
String pocketId = extractPocketId(epub);
|
||||
return new DocumentMetadata(rmapi.info(name), pageCount, pocketId);
|
||||
} catch (IOException | SAXException | XPathExpressionException e) {
|
||||
throw new RuntimeException(e);
|
||||
try (ZipFile zip = new ZipFile(rmapi.download(name, workDir.toString()))) {
|
||||
String fileHash = zip.entries().nextElement().getName().split("\\.")[0];
|
||||
if (zip.getEntry(fileHash + ".pdf") != null) {
|
||||
// In this case the article was converted to pdf because Remarkable
|
||||
// couldn't read the epub file. This means we lost the metadata,
|
||||
// so we delete it.
|
||||
return null;
|
||||
}
|
||||
try (InputStream linesStream = zip.getInputStream(zip.getEntry(fileHash + ".content"));
|
||||
InputStream epubStream = zip.getInputStream(zip.getEntry(fileHash + ".epub"))) {
|
||||
int pageCount = objectMapper.readValue(linesStream, Lines.class).pageCount();
|
||||
String pocketId = extractPocketId(epubStream);
|
||||
return new DocumentMetadata(rmapi.info(name), pageCount, pocketId);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
LOG.info(
|
||||
"Article '{}' is corrupted. Deleting file and retrieving new article in next sync.",
|
||||
name);
|
||||
rmapi.delete(name);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ import static com.google.common.base.Preconditions.checkArgument;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import javax.annotation.PostConstruct;
|
||||
import nl.carosi.remarkablepocket.model.DocumentMetadata;
|
||||
import org.slf4j.Logger;
|
||||
@@ -43,6 +44,7 @@ final class RemarkableService {
|
||||
List<DocumentMetadata> listReadDocuments() {
|
||||
return rmapi.list().stream()
|
||||
.map(metadataProvider::getMetadata)
|
||||
.filter(Objects::nonNull)
|
||||
.peek(this::logPages)
|
||||
// Current page starts counting at 0.
|
||||
.filter(e -> e.doc().currentPage() + 1 == e.pageCount())
|
||||
|
||||
@@ -19,7 +19,7 @@ import picocli.CommandLine.Option;
|
||||
sortOptions = false,
|
||||
usageHelpAutoWidth = true,
|
||||
// TODO: Read from gradle.properties
|
||||
version = "0.2.1",
|
||||
version = "0.2.2",
|
||||
mixinStandardHelpOptions = true)
|
||||
class SyncCommand implements Callable<Integer> {
|
||||
@Option(
|
||||
|
||||
Binary file not shown.
Reference in New Issue
Block a user