Compare commits
236 commits
Author | SHA1 | Date | |
---|---|---|---|
041590a559 | |||
d6f883f890 | |||
b07420e0bd | |||
0fc71f0a7d | |||
2ae6468ad8 | |||
2ecfe88cb9 | |||
7dcc7bfee2 | |||
94d8a4e673 | |||
1b585eab7e | |||
b6f5c38e4a | |||
5d708bdb82 | |||
6a8c1662f0 | |||
e02cd900ed | |||
32ea83a7bb | |||
4297860b9e | |||
affe62b973 | |||
6520cc65a3 | |||
aefceda628 | |||
ee5a159431 | |||
85f8b97607 | |||
966dd8f359 | |||
17e161bc27 | |||
3928367692 | |||
070eae961a | |||
92103e28ba | |||
cd78d3c1c7 | |||
22bbaaa002 | |||
9ee9db5792 | |||
23ac0de189 | |||
2dc695577e | |||
534a8022a9 | |||
45bfca8cc5 | |||
34b3bb45c5 | |||
3e78ce5bf6 | |||
fc4ce74567 | |||
85f3044224 | |||
d50bf01db6 | |||
c8d7053b87 | |||
962d90fe1d | |||
36b59240d9 | |||
1cd30b1145 | |||
167fcdb7ad | |||
b9a26a7b1c | |||
e5862ba0ec | |||
6bd7369ecc | |||
ba3110da0e | |||
0e88326293 | |||
a0ff81d582 | |||
2d65a12781 | |||
bed8881d70 | |||
bb98a6bfce | |||
7a6ebd6381 | |||
d0375b1d8d | |||
75d479b4e2 | |||
5e565df7c0 | |||
8c1da63e0c | |||
8be74585a0 | |||
c3ff578c57 | |||
cbb50e5d53 | |||
f08e60a89d | |||
0f1de67db6 | |||
9c15ea791f | |||
4a4dff8c22 | |||
c355bc141f | |||
1db4cb19bd | |||
e4e1767083 | |||
f2730a8eaf | |||
89b2d19c80 | |||
c0bff03120 | |||
ecc05a2812 | |||
9cca302018 | |||
a66180d817 | |||
b8a5ca2b95 | |||
295a7b95a1 | |||
81c51e52cd | |||
7a4f075b58 | |||
855988e947 | |||
c5f28890a8 | |||
1ebedb3eb2 | |||
80aa007857 | |||
e1a85fbc31 | |||
94b8ec6d2c | |||
4a4980e38b | |||
f7c4aa395c | |||
8d75aaa4f7 | |||
654bc5c7f8 | |||
3ecd434580 | |||
e1fe276fa7 | |||
9771b75b94 | |||
c85f761e85 | |||
2531af3739 | |||
f22e2d6278 | |||
b94aecefe2 | |||
f32e7d6ee5 | |||
db88d475dd | |||
8ee5da5d53 | |||
1503628491 | |||
c6297b9157 | |||
1f10a39db1 | |||
5c59437595 | |||
1f0c42bfdb | |||
5084da92fb | |||
9fa940f385 | |||
f0e1bca08e | |||
b14d37e01c | |||
51d3cef75f | |||
57c9891d9b | |||
6e5d8d27fd | |||
1e6e431a56 | |||
67e02e79fd | |||
173a93280e | |||
5ba963305c | |||
080b0bf4d8 | |||
2069345e9e | |||
469d5b5a2b | |||
4cb22e630e | |||
4f61905ba7 | |||
0d8ecb2a55 | |||
b218773148 | |||
608a3bbdeb | |||
3badff94ec | |||
2f428470e1 | |||
c9998cad57 | |||
0c6ae1fcb0 | |||
47e6cc59c0 | |||
bba7fae8b9 | |||
b10455a30f | |||
40e142ccc7 | |||
079e9f5e11 | |||
f0da95ffae | |||
7cd56e530d | |||
6cfdf3e085 | |||
d3d61f6602 | |||
9a26d2821f | |||
a7354f1939 | |||
69aedda7a1 | |||
966847f788 | |||
3675495d5f | |||
5ddb6b3b75 | |||
dd11620ffa | |||
da9505cd61 | |||
d32e1001a1 | |||
8683282182 | |||
955592ac41 | |||
de435e00cf | |||
7b712727bd | |||
e7bbe9cf03 | |||
dd2cde35e4 | |||
6187fa1230 | |||
30e5fcbf72 | |||
b128f243fc | |||
7ea596760e | |||
de542aa9b2 | |||
09cf07a25a | |||
3dff75922d | |||
8d1e9c3d03 | |||
9ff6661a59 | |||
4e7331f0b7 | |||
7a5198bf56 | |||
9599a2070d | |||
ff2b443005 | |||
2e8dfe9327 | |||
97c3ab5fc6 | |||
02c1ba7b83 | |||
2a24ac1ec1 | |||
ec565523b3 | |||
0d99cffb34 | |||
1b922e4d37 | |||
461066fdff | |||
222b59c9d2 | |||
ba78bca3ab | |||
d0dccfe946 | |||
5ea18fa900 | |||
82efecded4 | |||
d28be84001 | |||
2b90bf3438 | |||
195f88e297 | |||
8d703347df | |||
92a26a798b | |||
732b210b58 | |||
9f20630511 | |||
3097c7cf90 | |||
a3a4efb2d9 | |||
621975df0f | |||
66449c732a | |||
622e30caa5 | |||
c170618df9 | |||
3d2510162a | |||
807821c195 | |||
83dd012fee | |||
9274ab9972 | |||
c7f1988cc2 | |||
a0d414a091 | |||
ba052a29b5 | |||
c62cd1e285 | |||
594d3e08fe | |||
1a2a489e48 | |||
a12bca1f38 | |||
9d99bc32ee | |||
a17de20b2b | |||
19c41eff6b | |||
dd1fbb77c6 | |||
211b44978a | |||
8b3e6a8380 | |||
a549c89c33 | |||
8c58088321 | |||
7f717d30b7 | |||
17d375a5dc | |||
1c619f1b97 | |||
4109efc3c3 | |||
767f9652dd | |||
0159724a7c | |||
1ee425352d | |||
e7f971ccd8 | |||
9d79508687 | |||
210ca895db | |||
d31f291e26 | |||
355040b9a0 | |||
8cc16a675b | |||
890e6baef5 | |||
5740d83d11 | |||
813f661ee2 | |||
cf82a4535b | |||
08786bdd69 | |||
649d575324 | |||
054433053b | |||
a366ba9ca1 | |||
a36115d6e6 | |||
f20dbe247c | |||
06b90cb5bf | |||
007570c2e3 | |||
877c7ef324 | |||
5e95d2b62c | |||
|
4e9a2075f5 | ||
63652ca090 | |||
8c7ec97637 |
20 changed files with 3545 additions and 1524 deletions
146
.forgejo/workflows/build+release.yml
Normal file
146
.forgejo/workflows/build+release.yml
Normal file
|
@ -0,0 +1,146 @@
|
||||||
|
name: 'Build and Release Binary File'
|
||||||
|
author: 'Neshura'
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- '[0-9]+.[0-9]+.[0-9]+'
|
||||||
|
- '[0-9]+.[0-9]+.[0-9]+-rc.[0-9]+'
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: docker
|
||||||
|
container: forgejo.neshweb.net/ci-docker-images/rust-node:latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Add Clippy
|
||||||
|
run: rustup component add clippy
|
||||||
|
-
|
||||||
|
name: Checking Out Repository Code
|
||||||
|
uses: https://code.forgejo.org/actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set Up Cargo Cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo/bin/
|
||||||
|
~/.cargo/registry/index/
|
||||||
|
~/.cargo/registry/cache/
|
||||||
|
~/.cargo/git/db/
|
||||||
|
target/
|
||||||
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
-
|
||||||
|
name: Run Clippy
|
||||||
|
run: cargo clippy
|
||||||
|
-
|
||||||
|
name: Check if Version in Cargo.toml matches Tag
|
||||||
|
run: |
|
||||||
|
VERSION=$(cat Cargo.toml | grep -E "(^|\|)version =" | cut -f2- -d= | tr -d \" | tr -d " ")
|
||||||
|
if test $VERSION != "${{ github.ref_name }}"; then
|
||||||
|
echo "Expected Version is: '${{ github.ref_name }}' actual Version is: '$VERSION'";
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo "Version is: '$VERSION'";
|
||||||
|
fi
|
||||||
|
|
||||||
|
build:
|
||||||
|
needs: test
|
||||||
|
if: success()
|
||||||
|
runs-on: docker
|
||||||
|
container: forgejo.neshweb.net/ci-docker-images/rust-node:latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checking Out Repository Code
|
||||||
|
uses: https://code.forgejo.org/actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Prepare build environment
|
||||||
|
run: mkdir dist
|
||||||
|
-
|
||||||
|
name: Compiling To Linux Target
|
||||||
|
run: |
|
||||||
|
cargo build -r
|
||||||
|
mv target/release/${{ github.event.repository.name }} dist/${{ github.event.repository.name }}-linux-amd64
|
||||||
|
-
|
||||||
|
name: Bundle .deb package
|
||||||
|
run: |
|
||||||
|
cargo deb
|
||||||
|
DEBIAN_REF=$(echo ${{ github.ref_name }} | tr - \~)
|
||||||
|
echo "DEBIAN_REF=$DEBIAN_REF" >> dist/build.env
|
||||||
|
DEBIAN_REV=-$(cat Cargo.toml | grep -E "(^|\|)revision =" | cut -f2- -d= | tr -d \" | tr -d " ")
|
||||||
|
echo "DEBIAN_REV=$DEBIAN_REV" >> dist/build.env
|
||||||
|
mv target/debian/${{ github.event.repository.name }}_"$DEBIAN_REF""$DEBIAN_REV"_amd64.deb dist/${{ github.event.repository.name }}_"$DEBIAN_REF""$DEBIAN_REV"_amd64.deb
|
||||||
|
-
|
||||||
|
name: Uploading Build Artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: release_blobs
|
||||||
|
path: dist
|
||||||
|
if-no-files-found: error
|
||||||
|
|
||||||
|
upload-generic-package:
|
||||||
|
needs: build
|
||||||
|
if: success()
|
||||||
|
runs-on: docker
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Downloading All Build Artifacts
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
-
|
||||||
|
name: Upload Binary
|
||||||
|
run: |
|
||||||
|
echo 'curl -v --user ${{ secrets.FORGEJO_USERNAME }}:${{ secrets.FORGEJO_TOKEN }} \
|
||||||
|
--upload-file release_blobs/${{ github.event.repository.name }}-linux-amd64 \
|
||||||
|
https://forgejo.neshweb.net/api/packages/${{ secrets.FORGEJO_USERNAME }}/generic/${{ github.event.repository.name }}/${{ github.ref_name }}/${{ github.event.repository.name }}-linux-amd64'
|
||||||
|
curl -v --user ${{ secrets.FORGEJO_USERNAME }}:${{ secrets.FORGEJO_TOKEN }} \
|
||||||
|
--upload-file release_blobs/${{ github.event.repository.name }}-linux-amd64 \
|
||||||
|
https://forgejo.neshweb.net/api/packages/${{ secrets.FORGEJO_USERNAME }}/generic/${{ github.event.repository.name }}/${{ github.ref_name }}/${{ github.event.repository.name }}-linux-amd64
|
||||||
|
|
||||||
|
upload-debian-package:
|
||||||
|
needs: build
|
||||||
|
if: success()
|
||||||
|
runs-on: docker
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Downloading All Build Artifacts
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
-
|
||||||
|
name: Upload Debian Package to staging
|
||||||
|
run: |
|
||||||
|
source release_blobs/build.env
|
||||||
|
echo 'curl -v --user ${{ secrets.FORGEJO_USERNAME }}:${{ secrets.FORGEJO_TOKEN }} \
|
||||||
|
--upload-file release_blobs/${{ github.event.repository.name }}_'"$DEBIAN_REF""$DEBIAN_REV"'_amd64.deb \
|
||||||
|
https://forgejo.neshweb.net/api/packages/${{ secrets.FORGEJO_USERNAME }}/debian/pool/bookworm/staging/upload'
|
||||||
|
curl -v --user ${{ secrets.FORGEJO_USERNAME }}:${{ secrets.FORGEJO_TOKEN }} \
|
||||||
|
--upload-file release_blobs/${{ github.event.repository.name }}_"$DEBIAN_REF""$DEBIAN_REV"_amd64.deb \
|
||||||
|
https://forgejo.neshweb.net/api/packages/${{ secrets.FORGEJO_USERNAME }}/debian/pool/bookworm/staging/upload
|
||||||
|
-
|
||||||
|
name: Upload Debian Package to main
|
||||||
|
if: (! contains(github.ref_name, '-rc'))
|
||||||
|
run: |
|
||||||
|
source release_blobs/build.env
|
||||||
|
echo 'curl -v --user ${{ secrets.FORGEJO_USERNAME }}:${{ secrets.FORGEJO_TOKEN }} \
|
||||||
|
--upload-file release_blobs/${{ github.event.repository.name }}_'"$DEBIAN_REF""$DEBIAN_REV"'_amd64.deb \
|
||||||
|
https://forgejo.neshweb.net/api/packages/${{ secrets.FORGEJO_USERNAME }}/debian/pool/bookworm/main/upload'
|
||||||
|
curl -v --user ${{ secrets.FORGEJO_USERNAME }}:${{ secrets.FORGEJO_TOKEN }} \
|
||||||
|
--upload-file release_blobs/${{ github.event.repository.name }}_"$DEBIAN_REF""$DEBIAN_REV"_amd64.deb \
|
||||||
|
https://forgejo.neshweb.net/api/packages/${{ secrets.FORGEJO_USERNAME }}/debian/pool/bookworm/main/upload
|
||||||
|
|
||||||
|
upload-release:
|
||||||
|
needs: build
|
||||||
|
if: success()
|
||||||
|
runs-on: docker
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Downloading All Build Artifacts
|
||||||
|
uses: actions/download-artifact@v3
|
||||||
|
-
|
||||||
|
name: Filter out env files
|
||||||
|
run: rm release_blobs/build.env
|
||||||
|
-
|
||||||
|
name: Release New Version
|
||||||
|
uses: actions/forgejo-release@v2
|
||||||
|
with:
|
||||||
|
direction: upload
|
||||||
|
url: https://forgejo.neshweb.net
|
||||||
|
release-dir: release_blobs
|
||||||
|
token: ${{ secrets.FORGEJO_TOKEN }}
|
||||||
|
tag: ${{ github.ref_name }}
|
67
.forgejo/workflows/pull-requests.yml
Normal file
67
.forgejo/workflows/pull-requests.yml
Normal file
|
@ -0,0 +1,67 @@
|
||||||
|
name: 'Build binary file and bundle packages'
|
||||||
|
author: 'Neshura'
|
||||||
|
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
test:
|
||||||
|
runs-on: docker
|
||||||
|
container: forgejo.neshweb.net/ci-docker-images/rust-node:latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Add Clippy
|
||||||
|
run: rustup component add clippy
|
||||||
|
-
|
||||||
|
name: Checking Out Repository Code
|
||||||
|
uses: https://code.forgejo.org/actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set Up Cargo Cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo/bin/
|
||||||
|
~/.cargo/registry/index/
|
||||||
|
~/.cargo/registry/cache/
|
||||||
|
~/.cargo/git/db/
|
||||||
|
target/
|
||||||
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
-
|
||||||
|
name: Run Clippy
|
||||||
|
run: cargo clippy
|
||||||
|
|
||||||
|
build:
|
||||||
|
needs: test
|
||||||
|
if: success()
|
||||||
|
runs-on: docker
|
||||||
|
container: forgejo.neshweb.net/ci-docker-images/rust-node:latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Checking Out Repository Code
|
||||||
|
uses: https://code.forgejo.org/actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Prepare build environment
|
||||||
|
run: mkdir dist
|
||||||
|
-
|
||||||
|
name: Compiling To Linux Target
|
||||||
|
run: |
|
||||||
|
cargo build -r
|
||||||
|
mv target/release/${{ github.event.repository.name }} dist/${{ github.event.repository.name }}-linux-amd64
|
||||||
|
-
|
||||||
|
name: Bundle .deb package
|
||||||
|
run: |
|
||||||
|
cargo deb
|
||||||
|
DEBIAN_REF=$(cat Cargo.toml | grep -E "(^|\|)version =" | cut -f2- -d= | tr -d \" | tr -d " " | tr - \~)
|
||||||
|
echo "DEBIAN_REF=$DEBIAN_REF" >> dist/build.env
|
||||||
|
DEBIAN_REV=-$(cat Cargo.toml | grep -E "(^|\|)revision =" | cut -f2- -d= | tr -d \" | tr -d " ")
|
||||||
|
echo "DEBIAN_REV=$DEBIAN_REV" >> dist/build.env
|
||||||
|
mv target/debian/${{ github.event.repository.name }}_"$DEBIAN_REF""$DEBIAN_REV"_amd64.deb dist/${{ github.event.repository.name }}_"$DEBIAN_REF""$DEBIAN_REV"_amd64.deb
|
||||||
|
-
|
||||||
|
name: Uploading Build Artifact
|
||||||
|
uses: actions/upload-artifact@v3
|
||||||
|
with:
|
||||||
|
name: release_blobs
|
||||||
|
path: dist
|
||||||
|
if-no-files-found: error
|
34
.forgejo/workflows/test.yml
Normal file
34
.forgejo/workflows/test.yml
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
name: 'Run Tests on Code'
|
||||||
|
author: 'Neshura'
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags-ignore:
|
||||||
|
- '**'
|
||||||
|
branches:
|
||||||
|
- '**'
|
||||||
|
jobs:
|
||||||
|
run-tests:
|
||||||
|
runs-on: docker
|
||||||
|
container: forgejo.neshweb.net/ci-docker-images/rust-node:latest
|
||||||
|
steps:
|
||||||
|
-
|
||||||
|
name: Add Clippy
|
||||||
|
run: rustup component add clippy
|
||||||
|
-
|
||||||
|
name: Checking Out Repository Code
|
||||||
|
uses: https://code.forgejo.org/actions/checkout@v3
|
||||||
|
-
|
||||||
|
name: Set Up Cargo Cache
|
||||||
|
uses: actions/cache@v3
|
||||||
|
with:
|
||||||
|
path: |
|
||||||
|
~/.cargo/bin/
|
||||||
|
~/.cargo/registry/index/
|
||||||
|
~/.cargo/registry/cache/
|
||||||
|
~/.cargo/git/db/
|
||||||
|
target/
|
||||||
|
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
|
||||||
|
-
|
||||||
|
name: Run Clippy
|
||||||
|
run: cargo clippy
|
6
.gitignore
vendored
6
.gitignore
vendored
|
@ -1,7 +1,7 @@
|
||||||
/secrets.json
|
|
||||||
/config.json
|
|
||||||
/posts.json
|
|
||||||
/.vscode
|
/.vscode
|
||||||
|
/.idea
|
||||||
|
/jnc_api_examples
|
||||||
|
/.directory
|
||||||
|
|
||||||
# Added by cargo
|
# Added by cargo
|
||||||
|
|
||||||
|
|
|
@ -1,64 +0,0 @@
|
||||||
image: 3.10.8-slim-buster
|
|
||||||
|
|
||||||
.deploy:
|
|
||||||
rules:
|
|
||||||
# Regex magic copied from Neshura/page-test, only deploys on x.y.z or higher (x.y) Tags
|
|
||||||
- if: $CI_COMMIT_TAG =~ /^((([\d])+\.){1,2}[\d]+)\s*$/ && $CI_COMMIT_TAG
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- build
|
|
||||||
- upload
|
|
||||||
- release
|
|
||||||
|
|
||||||
## Docker steps
|
|
||||||
|
|
||||||
build:
|
|
||||||
image: rust:latest
|
|
||||||
stage: build
|
|
||||||
|
|
||||||
variables:
|
|
||||||
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_BRANCH
|
|
||||||
CACHING:
|
|
||||||
script:
|
|
||||||
- echo "Compiling the code..."
|
|
||||||
- cargo build -r
|
|
||||||
- echo "Compile complete."
|
|
||||||
after_script:
|
|
||||||
- echo JOB_ID=$CI_JOB_ID >> job.env
|
|
||||||
- mkdir ./artifacts
|
|
||||||
- cp /builds/Neshura/ascendance-of-a-bookworm-bot/target/release/ascendance-of-a-bookworm-bot ./artifacts/
|
|
||||||
artifacts:
|
|
||||||
paths:
|
|
||||||
- ./artifacts/
|
|
||||||
reports:
|
|
||||||
dotenv: job.env
|
|
||||||
rules:
|
|
||||||
- !reference [.deploy, rules]
|
|
||||||
|
|
||||||
upload:
|
|
||||||
needs:
|
|
||||||
- job: build
|
|
||||||
artifacts: true
|
|
||||||
image: curlimages/curl:latest
|
|
||||||
stage: upload
|
|
||||||
script:
|
|
||||||
- 'curl --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file artifacts/ascendance-of-a-bookworm-bot "${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/linux/$CI_COMMIT_TAG/ascendance-of-a-bookworm-bot"'
|
|
||||||
rules:
|
|
||||||
- !reference [.deploy, rules]
|
|
||||||
|
|
||||||
|
|
||||||
Tag Release:
|
|
||||||
stage: release
|
|
||||||
image: registry.gitlab.com/gitlab-org/release-cli:latest
|
|
||||||
rules:
|
|
||||||
- !reference [.deploy, rules]
|
|
||||||
script:
|
|
||||||
- apk add curl
|
|
||||||
- echo "running Release Job, attaching Artifact from Job $JOB_ID"
|
|
||||||
release:
|
|
||||||
tag_name: '$CI_COMMIT_TAG'
|
|
||||||
description: '$CI_COMMIT_TAG'
|
|
||||||
assets:
|
|
||||||
links:
|
|
||||||
- name: "ascendance-of-a-bookworm-bot.zip"
|
|
||||||
url: "https://gitlab.neshweb.net/Neshura/ascendance-of-a-bookworm-bot/packages/generic/linux/$CI_COMMIT_TAG/ascendance-of-a-bookworm-bot"
|
|
674
COPYING
Normal file
674
COPYING
Normal file
|
@ -0,0 +1,674 @@
|
||||||
|
GNU GENERAL PUBLIC LICENSE
|
||||||
|
Version 3, 29 June 2007
|
||||||
|
|
||||||
|
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||||
|
Everyone is permitted to copy and distribute verbatim copies
|
||||||
|
of this license document, but changing it is not allowed.
|
||||||
|
|
||||||
|
Preamble
|
||||||
|
|
||||||
|
The GNU General Public License is a free, copyleft license for
|
||||||
|
software and other kinds of works.
|
||||||
|
|
||||||
|
The licenses for most software and other practical works are designed
|
||||||
|
to take away your freedom to share and change the works. By contrast,
|
||||||
|
the GNU General Public License is intended to guarantee your freedom to
|
||||||
|
share and change all versions of a program--to make sure it remains free
|
||||||
|
software for all its users. We, the Free Software Foundation, use the
|
||||||
|
GNU General Public License for most of our software; it applies also to
|
||||||
|
any other work released this way by its authors. You can apply it to
|
||||||
|
your programs, too.
|
||||||
|
|
||||||
|
When we speak of free software, we are referring to freedom, not
|
||||||
|
price. Our General Public Licenses are designed to make sure that you
|
||||||
|
have the freedom to distribute copies of free software (and charge for
|
||||||
|
them if you wish), that you receive source code or can get it if you
|
||||||
|
want it, that you can change the software or use pieces of it in new
|
||||||
|
free programs, and that you know you can do these things.
|
||||||
|
|
||||||
|
To protect your rights, we need to prevent others from denying you
|
||||||
|
these rights or asking you to surrender the rights. Therefore, you have
|
||||||
|
certain responsibilities if you distribute copies of the software, or if
|
||||||
|
you modify it: responsibilities to respect the freedom of others.
|
||||||
|
|
||||||
|
For example, if you distribute copies of such a program, whether
|
||||||
|
gratis or for a fee, you must pass on to the recipients the same
|
||||||
|
freedoms that you received. You must make sure that they, too, receive
|
||||||
|
or can get the source code. And you must show them these terms so they
|
||||||
|
know their rights.
|
||||||
|
|
||||||
|
Developers that use the GNU GPL protect your rights with two steps:
|
||||||
|
(1) assert copyright on the software, and (2) offer you this License
|
||||||
|
giving you legal permission to copy, distribute and/or modify it.
|
||||||
|
|
||||||
|
For the developers' and authors' protection, the GPL clearly explains
|
||||||
|
that there is no warranty for this free software. For both users' and
|
||||||
|
authors' sake, the GPL requires that modified versions be marked as
|
||||||
|
changed, so that their problems will not be attributed erroneously to
|
||||||
|
authors of previous versions.
|
||||||
|
|
||||||
|
Some devices are designed to deny users access to install or run
|
||||||
|
modified versions of the software inside them, although the manufacturer
|
||||||
|
can do so. This is fundamentally incompatible with the aim of
|
||||||
|
protecting users' freedom to change the software. The systematic
|
||||||
|
pattern of such abuse occurs in the area of products for individuals to
|
||||||
|
use, which is precisely where it is most unacceptable. Therefore, we
|
||||||
|
have designed this version of the GPL to prohibit the practice for those
|
||||||
|
products. If such problems arise substantially in other domains, we
|
||||||
|
stand ready to extend this provision to those domains in future versions
|
||||||
|
of the GPL, as needed to protect the freedom of users.
|
||||||
|
|
||||||
|
Finally, every program is threatened constantly by software patents.
|
||||||
|
States should not allow patents to restrict development and use of
|
||||||
|
software on general-purpose computers, but in those that do, we wish to
|
||||||
|
avoid the special danger that patents applied to a free program could
|
||||||
|
make it effectively proprietary. To prevent this, the GPL assures that
|
||||||
|
patents cannot be used to render the program non-free.
|
||||||
|
|
||||||
|
The precise terms and conditions for copying, distribution and
|
||||||
|
modification follow.
|
||||||
|
|
||||||
|
TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
0. Definitions.
|
||||||
|
|
||||||
|
"This License" refers to version 3 of the GNU General Public License.
|
||||||
|
|
||||||
|
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||||
|
works, such as semiconductor masks.
|
||||||
|
|
||||||
|
"The Program" refers to any copyrightable work licensed under this
|
||||||
|
License. Each licensee is addressed as "you". "Licensees" and
|
||||||
|
"recipients" may be individuals or organizations.
|
||||||
|
|
||||||
|
To "modify" a work means to copy from or adapt all or part of the work
|
||||||
|
in a fashion requiring copyright permission, other than the making of an
|
||||||
|
exact copy. The resulting work is called a "modified version" of the
|
||||||
|
earlier work or a work "based on" the earlier work.
|
||||||
|
|
||||||
|
A "covered work" means either the unmodified Program or a work based
|
||||||
|
on the Program.
|
||||||
|
|
||||||
|
To "propagate" a work means to do anything with it that, without
|
||||||
|
permission, would make you directly or secondarily liable for
|
||||||
|
infringement under applicable copyright law, except executing it on a
|
||||||
|
computer or modifying a private copy. Propagation includes copying,
|
||||||
|
distribution (with or without modification), making available to the
|
||||||
|
public, and in some countries other activities as well.
|
||||||
|
|
||||||
|
To "convey" a work means any kind of propagation that enables other
|
||||||
|
parties to make or receive copies. Mere interaction with a user through
|
||||||
|
a computer network, with no transfer of a copy, is not conveying.
|
||||||
|
|
||||||
|
An interactive user interface displays "Appropriate Legal Notices"
|
||||||
|
to the extent that it includes a convenient and prominently visible
|
||||||
|
feature that (1) displays an appropriate copyright notice, and (2)
|
||||||
|
tells the user that there is no warranty for the work (except to the
|
||||||
|
extent that warranties are provided), that licensees may convey the
|
||||||
|
work under this License, and how to view a copy of this License. If
|
||||||
|
the interface presents a list of user commands or options, such as a
|
||||||
|
menu, a prominent item in the list meets this criterion.
|
||||||
|
|
||||||
|
1. Source Code.
|
||||||
|
|
||||||
|
The "source code" for a work means the preferred form of the work
|
||||||
|
for making modifications to it. "Object code" means any non-source
|
||||||
|
form of a work.
|
||||||
|
|
||||||
|
A "Standard Interface" means an interface that either is an official
|
||||||
|
standard defined by a recognized standards body, or, in the case of
|
||||||
|
interfaces specified for a particular programming language, one that
|
||||||
|
is widely used among developers working in that language.
|
||||||
|
|
||||||
|
The "System Libraries" of an executable work include anything, other
|
||||||
|
than the work as a whole, that (a) is included in the normal form of
|
||||||
|
packaging a Major Component, but which is not part of that Major
|
||||||
|
Component, and (b) serves only to enable use of the work with that
|
||||||
|
Major Component, or to implement a Standard Interface for which an
|
||||||
|
implementation is available to the public in source code form. A
|
||||||
|
"Major Component", in this context, means a major essential component
|
||||||
|
(kernel, window system, and so on) of the specific operating system
|
||||||
|
(if any) on which the executable work runs, or a compiler used to
|
||||||
|
produce the work, or an object code interpreter used to run it.
|
||||||
|
|
||||||
|
The "Corresponding Source" for a work in object code form means all
|
||||||
|
the source code needed to generate, install, and (for an executable
|
||||||
|
work) run the object code and to modify the work, including scripts to
|
||||||
|
control those activities. However, it does not include the work's
|
||||||
|
System Libraries, or general-purpose tools or generally available free
|
||||||
|
programs which are used unmodified in performing those activities but
|
||||||
|
which are not part of the work. For example, Corresponding Source
|
||||||
|
includes interface definition files associated with source files for
|
||||||
|
the work, and the source code for shared libraries and dynamically
|
||||||
|
linked subprograms that the work is specifically designed to require,
|
||||||
|
such as by intimate data communication or control flow between those
|
||||||
|
subprograms and other parts of the work.
|
||||||
|
|
||||||
|
The Corresponding Source need not include anything that users
|
||||||
|
can regenerate automatically from other parts of the Corresponding
|
||||||
|
Source.
|
||||||
|
|
||||||
|
The Corresponding Source for a work in source code form is that
|
||||||
|
same work.
|
||||||
|
|
||||||
|
2. Basic Permissions.
|
||||||
|
|
||||||
|
All rights granted under this License are granted for the term of
|
||||||
|
copyright on the Program, and are irrevocable provided the stated
|
||||||
|
conditions are met. This License explicitly affirms your unlimited
|
||||||
|
permission to run the unmodified Program. The output from running a
|
||||||
|
covered work is covered by this License only if the output, given its
|
||||||
|
content, constitutes a covered work. This License acknowledges your
|
||||||
|
rights of fair use or other equivalent, as provided by copyright law.
|
||||||
|
|
||||||
|
You may make, run and propagate covered works that you do not
|
||||||
|
convey, without conditions so long as your license otherwise remains
|
||||||
|
in force. You may convey covered works to others for the sole purpose
|
||||||
|
of having them make modifications exclusively for you, or provide you
|
||||||
|
with facilities for running those works, provided that you comply with
|
||||||
|
the terms of this License in conveying all material for which you do
|
||||||
|
not control copyright. Those thus making or running the covered works
|
||||||
|
for you must do so exclusively on your behalf, under your direction
|
||||||
|
and control, on terms that prohibit them from making any copies of
|
||||||
|
your copyrighted material outside their relationship with you.
|
||||||
|
|
||||||
|
Conveying under any other circumstances is permitted solely under
|
||||||
|
the conditions stated below. Sublicensing is not allowed; section 10
|
||||||
|
makes it unnecessary.
|
||||||
|
|
||||||
|
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||||
|
|
||||||
|
No covered work shall be deemed part of an effective technological
|
||||||
|
measure under any applicable law fulfilling obligations under article
|
||||||
|
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||||
|
similar laws prohibiting or restricting circumvention of such
|
||||||
|
measures.
|
||||||
|
|
||||||
|
When you convey a covered work, you waive any legal power to forbid
|
||||||
|
circumvention of technological measures to the extent such circumvention
|
||||||
|
is effected by exercising rights under this License with respect to
|
||||||
|
the covered work, and you disclaim any intention to limit operation or
|
||||||
|
modification of the work as a means of enforcing, against the work's
|
||||||
|
users, your or third parties' legal rights to forbid circumvention of
|
||||||
|
technological measures.
|
||||||
|
|
||||||
|
4. Conveying Verbatim Copies.
|
||||||
|
|
||||||
|
You may convey verbatim copies of the Program's source code as you
|
||||||
|
receive it, in any medium, provided that you conspicuously and
|
||||||
|
appropriately publish on each copy an appropriate copyright notice;
|
||||||
|
keep intact all notices stating that this License and any
|
||||||
|
non-permissive terms added in accord with section 7 apply to the code;
|
||||||
|
keep intact all notices of the absence of any warranty; and give all
|
||||||
|
recipients a copy of this License along with the Program.
|
||||||
|
|
||||||
|
You may charge any price or no price for each copy that you convey,
|
||||||
|
and you may offer support or warranty protection for a fee.
|
||||||
|
|
||||||
|
5. Conveying Modified Source Versions.
|
||||||
|
|
||||||
|
You may convey a work based on the Program, or the modifications to
|
||||||
|
produce it from the Program, in the form of source code under the
|
||||||
|
terms of section 4, provided that you also meet all of these conditions:
|
||||||
|
|
||||||
|
a) The work must carry prominent notices stating that you modified
|
||||||
|
it, and giving a relevant date.
|
||||||
|
|
||||||
|
b) The work must carry prominent notices stating that it is
|
||||||
|
released under this License and any conditions added under section
|
||||||
|
7. This requirement modifies the requirement in section 4 to
|
||||||
|
"keep intact all notices".
|
||||||
|
|
||||||
|
c) You must license the entire work, as a whole, under this
|
||||||
|
License to anyone who comes into possession of a copy. This
|
||||||
|
License will therefore apply, along with any applicable section 7
|
||||||
|
additional terms, to the whole of the work, and all its parts,
|
||||||
|
regardless of how they are packaged. This License gives no
|
||||||
|
permission to license the work in any other way, but it does not
|
||||||
|
invalidate such permission if you have separately received it.
|
||||||
|
|
||||||
|
d) If the work has interactive user interfaces, each must display
|
||||||
|
Appropriate Legal Notices; however, if the Program has interactive
|
||||||
|
interfaces that do not display Appropriate Legal Notices, your
|
||||||
|
work need not make them do so.
|
||||||
|
|
||||||
|
A compilation of a covered work with other separate and independent
|
||||||
|
works, which are not by their nature extensions of the covered work,
|
||||||
|
and which are not combined with it such as to form a larger program,
|
||||||
|
in or on a volume of a storage or distribution medium, is called an
|
||||||
|
"aggregate" if the compilation and its resulting copyright are not
|
||||||
|
used to limit the access or legal rights of the compilation's users
|
||||||
|
beyond what the individual works permit. Inclusion of a covered work
|
||||||
|
in an aggregate does not cause this License to apply to the other
|
||||||
|
parts of the aggregate.
|
||||||
|
|
||||||
|
6. Conveying Non-Source Forms.
|
||||||
|
|
||||||
|
You may convey a covered work in object code form under the terms
|
||||||
|
of sections 4 and 5, provided that you also convey the
|
||||||
|
machine-readable Corresponding Source under the terms of this License,
|
||||||
|
in one of these ways:
|
||||||
|
|
||||||
|
a) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by the
|
||||||
|
Corresponding Source fixed on a durable physical medium
|
||||||
|
customarily used for software interchange.
|
||||||
|
|
||||||
|
b) Convey the object code in, or embodied in, a physical product
|
||||||
|
(including a physical distribution medium), accompanied by a
|
||||||
|
written offer, valid for at least three years and valid for as
|
||||||
|
long as you offer spare parts or customer support for that product
|
||||||
|
model, to give anyone who possesses the object code either (1) a
|
||||||
|
copy of the Corresponding Source for all the software in the
|
||||||
|
product that is covered by this License, on a durable physical
|
||||||
|
medium customarily used for software interchange, for a price no
|
||||||
|
more than your reasonable cost of physically performing this
|
||||||
|
conveying of source, or (2) access to copy the
|
||||||
|
Corresponding Source from a network server at no charge.
|
||||||
|
|
||||||
|
c) Convey individual copies of the object code with a copy of the
|
||||||
|
written offer to provide the Corresponding Source. This
|
||||||
|
alternative is allowed only occasionally and noncommercially, and
|
||||||
|
only if you received the object code with such an offer, in accord
|
||||||
|
with subsection 6b.
|
||||||
|
|
||||||
|
d) Convey the object code by offering access from a designated
|
||||||
|
place (gratis or for a charge), and offer equivalent access to the
|
||||||
|
Corresponding Source in the same way through the same place at no
|
||||||
|
further charge. You need not require recipients to copy the
|
||||||
|
Corresponding Source along with the object code. If the place to
|
||||||
|
copy the object code is a network server, the Corresponding Source
|
||||||
|
may be on a different server (operated by you or a third party)
|
||||||
|
that supports equivalent copying facilities, provided you maintain
|
||||||
|
clear directions next to the object code saying where to find the
|
||||||
|
Corresponding Source. Regardless of what server hosts the
|
||||||
|
Corresponding Source, you remain obligated to ensure that it is
|
||||||
|
available for as long as needed to satisfy these requirements.
|
||||||
|
|
||||||
|
e) Convey the object code using peer-to-peer transmission, provided
|
||||||
|
you inform other peers where the object code and Corresponding
|
||||||
|
Source of the work are being offered to the general public at no
|
||||||
|
charge under subsection 6d.
|
||||||
|
|
||||||
|
A separable portion of the object code, whose source code is excluded
|
||||||
|
from the Corresponding Source as a System Library, need not be
|
||||||
|
included in conveying the object code work.
|
||||||
|
|
||||||
|
A "User Product" is either (1) a "consumer product", which means any
|
||||||
|
tangible personal property which is normally used for personal, family,
|
||||||
|
or household purposes, or (2) anything designed or sold for incorporation
|
||||||
|
into a dwelling. In determining whether a product is a consumer product,
|
||||||
|
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||||
|
product received by a particular user, "normally used" refers to a
|
||||||
|
typical or common use of that class of product, regardless of the status
|
||||||
|
of the particular user or of the way in which the particular user
|
||||||
|
actually uses, or expects or is expected to use, the product. A product
|
||||||
|
is a consumer product regardless of whether the product has substantial
|
||||||
|
commercial, industrial or non-consumer uses, unless such uses represent
|
||||||
|
the only significant mode of use of the product.
|
||||||
|
|
||||||
|
"Installation Information" for a User Product means any methods,
|
||||||
|
procedures, authorization keys, or other information required to install
|
||||||
|
and execute modified versions of a covered work in that User Product from
|
||||||
|
a modified version of its Corresponding Source. The information must
|
||||||
|
suffice to ensure that the continued functioning of the modified object
|
||||||
|
code is in no case prevented or interfered with solely because
|
||||||
|
modification has been made.
|
||||||
|
|
||||||
|
If you convey an object code work under this section in, or with, or
|
||||||
|
specifically for use in, a User Product, and the conveying occurs as
|
||||||
|
part of a transaction in which the right of possession and use of the
|
||||||
|
User Product is transferred to the recipient in perpetuity or for a
|
||||||
|
fixed term (regardless of how the transaction is characterized), the
|
||||||
|
Corresponding Source conveyed under this section must be accompanied
|
||||||
|
by the Installation Information. But this requirement does not apply
|
||||||
|
if neither you nor any third party retains the ability to install
|
||||||
|
modified object code on the User Product (for example, the work has
|
||||||
|
been installed in ROM).
|
||||||
|
|
||||||
|
The requirement to provide Installation Information does not include a
|
||||||
|
requirement to continue to provide support service, warranty, or updates
|
||||||
|
for a work that has been modified or installed by the recipient, or for
|
||||||
|
the User Product in which it has been modified or installed. Access to a
|
||||||
|
network may be denied when the modification itself materially and
|
||||||
|
adversely affects the operation of the network or violates the rules and
|
||||||
|
protocols for communication across the network.
|
||||||
|
|
||||||
|
Corresponding Source conveyed, and Installation Information provided,
|
||||||
|
in accord with this section must be in a format that is publicly
|
||||||
|
documented (and with an implementation available to the public in
|
||||||
|
source code form), and must require no special password or key for
|
||||||
|
unpacking, reading or copying.
|
||||||
|
|
||||||
|
7. Additional Terms.
|
||||||
|
|
||||||
|
"Additional permissions" are terms that supplement the terms of this
|
||||||
|
License by making exceptions from one or more of its conditions.
|
||||||
|
Additional permissions that are applicable to the entire Program shall
|
||||||
|
be treated as though they were included in this License, to the extent
|
||||||
|
that they are valid under applicable law. If additional permissions
|
||||||
|
apply only to part of the Program, that part may be used separately
|
||||||
|
under those permissions, but the entire Program remains governed by
|
||||||
|
this License without regard to the additional permissions.
|
||||||
|
|
||||||
|
When you convey a copy of a covered work, you may at your option
|
||||||
|
remove any additional permissions from that copy, or from any part of
|
||||||
|
it. (Additional permissions may be written to require their own
|
||||||
|
removal in certain cases when you modify the work.) You may place
|
||||||
|
additional permissions on material, added by you to a covered work,
|
||||||
|
for which you have or can give appropriate copyright permission.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, for material you
|
||||||
|
add to a covered work, you may (if authorized by the copyright holders of
|
||||||
|
that material) supplement the terms of this License with terms:
|
||||||
|
|
||||||
|
a) Disclaiming warranty or limiting liability differently from the
|
||||||
|
terms of sections 15 and 16 of this License; or
|
||||||
|
|
||||||
|
b) Requiring preservation of specified reasonable legal notices or
|
||||||
|
author attributions in that material or in the Appropriate Legal
|
||||||
|
Notices displayed by works containing it; or
|
||||||
|
|
||||||
|
c) Prohibiting misrepresentation of the origin of that material, or
|
||||||
|
requiring that modified versions of such material be marked in
|
||||||
|
reasonable ways as different from the original version; or
|
||||||
|
|
||||||
|
d) Limiting the use for publicity purposes of names of licensors or
|
||||||
|
authors of the material; or
|
||||||
|
|
||||||
|
e) Declining to grant rights under trademark law for use of some
|
||||||
|
trade names, trademarks, or service marks; or
|
||||||
|
|
||||||
|
f) Requiring indemnification of licensors and authors of that
|
||||||
|
material by anyone who conveys the material (or modified versions of
|
||||||
|
it) with contractual assumptions of liability to the recipient, for
|
||||||
|
any liability that these contractual assumptions directly impose on
|
||||||
|
those licensors and authors.
|
||||||
|
|
||||||
|
All other non-permissive additional terms are considered "further
|
||||||
|
restrictions" within the meaning of section 10. If the Program as you
|
||||||
|
received it, or any part of it, contains a notice stating that it is
|
||||||
|
governed by this License along with a term that is a further
|
||||||
|
restriction, you may remove that term. If a license document contains
|
||||||
|
a further restriction but permits relicensing or conveying under this
|
||||||
|
License, you may add to a covered work material governed by the terms
|
||||||
|
of that license document, provided that the further restriction does
|
||||||
|
not survive such relicensing or conveying.
|
||||||
|
|
||||||
|
If you add terms to a covered work in accord with this section, you
|
||||||
|
must place, in the relevant source files, a statement of the
|
||||||
|
additional terms that apply to those files, or a notice indicating
|
||||||
|
where to find the applicable terms.
|
||||||
|
|
||||||
|
Additional terms, permissive or non-permissive, may be stated in the
|
||||||
|
form of a separately written license, or stated as exceptions;
|
||||||
|
the above requirements apply either way.
|
||||||
|
|
||||||
|
8. Termination.
|
||||||
|
|
||||||
|
You may not propagate or modify a covered work except as expressly
|
||||||
|
provided under this License. Any attempt otherwise to propagate or
|
||||||
|
modify it is void, and will automatically terminate your rights under
|
||||||
|
this License (including any patent licenses granted under the third
|
||||||
|
paragraph of section 11).
|
||||||
|
|
||||||
|
However, if you cease all violation of this License, then your
|
||||||
|
license from a particular copyright holder is reinstated (a)
|
||||||
|
provisionally, unless and until the copyright holder explicitly and
|
||||||
|
finally terminates your license, and (b) permanently, if the copyright
|
||||||
|
holder fails to notify you of the violation by some reasonable means
|
||||||
|
prior to 60 days after the cessation.
|
||||||
|
|
||||||
|
Moreover, your license from a particular copyright holder is
|
||||||
|
reinstated permanently if the copyright holder notifies you of the
|
||||||
|
violation by some reasonable means, this is the first time you have
|
||||||
|
received notice of violation of this License (for any work) from that
|
||||||
|
copyright holder, and you cure the violation prior to 30 days after
|
||||||
|
your receipt of the notice.
|
||||||
|
|
||||||
|
Termination of your rights under this section does not terminate the
|
||||||
|
licenses of parties who have received copies or rights from you under
|
||||||
|
this License. If your rights have been terminated and not permanently
|
||||||
|
reinstated, you do not qualify to receive new licenses for the same
|
||||||
|
material under section 10.
|
||||||
|
|
||||||
|
9. Acceptance Not Required for Having Copies.
|
||||||
|
|
||||||
|
You are not required to accept this License in order to receive or
|
||||||
|
run a copy of the Program. Ancillary propagation of a covered work
|
||||||
|
occurring solely as a consequence of using peer-to-peer transmission
|
||||||
|
to receive a copy likewise does not require acceptance. However,
|
||||||
|
nothing other than this License grants you permission to propagate or
|
||||||
|
modify any covered work. These actions infringe copyright if you do
|
||||||
|
not accept this License. Therefore, by modifying or propagating a
|
||||||
|
covered work, you indicate your acceptance of this License to do so.
|
||||||
|
|
||||||
|
10. Automatic Licensing of Downstream Recipients.
|
||||||
|
|
||||||
|
Each time you convey a covered work, the recipient automatically
|
||||||
|
receives a license from the original licensors, to run, modify and
|
||||||
|
propagate that work, subject to this License. You are not responsible
|
||||||
|
for enforcing compliance by third parties with this License.
|
||||||
|
|
||||||
|
An "entity transaction" is a transaction transferring control of an
|
||||||
|
organization, or substantially all assets of one, or subdividing an
|
||||||
|
organization, or merging organizations. If propagation of a covered
|
||||||
|
work results from an entity transaction, each party to that
|
||||||
|
transaction who receives a copy of the work also receives whatever
|
||||||
|
licenses to the work the party's predecessor in interest had or could
|
||||||
|
give under the previous paragraph, plus a right to possession of the
|
||||||
|
Corresponding Source of the work from the predecessor in interest, if
|
||||||
|
the predecessor has it or can get it with reasonable efforts.
|
||||||
|
|
||||||
|
You may not impose any further restrictions on the exercise of the
|
||||||
|
rights granted or affirmed under this License. For example, you may
|
||||||
|
not impose a license fee, royalty, or other charge for exercise of
|
||||||
|
rights granted under this License, and you may not initiate litigation
|
||||||
|
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||||
|
any patent claim is infringed by making, using, selling, offering for
|
||||||
|
sale, or importing the Program or any portion of it.
|
||||||
|
|
||||||
|
11. Patents.
|
||||||
|
|
||||||
|
A "contributor" is a copyright holder who authorizes use under this
|
||||||
|
License of the Program or a work on which the Program is based. The
|
||||||
|
work thus licensed is called the contributor's "contributor version".
|
||||||
|
|
||||||
|
A contributor's "essential patent claims" are all patent claims
|
||||||
|
owned or controlled by the contributor, whether already acquired or
|
||||||
|
hereafter acquired, that would be infringed by some manner, permitted
|
||||||
|
by this License, of making, using, or selling its contributor version,
|
||||||
|
but do not include claims that would be infringed only as a
|
||||||
|
consequence of further modification of the contributor version. For
|
||||||
|
purposes of this definition, "control" includes the right to grant
|
||||||
|
patent sublicenses in a manner consistent with the requirements of
|
||||||
|
this License.
|
||||||
|
|
||||||
|
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||||
|
patent license under the contributor's essential patent claims, to
|
||||||
|
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||||
|
propagate the contents of its contributor version.
|
||||||
|
|
||||||
|
In the following three paragraphs, a "patent license" is any express
|
||||||
|
agreement or commitment, however denominated, not to enforce a patent
|
||||||
|
(such as an express permission to practice a patent or covenant not to
|
||||||
|
sue for patent infringement). To "grant" such a patent license to a
|
||||||
|
party means to make such an agreement or commitment not to enforce a
|
||||||
|
patent against the party.
|
||||||
|
|
||||||
|
If you convey a covered work, knowingly relying on a patent license,
|
||||||
|
and the Corresponding Source of the work is not available for anyone
|
||||||
|
to copy, free of charge and under the terms of this License, through a
|
||||||
|
publicly available network server or other readily accessible means,
|
||||||
|
then you must either (1) cause the Corresponding Source to be so
|
||||||
|
available, or (2) arrange to deprive yourself of the benefit of the
|
||||||
|
patent license for this particular work, or (3) arrange, in a manner
|
||||||
|
consistent with the requirements of this License, to extend the patent
|
||||||
|
license to downstream recipients. "Knowingly relying" means you have
|
||||||
|
actual knowledge that, but for the patent license, your conveying the
|
||||||
|
covered work in a country, or your recipient's use of the covered work
|
||||||
|
in a country, would infringe one or more identifiable patents in that
|
||||||
|
country that you have reason to believe are valid.
|
||||||
|
|
||||||
|
If, pursuant to or in connection with a single transaction or
|
||||||
|
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||||
|
covered work, and grant a patent license to some of the parties
|
||||||
|
receiving the covered work authorizing them to use, propagate, modify
|
||||||
|
or convey a specific copy of the covered work, then the patent license
|
||||||
|
you grant is automatically extended to all recipients of the covered
|
||||||
|
work and works based on it.
|
||||||
|
|
||||||
|
A patent license is "discriminatory" if it does not include within
|
||||||
|
the scope of its coverage, prohibits the exercise of, or is
|
||||||
|
conditioned on the non-exercise of one or more of the rights that are
|
||||||
|
specifically granted under this License. You may not convey a covered
|
||||||
|
work if you are a party to an arrangement with a third party that is
|
||||||
|
in the business of distributing software, under which you make payment
|
||||||
|
to the third party based on the extent of your activity of conveying
|
||||||
|
the work, and under which the third party grants, to any of the
|
||||||
|
parties who would receive the covered work from you, a discriminatory
|
||||||
|
patent license (a) in connection with copies of the covered work
|
||||||
|
conveyed by you (or copies made from those copies), or (b) primarily
|
||||||
|
for and in connection with specific products or compilations that
|
||||||
|
contain the covered work, unless you entered into that arrangement,
|
||||||
|
or that patent license was granted, prior to 28 March 2007.
|
||||||
|
|
||||||
|
Nothing in this License shall be construed as excluding or limiting
|
||||||
|
any implied license or other defenses to infringement that may
|
||||||
|
otherwise be available to you under applicable patent law.
|
||||||
|
|
||||||
|
12. No Surrender of Others' Freedom.
|
||||||
|
|
||||||
|
If conditions are imposed on you (whether by court order, agreement or
|
||||||
|
otherwise) that contradict the conditions of this License, they do not
|
||||||
|
excuse you from the conditions of this License. If you cannot convey a
|
||||||
|
covered work so as to satisfy simultaneously your obligations under this
|
||||||
|
License and any other pertinent obligations, then as a consequence you may
|
||||||
|
not convey it at all. For example, if you agree to terms that obligate you
|
||||||
|
to collect a royalty for further conveying from those to whom you convey
|
||||||
|
the Program, the only way you could satisfy both those terms and this
|
||||||
|
License would be to refrain entirely from conveying the Program.
|
||||||
|
|
||||||
|
13. Use with the GNU Affero General Public License.
|
||||||
|
|
||||||
|
Notwithstanding any other provision of this License, you have
|
||||||
|
permission to link or combine any covered work with a work licensed
|
||||||
|
under version 3 of the GNU Affero General Public License into a single
|
||||||
|
combined work, and to convey the resulting work. The terms of this
|
||||||
|
License will continue to apply to the part which is the covered work,
|
||||||
|
but the special requirements of the GNU Affero General Public License,
|
||||||
|
section 13, concerning interaction through a network will apply to the
|
||||||
|
combination as such.
|
||||||
|
|
||||||
|
14. Revised Versions of this License.
|
||||||
|
|
||||||
|
The Free Software Foundation may publish revised and/or new versions of
|
||||||
|
the GNU General Public License from time to time. Such new versions will
|
||||||
|
be similar in spirit to the present version, but may differ in detail to
|
||||||
|
address new problems or concerns.
|
||||||
|
|
||||||
|
Each version is given a distinguishing version number. If the
|
||||||
|
Program specifies that a certain numbered version of the GNU General
|
||||||
|
Public License "or any later version" applies to it, you have the
|
||||||
|
option of following the terms and conditions either of that numbered
|
||||||
|
version or of any later version published by the Free Software
|
||||||
|
Foundation. If the Program does not specify a version number of the
|
||||||
|
GNU General Public License, you may choose any version ever published
|
||||||
|
by the Free Software Foundation.
|
||||||
|
|
||||||
|
If the Program specifies that a proxy can decide which future
|
||||||
|
versions of the GNU General Public License can be used, that proxy's
|
||||||
|
public statement of acceptance of a version permanently authorizes you
|
||||||
|
to choose that version for the Program.
|
||||||
|
|
||||||
|
Later license versions may give you additional or different
|
||||||
|
permissions. However, no additional obligations are imposed on any
|
||||||
|
author or copyright holder as a result of your choosing to follow a
|
||||||
|
later version.
|
||||||
|
|
||||||
|
15. Disclaimer of Warranty.
|
||||||
|
|
||||||
|
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||||
|
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||||
|
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||||
|
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||||
|
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||||
|
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||||
|
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||||
|
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||||
|
|
||||||
|
16. Limitation of Liability.
|
||||||
|
|
||||||
|
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||||
|
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||||
|
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||||
|
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||||
|
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||||
|
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||||
|
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||||
|
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||||
|
SUCH DAMAGES.
|
||||||
|
|
||||||
|
17. Interpretation of Sections 15 and 16.
|
||||||
|
|
||||||
|
If the disclaimer of warranty and limitation of liability provided
|
||||||
|
above cannot be given local legal effect according to their terms,
|
||||||
|
reviewing courts shall apply local law that most closely approximates
|
||||||
|
an absolute waiver of all civil liability in connection with the
|
||||||
|
Program, unless a warranty or assumption of liability accompanies a
|
||||||
|
copy of the Program in return for a fee.
|
||||||
|
|
||||||
|
END OF TERMS AND CONDITIONS
|
||||||
|
|
||||||
|
How to Apply These Terms to Your New Programs
|
||||||
|
|
||||||
|
If you develop a new program, and you want it to be of the greatest
|
||||||
|
possible use to the public, the best way to achieve this is to make it
|
||||||
|
free software which everyone can redistribute and change under these terms.
|
||||||
|
|
||||||
|
To do so, attach the following notices to the program. It is safest
|
||||||
|
to attach them to the start of each source file to most effectively
|
||||||
|
state the exclusion of warranty; and each file should have at least
|
||||||
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
|
<one line to give the program's name and a brief idea of what it does.>
|
||||||
|
Copyright (C) <year> <name of author>
|
||||||
|
|
||||||
|
This program is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
This program is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
Also add information on how to contact you by electronic and paper mail.
|
||||||
|
|
||||||
|
If the program does terminal interaction, make it output a short
|
||||||
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
|
<program> Copyright (C) <year> <name of author>
|
||||||
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
|
This is free software, and you are welcome to redistribute it
|
||||||
|
under certain conditions; type `show c' for details.
|
||||||
|
|
||||||
|
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||||
|
parts of the General Public License. Of course, your program's commands
|
||||||
|
might be different; for a GUI interface, you would use an "about box".
|
||||||
|
|
||||||
|
You should also get your employer (if you work as a programmer) or school,
|
||||||
|
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||||
|
For more information on this, and how to apply and follow the GNU GPL, see
|
||||||
|
<https://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
The GNU General Public License does not permit incorporating your program
|
||||||
|
into proprietary programs. If your program is a subroutine library, you
|
||||||
|
may consider it more useful to permit linking proprietary applications with
|
||||||
|
the library. If this is what you want to do, use the GNU Lesser General
|
||||||
|
Public License instead of this License. But first, please read
|
||||||
|
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
1723
Cargo.lock
generated
1723
Cargo.lock
generated
File diff suppressed because it is too large
Load diff
41
Cargo.toml
41
Cargo.toml
|
@ -1,18 +1,35 @@
|
||||||
[package]
|
[package]
|
||||||
name = "ascendance-of-a-bookworm-bot"
|
authors = ["Neshura"]
|
||||||
version = "0.1.0"
|
name = "aob-lemmy-bot"
|
||||||
|
version = "3.2.0"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
|
description = "Bot for automatically posting new chapters of 'Ascendance of a Bookworm' released by J-Novel Club"
|
||||||
|
license = "GPL-3.0-or-later"
|
||||||
|
|
||||||
|
[package.metadata.deb]
|
||||||
|
extended-description = "Bot for automatically posting new chapters of 'Ascendance of a Bookworm' released by J-Novel Club"
|
||||||
|
maintainer-scripts = "debian/"
|
||||||
|
revision = "1"
|
||||||
|
depends = ["libc6", "libssl3", "systemd"]
|
||||||
|
systemd-units = { enable = false }
|
||||||
|
|
||||||
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
chrono = "0.4.26"
|
chrono = "^0.4"
|
||||||
lemmy_api_common = "0.17.4"
|
lemmy_api_common = "0.19.5"
|
||||||
lemmy_db_schema = "0.17.4"
|
lemmy_db_schema = "0.19.5"
|
||||||
once_cell = "1.18.0"
|
once_cell = "^1.19"
|
||||||
reqwest = { version = "0.11.18", features = ["blocking", "json"] }
|
reqwest = { version = "^0.12", features = ["blocking", "json"] }
|
||||||
serde = "1.0.164"
|
serde = "^1.0"
|
||||||
serde_derive = "1.0.164"
|
serde_derive = "^1.0"
|
||||||
serde_json = "1.0.97"
|
serde_json = "^1.0"
|
||||||
strum_macros = "0.25.0"
|
strum_macros = "^0.26"
|
||||||
url = "2.4.0"
|
tokio = { version = "^1.37", features = ["rt", "rt-multi-thread", "macros"] }
|
||||||
|
url = "^2.5"
|
||||||
|
confy = "^0.6"
|
||||||
|
toml = "^0.8"
|
||||||
|
systemd-journal-logger = "^2.1.1"
|
||||||
|
log = "^0.4"
|
||||||
|
async-trait = "^0.1"
|
||||||
|
notify = "6.1.1"
|
53
README.md
53
README.md
|
@ -1 +1,52 @@
|
||||||
# ascendance-of-a-bookworm-bot
|
# aob-lemmy-bot
|
||||||
|
|
||||||
|
**config.toml**
|
||||||
|
```toml
|
||||||
|
instance = "https://lemmy.example.org"
|
||||||
|
username = "BotUserName"
|
||||||
|
password = "BotPassword"
|
||||||
|
status_post_url = "PostUrlForStatusMonitoring"
|
||||||
|
config_reload_seconds = 10800
|
||||||
|
|
||||||
|
protected_communities = [ "community_where_pins_should_stay" ]
|
||||||
|
|
||||||
|
[[series]]
|
||||||
|
slug = "example-slug"
|
||||||
|
parted = false
|
||||||
|
[series.prepub_community]
|
||||||
|
name = "communityforprepubs"
|
||||||
|
[series.prepub_community.pin_settings]
|
||||||
|
pin_new_post_local = true
|
||||||
|
pin_new_post_community = true
|
||||||
|
[series.prepub_community.post_body]
|
||||||
|
body_type = "Custom"
|
||||||
|
body_content = """
|
||||||
|
Custom Text for the Post\n\n\
|
||||||
|
Can contain new lines and [links](https://join-lemmy.org)"""
|
||||||
|
[series.volume_community]
|
||||||
|
name = "communityforvolumes"
|
||||||
|
[series.volume_community.pin_settings]
|
||||||
|
pin_new_post_local = false
|
||||||
|
pin_new_post_community = true
|
||||||
|
[series.volume_community.post_body]
|
||||||
|
body_type = "Description"
|
||||||
|
|
||||||
|
[[series]]
|
||||||
|
slug = "example-slug-2"
|
||||||
|
parted = true
|
||||||
|
[series.prepub_community]
|
||||||
|
name = "communityforprepubs"
|
||||||
|
[series.prepub_community.pin_settings]
|
||||||
|
pin_new_post_local = false
|
||||||
|
pin_new_post_community = false
|
||||||
|
[series.prepub_community.post_body]
|
||||||
|
body_type = "Custom"
|
||||||
|
body_content = "single line content"
|
||||||
|
[series.volume_community]
|
||||||
|
name = "communityforvolumes"
|
||||||
|
[series.volume_community.pin_settings]
|
||||||
|
pin_new_post_local = false
|
||||||
|
pin_new_post_community = false
|
||||||
|
[series.volume_community.post_body]
|
||||||
|
body_type = "None"
|
||||||
|
```
|
13
debian/aob-lemmy-bot.service
vendored
Normal file
13
debian/aob-lemmy-bot.service
vendored
Normal file
|
@ -0,0 +1,13 @@
|
||||||
|
[Unit]
|
||||||
|
Description="Bot for automatically posting new chapters of 'Ascendance of a Bookworm' released by J-Novel Club"
|
||||||
|
After=syslog.target
|
||||||
|
After=network-online.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Type=simple
|
||||||
|
ExecStart=/usr/bin/aob-lemmy-bot
|
||||||
|
Restart=always
|
||||||
|
RestartSec=3
|
||||||
|
|
||||||
|
[Install]
|
||||||
|
WantedBy=multi-user.target
|
|
@ -1,411 +0,0 @@
|
||||||
{
|
|
||||||
"version": "https://jsonfeed.org/version/1",
|
|
||||||
"title": "Ascendance of a Bookworm",
|
|
||||||
"home_page_url": "https://j-novel.club/series/ascendance-of-a-bookworm",
|
|
||||||
"description": "A young woman who loves books dies and is reborn in another world as Myne, a sickly child from a poor family. Worst of all, there are almost no books in this world! So Myne decides that she'll just have to make her own and become a librarian.",
|
|
||||||
"author": {
|
|
||||||
"name": "J-Novel Club"
|
|
||||||
},
|
|
||||||
"items": [
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-5-part-6",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-5-part-6",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 5 Part 6",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 5 Part 6 (available for subscribers)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-64872b31036804ff1be232c8/bookworm5.5-cover-400.jpg",
|
|
||||||
"date_published": "2023-06-12T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-5-part-5",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-5-part-5",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 5 Part 5",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 5 Part 5 (available for subscribers)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-647df642f839a63a784c8b24/bookworm5.5-cover-400.jpg",
|
|
||||||
"date_published": "2023-06-05T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-5-part-4",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-5-part-4",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 5 Part 4",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 5 Part 4 (available for subscribers)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-6474c52538f2134856b56bbe/bookworm5.5-cover-400.jpg",
|
|
||||||
"date_published": "2023-05-29T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-5-part-3",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-5-part-3",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 5 Part 3",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 5 Part 3 (available for subscribers)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-646b844e036804ff1be23118/bookworm5.5-cover-400.jpg",
|
|
||||||
"date_published": "2023-05-22T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-5-part-2",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-5-part-2",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 5 Part 2",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 5 Part 2 (available for subscribers)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-64624ef7a2ea846d6b3f5307/bookworm5.5-cover-400.jpg",
|
|
||||||
"date_published": "2023-05-15T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-5-part-1",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-5-part-1",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 5 Part 1",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 5 Part 1 (free)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-64594c97cabacabb2c498bfb/bookworm5.5-cover-400.jpg",
|
|
||||||
"date_published": "2023-05-08T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-4-part-8",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-4-part-8",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 4 Part 8",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 4 Part 8 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-64400ee2bbfa9b9015a3b4c2/bookworm5.4-cover-400.jpg",
|
|
||||||
"date_published": "2023-05-01T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-4-part-7",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-4-part-7",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 4 Part 7",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 4 Part 7 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-64400e5f6f9feb2622ff757a/bookworm5.4-cover-400.jpg",
|
|
||||||
"date_published": "2023-04-24T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-4-part-6",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-4-part-6",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 4 Part 6",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 4 Part 6 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-643d5c02bbfa9b9015a3b46a/bookworm5.4-cover-400.jpg",
|
|
||||||
"date_published": "2023-04-17T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-4-part-5",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-4-part-5",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 4 Part 5",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 4 Part 5 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-64342367f2df38506778bf87/bookworm5.4-cover-400.jpg",
|
|
||||||
"date_published": "2023-04-10T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-4-part-4",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-4-part-4",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 4 Part 4",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 4 Part 4 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-642b04fc89f12f4d2bf611ac/bookworm5.4-cover-400.jpg",
|
|
||||||
"date_published": "2023-04-03T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-4-part-3",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-4-part-3",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 4 Part 3",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 4 Part 3 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-6421b4627686c3cd55fc00aa/bookworm5.4-cover-400.jpg",
|
|
||||||
"date_published": "2023-03-27T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-4-part-2",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-4-part-2",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 4 Part 2",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 4 Part 2 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-64188110e9be8e3e55d5c6a5/bookworm5.4-cover-400.jpg",
|
|
||||||
"date_published": "2023-03-20T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-4-part-1",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-4-part-1",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 4 Part 1",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 4 Part 1 (free)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-640f67a67877a2862d88758b/bookworm5.4-cover-400.jpg",
|
|
||||||
"date_published": "2023-03-13T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-10",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-10",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 3 Part 10",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 3 Part 10 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-63f5f58e785e215d51f3969e/bookworm5.3-cover-400.jpg",
|
|
||||||
"date_published": "2023-03-06T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-9",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-9",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 3 Part 9",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 3 Part 9 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-63f5f49fd69a89450c0cf2d4/bookworm5.3-cover-400.jpg",
|
|
||||||
"date_published": "2023-02-27T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-8",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-8",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 3 Part 8",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 3 Part 8 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-63f3efb20179968f16229033/bookworm5.3-cover-400.jpg",
|
|
||||||
"date_published": "2023-02-20T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-7",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-7",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 3 Part 7",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 3 Part 7 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-63ea88e2d67ef0a916a929ca/bookworm5.3-cover-400.jpg",
|
|
||||||
"date_published": "2023-02-13T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-6",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-6",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 3 Part 6",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 3 Part 6 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-63e14f6c2f6ef88b59e0cc3d/bookworm5.3-cover-400.jpg",
|
|
||||||
"date_published": "2023-02-06T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-5",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-5",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 3 Part 5",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 3 Part 5 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-63d817bc552bedd02ef0f2d2/bookworm5.3-cover-400.jpg",
|
|
||||||
"date_published": "2023-01-30T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-4",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-4",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 3 Part 4",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 3 Part 4 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-63cef187c1f813e8051c11f6/bookworm5.3-cover-400.jpg",
|
|
||||||
"date_published": "2023-01-23T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-3",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-3",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 3 Part 3",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 3 Part 3 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-63c5c96cfcd981160ed7f4b9/bookworm5.3-cover-400.jpg",
|
|
||||||
"date_published": "2023-01-16T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-2",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-2",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 3 Part 2",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 3 Part 2 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-63bc72e9482b67ed0f4e130f/bookworm5.3-cover-400.jpg",
|
|
||||||
"date_published": "2023-01-09T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-1",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-3-part-1",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 3 Part 1",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 3 Part 1 (free)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-63af316e41fdb4b16fa9f3b5/bookworm5.3-cover-400.jpg",
|
|
||||||
"date_published": "2023-01-02T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-2-part-8",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-2-part-8",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 2 Part 8",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 2 Part 8 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-63971a23811dc9950fe219ad/bookworm5.2-cover-400.jpg",
|
|
||||||
"date_published": "2022-12-26T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-2-part-7",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-2-part-7",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 2 Part 7",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 2 Part 7 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-639719efa6449c0010fb311e/bookworm5.2-cover-400.jpg",
|
|
||||||
"date_published": "2022-12-19T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-2-part-6",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-2-part-6",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 2 Part 6",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 2 Part 6 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-6397050a75e261ab0f505a6b/bookworm5.2-cover-400.jpg",
|
|
||||||
"date_published": "2022-12-12T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-2-part-5",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-2-part-5",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 2 Part 5",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 2 Part 5 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-638e67708fc63f8c3f1a524a/bookworm5.2-cover-400.jpg",
|
|
||||||
"date_published": "2022-12-05T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-2-part-4",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-2-part-4",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 2 Part 4",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 2 Part 4 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-6384ed590517e1e171e6c551/bookworm5.2-cover-400.jpg",
|
|
||||||
"date_published": "2022-11-28T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-2-part-3",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-2-part-3",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 2 Part 3",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 2 Part 3 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-637b9c13449c28d01bb4b4cd/bookworm5.2-cover-400.jpg",
|
|
||||||
"date_published": "2022-11-21T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-2-part-2",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-2-part-2",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 2 Part 2",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 2 Part 2 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-63729a99563cdce739e17427/bookworm5.2-cover-400.jpg",
|
|
||||||
"date_published": "2022-11-14T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-2-part-1",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-2-part-1",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 2 Part 1",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 2 Part 1 (free)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-636942940f70ce58739b2844/bookworm5.2-cover-400.jpg",
|
|
||||||
"date_published": "2022-11-07T22:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-1-part-8",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-1-part-8",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 1 Part 8",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 1 Part 8 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-634dbbabb2895e4e5862a45e/bookworm5.1-cover-400.jpg",
|
|
||||||
"date_published": "2022-10-31T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-1-part-7",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-1-part-7",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 1 Part 7",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 1 Part 7 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-634dbb87a25e943074d2ede9/bookworm5.1-cover-400.jpg",
|
|
||||||
"date_published": "2022-10-24T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-1-part-6",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-1-part-6",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 1 Part 6",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 1 Part 6 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-634dbab44f712abf7c52d3a0/bookworm5.1-cover-400.jpg",
|
|
||||||
"date_published": "2022-10-17T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-1-part-5",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-1-part-5",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 1 Part 5",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 1 Part 5 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-63443bda3b3c7e893a05596b/bookworm5.1-cover-400.jpg",
|
|
||||||
"date_published": "2022-10-10T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-1-part-4",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-1-part-4",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 1 Part 4",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 1 Part 4 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-633b2f6c95d05f661f46b179/bookworm5.1-cover-400.jpg",
|
|
||||||
"date_published": "2022-10-03T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-1-part-3",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-1-part-3",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 1 Part 3",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 1 Part 3 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-6331af2e6d287a7b7268489d/bookworm5.1-cover-400.jpg",
|
|
||||||
"date_published": "2022-09-26T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-1-part-2",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-1-part-2",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 1 Part 2",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 1 Part 2 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-6328d459853da3577cbdd6f9/bookworm5.1-cover-400.jpg",
|
|
||||||
"date_published": "2022-09-19T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-1-part-1",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-5-volume-1-part-1",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 5 Volume 1 Part 1",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 5 Volume 1 Part 1 (free)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-631f9aed59b60299586f0b29/bookworm5.1-cover-400.jpg",
|
|
||||||
"date_published": "2022-09-12T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-9-part-8",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-9-part-8",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 4 Volume 9 Part 8",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 4 Volume 9 Part 8 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-6303e4666164ffe71fb3039c/bookworm4.9-cover-400.jpg",
|
|
||||||
"date_published": "2022-09-05T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-9-part-7",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-9-part-7",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 4 Volume 9 Part 7",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 4 Volume 9 Part 7 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-6303e45cbfd3ac0620743003/bookworm4.9-cover-400.jpg",
|
|
||||||
"date_published": "2022-08-29T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-9-part-6",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-9-part-6",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 4 Volume 9 Part 6",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 4 Volume 9 Part 6 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-6303e3df95d05f661f46ae31/bookworm4.9-cover-400.jpg",
|
|
||||||
"date_published": "2022-08-22T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-9-part-5",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-9-part-5",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 4 Volume 9 Part 5",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 4 Volume 9 Part 5 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-62fa9d2e3690f46d54265b03/bookworm4.9-cover-400.jpg",
|
|
||||||
"date_published": "2022-08-15T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-9-part-4",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-9-part-4",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 4 Volume 9 Part 4",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 4 Volume 9 Part 4 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-62f16bb8a9f787ca5446a1b8/bookworm4.9-cover-400.jpg",
|
|
||||||
"date_published": "2022-08-08T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-9-part-3",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-9-part-3",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 4 Volume 9 Part 3",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 4 Volume 9 Part 3 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-62e792b17d8cd29c54d666b6/bookworm4.9-cover-400.jpg",
|
|
||||||
"date_published": "2022-08-01T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-9-part-2",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-9-part-2",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 4 Volume 9 Part 2",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 4 Volume 9 Part 2 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-62def2b5de7f5911540ea23e/bookworm4.9-cover-400.jpg",
|
|
||||||
"date_published": "2022-07-25T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-9-part-1",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-9-part-1",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 4 Volume 9 Part 1",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 4 Volume 9 Part 1 (free)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-62d599c27d8cd29c54d665d5/bookworm4.9-cover-400.jpg",
|
|
||||||
"date_published": "2022-07-18T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-8-part-8",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-8-part-8",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 4 Volume 8 Part 8",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 4 Volume 8 Part 8 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-62bb698fd440cc5d411b50b1/bookworm4.8-cover-400.jpg",
|
|
||||||
"date_published": "2022-07-11T21:00:00Z"
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"id": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-8-part-7",
|
|
||||||
"url": "https://j-novel.club/read/ascendance-of-a-bookworm-part-4-volume-8-part-7",
|
|
||||||
"title": "Ascendance of a Bookworm: Part 4 Volume 8 Part 7",
|
|
||||||
"summary": "Read Ascendance of a Bookworm: Part 4 Volume 8 Part 7 (expired)",
|
|
||||||
"image": "https://d2dq7ifhe7bu0f.cloudfront.net/Part-62ba0e44cbbd90be7aca1380/bookworm4.8-cover-400.jpg",
|
|
||||||
"date_published": "2022-07-04T21:00:00Z"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
77
rustfmt.toml
Normal file
77
rustfmt.toml
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
max_width = 160
|
||||||
|
hard_tabs = false
|
||||||
|
tab_spaces = 4
|
||||||
|
newline_style = "Auto"
|
||||||
|
indent_style = "Block"
|
||||||
|
use_small_heuristics = "Default"
|
||||||
|
fn_call_width = 60
|
||||||
|
attr_fn_like_width = 70
|
||||||
|
struct_lit_width = 18
|
||||||
|
struct_variant_width = 35
|
||||||
|
array_width = 60
|
||||||
|
chain_width = 60
|
||||||
|
single_line_if_else_max_width = 50
|
||||||
|
wrap_comments = false
|
||||||
|
format_code_in_doc_comments = false
|
||||||
|
doc_comment_code_block_width = 100
|
||||||
|
comment_width = 80
|
||||||
|
normalize_comments = false
|
||||||
|
normalize_doc_attributes = false
|
||||||
|
format_strings = false
|
||||||
|
format_macro_matchers = false
|
||||||
|
format_macro_bodies = true
|
||||||
|
skip_macro_invocations = []
|
||||||
|
hex_literal_case = "Preserve"
|
||||||
|
empty_item_single_line = true
|
||||||
|
struct_lit_single_line = true
|
||||||
|
fn_single_line = false
|
||||||
|
where_single_line = false
|
||||||
|
imports_indent = "Block"
|
||||||
|
imports_layout = "Mixed"
|
||||||
|
imports_granularity = "Preserve"
|
||||||
|
group_imports = "Preserve"
|
||||||
|
reorder_imports = true
|
||||||
|
reorder_modules = true
|
||||||
|
reorder_impl_items = false
|
||||||
|
type_punctuation_density = "Wide"
|
||||||
|
space_before_colon = false
|
||||||
|
space_after_colon = true
|
||||||
|
spaces_around_ranges = false
|
||||||
|
binop_separator = "Front"
|
||||||
|
remove_nested_parens = true
|
||||||
|
combine_control_expr = true
|
||||||
|
short_array_element_width_threshold = 10
|
||||||
|
overflow_delimited_expr = false
|
||||||
|
struct_field_align_threshold = 0
|
||||||
|
enum_discrim_align_threshold = 0
|
||||||
|
match_arm_blocks = true
|
||||||
|
match_arm_leading_pipes = "Never"
|
||||||
|
force_multiline_blocks = false
|
||||||
|
fn_params_layout = "Tall"
|
||||||
|
brace_style = "SameLineWhere"
|
||||||
|
control_brace_style = "AlwaysSameLine"
|
||||||
|
trailing_semicolon = true
|
||||||
|
trailing_comma = "Vertical"
|
||||||
|
match_block_trailing_comma = false
|
||||||
|
blank_lines_upper_bound = 1
|
||||||
|
blank_lines_lower_bound = 0
|
||||||
|
edition = "2015"
|
||||||
|
version = "One"
|
||||||
|
inline_attribute_width = 0
|
||||||
|
format_generated_files = true
|
||||||
|
merge_derives = true
|
||||||
|
use_try_shorthand = false
|
||||||
|
use_field_init_shorthand = false
|
||||||
|
force_explicit_abi = true
|
||||||
|
condense_wildcard_suffixes = false
|
||||||
|
color = "Auto"
|
||||||
|
required_version = "1.5.2"
|
||||||
|
unstable_features = false
|
||||||
|
disable_all_formatting = false
|
||||||
|
skip_children = false
|
||||||
|
hide_parse_errors = false
|
||||||
|
error_on_line_overflow = false
|
||||||
|
error_on_unformatted = false
|
||||||
|
ignore = []
|
||||||
|
emit_mode = "Files"
|
||||||
|
make_backup = false
|
136
src/bot.rs
Normal file
136
src/bot.rs
Normal file
|
@ -0,0 +1,136 @@
|
||||||
|
use crate::{config::{Config}, HTTP_CLIENT};
|
||||||
|
use crate::lemmy::{Lemmy};
|
||||||
|
use crate::post_history::{SeriesHistory};
|
||||||
|
use chrono::{DateTime, Duration, Utc};
|
||||||
|
use std::sync::{Arc, RwLock};
|
||||||
|
use notify::{Event, EventKind, event::{AccessKind, AccessMode}, RecursiveMode, Watcher};
|
||||||
|
use tokio::time::sleep;
|
||||||
|
use systemd_journal_logger::connected_to_journal;
|
||||||
|
|
||||||
|
macro_rules! debug {
|
||||||
|
($msg:tt) => {
|
||||||
|
match connected_to_journal() {
|
||||||
|
true => log::debug!("[DEBUG] {}", $msg),
|
||||||
|
false => println!("[DEBUG] {}", $msg),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! info {
|
||||||
|
($msg:tt) => {
|
||||||
|
match connected_to_journal() {
|
||||||
|
true => log::info!("[INFO] {}", $msg),
|
||||||
|
false => println!("[INFO] {}", $msg),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! error {
|
||||||
|
($msg:tt) => {
|
||||||
|
match connected_to_journal() {
|
||||||
|
true => log::error!("[ERROR] {}", $msg),
|
||||||
|
false => eprintln!("[ERROR] {}", $msg),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) struct Bot {
|
||||||
|
shared_config: Arc<RwLock<Config>>,
|
||||||
|
history: SeriesHistory,
|
||||||
|
run_start_time: DateTime<Utc>
|
||||||
|
}
|
||||||
|
|
||||||
|
enum Wait {
|
||||||
|
Absolute,
|
||||||
|
Buffer
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Bot {
|
||||||
|
pub(crate) fn new() -> Self {
|
||||||
|
let config = Config::load();
|
||||||
|
let shared_config: Arc<RwLock<Config>> = Arc::new(RwLock::new(config));
|
||||||
|
|
||||||
|
let shared_config_copy = shared_config.clone();
|
||||||
|
let mut watcher = notify::recommended_watcher(move |res: Result<Event, notify::Error>| {
|
||||||
|
match res {
|
||||||
|
Ok(event) => {
|
||||||
|
if event.kind == EventKind::Access(AccessKind::Close(AccessMode::Write)) {
|
||||||
|
let mut write = shared_config_copy.write().expect("Write Lock Failed");
|
||||||
|
let new_config = Config::load();
|
||||||
|
write.series = new_config.series;
|
||||||
|
write.instance = new_config.instance;
|
||||||
|
write.protected_communities = new_config.protected_communities;
|
||||||
|
write.status_post_url = new_config.status_post_url;
|
||||||
|
info!("Reloaded Configuration");
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
let msg = format!("Error watching files: {e}");
|
||||||
|
error!(msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).expect("Watcher Error");
|
||||||
|
|
||||||
|
watcher.watch(&Config::get_path(), RecursiveMode::NonRecursive).expect("Error in watcher");
|
||||||
|
|
||||||
|
let history: SeriesHistory = SeriesHistory::load_history();
|
||||||
|
|
||||||
|
Bot { shared_config, history, run_start_time: Utc::now() }
|
||||||
|
}
|
||||||
|
pub(crate) async fn run(&mut self) {
|
||||||
|
loop {
|
||||||
|
let mut lemmy = match Lemmy::new(&self.shared_config).await {
|
||||||
|
Ok(data) => data,
|
||||||
|
Err(_) => continue,
|
||||||
|
};
|
||||||
|
|
||||||
|
lemmy.get_communities().await;
|
||||||
|
|
||||||
|
self.history = SeriesHistory::load_history();
|
||||||
|
|
||||||
|
let start: DateTime<Utc> = Utc::now();
|
||||||
|
while Utc::now() - start <= Duration::minutes(60) {
|
||||||
|
self.run_start_time = Utc::now();
|
||||||
|
self.ping_status().await;
|
||||||
|
let read_copy = self.shared_config.read().expect("Read Lock Failed").clone();
|
||||||
|
for series in read_copy.series {
|
||||||
|
series.update(&mut self.history, &lemmy, &self.shared_config).await;
|
||||||
|
debug!("Done Updating Series");
|
||||||
|
self.wait(1, Wait::Absolute).await;
|
||||||
|
}
|
||||||
|
debug!("Awaiting Timeout");
|
||||||
|
self.wait(30, Wait::Buffer).await;
|
||||||
|
debug!("Pinging Server");
|
||||||
|
self.ping_status().await;
|
||||||
|
debug!("Awaiting Timeout 2");
|
||||||
|
self.wait(30, Wait::Absolute).await;
|
||||||
|
}
|
||||||
|
|
||||||
|
lemmy.logout().await;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn ping_status(&self) {
|
||||||
|
let read_config = &self.shared_config.read().expect("Read Lock Failed").clone();
|
||||||
|
if let Some(status_url) = &read_config.status_post_url {
|
||||||
|
match HTTP_CLIENT.get(status_url).send().await {
|
||||||
|
Ok(_) => {},
|
||||||
|
Err(e) => {
|
||||||
|
let err_msg = format!("While pinging status URL: {e}");
|
||||||
|
error!(err_msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn wait(&self, seconds: i64, start_time: Wait) {
|
||||||
|
let duration: Duration = Duration::seconds(seconds);
|
||||||
|
let start_time: DateTime<Utc> = match start_time {
|
||||||
|
Wait::Absolute => Utc::now(),
|
||||||
|
Wait::Buffer => self.run_start_time,
|
||||||
|
};
|
||||||
|
while Utc::now() - start_time < duration {
|
||||||
|
sleep(Duration::milliseconds(100).to_std().unwrap()).await
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
298
src/config.rs
Normal file
298
src/config.rs
Normal file
|
@ -0,0 +1,298 @@
|
||||||
|
use std::path::PathBuf;
|
||||||
|
use std::sync::{Arc, RwLock};
|
||||||
|
use chrono::{Timelike, Utc};
|
||||||
|
use crate::config::PostBody::Description;
|
||||||
|
use lemmy_db_schema::PostFeatureType;
|
||||||
|
use lemmy_db_schema::sensitive::SensitiveString;
|
||||||
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
use crate::lemmy::{Lemmy, PartInfo, PostType};
|
||||||
|
use crate::post_history::{SeriesHistory};
|
||||||
|
use systemd_journal_logger::connected_to_journal;
|
||||||
|
use crate::fetchers::{FetcherTrait, Fetcher};
|
||||||
|
use crate::fetchers::jnovel::{JNovelFetcher};
|
||||||
|
|
||||||
|
macro_rules! debug {
|
||||||
|
($msg:tt) => {
|
||||||
|
match connected_to_journal() {
|
||||||
|
true => log::debug!("[DEBUG] {}", $msg),
|
||||||
|
false => println!("[DEBUG] {}", $msg),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! info {
|
||||||
|
($msg:tt) => {
|
||||||
|
match connected_to_journal() {
|
||||||
|
true => log::info!("[INFO] {}", $msg),
|
||||||
|
false => println!("[INFO] {}", $msg),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! warn {
|
||||||
|
($msg:tt) => {
|
||||||
|
match connected_to_journal() {
|
||||||
|
true => log::warn!("[WARN] {}", $msg),
|
||||||
|
false => println!("[WARN] {}", $msg),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! error {
|
||||||
|
($msg:tt) => {
|
||||||
|
match connected_to_journal() {
|
||||||
|
true => log::error!("[ERROR] {}", $msg),
|
||||||
|
false => eprintln!("[ERROR] {}", $msg),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
|
pub(crate) struct Config {
|
||||||
|
pub(crate) instance: String,
|
||||||
|
username: SensitiveString,
|
||||||
|
password: SensitiveString,
|
||||||
|
pub(crate) status_post_url: Option<String>,
|
||||||
|
pub(crate) config_reload_seconds: u32,
|
||||||
|
pub(crate) protected_communities: Vec<String>,
|
||||||
|
pub(crate) series: Vec<SeriesConfig>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Config {
|
||||||
|
pub(crate) fn load() -> Self {
|
||||||
|
let cfg: Self = match confy::load(env!("CARGO_PKG_NAME"), "config") {
|
||||||
|
Ok(data) => data,
|
||||||
|
Err(e) => panic!("config.toml not found: {e}"),
|
||||||
|
};
|
||||||
|
|
||||||
|
if cfg.instance.is_empty() {
|
||||||
|
panic!("bot instance not set!")
|
||||||
|
}
|
||||||
|
|
||||||
|
if cfg.username.is_empty() {
|
||||||
|
panic!("bot username not set!")
|
||||||
|
}
|
||||||
|
|
||||||
|
if cfg.password.is_empty() {
|
||||||
|
panic!("bot password not provided!")
|
||||||
|
}
|
||||||
|
|
||||||
|
cfg.series.iter().for_each(|series| {
|
||||||
|
if series.prepub_community.post_body == Description {
|
||||||
|
panic!("'Description' type Post Body only supported for Volumes!")
|
||||||
|
}
|
||||||
|
});
|
||||||
|
cfg
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_path() -> PathBuf {
|
||||||
|
confy::get_configuration_file_path(env!("CARGO_PKG_NAME"), "config").expect("Application will not without confy")
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_username(&self) -> SensitiveString {
|
||||||
|
self.username.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_password(&self) -> SensitiveString {
|
||||||
|
self.password.clone()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Config {
|
||||||
|
fn default() -> Self {
|
||||||
|
Config {
|
||||||
|
instance: "".to_owned(),
|
||||||
|
username: SensitiveString::from("".to_owned()),
|
||||||
|
password: SensitiveString::from("".to_owned()),
|
||||||
|
status_post_url: None,
|
||||||
|
config_reload_seconds: 21600,
|
||||||
|
protected_communities: vec![],
|
||||||
|
series: vec![],
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
|
pub(crate) struct SeriesConfig {
|
||||||
|
pub(crate) slug: String,
|
||||||
|
pub(crate) parted: bool,
|
||||||
|
pub(crate) prepub_community: PostConfig,
|
||||||
|
pub(crate) volume_community: PostConfig,
|
||||||
|
pub(crate) fetcher: Fetcher
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SeriesConfig {
|
||||||
|
pub(crate) async fn update(&self, history: &mut SeriesHistory, lemmy: &Lemmy, config: &Arc<RwLock<Config>>) {
|
||||||
|
let info_msg = format!("Checking {} for Updates", self.slug);
|
||||||
|
info!(info_msg);
|
||||||
|
|
||||||
|
let mut fetcher: Fetcher = match &self.fetcher {
|
||||||
|
Fetcher::Jnc(_) => {
|
||||||
|
Fetcher::Jnc(JNovelFetcher::new())
|
||||||
|
},
|
||||||
|
/*default => {
|
||||||
|
let err_msg = format!("Fetcher {default} not implemented");
|
||||||
|
error!(err_msg);
|
||||||
|
return;
|
||||||
|
}*/
|
||||||
|
};
|
||||||
|
|
||||||
|
match fetcher {
|
||||||
|
Fetcher::Jnc(ref mut jnc) => {
|
||||||
|
jnc.set_series(self.slug.clone());
|
||||||
|
jnc.set_part_option(self.parted);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let post_list = match fetcher.check_feed().await {
|
||||||
|
Ok(data) => data,
|
||||||
|
Err(_) => {
|
||||||
|
let err_msg = format!("While checking feed for {}", self.slug);
|
||||||
|
error!(err_msg);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if post_list.is_empty() && Utc::now().minute() % 10 == 0 {
|
||||||
|
let info_msg = "No Updates found";
|
||||||
|
info!(info_msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
for post_info in post_list.iter() {
|
||||||
|
if history.check_for_post(
|
||||||
|
self.slug.as_str(),
|
||||||
|
post_info.get_part_info().unwrap_or(PartInfo::NoParts).as_string().as_str(),
|
||||||
|
post_info.get_info().title.as_str()
|
||||||
|
) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
let post_data = post_info.get_post_data(self, lemmy);
|
||||||
|
|
||||||
|
let info = format!(
|
||||||
|
"Posting '{}' to {}",
|
||||||
|
post_info.get_info().title.as_str(),
|
||||||
|
post_info.get_post_config(self).name.as_str()
|
||||||
|
);
|
||||||
|
info!(info);
|
||||||
|
|
||||||
|
let post_id = match lemmy.post(post_data).await {
|
||||||
|
Some(data) => data,
|
||||||
|
None=> {
|
||||||
|
error!("Error posting chapter");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let read_config = config.read().expect("Read Lock Failed").clone();
|
||||||
|
|
||||||
|
if post_info.get_post_config(self).pin_settings.pin_new_post_community
|
||||||
|
&& !read_config
|
||||||
|
.protected_communities
|
||||||
|
.contains(&post_info.get_post_config(self).name)
|
||||||
|
{
|
||||||
|
let info = format!(
|
||||||
|
"Pinning '{}' to {}",
|
||||||
|
post_info.get_info().title,
|
||||||
|
post_info.get_post_config(self).name.as_str()
|
||||||
|
);
|
||||||
|
info!(info);
|
||||||
|
let pinned_posts = lemmy.get_community_pinned(lemmy.get_community_id(&post_info.get_post_config(self).name)).await.unwrap_or_else(|| {
|
||||||
|
error!("Pinning of Post to community failed");
|
||||||
|
vec![]
|
||||||
|
});
|
||||||
|
if !pinned_posts.is_empty() {
|
||||||
|
let community_pinned_post = &pinned_posts[0];
|
||||||
|
if lemmy.unpin(community_pinned_post.post.id, PostFeatureType::Community).await.is_none() {
|
||||||
|
error!("Error un-pinning post");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if lemmy.pin(post_id, PostFeatureType::Community).await.is_none() {
|
||||||
|
error!("Error pinning post");
|
||||||
|
}
|
||||||
|
} else if read_config
|
||||||
|
.protected_communities
|
||||||
|
.contains(&post_info.get_post_config(self).name)
|
||||||
|
{
|
||||||
|
let message = format!(
|
||||||
|
"Community '{}' for Series '{}' is protected. Is this intended?",
|
||||||
|
&post_info.get_post_config(self).name, self.slug
|
||||||
|
);
|
||||||
|
warn!(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if post_info.get_post_config(self).pin_settings.pin_new_post_local {
|
||||||
|
let info = format!("Pinning '{}' to Instance", post_info.get_info().title);
|
||||||
|
info!(info);
|
||||||
|
let pinned_posts = match lemmy.get_local_pinned().await {
|
||||||
|
Some(data) => {data}
|
||||||
|
None => {
|
||||||
|
error!("Error fetching pinned posts");
|
||||||
|
vec![]
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
if !pinned_posts.is_empty() {
|
||||||
|
for pinned_post in pinned_posts {
|
||||||
|
if read_config
|
||||||
|
.protected_communities
|
||||||
|
.contains(&pinned_post.community.name)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
let community_pinned_post = &pinned_post;
|
||||||
|
if lemmy.unpin(community_pinned_post.post.id, PostFeatureType::Local).await.is_none() {
|
||||||
|
error!("Error pinning post");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if lemmy.pin(post_id, PostFeatureType::Local).await.is_none() {
|
||||||
|
error!("Error pinning post");
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut series_history = history.get_series(self.slug.as_str());
|
||||||
|
let mut part_history = series_history.get_part(post_info.get_part_info().unwrap_or(PartInfo::NoParts).as_string().as_str());
|
||||||
|
|
||||||
|
match post_info.post_type {
|
||||||
|
Some(post_type) => {
|
||||||
|
match post_type {
|
||||||
|
PostType::Chapter => part_history.chapter = post_info.get_info().title,
|
||||||
|
PostType::Volume => part_history.volume = post_info.get_info().title,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => part_history.chapter = post_info.get_info().title,
|
||||||
|
}
|
||||||
|
|
||||||
|
series_history.set_part(post_info.get_part_info().unwrap_or(PartInfo::NoParts).as_string().as_str(), part_history);
|
||||||
|
history
|
||||||
|
.set_series(self.slug.as_str(), series_history);
|
||||||
|
debug!("Saving History");
|
||||||
|
history.save_history();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
|
pub(crate) struct PostConfig {
|
||||||
|
pub(crate) name: String,
|
||||||
|
pub(crate) pin_settings: PinConfig,
|
||||||
|
pub(crate) post_body: PostBody,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Clone)]
|
||||||
|
pub(crate) struct PinConfig {
|
||||||
|
pub(crate) pin_new_post_local: bool,
|
||||||
|
pub(crate) pin_new_post_community: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Serialize, Deserialize, Clone, PartialEq)]
|
||||||
|
#[serde(tag = "body_type", content = "body_content")]
|
||||||
|
pub(crate) enum PostBody {
|
||||||
|
None,
|
||||||
|
Description,
|
||||||
|
Custom(String),
|
||||||
|
}
|
|
@ -1,178 +0,0 @@
|
||||||
use std::{fs::{self, OpenOptions}, path::Path, io::Write};
|
|
||||||
|
|
||||||
use lemmy_api_common::sensitive::Sensitive;
|
|
||||||
use serde_derive::{Deserialize, Serialize};
|
|
||||||
|
|
||||||
macro_rules! pub_struct {
|
|
||||||
($name:ident {$($field:ident: $t:ty,)*}) => {
|
|
||||||
#[derive(Serialize, Deserialize, Clone, PartialEq)]
|
|
||||||
pub(crate) struct $name {
|
|
||||||
$(pub(crate) $field: $t), *
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Secrets structs
|
|
||||||
pub_struct!(Secrets {
|
|
||||||
lemmy: LemmyLogin,
|
|
||||||
reddit: RedditLogin,
|
|
||||||
});
|
|
||||||
|
|
||||||
impl Secrets {
|
|
||||||
pub(crate) fn load() -> Secrets {
|
|
||||||
let file_contents = match fs::read_to_string("secrets.json") {
|
|
||||||
Ok(data) => data,
|
|
||||||
Err(e) => panic!("ERROR: secrets.json could not be read:\n\n{:#?}", e),
|
|
||||||
};
|
|
||||||
let config_parse: Secrets = match serde_json::from_str(&file_contents) {
|
|
||||||
Ok(data) => data,
|
|
||||||
Err(e) => panic!("ERROR: secrets.json could not be parsed:\n\n{:#?}", e),
|
|
||||||
};
|
|
||||||
|
|
||||||
return config_parse;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, PartialEq)]
|
|
||||||
pub(crate) struct LemmyLogin {
|
|
||||||
pub(crate) username: String,
|
|
||||||
password: String
|
|
||||||
}
|
|
||||||
|
|
||||||
impl LemmyLogin {
|
|
||||||
pub(crate) fn get_username(&self) -> Sensitive<String> {
|
|
||||||
return Sensitive::new(self.username.clone());
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn get_password(&self) -> Sensitive<String> {
|
|
||||||
return Sensitive::new(self.password.clone())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, PartialEq)]
|
|
||||||
pub(crate) struct RedditLogin {
|
|
||||||
pub(crate) app_id: String,
|
|
||||||
app_secret: String,
|
|
||||||
refresh_token: String,
|
|
||||||
redirect_uri: String,
|
|
||||||
}
|
|
||||||
|
|
||||||
// Config structs
|
|
||||||
pub_struct!(Config {
|
|
||||||
reddit_config: RedditConfig,
|
|
||||||
feeds: Vec<FeedSetting>,
|
|
||||||
});
|
|
||||||
|
|
||||||
impl Config {
|
|
||||||
pub(crate) fn load() -> Config {
|
|
||||||
let file_contents = match fs::read_to_string("config.json") {
|
|
||||||
Ok(data) => data,
|
|
||||||
Err(e) => panic!("ERROR: config.json could not be read:\n\n{:#?}", e),
|
|
||||||
};
|
|
||||||
let config_parse: Config = match serde_json::from_str(&file_contents) {
|
|
||||||
Ok(data) => data,
|
|
||||||
Err(e) => panic!("ERROR: config.json could not be parsed:\n\n{:#?}", e),
|
|
||||||
};
|
|
||||||
|
|
||||||
return config_parse;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub_struct!(RedditConfig {
|
|
||||||
user_agent: String,
|
|
||||||
subreddit: String,
|
|
||||||
});
|
|
||||||
|
|
||||||
pub_struct!(FeedSetting {
|
|
||||||
feed_url: String,
|
|
||||||
communities: FeedCommunities,
|
|
||||||
reddit: FeedRedditSettings,
|
|
||||||
});
|
|
||||||
|
|
||||||
pub_struct!(FeedCommunities {
|
|
||||||
chapter: LemmyCommunities,
|
|
||||||
volume: LemmyCommunities,
|
|
||||||
});
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Clone, PartialEq, strum_macros::Display)]
|
|
||||||
#[allow(non_camel_case_types)]
|
|
||||||
pub(crate) enum LemmyCommunities {
|
|
||||||
aobwebnovel,
|
|
||||||
aobprepub,
|
|
||||||
aoblightnovel,
|
|
||||||
aobmanga,
|
|
||||||
aobanime
|
|
||||||
}
|
|
||||||
|
|
||||||
pub_struct!(FeedRedditSettings {
|
|
||||||
enabled: bool,
|
|
||||||
flair: String,
|
|
||||||
});
|
|
||||||
|
|
||||||
// Posts structs
|
|
||||||
pub_struct!(PrevPost {
|
|
||||||
title: String,
|
|
||||||
last_post_url: String,
|
|
||||||
});
|
|
||||||
|
|
||||||
impl PrevPost {
|
|
||||||
pub(crate) fn load() -> Vec<PrevPost> {
|
|
||||||
let history;
|
|
||||||
|
|
||||||
if Path::new("posts.json").exists() {
|
|
||||||
let file_contents = match fs::read_to_string("posts.json") {
|
|
||||||
Ok(data) => data,
|
|
||||||
Err(e) => panic!("ERROR: secrets.json could not be read:\n\n{:#?}", e),
|
|
||||||
};
|
|
||||||
|
|
||||||
if file_contents.len() > 0 {
|
|
||||||
let history_parse: Vec<PrevPost> = match serde_json::from_str(&file_contents) {
|
|
||||||
Ok(data) => data,
|
|
||||||
Err(e) => panic!("ERROR: secrets.json could not be parsed:\n\n{:#?}", e),
|
|
||||||
};
|
|
||||||
history = history_parse;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
history = [].to_vec()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
let _ = fs::File::create("posts.json");
|
|
||||||
history = [].to_vec()
|
|
||||||
}
|
|
||||||
|
|
||||||
return history;
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn save(data: &Vec<PrevPost>) {
|
|
||||||
let mut file = OpenOptions::new().read(true).write(true).create(true).open("posts.json").unwrap();
|
|
||||||
|
|
||||||
let json_data = serde_json::to_string_pretty(&data).unwrap();
|
|
||||||
|
|
||||||
write!(&mut file, "{}", json_data).unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// RSS Feed Structs
|
|
||||||
pub_struct!(FeedData {
|
|
||||||
version: String,
|
|
||||||
title: String,
|
|
||||||
home_page_url: String,
|
|
||||||
description: String,
|
|
||||||
author: FeedAuthor,
|
|
||||||
items: Vec<FeedEntry>,
|
|
||||||
});
|
|
||||||
|
|
||||||
pub_struct!(FeedAuthor {
|
|
||||||
name: String,
|
|
||||||
});
|
|
||||||
|
|
||||||
pub_struct!(FeedEntry {
|
|
||||||
id: String,
|
|
||||||
url: String,
|
|
||||||
title: String,
|
|
||||||
summary: String,
|
|
||||||
image: Option<String>,
|
|
||||||
date_published: String,
|
|
||||||
});
|
|
||||||
|
|
307
src/fetchers/jnovel.rs
Normal file
307
src/fetchers/jnovel.rs
Normal file
|
@ -0,0 +1,307 @@
|
||||||
|
use crate::{HTTP_CLIENT};
|
||||||
|
use chrono::{DateTime, Duration, Utc};
|
||||||
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::ops::Sub;
|
||||||
|
use async_trait::async_trait;
|
||||||
|
use crate::fetchers::{FetcherTrait};
|
||||||
|
use crate::lemmy::{PartInfo, PostInfo, PostInfoInner, PostType};
|
||||||
|
use systemd_journal_logger::connected_to_journal;
|
||||||
|
use crate::lemmy::PartInfo::{NoParts, Part};
|
||||||
|
|
||||||
|
macro_rules! error {
|
||||||
|
($msg:tt) => {
|
||||||
|
match connected_to_journal() {
|
||||||
|
true => log::error!("[ERROR] {}", $msg),
|
||||||
|
false => eprintln!("[ERROR] {}", $msg),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! info {
|
||||||
|
($msg:tt) => {
|
||||||
|
match connected_to_journal() {
|
||||||
|
true => log::info!("[INFO] {}", $msg),
|
||||||
|
false => println!("[INFO] {}", $msg),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
static PAST_DAYS_ELIGIBLE: u8 = 4;
|
||||||
|
|
||||||
|
macro_rules! api_url {
|
||||||
|
() => {
|
||||||
|
"https://labs.j-novel.club/app/v2".to_owned()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! jnc_base_url {
|
||||||
|
() => {
|
||||||
|
"https://j-novel.club".to_owned()
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
||||||
|
struct VolumesWrapper {
|
||||||
|
volumes: Vec<VolumeDetail>,
|
||||||
|
pagination: PaginationInfo,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
||||||
|
struct ChapterWrapper {
|
||||||
|
parts: Vec<ChapterDetail>,
|
||||||
|
pagination: PaginationInfo,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
||||||
|
struct PaginationInfo {
|
||||||
|
limit: usize,
|
||||||
|
skip: usize,
|
||||||
|
#[serde(alias = "lastPage")]
|
||||||
|
last_page: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
||||||
|
pub(crate) struct Cover {
|
||||||
|
#[serde(alias = "coverUrl")]
|
||||||
|
pub(crate) cover: String,
|
||||||
|
#[serde(alias = "thumbnailUrl")]
|
||||||
|
pub(crate) thumbnail: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
||||||
|
pub(crate) struct VolumeDetail {
|
||||||
|
pub(crate) title: String,
|
||||||
|
pub(crate) slug: String,
|
||||||
|
number: u8,
|
||||||
|
publishing: String,
|
||||||
|
#[serde(alias = "shortDescription")]
|
||||||
|
short_description: String,
|
||||||
|
cover: Cover,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq)]
|
||||||
|
pub(crate) struct ChapterDetail {
|
||||||
|
pub(crate) title: String,
|
||||||
|
pub(crate) slug: String,
|
||||||
|
launch: String,
|
||||||
|
pub(crate) cover: Option<Cover>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize, Debug, Clone)]
|
||||||
|
pub(crate) struct JNovelFetcher {
|
||||||
|
series_slug: String,
|
||||||
|
series_has_parts: bool
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for JNovelFetcher {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
series_slug: "".to_owned(),
|
||||||
|
series_has_parts: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl JNovelFetcher {
|
||||||
|
pub(crate) fn set_series(&mut self, series: String) {
|
||||||
|
self.series_slug = series;
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn set_part_option(&mut self, has_parts: bool) {
|
||||||
|
self.series_has_parts = has_parts;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
impl FetcherTrait for JNovelFetcher {
|
||||||
|
fn new() -> Self {
|
||||||
|
JNovelFetcher {
|
||||||
|
series_slug: "".to_owned(),
|
||||||
|
series_has_parts: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn check_feed(&self) -> Result<Vec<PostInfo>, ()> {
|
||||||
|
let response = match HTTP_CLIENT
|
||||||
|
.get(api_url!() + "/series/" + self.series_slug.as_str() + "/volumes?format=json")
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(data) => match data.text().await {
|
||||||
|
Ok(data) => data,
|
||||||
|
Err(e) => {
|
||||||
|
let err_msg = format!("While checking feed: {e}");
|
||||||
|
error!(err_msg);
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
let err_msg = format!("{e}");
|
||||||
|
error!(err_msg);
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut volume_brief_data: VolumesWrapper = match serde_json::from_str(&response) {
|
||||||
|
Ok(data) => data,
|
||||||
|
Err(e) => {
|
||||||
|
let err_msg = format!("{e}");
|
||||||
|
error!(err_msg);
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
volume_brief_data.volumes.reverse(); // Makes breaking out of the volume loop easier
|
||||||
|
|
||||||
|
// If no parts just use 0 as Part indicator as no Series with Parts has a Part 0
|
||||||
|
let mut volume_map: HashMap<u8, PostInfo> = HashMap::new();
|
||||||
|
let mut prepub_map: HashMap<u8, PostInfo> = HashMap::new();
|
||||||
|
|
||||||
|
for volume in volume_brief_data.volumes.iter() {
|
||||||
|
let publishing_date = DateTime::parse_from_rfc3339(&volume.publishing).unwrap();
|
||||||
|
if publishing_date < Utc::now().sub(Duration::days(PAST_DAYS_ELIGIBLE as i64)) {
|
||||||
|
match self.series_has_parts {
|
||||||
|
true => continue,
|
||||||
|
false => break,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
let new_part_info: PartInfo;
|
||||||
|
|
||||||
|
if self.series_has_parts {
|
||||||
|
let mut part_number: Option<u8> = None;
|
||||||
|
let splits: Vec<&str> = volume.slug.split('-').collect();
|
||||||
|
for (index, split) in splits.clone().into_iter().enumerate() {
|
||||||
|
if split == "part" {
|
||||||
|
part_number = Some(
|
||||||
|
splits[index + 1]
|
||||||
|
.parse::<u8>()
|
||||||
|
.expect("Split Element after 'Part' should always be a number"),
|
||||||
|
);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
match part_number {
|
||||||
|
Some(number) => new_part_info = Part(number),
|
||||||
|
None => {
|
||||||
|
info!("No Part found, assuming 1");
|
||||||
|
new_part_info = Part(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
new_part_info = NoParts;
|
||||||
|
}
|
||||||
|
|
||||||
|
let post_url = format!(
|
||||||
|
"{}/series/{}#volume-{}",
|
||||||
|
jnc_base_url!(),
|
||||||
|
self.series_slug.as_str(),
|
||||||
|
volume.number
|
||||||
|
);
|
||||||
|
let post_details = PostInfoInner {
|
||||||
|
title: volume.title.clone(),
|
||||||
|
url: post_url.clone(),
|
||||||
|
thumbnail: Some(volume.cover.thumbnail.clone())
|
||||||
|
};
|
||||||
|
|
||||||
|
let new_post_info = PostInfo {
|
||||||
|
post_type: Some(PostType::Volume),
|
||||||
|
part: Some(new_part_info),
|
||||||
|
description: Some(volume.short_description.clone()),
|
||||||
|
lemmy_info: post_details,
|
||||||
|
};
|
||||||
|
|
||||||
|
let part_id = new_part_info.as_u8();
|
||||||
|
|
||||||
|
if publishing_date <= Utc::now() {
|
||||||
|
volume_map
|
||||||
|
.entry(part_id)
|
||||||
|
.and_modify(|val| {
|
||||||
|
if *val < new_post_info {
|
||||||
|
*val = new_post_info.clone()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.or_insert(new_post_info);
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(prepub_info) = get_latest_prepub(&volume.slug).await {
|
||||||
|
let prepub_post_info = PostInfo {
|
||||||
|
post_type: Some(PostType::Chapter),
|
||||||
|
part: Some(new_part_info),
|
||||||
|
lemmy_info: prepub_info,
|
||||||
|
description: None,
|
||||||
|
};
|
||||||
|
|
||||||
|
prepub_map
|
||||||
|
.entry(part_id)
|
||||||
|
.and_modify(|val| {
|
||||||
|
if *val < prepub_post_info {
|
||||||
|
*val = prepub_post_info.clone()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.or_insert(prepub_post_info);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut result_vec: Vec<PostInfo> = volume_map.values().cloned().collect();
|
||||||
|
let mut prepub_vec: Vec<PostInfo> = prepub_map.values().cloned().collect();
|
||||||
|
result_vec.append(&mut prepub_vec);
|
||||||
|
|
||||||
|
Ok(result_vec)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
async fn get_latest_prepub(volume_slug: &str) -> Option<PostInfoInner> {
|
||||||
|
let response = match HTTP_CLIENT
|
||||||
|
.get(api_url!() + "/volumes/" + volume_slug + "/parts?format=json")
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(data) => match data.text().await {
|
||||||
|
Ok(data) => data,
|
||||||
|
Err(e) => {
|
||||||
|
let err_msg = format!("While getting latest PrePub: {e}");
|
||||||
|
error!(err_msg);
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
let err_msg = format!("{e}");
|
||||||
|
error!(err_msg);
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut volume_prepub_parts_data: ChapterWrapper = match serde_json::from_str(&response) {
|
||||||
|
Ok(data) => data,
|
||||||
|
Err(e) => {
|
||||||
|
let err_msg = format!("{e}");
|
||||||
|
error!(err_msg);
|
||||||
|
return None;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
volume_prepub_parts_data.parts.reverse(); // Makes breaking out of the parts loop easier
|
||||||
|
|
||||||
|
let mut post_details: Option<PostInfoInner> = None;
|
||||||
|
|
||||||
|
for prepub_part in volume_prepub_parts_data.parts.iter() {
|
||||||
|
let publishing_date = DateTime::parse_from_rfc3339(&prepub_part.launch).unwrap();
|
||||||
|
if publishing_date > Utc::now() {
|
||||||
|
break;
|
||||||
|
} else if publishing_date < Utc::now().sub(Duration::days(PAST_DAYS_ELIGIBLE as i64)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
let thumbnail = prepub_part.cover.as_ref().map(|cover| cover.thumbnail.clone());
|
||||||
|
|
||||||
|
let post_url = format!("{}/read/{}", jnc_base_url!(), prepub_part.slug);
|
||||||
|
post_details = Some(PostInfoInner {
|
||||||
|
title: prepub_part.title.clone(),
|
||||||
|
url: post_url.clone(),
|
||||||
|
thumbnail
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
post_details
|
||||||
|
}
|
33
src/fetchers/mod.rs
Normal file
33
src/fetchers/mod.rs
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
use async_trait::async_trait;
|
||||||
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
use strum_macros::Display;
|
||||||
|
use crate::fetchers::Fetcher::Jnc;
|
||||||
|
use crate::fetchers::jnovel::JNovelFetcher;
|
||||||
|
use crate::lemmy::{PostInfo};
|
||||||
|
|
||||||
|
pub mod jnovel;
|
||||||
|
|
||||||
|
#[async_trait]
|
||||||
|
pub(crate) trait FetcherTrait {
|
||||||
|
fn new() -> Self where Self: Sized;
|
||||||
|
async fn check_feed(&self) -> Result<Vec<PostInfo>, ()>;
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Fetcher {
|
||||||
|
pub(crate) async fn check_feed(&self) -> Result<Vec<PostInfo>, ()> {
|
||||||
|
match self {
|
||||||
|
Jnc(fetcher) => fetcher.check_feed().await,
|
||||||
|
/*default => {
|
||||||
|
let err_msg = format!("Fetcher {default} is not implemented");
|
||||||
|
error!(err_msg);
|
||||||
|
Err(())
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Deserialize, Serialize, Debug, Clone, Display)]
|
||||||
|
pub(crate) enum Fetcher {
|
||||||
|
#[serde(rename = "jnc")]
|
||||||
|
Jnc(#[serde(skip)] JNovelFetcher)
|
||||||
|
}
|
450
src/lemmy.rs
Normal file
450
src/lemmy.rs
Normal file
|
@ -0,0 +1,450 @@
|
||||||
|
use std::cmp::Ordering;
|
||||||
|
use crate::config::{Config, PostBody, PostConfig, SeriesConfig};
|
||||||
|
use crate::{HTTP_CLIENT};
|
||||||
|
use lemmy_api_common::community::{ListCommunities, ListCommunitiesResponse};
|
||||||
|
use lemmy_api_common::lemmy_db_views::structs::PostView;
|
||||||
|
use lemmy_api_common::person::{Login, LoginResponse};
|
||||||
|
use lemmy_api_common::post::{CreatePost, FeaturePost, GetPosts, GetPostsResponse};
|
||||||
|
use lemmy_db_schema::newtypes::{CommunityId, LanguageId, PostId};
|
||||||
|
use lemmy_db_schema::{ListingType, PostFeatureType};
|
||||||
|
use reqwest::StatusCode;
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use std::sync::{RwLock};
|
||||||
|
use lemmy_db_schema::sensitive::SensitiveString;
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
use systemd_journal_logger::connected_to_journal;
|
||||||
|
|
||||||
|
macro_rules! debug {
|
||||||
|
($msg:tt) => {
|
||||||
|
match connected_to_journal() {
|
||||||
|
true => log::debug!("[DEBUG] {}", $msg),
|
||||||
|
false => println!("[DEBUG] {}", $msg),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! error {
|
||||||
|
($msg:tt) => {
|
||||||
|
match connected_to_journal() {
|
||||||
|
true => log::error!("[ERROR] {}", $msg),
|
||||||
|
false => eprintln!("[ERROR] {}", $msg),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) struct Lemmy {
|
||||||
|
jwt_token: SensitiveString,
|
||||||
|
instance: String,
|
||||||
|
communities: HashMap<String, CommunityId>,
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub(crate) struct PostInfoInner {
|
||||||
|
pub(crate) title: String,
|
||||||
|
pub(crate) url: String,
|
||||||
|
pub(crate) thumbnail: Option<String>
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Copy, Clone)]
|
||||||
|
pub(crate) enum PartInfo {
|
||||||
|
NoParts,
|
||||||
|
Part(u8),
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartInfo {
|
||||||
|
pub(crate) fn as_u8(&self) -> u8 {
|
||||||
|
match self {
|
||||||
|
PartInfo::Part(number) => *number,
|
||||||
|
PartInfo::NoParts => 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn as_string(&self) -> String {
|
||||||
|
self.as_u8().to_string()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq for PartInfo {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
let self_numeric = self.as_u8();
|
||||||
|
let other_numeric = other.as_u8();
|
||||||
|
self_numeric == other_numeric
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialOrd for PartInfo {
|
||||||
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
|
if self.gt(other) {
|
||||||
|
Some(Ordering::Greater)
|
||||||
|
} else if self.eq(other) {
|
||||||
|
Some(Ordering::Equal)
|
||||||
|
} else {
|
||||||
|
Some(Ordering::Less)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn lt(&self, other: &Self) -> bool {
|
||||||
|
let self_numeric = self.as_u8();
|
||||||
|
let other_numeric = other.as_u8();
|
||||||
|
|
||||||
|
self_numeric < other_numeric
|
||||||
|
}
|
||||||
|
|
||||||
|
fn le(&self, other: &Self) -> bool {
|
||||||
|
!self.gt(other)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn gt(&self, other: &Self) -> bool {
|
||||||
|
let self_numeric = self.as_u8();
|
||||||
|
let other_numeric = other.as_u8();
|
||||||
|
|
||||||
|
self_numeric > other_numeric
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ge(&self, other: &Self) -> bool {
|
||||||
|
!self.lt(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Copy)]
|
||||||
|
pub(crate) enum PostType {
|
||||||
|
Chapter,
|
||||||
|
Volume
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone)]
|
||||||
|
pub(crate) struct PostInfo {
|
||||||
|
pub(crate) part: Option<PartInfo>,
|
||||||
|
pub(crate) lemmy_info: PostInfoInner,
|
||||||
|
pub(crate) description: Option<String>,
|
||||||
|
pub(crate) post_type: Option<PostType>
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PostInfo {
|
||||||
|
pub(crate)fn get_info(&self) -> PostInfoInner {
|
||||||
|
self.lemmy_info.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate)fn get_description(&self) -> Option<String> {
|
||||||
|
self.description.clone()
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_part_info(&self) -> Option<PartInfo> {
|
||||||
|
self.part
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_post_config(&self, series: &SeriesConfig) -> PostConfig {
|
||||||
|
match self.post_type {
|
||||||
|
Some(post_type) => {
|
||||||
|
match post_type {
|
||||||
|
PostType::Chapter => series.prepub_community.clone(),
|
||||||
|
PostType::Volume => series.volume_community.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
None => series.prepub_community.clone(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_post_data(&self, series: &SeriesConfig, lemmy: &Lemmy) -> CreatePost {
|
||||||
|
let post_config = self.get_post_config(series);
|
||||||
|
|
||||||
|
let post_body = match &post_config.post_body {
|
||||||
|
PostBody::None => None,
|
||||||
|
PostBody::Description => self.get_description(),
|
||||||
|
PostBody::Custom(text) => Some(text.clone()),
|
||||||
|
};
|
||||||
|
|
||||||
|
let community_id: CommunityId = lemmy.get_community_id(&post_config.name);
|
||||||
|
|
||||||
|
CreatePost {
|
||||||
|
name: self.get_info().title.clone(),
|
||||||
|
community_id,
|
||||||
|
url: Some(self.get_info().url),
|
||||||
|
custom_thumbnail: self.get_info().thumbnail,
|
||||||
|
body: post_body,
|
||||||
|
alt_text: None,
|
||||||
|
honeypot: None,
|
||||||
|
nsfw: None,
|
||||||
|
language_id: Some(LanguageId(37)), // TODO get this id once every few hours per API request, the ordering of IDs suggests that the EN Id might change in the future
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialEq for PostInfo {
|
||||||
|
fn eq(&self, other: &Self) -> bool {
|
||||||
|
self.part.eq(&other.part)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PartialOrd for PostInfo {
|
||||||
|
fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
|
||||||
|
if self.gt(other) {
|
||||||
|
Some(Ordering::Greater)
|
||||||
|
} else if self.eq(other) {
|
||||||
|
Some(Ordering::Equal)
|
||||||
|
} else {
|
||||||
|
Some(Ordering::Less)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn lt(&self, other: &Self) -> bool {
|
||||||
|
self.part < other.part
|
||||||
|
}
|
||||||
|
|
||||||
|
fn le(&self, other: &Self) -> bool {
|
||||||
|
!self.gt(other)
|
||||||
|
}
|
||||||
|
|
||||||
|
fn gt(&self, other: &Self) -> bool {
|
||||||
|
self.part > other.part
|
||||||
|
}
|
||||||
|
|
||||||
|
fn ge(&self, other: &Self) -> bool {
|
||||||
|
!self.lt(other)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Lemmy {
|
||||||
|
pub(crate) fn get_community_id(&self, name: &str) -> CommunityId {
|
||||||
|
*self.communities.get(name).expect("Given community is invalid")
|
||||||
|
}
|
||||||
|
pub(crate) async fn new(config: &RwLock<Config>) -> Result<Self, ()> {
|
||||||
|
let read_config = config.read().expect("Read Lock Failed").clone();
|
||||||
|
let login_params = Login {
|
||||||
|
username_or_email: read_config.get_username(),
|
||||||
|
password: read_config.get_password(),
|
||||||
|
totp_2fa_token: None,
|
||||||
|
};
|
||||||
|
|
||||||
|
let response = match HTTP_CLIENT
|
||||||
|
.post(read_config.instance.to_owned() + "/api/v3/user/login")
|
||||||
|
.json(&login_params)
|
||||||
|
.send()
|
||||||
|
.await
|
||||||
|
{
|
||||||
|
Ok(data) => data,
|
||||||
|
Err(e) => {
|
||||||
|
let err_msg = format!("{e}");
|
||||||
|
error!(err_msg);
|
||||||
|
return Err(());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
match response.status() {
|
||||||
|
StatusCode::OK => {
|
||||||
|
let data: LoginResponse = response
|
||||||
|
.json()
|
||||||
|
.await
|
||||||
|
.expect("Successful Login Request should return JSON");
|
||||||
|
match data.jwt {
|
||||||
|
Some(token) => Ok(Lemmy {
|
||||||
|
jwt_token: token.clone(),
|
||||||
|
instance: read_config.instance.to_owned(),
|
||||||
|
communities: HashMap::new(),
|
||||||
|
}),
|
||||||
|
None => {
|
||||||
|
let err_msg = "Login did not return JWT token. Are the credentials valid?".to_owned();
|
||||||
|
error!(err_msg);
|
||||||
|
Err(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
status => {
|
||||||
|
let err_msg = format!("Unexpected HTTP Status '{}' during Login", status);
|
||||||
|
error!(err_msg);
|
||||||
|
Err(())
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn logout(&self) {
|
||||||
|
let _ = self.post_data_json("/api/v3/user/logout", &"").await;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
pub(crate) async fn post(&self, post: CreatePost) -> Option<PostId> {
|
||||||
|
let response: String = match self.post_data_json("/api/v3/post", &post).await {
|
||||||
|
Some(data) => data,
|
||||||
|
None => return None,
|
||||||
|
};
|
||||||
|
let json_data: PostView = match self.parse_json_map(&response).await {
|
||||||
|
Some(data) => data,
|
||||||
|
None => return None,
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(json_data.post.id)
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn feature(&self, params: FeaturePost) -> Option<PostView> {
|
||||||
|
let response: String = match self.post_data_json("/api/v3/post/feature", ¶ms).await {
|
||||||
|
Some(data) => data,
|
||||||
|
None => return None,
|
||||||
|
};
|
||||||
|
let json_data: PostView = match self.parse_json_map(&response).await {
|
||||||
|
Some(data) => data,
|
||||||
|
None => return None,
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(json_data)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn unpin(&self, post_id: PostId, location: PostFeatureType) -> Option<PostView> {
|
||||||
|
let pin_params = FeaturePost {
|
||||||
|
post_id,
|
||||||
|
featured: false,
|
||||||
|
feature_type: location,
|
||||||
|
};
|
||||||
|
self.feature(pin_params).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn pin(&self, post_id: PostId, location: PostFeatureType) -> Option<PostView> {
|
||||||
|
let pin_params = FeaturePost {
|
||||||
|
post_id,
|
||||||
|
featured: true,
|
||||||
|
feature_type: location,
|
||||||
|
};
|
||||||
|
self.feature(pin_params).await
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn get_community_pinned(&self, community: CommunityId) -> Option<Vec<PostView>> {
|
||||||
|
let list_params = GetPosts {
|
||||||
|
community_id: Some(community),
|
||||||
|
type_: Some(ListingType::Local),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let response: String = match self.get_data_query("/api/v3/post/list", &list_params).await {
|
||||||
|
Some(data) => data,
|
||||||
|
None => return None,
|
||||||
|
};
|
||||||
|
let json_data: GetPostsResponse = match self.parse_json(&response).await {
|
||||||
|
Some(data) => data,
|
||||||
|
None => return None,
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(json_data
|
||||||
|
.posts
|
||||||
|
.iter()
|
||||||
|
.filter(|post| post.post.featured_community)
|
||||||
|
.cloned()
|
||||||
|
.collect())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn get_local_pinned(&self) -> Option<Vec<PostView>> {
|
||||||
|
let list_params = GetPosts {
|
||||||
|
type_: Some(ListingType::Local),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let response: String = match self.get_data_query("/api/v3/post/list", &list_params).await {
|
||||||
|
Some(data) => data,
|
||||||
|
None => return None,
|
||||||
|
};
|
||||||
|
let json_data: GetPostsResponse = match self.parse_json(&response).await {
|
||||||
|
Some(data) => data,
|
||||||
|
None => return None,
|
||||||
|
};
|
||||||
|
|
||||||
|
Some(json_data
|
||||||
|
.posts
|
||||||
|
.iter()
|
||||||
|
.filter(|post| post.post.featured_local)
|
||||||
|
.cloned()
|
||||||
|
.collect())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) async fn get_communities(&mut self) {
|
||||||
|
let list_params = ListCommunities {
|
||||||
|
type_: Some(ListingType::Local),
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
|
||||||
|
let response: String = match self.get_data_query("/api/v3/community/list", &list_params).await {
|
||||||
|
Some(data) => data,
|
||||||
|
None => return,
|
||||||
|
};
|
||||||
|
let json_data: ListCommunitiesResponse = match self.parse_json::<ListCommunitiesResponse>(&response).await {
|
||||||
|
Some(data) => data,
|
||||||
|
None => return,
|
||||||
|
};
|
||||||
|
|
||||||
|
let mut communities: HashMap<String, CommunityId> = HashMap::new();
|
||||||
|
for community_view in json_data.communities {
|
||||||
|
let community = community_view.community;
|
||||||
|
communities.insert(community.name, community.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
self.communities = communities;
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn post_data_json<T: Serialize>(&self, route: &str, json: &T ) -> Option<String> {
|
||||||
|
let res = HTTP_CLIENT
|
||||||
|
.post(format!("{}{route}", &self.instance))
|
||||||
|
.bearer_auth(&self.jwt_token.to_string())
|
||||||
|
.json(&json)
|
||||||
|
.send()
|
||||||
|
.await;
|
||||||
|
self.extract_data(res).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn get_data_query<T: Serialize>(&self, route: &str, param: &T ) -> Option<String> {
|
||||||
|
let res = HTTP_CLIENT
|
||||||
|
.get(format!("{}{route}", &self.instance))
|
||||||
|
.bearer_auth(&self.jwt_token.to_string())
|
||||||
|
.query(¶m)
|
||||||
|
.send()
|
||||||
|
.await;
|
||||||
|
self.extract_data(res).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn extract_data(&self, response: Result<reqwest::Response, reqwest::Error>) -> Option<String> {
|
||||||
|
match response {
|
||||||
|
Ok(data) => {
|
||||||
|
if data.status().is_success() {
|
||||||
|
match data.text().await {
|
||||||
|
Ok(data) => Some(data),
|
||||||
|
Err(e) => {
|
||||||
|
let err_msg = format!("{e}");
|
||||||
|
error!(err_msg);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let err_msg = format!("HTTP Request failed: {}", data.text().await.unwrap());
|
||||||
|
error!(err_msg);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Err(e) => {
|
||||||
|
let err_msg = format!("{e}");
|
||||||
|
error!(err_msg);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn parse_json<'a, T: Deserialize<'a>>(&self, response: &'a str) -> Option<T> {
|
||||||
|
match serde_json::from_str::<T>(response) {
|
||||||
|
Ok(data) => Some(data),
|
||||||
|
Err(e) => {
|
||||||
|
let err_msg = format!("while parsing JSON: {e} ");
|
||||||
|
error!(err_msg);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn parse_json_map<'a, T: Deserialize<'a>>(&self, response: &'a str) -> Option<T> {
|
||||||
|
debug!(response);
|
||||||
|
match serde_json::from_str::<HashMap<&str, T>>(response) {
|
||||||
|
Ok(mut data) => Some(data.remove("post_view").expect("Element should be present")),
|
||||||
|
Err(e) => {
|
||||||
|
let err_msg = format!("while parsing JSON HashMap: {e}");
|
||||||
|
error!(err_msg);
|
||||||
|
None
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
257
src/main.rs
257
src/main.rs
|
@ -1,238 +1,41 @@
|
||||||
use chrono::Utc;
|
use chrono::{Duration};
|
||||||
use config::{Config, PrevPost, Secrets, LemmyCommunities};
|
use log::{LevelFilter};
|
||||||
use lemmy_api_common::{
|
|
||||||
person::{Login, LoginResponse},
|
|
||||||
post::{CreatePost, GetPosts, GetPostsResponse},
|
|
||||||
sensitive::Sensitive, community::{ListCommunities, ListCommunitiesResponse},
|
|
||||||
};
|
|
||||||
use lemmy_db_schema::{
|
|
||||||
newtypes::{CommunityId, LanguageId},
|
|
||||||
ListingType, SortType,
|
|
||||||
};
|
|
||||||
use once_cell::sync::Lazy;
|
use once_cell::sync::Lazy;
|
||||||
use reqwest::{blocking::Client, StatusCode};
|
use reqwest::Client;
|
||||||
use std::{thread::sleep, time};
|
use systemd_journal_logger::{JournalLog};
|
||||||
use url::Url;
|
use crate::bot::Bot;
|
||||||
|
|
||||||
use crate::config::FeedData;
|
mod bot;
|
||||||
mod config;
|
mod config;
|
||||||
|
mod lemmy;
|
||||||
|
mod post_history;
|
||||||
|
mod fetchers;
|
||||||
|
|
||||||
pub static CLIENT: Lazy<Client> = Lazy::new(|| {
|
pub static HTTP_CLIENT: Lazy<Client> = Lazy::new(|| {
|
||||||
let client = Client::builder()
|
Client::builder()
|
||||||
.timeout(time::Duration::from_secs(30))
|
.timeout(Duration::seconds(10).to_std().unwrap())
|
||||||
.connect_timeout(time::Duration::from_secs(30))
|
.connect_timeout(Duration::seconds(10).to_std().unwrap())
|
||||||
.build()
|
.build()
|
||||||
.expect("build client");
|
.expect("build client")
|
||||||
client
|
|
||||||
});
|
});
|
||||||
|
|
||||||
struct Bot {
|
#[tokio::main]
|
||||||
secrets: Secrets,
|
async fn main() {
|
||||||
config: Config,
|
JournalLog::new()
|
||||||
post_history: Vec<PrevPost>,
|
.expect("Systemd-Logger crate error")
|
||||||
community_ids: CommunitiesVector,
|
.install()
|
||||||
auth: Sensitive<String>,
|
.expect("Systemd-Logger crate error");
|
||||||
}
|
match std::env::var("LOG_LEVEL") {
|
||||||
|
Ok(level) => {
|
||||||
impl Bot {
|
match level.as_str() {
|
||||||
pub(crate) fn new() -> Bot {
|
"debug" => log::set_max_level(LevelFilter::Debug),
|
||||||
Bot {
|
"info" => log::set_max_level(LevelFilter::Info),
|
||||||
secrets: Secrets::load(),
|
_ => log::set_max_level(LevelFilter::Info),
|
||||||
config: Config::load(),
|
|
||||||
post_history: PrevPost::load(),
|
|
||||||
community_ids: CommunitiesVector::new(),
|
|
||||||
auth: Sensitive::new("".to_string()),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn login(&mut self) {
|
|
||||||
let login_params = Login {
|
|
||||||
username_or_email: self.secrets.lemmy.get_username(),
|
|
||||||
password: self.secrets.lemmy.get_password(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let res = CLIENT
|
|
||||||
.post("https://lemmy.neshweb.net/api/v3/user/login")
|
|
||||||
.json(&login_params)
|
|
||||||
.send()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
if res.status() == StatusCode::OK {
|
|
||||||
let data: &LoginResponse = &res.json().unwrap();
|
|
||||||
|
|
||||||
let jwt = data.jwt.clone().expect("JWT Token could not be acquired");
|
|
||||||
self.auth = jwt;
|
|
||||||
} else {
|
|
||||||
println!("Error Code: {:?}", res.status());
|
|
||||||
panic!("JWT Token could not be acquired");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub(crate) fn post(&mut self, post_data: CreatePost) {
|
|
||||||
let res = CLIENT
|
|
||||||
.post("https://lemmy.neshweb.net/api/v3/post")
|
|
||||||
.json(&post_data)
|
|
||||||
.send()
|
|
||||||
.unwrap();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn list_posts(auth: &Sensitive<String>) -> GetPostsResponse {
|
|
||||||
let params = GetPosts {
|
|
||||||
type_: Some(ListingType::Local),
|
|
||||||
sort: Some(SortType::New),
|
|
||||||
auth: Some(auth.clone()),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
let res = CLIENT
|
|
||||||
.get("https://lemmy.neshweb.net/api/v3/post/list")
|
|
||||||
.query(¶ms)
|
|
||||||
.send()
|
|
||||||
.unwrap()
|
|
||||||
.text()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
return serde_json::from_str(&res).unwrap();
|
|
||||||
}
|
|
||||||
|
|
||||||
struct CommunitiesVector {
|
|
||||||
ids: Vec<(CommunityId, String)>,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl CommunitiesVector {
|
|
||||||
fn new() -> CommunitiesVector {
|
|
||||||
CommunitiesVector{ids: vec![]}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn load(&mut self, auth: &Sensitive<String>) {
|
|
||||||
let params = ListCommunities {
|
|
||||||
auth: Some(auth.clone()),
|
|
||||||
..Default::default()
|
|
||||||
};
|
|
||||||
|
|
||||||
let res = CLIENT
|
|
||||||
.get("https://lemmy.neshweb.net/api/v3/community/list")
|
|
||||||
.query(¶ms)
|
|
||||||
.send()
|
|
||||||
.unwrap()
|
|
||||||
.text()
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
let site_data: ListCommunitiesResponse = serde_json::from_str(&res).unwrap();
|
|
||||||
|
|
||||||
let mut ids = [].to_vec();
|
|
||||||
|
|
||||||
site_data.communities.iter().for_each(|entry| {
|
|
||||||
let new_id = (entry.community.id, entry.community.name.clone());
|
|
||||||
ids.push(new_id);
|
|
||||||
});
|
|
||||||
|
|
||||||
self.ids = ids;
|
|
||||||
}
|
|
||||||
|
|
||||||
fn find(&self, name: &LemmyCommunities) -> CommunityId {
|
|
||||||
let mut ret_id = CommunityId(0);
|
|
||||||
|
|
||||||
self.ids.iter().for_each(|id| {
|
|
||||||
let id_name = &id.1;
|
|
||||||
if &name.to_string() == id_name {
|
|
||||||
ret_id = id.0;
|
|
||||||
}
|
}
|
||||||
});
|
|
||||||
return ret_id;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fn main() {
|
|
||||||
// Get all needed auth tokens at the start
|
|
||||||
let mut old = Utc::now().time();
|
|
||||||
let mut this = Bot::new();
|
|
||||||
println!("{}", this.secrets.lemmy.username);
|
|
||||||
this.login();
|
|
||||||
this.community_ids.load(&this.auth);
|
|
||||||
|
|
||||||
// Create empty eTag list
|
|
||||||
println!("TODO: Etag list");
|
|
||||||
|
|
||||||
// Enter a loop (not for debugging)
|
|
||||||
loop {
|
|
||||||
let start = Utc::now();
|
|
||||||
print!("\x1B[2J\x1B[1;1H");
|
|
||||||
println!(
|
|
||||||
"Started loop at {} {}",
|
|
||||||
start.format("%H:%M:%S"),
|
|
||||||
start.timezone()
|
|
||||||
);
|
|
||||||
|
|
||||||
if start.time() - old > chrono::Duration::seconds(6) {
|
|
||||||
old = start.time();
|
|
||||||
this.config = Config::load();
|
|
||||||
this.community_ids.load(&this.auth);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start the polling process
|
|
||||||
// Get all feed URLs (use cache)
|
|
||||||
let mut post_queue: Vec<CreatePost> = vec![];
|
|
||||||
this.config.feeds.iter().for_each(|feed| {
|
|
||||||
let res = CLIENT
|
|
||||||
.get(feed.feed_url.clone())
|
|
||||||
.send()
|
|
||||||
.unwrap()
|
|
||||||
.text()
|
|
||||||
.unwrap();
|
|
||||||
let data: FeedData = serde_json::from_str(&res).unwrap();
|
|
||||||
|
|
||||||
let mut prev_post_idx: Option<usize> = None;
|
|
||||||
let mut do_post = true;
|
|
||||||
this.post_history
|
|
||||||
.iter()
|
|
||||||
.enumerate()
|
|
||||||
.for_each(|(idx, post)| {
|
|
||||||
if &post.last_post_url == &data.items[0].url {
|
|
||||||
do_post = false;
|
|
||||||
} else if &post.title == &data.title {
|
|
||||||
prev_post_idx = Some(idx);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
if do_post {
|
|
||||||
let item = &data.items[0];
|
|
||||||
let new_post = CreatePost {
|
|
||||||
name: item.title.clone(),
|
|
||||||
community_id: this.community_ids.find(&feed.communities.chapter),
|
|
||||||
url: Some(Url::parse(&item.url).unwrap()),
|
|
||||||
body: Some(
|
|
||||||
"[Reddit](https://reddit.com)\n\n[Discord](https://discord.com)".into(),
|
|
||||||
),
|
|
||||||
honeypot: None,
|
|
||||||
nsfw: Some(false),
|
|
||||||
language_id: Some(LanguageId(37)), // TODO get this id once every few hours per API request, the ordering of IDs suggests that the EN Id might change in the future
|
|
||||||
auth: this.auth.clone(),
|
|
||||||
};
|
|
||||||
post_queue.push(new_post);
|
|
||||||
match prev_post_idx {
|
|
||||||
Some(idx) => {
|
|
||||||
this.post_history[idx].title = data.title;
|
|
||||||
this.post_history[idx].last_post_url = item.url.clone();
|
|
||||||
}
|
|
||||||
None => this.post_history.push(PrevPost {
|
|
||||||
title: data.title,
|
|
||||||
last_post_url: item.url.clone(),
|
|
||||||
}),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sleep(time::Duration::from_millis(100)); // Should prevent dos-ing J-Novel servers
|
|
||||||
});
|
|
||||||
|
|
||||||
PrevPost::save(&this.post_history);
|
|
||||||
post_queue.iter().for_each(|post| {
|
|
||||||
println!("Posting: {}", post.name);
|
|
||||||
this.post(post.clone());
|
|
||||||
});
|
|
||||||
|
|
||||||
while Utc::now().time() - start.time() < chrono::Duration::seconds(60) {
|
|
||||||
sleep(time::Duration::from_secs(10));
|
|
||||||
}
|
}
|
||||||
|
_ => log::set_max_level(LevelFilter::Info),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let mut bot = Bot::new();
|
||||||
|
bot.run().await;
|
||||||
}
|
}
|
||||||
|
|
101
src/post_history.rs
Normal file
101
src/post_history.rs
Normal file
|
@ -0,0 +1,101 @@
|
||||||
|
use serde_derive::{Deserialize, Serialize};
|
||||||
|
use std::collections::HashMap;
|
||||||
|
use systemd_journal_logger::connected_to_journal;
|
||||||
|
|
||||||
|
macro_rules! info {
|
||||||
|
($msg:tt) => {
|
||||||
|
match connected_to_journal() {
|
||||||
|
true => log::info!("[INFO] {}", $msg),
|
||||||
|
false => println!("[INFO] {}", $msg),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
macro_rules! error {
|
||||||
|
($msg:tt) => {
|
||||||
|
match connected_to_journal() {
|
||||||
|
true => log::error!("[ERROR] {}", $msg),
|
||||||
|
false => eprintln!("[ERROR] {}", $msg),
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Default, Clone, Debug)]
|
||||||
|
pub(crate) struct SeriesHistory {
|
||||||
|
pub(crate) series: HashMap<String, PostHistory>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl SeriesHistory {
|
||||||
|
pub(crate) fn load_history() -> Self {
|
||||||
|
let info_msg = "Loading History";
|
||||||
|
info!(info_msg);
|
||||||
|
match confy::load(env!("CARGO_PKG_NAME"), "history") {
|
||||||
|
Ok(data) => data,
|
||||||
|
Err(e) => panic!("history.toml not found: {e}"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn save_history(&self) {
|
||||||
|
let info_msg = "Saving History";
|
||||||
|
info!(info_msg);
|
||||||
|
if let Err(e) = confy::store(env!("CARGO_PKG_NAME"), "history", self) {
|
||||||
|
let err_msg = format!("Unexpected error saving to history.toml: {e}");
|
||||||
|
error!(err_msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn check_for_post(&self, series: &str, part: &str, title: &str) -> bool {
|
||||||
|
if let Some(series_map) = self.series.get(series) {
|
||||||
|
if let Some(part_info) = series_map.parts.get(part) {
|
||||||
|
return part_info.volume == title || part_info.chapter == title;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
false
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn get_series(&self, series: &str) -> PostHistory {
|
||||||
|
match self.series.get(series) {
|
||||||
|
Some(history) => history.clone(),
|
||||||
|
None => PostHistory {
|
||||||
|
parts: HashMap::new(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn set_series(&mut self, series: &str, data: PostHistory) {
|
||||||
|
self.series
|
||||||
|
.entry(series.to_owned())
|
||||||
|
.and_modify(|val| *val = data.clone())
|
||||||
|
.or_insert(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
|
pub(crate) struct PostHistory {
|
||||||
|
pub(crate) parts: HashMap<String, PostHistoryInner>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl PostHistory {
|
||||||
|
pub(crate) fn get_part(&self, part: &str) -> PostHistoryInner {
|
||||||
|
match self.parts.get(part) {
|
||||||
|
Some(history) => history.clone(),
|
||||||
|
None => PostHistoryInner {
|
||||||
|
volume: "".to_owned(),
|
||||||
|
chapter: "".to_owned(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
pub(crate) fn set_part(&mut self, part: &str, data: PostHistoryInner) {
|
||||||
|
self.parts
|
||||||
|
.entry(part.to_owned())
|
||||||
|
.and_modify(|val| *val = data.clone())
|
||||||
|
.or_insert(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize, Clone, Debug)]
|
||||||
|
pub(crate) struct PostHistoryInner {
|
||||||
|
pub(crate) volume: String,
|
||||||
|
pub(crate) chapter: String,
|
||||||
|
}
|
Loading…
Reference in a new issue