Compare commits
409
Commits
3d585d14e0
..
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
ff6da7c88b | ||
|
|
f59810c989 | ||
|
|
c58d0f1101 | ||
|
|
fec627a7c1 | ||
|
|
a350796ccb | ||
|
|
c15822190f | ||
|
|
7d50901a2c | ||
|
|
8acb36dd59 | ||
|
|
13cfcdf7f0 | ||
|
|
f877d2da7c | ||
|
|
6010a3921b | ||
|
|
359945fed0 | ||
|
|
9caa2c10bc | ||
|
|
e889a4dc73 | ||
|
|
8eb7f77751 | ||
|
|
3d827ceb61 | ||
|
|
5f60b7a44e | ||
|
|
2c51aa79b5 | ||
|
|
1ad39ee042 | ||
|
|
501caee8b9 | ||
|
|
1992a3dcd0 | ||
|
|
5c1d9be81a | ||
|
|
ad738d8fdb | ||
|
|
9aacdc40e6 | ||
|
|
cfa80f38cf | ||
|
|
6e2d041814 | ||
|
|
94bd900f81 | ||
|
|
5d026332c0 | ||
|
|
fbb5efa838 | ||
|
|
5b940129ca | ||
|
|
2bb1d67c21 | ||
|
|
8fafb937aa | ||
|
|
da544f490e | ||
|
|
49801263c6 | ||
|
|
06719968a3 | ||
|
|
774e8792b9 | ||
|
|
f4c7610ab4 | ||
|
|
b973aa9e9b | ||
|
|
3fe6b39f22 | ||
|
|
bc1cf8278d | ||
|
|
4d0595e967 | ||
|
|
74d54baa1b | ||
|
|
d146f18144 | ||
|
|
be8e17f398 | ||
|
|
4a0bf338dc | ||
|
|
e73c8263a4 | ||
|
|
d41debdf81 | ||
|
|
04f4278770 | ||
|
|
c61c480cbb | ||
|
|
b48cd97076 | ||
|
|
e60a0898a0 | ||
|
|
a92eee5beb | ||
|
|
93ab3bdcee | ||
|
|
4c7eaf4f22 | ||
|
|
29eec52099 | ||
|
|
9c963ce74b | ||
|
|
9c69dab395 | ||
|
|
0ab31d16c2 | ||
|
|
8f027e2226 | ||
|
|
c894b465d2 | ||
|
|
d131533ae6 | ||
|
|
9e8ac1d37d | ||
|
|
70904598fb | ||
|
|
cdad6a5dca | ||
|
|
dac70a632c | ||
|
|
d229d4a980 | ||
|
|
753b4bcd35 | ||
|
|
968ef5dedb | ||
|
|
740d25f4e3 | ||
|
|
fb9e0c9c44 | ||
|
|
08f1b7a3e8 | ||
|
|
e063c32342 | ||
|
|
c4a1c76370 | ||
|
|
a47f913cc1 | ||
|
|
5c3550b657 | ||
|
|
97ef35caf5 | ||
|
|
c46871e41f | ||
|
|
9dc8b11673 | ||
|
|
792e86ae0d | ||
|
|
7f2e61746f | ||
|
|
d99ef28e71 | ||
|
|
8ca880ddff | ||
|
|
b89eb89d5e | ||
|
|
8b7d92d97b | ||
|
|
88cb666848 | ||
|
|
632bca8642 | ||
|
|
49b3c6a649 | ||
|
|
277a8cedaf | ||
|
|
dbff6b8327 | ||
|
|
02c53e0839 | ||
|
|
c92987736f | ||
|
|
96e06bb223 | ||
|
|
7d5494243f | ||
|
|
74519f62d7 | ||
|
|
e4263dd19b | ||
|
|
145242ebcc | ||
|
|
ed4c6253ea | ||
|
|
d40d4368b1 | ||
|
|
896fbab32d | ||
|
|
a7c8a6641e | ||
|
|
b327399efa | ||
|
|
a575fd8586 | ||
|
|
90fe1ae01f | ||
|
|
1e3b3ea62d | ||
|
|
5f0de3e4cf | ||
|
|
58d03c3ce2 | ||
|
|
e972f8b0ec | ||
|
|
f2a70dca82 | ||
|
|
c65e9b2e5e | ||
|
|
ea5216cf0a | ||
|
|
cdd7ebdb9f | ||
|
|
20109e7edf | ||
|
|
c7ea308c19 | ||
|
|
d6a828bb2e | ||
|
|
2fded74b59 | ||
|
|
cb37ee9275 | ||
|
|
e5fd0dd82a | ||
|
|
ad6a853771 | ||
|
|
26f387865c | ||
|
|
2e8f47ab86 | ||
|
|
f6e2d4a1cd | ||
|
|
c9a4d7f0c3 | ||
|
|
6ac508745c | ||
|
|
f2d5311719 | ||
|
|
9ae7083992 | ||
|
|
082bca7828 | ||
|
|
359f64df8e | ||
|
|
d28185b387 | ||
|
|
e7577de379 | ||
|
|
87ebf3bd66 | ||
|
|
118b73fda2 | ||
|
|
5249a6916d | ||
|
|
30dfc6fa53 | ||
|
|
bc26e4dbb0 | ||
|
|
0c3830c8f3 | ||
|
|
c2507707aa | ||
|
|
44e9f47185 | ||
|
|
8591d15f48 | ||
|
|
89eb301664 | ||
|
|
1a2f3ddf88 | ||
|
|
5a83f8fe40 | ||
|
|
725ee08897 | ||
|
|
4fbc6f1c90 | ||
|
|
f5b580c870 | ||
|
|
a85f5d90c1 | ||
|
|
ecc053bd0a | ||
|
|
b29bade385 | ||
|
|
dcddaf0f79 | ||
|
|
db4a293a6d | ||
|
|
ba5fbac806 | ||
|
|
07da497eed | ||
|
|
060f429282 | ||
|
|
0989ced202 | ||
|
|
15a1fddab3 | ||
|
|
23ad42d2b2 | ||
|
|
045a33d324 | ||
|
|
ea620151e9 | ||
|
|
0a691c49f6 | ||
|
|
048654f238 | ||
|
|
6743772c33 | ||
|
|
6db5fb528e | ||
|
|
4792a47c25 | ||
|
|
8136a9c3af | ||
|
|
cc4b092a08 | ||
|
|
06f290e99a | ||
|
|
9b4bf7422a | ||
|
|
9f73b601e8 | ||
|
|
e079a08d14 | ||
|
|
49fbc0a6ad | ||
|
|
1667362b9d | ||
|
|
79b3bdd91f | ||
|
|
e67dc91cc8 | ||
|
|
9f18d2975d | ||
|
|
be3e96b90f | ||
|
|
c5c293d7dc | ||
|
|
e9fb04cefe | ||
|
|
44957441b5 | ||
|
|
50467b8565 | ||
|
|
56d988faa3 | ||
|
|
f14cd89d7c | ||
|
|
d3561978fe | ||
|
|
dcbf8c8be0 | ||
|
|
5223bf030f | ||
|
|
3db65acf60 | ||
|
|
ad00c3c0f3 | ||
|
|
e37cf79883 | ||
|
|
009e43382d | ||
|
|
b511ea636e | ||
|
|
33a3cf036b | ||
|
|
5bb4a20da2 | ||
|
|
69b39940b0 | ||
|
|
8669499c36 | ||
|
|
9ddb167eb3 | ||
|
|
3c21820b3a | ||
|
|
2c7fe68b33 | ||
|
|
7ac877f018 | ||
|
|
152a095f51 | ||
|
|
9373e23592 | ||
|
|
37014ac829 | ||
|
|
69234da7cf | ||
|
|
1aeccb7b82 | ||
|
|
b76155f96d | ||
|
|
692ab8c6d8 | ||
|
|
78d32e3219 | ||
|
|
09752d64ad | ||
|
|
25bf86a8ec | ||
|
|
3a50a94c17 | ||
|
|
27f5dc644f | ||
|
|
5d5ca4a6d6 | ||
|
|
db1995c7b9 | ||
|
|
ce7da99296 | ||
|
|
5daa680948 | ||
|
|
8c48239b77 | ||
|
|
4481664c0b | ||
|
|
6fb22a7582 | ||
|
|
74c66ec88f | ||
|
|
8801ee5153 | ||
|
|
807d03f808 | ||
|
|
24292a3d01 | ||
|
|
057f3101bf | ||
|
|
ba81e01fee | ||
|
|
2dc2483c04 | ||
|
|
f8aa8a73d1 | ||
|
|
4d8d20c6d9 | ||
|
|
d09706f3be | ||
|
|
3aa90fa629 | ||
|
|
f5c794e9f5 | ||
|
|
db4778811f | ||
|
|
def77826ba | ||
|
|
dc0609480f | ||
|
|
08171bf2fb | ||
|
|
6c06998788 | ||
|
|
419d6ed784 | ||
|
|
a3f818f601 | ||
|
|
079915ee49 | ||
|
|
371faab2d9 | ||
|
|
04ac7f9ff7 | ||
|
|
968d007954 | ||
|
|
0bc0b53ed1 | ||
|
|
0c8f33559d | ||
|
|
d3410521bd | ||
|
|
492a2f0d5d | ||
|
|
2670e46526 | ||
|
|
edae754aa4 | ||
|
|
98c687ea9e | ||
|
|
b6a2908b48 | ||
|
|
5ca383e0da | ||
|
|
3470e24c82 | ||
|
|
f55b671ba3 | ||
|
|
7c6c9e6f58 | ||
|
|
cfe2ae0c9d | ||
|
|
d0731ef2b0 | ||
|
|
7404473a60 | ||
|
|
6268fca868 | ||
|
|
c24a20cbf6 | ||
|
|
745503a1ab | ||
|
|
266cfd5bf9 | ||
|
|
3dbdda0472 | ||
|
|
f3a1ca0842 | ||
|
|
5a397e482c | ||
|
|
373030ae74 | ||
|
|
f0c651691e | ||
|
|
64a94c865c | ||
|
|
033ada3924 | ||
|
|
836d8351b8 | ||
|
|
2994ffcc52 | ||
|
|
408293d866 | ||
|
|
aff23eae88 | ||
|
|
68819a3fce | ||
|
|
eb3d4a71f8 | ||
|
|
b00d8b8249 | ||
|
|
8377e61306 | ||
|
|
fbddea4ff6 | ||
|
|
001165c1a6 | ||
|
|
229e6f9b2b | ||
|
|
3aadb9b700 | ||
|
|
2d988203b8 | ||
|
|
97b9232cef | ||
|
|
4b42e5915e | ||
|
|
58bc7fb4bb | ||
|
|
ab300bfa01 | ||
|
|
60ab92d5e2 | ||
|
|
1a8b65cdb1 | ||
|
|
077c4899a0 | ||
|
|
c8b9a25ead | ||
|
|
6d8b2957c6 | ||
|
|
517490384f | ||
|
|
50a6d786f0 | ||
|
|
db350414d4 | ||
|
|
0272366480 | ||
|
|
d99ad7b966 | ||
|
|
1b6d39037c | ||
|
|
6f6bae9a55 | ||
|
|
8268b69004 | ||
|
|
e571fdc729 | ||
|
|
8fb3d4d3b9 | ||
|
|
11027fa9dc | ||
|
|
38736bb6b5 | ||
|
|
3df29a6da6 | ||
|
|
6cf309b454 | ||
|
|
73d6dc947b | ||
|
|
e8a0b2daf9 | ||
|
|
2bea411e45 | ||
|
|
0b020ab4ae | ||
|
|
7c50f30ad1 | ||
|
|
540a837052 | ||
|
|
89d2049288 | ||
|
|
995939d73b | ||
|
|
6e5f0ca0d0 | ||
|
|
a41b5c837f | ||
|
|
5ae7a8cd7f | ||
|
|
6f4dbfeb61 | ||
|
|
75267aad49 | ||
|
|
68ab26a509 | ||
|
|
163319b1cf | ||
|
|
8fc0b60838 | ||
|
|
af2f942465 | ||
|
|
62b73656e6 | ||
|
|
44c2f16c97 | ||
|
|
8c2541fb34 | ||
|
|
942bd7c1f7 | ||
|
|
c81d160d5c | ||
|
|
45aed47f03 | ||
|
|
4708d6a138 | ||
|
|
7bbedc8549 | ||
|
|
1a99bd631f | ||
|
|
6c61138a5e | ||
|
|
c9ba870bf5 | ||
|
|
aa01414bd8 | ||
|
|
76983f3783 | ||
|
|
6c1de5f350 | ||
|
|
2bb2f17746 | ||
|
|
00768fda2e | ||
|
|
ae91f3073d | ||
|
|
e9ed3ff9ab | ||
|
|
a553e51dd7 | ||
|
|
cfdadfd9aa | ||
|
|
a6bd1c2d1a | ||
|
|
07e24ad97e | ||
|
|
bbc56a9908 | ||
|
|
7214cfd52b | ||
|
|
58795e9d5e | ||
|
|
d241017c2a | ||
|
|
104b912404 | ||
|
|
e4ebc3c5b2 | ||
|
|
6e369c3656 | ||
|
|
63c34f5387 | ||
|
|
fcde06e8b6 | ||
|
|
f54919554b | ||
|
|
93a464f49d | ||
|
|
437c91dc7a | ||
|
|
7f27f187d8 | ||
|
|
073ddf11fc | ||
|
|
f5d7962aba | ||
|
|
0a6457abe0 | ||
|
|
aa27e1f350 | ||
|
|
59f1bcb5c1 | ||
|
|
b1c8365bd8 | ||
|
|
c5cf55fe21 | ||
|
|
99573fb241 | ||
|
|
f9d97de61f | ||
|
|
d5c82e364d | ||
|
|
c192114bcf | ||
|
|
179256de3e | ||
|
|
0e52aefa07 | ||
|
|
95c2f90031 | ||
|
|
1dd80d9a45 | ||
|
|
dc537635bb | ||
|
|
be012e334b | ||
|
|
35c2104852 | ||
|
|
d1e2f8a3e5 | ||
|
|
2eb7b8d6d1 | ||
|
|
045861ada6 | ||
|
|
8ae894ffb6 | ||
|
|
208fbd96b4 | ||
|
|
93b262977b | ||
|
|
fd91e7d678 | ||
|
|
9a476ef5cd | ||
|
|
dbb8eda1e6 | ||
|
|
2e273985b7 | ||
|
|
f7865f05a1 | ||
|
|
719c7068e2 | ||
|
|
580b667119 | ||
|
|
3bf1fc1be6 | ||
|
|
7b0b438740 | ||
|
|
2eda7cd33e | ||
|
|
efc150d9ce | ||
|
|
044fbd81ad | ||
|
|
01ab319eea | ||
|
|
d5e627325d | ||
|
|
deaff35bc3 | ||
|
|
27d570fc5c | ||
|
|
d5fb01adb2 | ||
|
|
52c02beb3d | ||
|
|
3f14f53184 | ||
|
|
c41bf36afb | ||
|
|
07bab58ae0 | ||
|
|
d06cff4cbd | ||
|
|
09343a7523 | ||
|
|
dc0cd02e58 | ||
|
|
7158dd4960 | ||
|
|
4c299c5a38 | ||
|
|
2f3a763054 | ||
|
|
f7ff789d81 | ||
|
|
7c6a121504 | ||
|
|
144d974731 | ||
|
|
9e4901699d | ||
|
|
8c29731ddc | ||
|
|
80ad918686 |
No files matched your search
@@ -0,0 +1,132 @@
|
||||
name: Audiobook Library CI
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
- main
|
||||
paths:
|
||||
- "audiobook_library/**"
|
||||
- "serverlibrary/**"
|
||||
- "testassets/audiobook_library/**"
|
||||
- ".gitea/workflows/audiobook_library.yaml"
|
||||
pull_request:
|
||||
branches:
|
||||
- dev
|
||||
paths:
|
||||
- "audiobook_library/**"
|
||||
- "serverlibrary/**"
|
||||
- "testassets/audiobook_library/**"
|
||||
- ".gitea/workflows/audiobook_library.yaml"
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: nikolaik/python-nodejs:python3.12-nodejs20
|
||||
env:
|
||||
AUDIOBOOK_TEST_ASSETS: ../testassets/audiobook_library
|
||||
AUDIOBOOK_TEST_DATABASE: test/ci-assets/absdatabase.sqlite_test
|
||||
|
||||
steps:
|
||||
- name: Check out the tested commit
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install FFmpeg
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install --yes --no-install-recommends ffmpeg
|
||||
|
||||
- name: Install audiobook_library
|
||||
working-directory: audiobook_library
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install ../serverlibrary .
|
||||
|
||||
- name: Generate database fixture
|
||||
working-directory: audiobook_library
|
||||
run: python test/create_ci_fixtures.py test/ci-assets
|
||||
|
||||
- name: Run tests
|
||||
working-directory: audiobook_library
|
||||
run: python run_tests.py
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: nikolaik/python-nodejs:python3.12-nodejs20
|
||||
|
||||
steps:
|
||||
- name: Check out the tested commit
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Ruff
|
||||
run: python -m pip install ruff
|
||||
|
||||
- name: Lint audiobook_library
|
||||
run: ruff check audiobook_library/src audiobook_library/test audiobook_library/main.py audiobook_library/run_tests.py
|
||||
|
||||
build:
|
||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
needs: [test, lint]
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: nikolaik/python-nodejs:python3.12-nodejs20
|
||||
|
||||
steps:
|
||||
- name: Check out the tested commit
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install build dependencies
|
||||
working-directory: audiobook_library
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install ../serverlibrary .
|
||||
python -m pip install pyinstaller
|
||||
|
||||
- name: Build one-file executable
|
||||
working-directory: audiobook_library
|
||||
run: python -m PyInstaller --clean --noconfirm --onefile --paths src --name audiobook_library main.py
|
||||
|
||||
- name: Verify executable
|
||||
working-directory: audiobook_library
|
||||
run: |
|
||||
test -x dist/audiobook_library
|
||||
dist/audiobook_library --help
|
||||
|
||||
- name: Upload executable
|
||||
uses: https://github.com/christopherHX/gitea-upload-artifact@v4
|
||||
with:
|
||||
name: audiobook-library-build
|
||||
path: audiobook_library/dist/audiobook_library
|
||||
if-no-files-found: error
|
||||
|
||||
install:
|
||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
needs: build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
runner:
|
||||
- vivohost
|
||||
- quiethost
|
||||
- serverhost
|
||||
- mediahost
|
||||
runs-on: ${{ matrix.runner }}
|
||||
|
||||
steps:
|
||||
- name: Download executable
|
||||
uses: https://github.com/christopherHX/gitea-download-artifact@v4
|
||||
with:
|
||||
name: audiobook-library-build
|
||||
path: dist/
|
||||
|
||||
- name: Install audiobook_library
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
install -d -m 755 "$HOME/tools"
|
||||
install -m 755 dist/audiobook_library "$HOME/tools/audiobook_library"
|
||||
@@ -0,0 +1,119 @@
|
||||
name: FFmpeg Handling CI
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
- main
|
||||
paths:
|
||||
- "ffmpeg_handling/**"
|
||||
- "serverlibrary/**"
|
||||
- ".gitea/workflows/ffmpeg_handling.yaml"
|
||||
pull_request:
|
||||
branches:
|
||||
- dev
|
||||
paths:
|
||||
- "ffmpeg_handling/**"
|
||||
- "serverlibrary/**"
|
||||
- ".gitea/workflows/ffmpeg_handling.yaml"
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: nikolaik/python-nodejs:python3.12-nodejs20
|
||||
|
||||
steps:
|
||||
- name: Check out the tested commit
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install FFmpeg
|
||||
run: |
|
||||
apt-get update
|
||||
apt-get install --yes --no-install-recommends ffmpeg
|
||||
|
||||
- name: Install ffmpeg_handling
|
||||
working-directory: ffmpeg_handling
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install ../serverlibrary .
|
||||
|
||||
- name: Run tests
|
||||
working-directory: ffmpeg_handling
|
||||
run: python src/ffmpeg_handling/run_test.py
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: nikolaik/python-nodejs:python3.12-nodejs20
|
||||
|
||||
steps:
|
||||
- name: Check out the tested commit
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Ruff
|
||||
run: python -m pip install ruff
|
||||
|
||||
- name: Lint ffmpeg_handling
|
||||
run: ruff check ffmpeg_handling/src ffmpeg_handling/tests ffmpeg_handling/main.py
|
||||
|
||||
build:
|
||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
needs: [test, lint]
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: nikolaik/python-nodejs:python3.12-nodejs20
|
||||
|
||||
steps:
|
||||
- name: Check out the tested commit
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install build dependencies
|
||||
working-directory: ffmpeg_handling
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install ../serverlibrary .
|
||||
python -m pip install pyinstaller
|
||||
|
||||
- name: Build one-file executable
|
||||
working-directory: ffmpeg_handling
|
||||
run: python -m PyInstaller --clean --noconfirm ffmpeg_handling.spec
|
||||
|
||||
- name: Verify executable
|
||||
run: test -x ffmpeg_handling/dist/ffmpeg_handling
|
||||
|
||||
- name: Upload executable
|
||||
uses: https://github.com/christopherHX/gitea-upload-artifact@v4
|
||||
with:
|
||||
name: ffmpeg-handling-build
|
||||
path: ffmpeg_handling/dist/ffmpeg_handling
|
||||
if-no-files-found: error
|
||||
|
||||
install:
|
||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
needs: build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
runner:
|
||||
- vivohost
|
||||
- quiethost
|
||||
- serverhost
|
||||
- mediahost
|
||||
runs-on: ${{ matrix.runner }}
|
||||
|
||||
steps:
|
||||
- name: Download executable
|
||||
uses: https://github.com/christopherHX/gitea-download-artifact@v4
|
||||
with:
|
||||
name: ffmpeg-handling-build
|
||||
path: dist/
|
||||
|
||||
- name: Install ffmpeg_handling
|
||||
run: |
|
||||
set -euo pipefail
|
||||
install -d -m 755 "$HOME/tools"
|
||||
install -m 755 dist/ffmpeg_handling "$HOME/tools/ffmpeg_handling"
|
||||
@@ -0,0 +1,49 @@
|
||||
name: Serverlibrary CI
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
on:
|
||||
push:
|
||||
paths:
|
||||
- "serverlibrary/**"
|
||||
- ".gitea/workflows/serverlibrary.yaml"
|
||||
pull_request:
|
||||
paths:
|
||||
- "serverlibrary/**"
|
||||
- ".gitea/workflows/serverlibrary.yaml"
|
||||
|
||||
jobs:
|
||||
test-serverlibrary:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: nikolaik/python-nodejs:python3.12-nodejs20
|
||||
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install serverlibrary
|
||||
working-directory: serverlibrary
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install .
|
||||
|
||||
- name: Run serverlibrary tests
|
||||
working-directory: serverlibrary
|
||||
run: python run_tests.py
|
||||
|
||||
lint-serverlibrary:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: nikolaik/python-nodejs:python3.12-nodejs20
|
||||
|
||||
steps:
|
||||
- name: Check out repository
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Ruff
|
||||
run: python -m pip install ruff
|
||||
|
||||
- name: Lint serverlibrary
|
||||
run: ruff check serverlibrary/src serverlibrary/tests serverlibrary/run_tests.py
|
||||
@@ -0,0 +1,108 @@
|
||||
name: Torrent API CI
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
- main
|
||||
paths:
|
||||
- "torrent_api/**"
|
||||
- "serverlibrary/**"
|
||||
- ".gitea/workflows/torrent_api.yaml"
|
||||
pull_request:
|
||||
branches:
|
||||
- dev
|
||||
paths:
|
||||
- "torrent_api/**"
|
||||
- "serverlibrary/**"
|
||||
- ".gitea/workflows/torrent_api.yaml"
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: nikolaik/python-nodejs:python3.12-nodejs20
|
||||
steps:
|
||||
- name: Check out the tested commit
|
||||
uses: actions/checkout@v4
|
||||
- name: Install torrent-api
|
||||
working-directory: torrent_api
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install ../serverlibrary .
|
||||
- name: Run tests
|
||||
working-directory: torrent_api
|
||||
run: python run_tests.py
|
||||
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: nikolaik/python-nodejs:python3.12-nodejs20
|
||||
|
||||
steps:
|
||||
- name: Check out the tested commit
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install Ruff
|
||||
run: python -m pip install ruff
|
||||
|
||||
- name: Lint torrent_api
|
||||
run: ruff check torrent_api/src torrent_api/tests torrent_api/main.py
|
||||
|
||||
build:
|
||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
needs: [test, lint]
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: nikolaik/python-nodejs:python3.12-nodejs20
|
||||
steps:
|
||||
- name: Check out the tested commit
|
||||
uses: actions/checkout@v4
|
||||
- name: Install build dependencies
|
||||
working-directory: torrent_api
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install ../serverlibrary .
|
||||
python -m pip install pyinstaller
|
||||
|
||||
- name: Build one-file executable
|
||||
working-directory: torrent_api
|
||||
run: python -m PyInstaller --noconfirm torrent_api.spec
|
||||
- name: Verify executable
|
||||
working-directory: torrent_api
|
||||
run: |
|
||||
test -x dist/torrent_api
|
||||
dist/torrent_api --help
|
||||
- name: Upload executable
|
||||
uses: https://github.com/christopherHX/gitea-upload-artifact@v4
|
||||
with:
|
||||
name: torrent-api-build
|
||||
path: torrent_api/dist/torrent_api
|
||||
if-no-files-found: error
|
||||
|
||||
install:
|
||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
needs: build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
runner:
|
||||
- vivohost
|
||||
- quiethost
|
||||
- serverhost
|
||||
- mediahost
|
||||
runs-on: ${{ matrix.runner }}
|
||||
steps:
|
||||
- name: Download executable
|
||||
uses: https://github.com/christopherHX/gitea-download-artifact@v4
|
||||
with:
|
||||
name: torrent-api-build
|
||||
path: dist/
|
||||
- name: Install torrent_api
|
||||
run: |
|
||||
set -euo pipefail
|
||||
install -d -m 755 "$HOME/tools"
|
||||
install -m 755 dist/torrent_api "$HOME/tools/torrent_api"
|
||||
@@ -0,0 +1,208 @@
|
||||
name: Wallpaper Changer CI
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- dev
|
||||
- main
|
||||
paths:
|
||||
- "wallpaper_changer/python/**"
|
||||
- ".gitea/workflows/wallpaper_changer.yaml"
|
||||
pull_request:
|
||||
branches:
|
||||
- dev
|
||||
paths:
|
||||
- "wallpaper_changer/python/**"
|
||||
- ".gitea/workflows/wallpaper_changer.yaml"
|
||||
|
||||
jobs:
|
||||
test-wallpaper-changer:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: nikolaik/python-nodejs:python3.12-nodejs20
|
||||
|
||||
steps:
|
||||
- name: Check out the tested commit
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install serverlibrary and wallpaper_changer
|
||||
working-directory: wallpaper_changer/python
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install ../../serverlibrary
|
||||
python -m pip install --group test .
|
||||
|
||||
- name: Run wallpaper_changer tests
|
||||
working-directory: wallpaper_changer/python
|
||||
run: python tests/run_tests.py all
|
||||
|
||||
lint-wallpaper-changer:
|
||||
if: >-
|
||||
${{ github.event_name != 'workflow_run'
|
||||
|| github.event.workflow_run.conclusion == 'success' }}
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: nikolaik/python-nodejs:python3.12-nodejs20
|
||||
|
||||
steps:
|
||||
- name: Check out the tested commit
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: ${{ github.event_name == 'workflow_run' && github.event.workflow_run.head_sha || github.sha }}
|
||||
|
||||
- name: Install Ruff
|
||||
run: python -m pip install ruff
|
||||
|
||||
- name: Lint wallpaper_changer
|
||||
run: ruff check wallpaper_changer/python
|
||||
|
||||
build:
|
||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
needs: test-wallpaper-changer
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: nikolaik/python-nodejs:python3.12-nodejs20
|
||||
|
||||
steps:
|
||||
- name: Check out the tested commit
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Install build dependencies
|
||||
working-directory: wallpaper_changer/python
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
python -m pip install ../../serverlibrary
|
||||
python -m pip install --group test .
|
||||
python -m pip install build
|
||||
|
||||
- name: Build executable
|
||||
working-directory: wallpaper_changer/python
|
||||
run: |
|
||||
python -m PyInstaller \
|
||||
--clean \
|
||||
--onefile \
|
||||
--paths src \
|
||||
--name wallpaper_changer \
|
||||
main.py
|
||||
|
||||
- name: Build wheel
|
||||
working-directory: wallpaper_changer/python
|
||||
run: python -m build --wheel
|
||||
|
||||
- name: Include user service unit
|
||||
working-directory: wallpaper_changer/python
|
||||
run: cp systemd/wallpaper-changer.service dist/
|
||||
|
||||
- name: Verify build outputs
|
||||
working-directory: wallpaper_changer/python
|
||||
run: |
|
||||
ls -lh dist/
|
||||
test -f dist/wallpaper_changer
|
||||
test -f dist/wallpaper-changer.service
|
||||
ls dist/*.whl
|
||||
|
||||
- name: Upload build artifacts
|
||||
uses: https://github.com/christopherHX/gitea-upload-artifact@v4
|
||||
with:
|
||||
name: wallpaper-changer-build
|
||||
path: wallpaper_changer/python/dist/
|
||||
if-no-files-found: error
|
||||
install:
|
||||
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
|
||||
needs: build
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
runner:
|
||||
- vivohost
|
||||
- quiethost
|
||||
- serverhost
|
||||
- mediahost
|
||||
runs-on: ${{ matrix.runner }}
|
||||
timeout-minutes: 5
|
||||
|
||||
steps:
|
||||
- name: Check runner environment
|
||||
run: |
|
||||
set -eux
|
||||
whoami
|
||||
echo "$HOME"
|
||||
id
|
||||
echo "UID: $(id -u)"
|
||||
echo "Checking user systemd bus..."
|
||||
ls -l "/run/user/$(id -u)/bus" || true
|
||||
|
||||
- name: Download build artifacts
|
||||
uses: https://github.com/christopherHX/gitea-download-artifact@v4
|
||||
with:
|
||||
name: wallpaper-changer-build
|
||||
path: dist/
|
||||
|
||||
- name: Verify downloaded artifacts
|
||||
run: |
|
||||
set -eux
|
||||
ls -lah dist/
|
||||
test -f dist/wallpaper_changer
|
||||
test -f dist/wallpaper-changer.service
|
||||
|
||||
- name: Install executable and provision encryption passphrase
|
||||
env:
|
||||
WALLPAPER_ENCRYPTION_PASSPHRASE: ${{ secrets.WALLPAPER_ENCRYPTION_PASSPHRASE }}
|
||||
shell: bash
|
||||
run: |
|
||||
set -euo pipefail
|
||||
|
||||
echo "1. Preparing directories"
|
||||
key_dir="$HOME/.wallpaper"
|
||||
passphrase_file="$key_dir/encryption.passphrase"
|
||||
install -d -m 700 "$key_dir"
|
||||
install -d -m 755 "$HOME/tools"
|
||||
|
||||
temporary_passphrase=""
|
||||
cleanup() {
|
||||
test -z "$temporary_passphrase" || rm -f "$temporary_passphrase"
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "2. Installing encryption passphrase"
|
||||
if [ -L "$passphrase_file" ] || { [ -e "$passphrase_file" ] && [ ! -f "$passphrase_file" ]; }; then
|
||||
echo "Invalid passphrase path" >&2
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$passphrase_file" ]; then
|
||||
: "${WALLPAPER_ENCRYPTION_PASSPHRASE:?Missing encryption passphrase secret}"
|
||||
temporary_passphrase="$(mktemp "$key_dir/.encryption_passphrase.XXXXXX")"
|
||||
printf '%s' "$WALLPAPER_ENCRYPTION_PASSPHRASE" > "$temporary_passphrase"
|
||||
chmod 600 "$temporary_passphrase"
|
||||
mv "$temporary_passphrase" "$passphrase_file"
|
||||
else
|
||||
echo "Preserving existing encryption passphrase"
|
||||
fi
|
||||
|
||||
echo "3. Installing executable"
|
||||
install -m 755 dist/wallpaper_changer "$HOME/tools/wallpaper_changer"
|
||||
|
||||
echo "4. Installing systemd service"
|
||||
user_unit_dir="$HOME/.config/systemd/user"
|
||||
install -d -m 755 "$user_unit_dir"
|
||||
install -m 644 dist/wallpaper-changer.service "$user_unit_dir/wallpaper-changer.service"
|
||||
|
||||
echo "5. Connecting to user systemd"
|
||||
export XDG_RUNTIME_DIR="/run/user/$(id -u)"
|
||||
export DBUS_SESSION_BUS_ADDRESS="unix:path=$XDG_RUNTIME_DIR/bus"
|
||||
|
||||
test -S "$XDG_RUNTIME_DIR/bus"
|
||||
|
||||
echo "6. Reloading systemd"
|
||||
timeout 15s systemctl --user daemon-reload
|
||||
|
||||
echo "7. Enabling service"
|
||||
timeout 15s systemctl --user enable wallpaper-changer.service
|
||||
|
||||
echo "8. Starting service"
|
||||
timeout 15s systemctl --user restart --no-block wallpaper-changer.service
|
||||
|
||||
echo "9. Installation completed"
|
||||
+6
-2
@@ -15,8 +15,12 @@ wheels/
|
||||
.idea
|
||||
uv.lock
|
||||
youtubelist.txt
|
||||
*.mkv
|
||||
*.mp4
|
||||
.spotdl-cache
|
||||
script_template.txt
|
||||
.kilo/
|
||||
/docker_compose/serverhost/qbittorrent/gluetun/wg0.conf
|
||||
|
||||
# Android/Gradle local state
|
||||
.gradle/
|
||||
local.properties
|
||||
.env
|
||||
Vendored
+12
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Python: torrent_qbittorrent_api",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/torrent/torrent_configure_indexers.py",
|
||||
"console": "integratedTerminal"
|
||||
}
|
||||
]
|
||||
}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "audiobook_library: Run sample command",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/main.py",
|
||||
"args": [],
|
||||
"cwd": "${workspaceFolder}",
|
||||
"python": "${workspaceFolder}/.venv/bin/python3",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": true
|
||||
},
|
||||
{
|
||||
"name": "audiobook_library: Run tests",
|
||||
"type": "debugpy",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/run_tests.py",
|
||||
"cwd": "${workspaceFolder}",
|
||||
"python": "${workspaceFolder}/.venv/bin/python3",
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": true
|
||||
}
|
||||
]
|
||||
}
|
||||
Vendored
+32
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "audiobook_library: Run tests",
|
||||
"type": "process",
|
||||
"command": "${workspaceFolder}/.venv/bin/python3",
|
||||
"args": [
|
||||
"run_tests.py"
|
||||
],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"group": "test",
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "audiobook_library: Build package",
|
||||
"type": "process",
|
||||
"command": "uv",
|
||||
"args": ["build"],
|
||||
"options": {
|
||||
"cwd": "${workspaceFolder}"
|
||||
},
|
||||
"group": {
|
||||
"kind": "build",
|
||||
"isDefault": false
|
||||
},
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
## CI
|
||||
|
||||
The Gitea workflow runs the test suite with committed audiobook media and a
|
||||
generated database fixture, and lints with Ruff. On pushes to `main`, it builds a
|
||||
standalone executable and installs it to `~/tools/audiobook_library` on the
|
||||
same runners used by ffmpeg_handling. FFmpeg and ffprobe must be available
|
||||
on the target host.
|
||||
|
||||
To run the suite locally, use `python run_tests.py`. It uses
|
||||
the committed MP3 files in `testassets/audiobook_library` at the scripts
|
||||
repository root by default; set `AUDIOBOOK_TEST_ASSETS` to use another media
|
||||
fixture directory. `AUDIOBOOK_TEST_DATABASE` can point to a database fixture
|
||||
file. CI generates only the database fixture with
|
||||
`python test/create_ci_fixtures.py <directory>`. Do not commit private database
|
||||
fixtures.
|
||||
Executable
+8
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
|
||||
from audiobook_library.cli import main
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,31 @@
|
||||
[project]
|
||||
name = "audiobook-library"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
authors = [
|
||||
{ name = "Lucas Vivo", email = "lucas@mediahost" }
|
||||
]
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"mutagen>=1.47.0",
|
||||
"requests>=2.33.1",
|
||||
"serverlibrary",
|
||||
]
|
||||
|
||||
[project.scripts]
|
||||
audiobook-library = "audiobook_library:main"
|
||||
|
||||
[build-system]
|
||||
requires = ["uv_build>=0.12.19,<0.13.0"]
|
||||
build-backend = "uv_build"
|
||||
|
||||
[tool.uv.sources]
|
||||
serverlibrary = { path = "../serverlibrary" }
|
||||
|
||||
[tool.ruff]
|
||||
line-length = 120
|
||||
target-version = "py312"
|
||||
|
||||
[tool.ruff.lint]
|
||||
select = ["E", "F", "I"]
|
||||
@@ -0,0 +1,24 @@
|
||||
"""Discover and run the audiobook_library unittest suite."""
|
||||
|
||||
import sys
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
PROJECT_DIR = Path(__file__).resolve().parent
|
||||
SOURCE_DIR = PROJECT_DIR / "src"
|
||||
TEST_DIR = PROJECT_DIR / "test"
|
||||
sys.path.insert(0, str(SOURCE_DIR))
|
||||
|
||||
|
||||
def run_tests(verbosity: int = 2) -> bool:
|
||||
suite = unittest.defaultTestLoader.discover(
|
||||
str(TEST_DIR),
|
||||
pattern="test_*.py",
|
||||
top_level_dir=str(TEST_DIR),
|
||||
)
|
||||
result = unittest.TextTestRunner(verbosity=verbosity).run(suite)
|
||||
return result.wasSuccessful()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(0 if run_tests() else 1)
|
||||
@@ -0,0 +1,13 @@
|
||||
from .audiobook import Audiobook
|
||||
from .audiobook_library import AudiobookLibrary
|
||||
from .audiobookshelf_api import AudiobookshelfApi
|
||||
from .cli import main
|
||||
from .sql_database import SqlDatabase
|
||||
|
||||
__all__ = [
|
||||
"Audiobook",
|
||||
"AudiobookLibrary",
|
||||
"AudiobookshelfApi",
|
||||
"SqlDatabase",
|
||||
"main",
|
||||
]
|
||||
@@ -0,0 +1,6 @@
|
||||
import sys
|
||||
|
||||
from .cli import main
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
@@ -0,0 +1,105 @@
|
||||
import argparse
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
from serverlibrary import parser_add_loglevel
|
||||
|
||||
|
||||
def create_parser() -> argparse.ArgumentParser:
|
||||
parser = argparse.ArgumentParser(description="Audiobook Directory Processing")
|
||||
parser.add_argument("library", type=Path, help="Library path")
|
||||
|
||||
parser_add_loglevel(parser)
|
||||
m4b_group = parser.add_argument_group("M4B creation")
|
||||
m4b_group.add_argument(
|
||||
"-cm",
|
||||
"--create-m4b",
|
||||
action="store_true",
|
||||
help="Create M4B files from multi-file audiobooks",
|
||||
)
|
||||
m4b_group.add_argument(
|
||||
"--keep-originals",
|
||||
action="store_true",
|
||||
help="Do not delete source files after M4B creation",
|
||||
)
|
||||
m4b_group.add_argument(
|
||||
"--name-filter",
|
||||
metavar="NAME",
|
||||
default="",
|
||||
help="Process only books whose name contains NAME",
|
||||
)
|
||||
m4b_group.add_argument(
|
||||
"--path-filter",
|
||||
metavar="PATH",
|
||||
default="",
|
||||
help="Process only books whose path contains PATH",
|
||||
)
|
||||
parser.add_argument("--dry-run", action="store_true", help="Dry run only")
|
||||
parser.add_argument(
|
||||
"--sql-database",
|
||||
type=Path,
|
||||
default=Path("/docker/audiobookshelf/config/absdatabase.sqlite"),
|
||||
help="SQL Database Path",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--api-url",
|
||||
default="https://audiobooks.someoneslinux.selfhost.eu",
|
||||
help="API Url for Audiobookshelf API",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--api-key",
|
||||
default="",
|
||||
help="API key for Audiobookshelf API",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-em",
|
||||
"--encode-meta",
|
||||
action="store_true",
|
||||
help="Encode Metadata to Audiobook files",
|
||||
)
|
||||
parser.add_argument("-fd", "--fix-db", action="store_true", help="Fix the Database")
|
||||
parser.add_argument(
|
||||
"-fa",
|
||||
"--force-artist-from-path",
|
||||
action="store_true",
|
||||
help="Force overwrite Artist from Path, only use if Path is correct",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-m",
|
||||
"--move",
|
||||
action="store_true",
|
||||
help="Create structured directories for all books",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--actions",
|
||||
nargs="+",
|
||||
choices=[
|
||||
"artist_dir",
|
||||
"artists",
|
||||
"composers",
|
||||
"series",
|
||||
"names",
|
||||
"genres",
|
||||
"comments",
|
||||
"titles",
|
||||
],
|
||||
default=[
|
||||
"artist_dir",
|
||||
"artists",
|
||||
"composers",
|
||||
"series",
|
||||
"names",
|
||||
"genres",
|
||||
"comments",
|
||||
"titles",
|
||||
],
|
||||
)
|
||||
return parser
|
||||
|
||||
|
||||
def parse_args(argv: list[str] | None = None) -> argparse.Namespace:
|
||||
arguments = sys.argv[1:] if argv is None else argv
|
||||
args = create_parser().parse_args(arguments)
|
||||
if "--sql-database" in arguments:
|
||||
args.fix_db = True
|
||||
return args
|
||||
@@ -0,0 +1,703 @@
|
||||
import re
|
||||
import subprocess
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
|
||||
from serverlibrary import (
|
||||
AUDIO_RE_SUFFIXES,
|
||||
AUDIO_SUFFIXES,
|
||||
blue_tag,
|
||||
green_tag,
|
||||
red_tag,
|
||||
)
|
||||
|
||||
from .audiobook_helpers import (
|
||||
SEP,
|
||||
clean_genre,
|
||||
cleanup,
|
||||
ffmetadata_escape,
|
||||
ffmpeg_escape,
|
||||
get_chapters,
|
||||
get_codec_bitrate,
|
||||
get_duration_ms,
|
||||
get_empty_keys,
|
||||
get_metadata_all,
|
||||
logger,
|
||||
normalize_name,
|
||||
series_patterns,
|
||||
write_metadata,
|
||||
)
|
||||
|
||||
|
||||
class Audiobook:
|
||||
def __init__(self, book_path: Path, library_root_path: Path) -> None:
|
||||
self.action_required = False
|
||||
self.changed = None
|
||||
# Metadata
|
||||
self.metadata = {}
|
||||
self.metadata_original = {}
|
||||
self.artist = ""
|
||||
self.genre = ""
|
||||
self.composer = ""
|
||||
self.name = ""
|
||||
self.comment = ""
|
||||
self.description = ""
|
||||
self.series_and_num = ""
|
||||
self.series = ""
|
||||
self.series_num = ""
|
||||
self.title: str = ""
|
||||
self.title_list: list = []
|
||||
# File Paths
|
||||
self.files: list[Path] = []
|
||||
self.files_extra = []
|
||||
self.bookPath = book_path
|
||||
self.library_root_path = library_root_path
|
||||
self.firstFile: Path | None = None
|
||||
self.pdf_file = None
|
||||
self.epub_file = None
|
||||
# Files
|
||||
self.singleFile = False
|
||||
self.fileConunt = 0
|
||||
self.size = 0
|
||||
|
||||
def init_book(self) -> None:
|
||||
self.files = sorted(
|
||||
(
|
||||
file
|
||||
for file in self.bookPath.iterdir()
|
||||
if file.is_file() and file.suffix.lower() in AUDIO_SUFFIXES
|
||||
),
|
||||
key=self.extract_track_number,
|
||||
)
|
||||
epubs = list(self.bookPath.glob("*.epub"))
|
||||
self.epub_file = epubs[0] if len(epubs) == 1 else None
|
||||
pdfs = list(self.bookPath.glob("*.pdf"))
|
||||
self.pdf_file = pdfs[0] if len(pdfs) == 1 else None
|
||||
|
||||
self.files_extra = [
|
||||
file
|
||||
for file in self.bookPath.glob("*")
|
||||
if file.suffix.lower() not in AUDIO_SUFFIXES
|
||||
]
|
||||
self.firstFile = self.get_first_file()
|
||||
self.size = sum(
|
||||
file.stat().st_size
|
||||
for pattern in AUDIO_RE_SUFFIXES
|
||||
for file in self.bookPath.glob(pattern)
|
||||
)
|
||||
self.fileConunt = len(self.files)
|
||||
self.singleFile = self.fileConunt == 1
|
||||
# Metadata
|
||||
self.load_metadata()
|
||||
logger.info(
|
||||
f"Found {self.bookPath.name}, {self.fileConunt} files, {get_empty_keys(self.metadata)}"
|
||||
)
|
||||
self.changed = False
|
||||
|
||||
def __repr__(self):
|
||||
return (
|
||||
f"Audiobook("
|
||||
f"name={self.name!r}, "
|
||||
f"artist={self.artist!r}, "
|
||||
f"composer={self.composer!r}, "
|
||||
f"path={str(self.bookPath)!r}),"
|
||||
f"size={self.size!r}, "
|
||||
f"fileConunt={self.fileConunt!r}, "
|
||||
)
|
||||
|
||||
def get_first_file(self) -> Path:
|
||||
return self.files[0]
|
||||
|
||||
def write_fields_from_metadata(self) -> None:
|
||||
self.name = self.metadata["album"]
|
||||
self.title = self.metadata["title"]
|
||||
self.composer = self.metadata["composer"]
|
||||
self.comment = self.metadata["comment"]
|
||||
self.genre = self.metadata["genre"]
|
||||
if "#" in self.metadata["grouping"]:
|
||||
self.series, self.series_num = self.metadata["grouping"].rsplit("#", 1)
|
||||
self.series = self.series.strip()
|
||||
self.series_and_num = self.metadata["grouping"]
|
||||
if self.series_and_num and not self.series:
|
||||
self.series = self.series_and_num.split("#", 1)[0].strip()
|
||||
self.series_num = self.series_and_num.split("#", 1)[1].strip() if "#" in self.series_and_num else ""
|
||||
|
||||
if self.metadata.get("artist"):
|
||||
self.artist = self.metadata["artist"].strip()
|
||||
elif self.metadata.get("albumartist"):
|
||||
self.artist = self.metadata.get("albumartist")
|
||||
self.description = self.metadata["description"]
|
||||
|
||||
def write_metadata_from_fields(self):
|
||||
self.metadata["album"] = self.name
|
||||
self.metadata["title"] = self.title
|
||||
self.metadata["composer"] = self.composer
|
||||
self.metadata["genre"] = self.genre
|
||||
self.metadata["grouping"] = self.series_and_num
|
||||
self.metadata["comment"] = self.comment
|
||||
self.metadata["description"] = self.description
|
||||
if self.artist:
|
||||
self.metadata["artist"] = self.artist
|
||||
self.metadata["albumartist"] = self.artist
|
||||
|
||||
def extract_track_number(self, file: Path) -> int:
|
||||
stem = file.stem
|
||||
title = self.name
|
||||
# Remove title if it appears at the beginning
|
||||
if title:
|
||||
escaped_title = re.escape(title)
|
||||
stem = re.sub(
|
||||
rf"^{escaped_title}(?:\s*[-_:]\s*)?",
|
||||
"",
|
||||
stem,
|
||||
flags=re.IGNORECASE,
|
||||
).strip()
|
||||
|
||||
patterns = [
|
||||
# 0099_Apollo, 01 Title, 001 Chapter, 02GLCK~1.WMA
|
||||
r"^(\d+)(?=\D|$)",
|
||||
# CD1-01, CD 1 - 01, CD1 - 01.
|
||||
r"CD\s*(\d+)\s*-\s*(\d{1,3})",
|
||||
# 018-01, 018 - 01, 138-01, 0001-0999
|
||||
r"^(\d+)\s*-\s*(\d+)(?:\D|$)",
|
||||
# Track 01
|
||||
r"Track\s+(\d+)$",
|
||||
# 01 - Kapitel 01
|
||||
r"^(\d+)\s*-",
|
||||
# Rubinrot 101, 102, 201, 202
|
||||
r".*?(\d)(\d{2})$",
|
||||
# A Thousand Ships - 007
|
||||
r".*?-\s*(\d+)\s*$",
|
||||
]
|
||||
for pattern in patterns:
|
||||
m = re.search(pattern, stem, re.IGNORECASE)
|
||||
if not m:
|
||||
continue
|
||||
|
||||
groups = m.groups()
|
||||
if len(groups) == 1:
|
||||
return int(groups[0])
|
||||
|
||||
if len(groups) == 2 and "CD" in pattern:
|
||||
disc = int(groups[0])
|
||||
track = int(groups[1])
|
||||
return (disc - 1) * 1000 + track
|
||||
|
||||
if len(groups) == 2 and stem.startswith(groups[0]):
|
||||
disc = int(groups[0])
|
||||
track = int(groups[1])
|
||||
|
||||
if track < 100:
|
||||
return disc * 1000 + track
|
||||
|
||||
if len(groups) == 2 and len(groups[0]) == 1:
|
||||
disc = int(groups[0])
|
||||
track = int(groups[1])
|
||||
return disc * 1000 + track
|
||||
|
||||
return int(groups[-1])
|
||||
|
||||
return 0
|
||||
|
||||
def load_metadata(self):
|
||||
self.metadata = get_metadata_all(self.get_first_file())
|
||||
self.metadata_original = self.metadata.copy()
|
||||
self.write_fields_from_metadata()
|
||||
logger.trace(f"Load metadata {self.metadata}")
|
||||
|
||||
def fix_artist_dir(self):
|
||||
rel_path = self.bookPath.relative_to(self.library_root_path).parts
|
||||
if not self.artist:
|
||||
logger.trace(f"No artist tag for {self.name}")
|
||||
return
|
||||
if len(rel_path) < 2:
|
||||
desired_path, desired_name = self.generate_dir_from_metadata()
|
||||
self.move(desired_path, desired_name)
|
||||
logger.debug(f"Artist not visible in folder structure: {rel_path}")
|
||||
|
||||
def fix_artist_from_comment(self):
|
||||
if not isinstance(self.comment, str):
|
||||
logger.trace(f"No comment for {self.name}")
|
||||
return
|
||||
m = re.search(
|
||||
r"(?:"
|
||||
r"author(?:s)?:?|"
|
||||
r"writer(?:s)?:?|"
|
||||
r"co[- ]?author(?:s)?:?|"
|
||||
r"co[- ]?writer(?:s)?:?|"
|
||||
r"creator(?:s)?:?|"
|
||||
r"contributor(?:s)?:?|"
|
||||
r"composer(?:s)?:?|"
|
||||
r"lyricist(?:s)?:?|"
|
||||
r"songwriter(?:s)?:?|"
|
||||
r"written\s+by:?|"
|
||||
r"story\s+by:?|"
|
||||
r"autorin(?:nen)?:?|"
|
||||
r"autor\(en\):?|"
|
||||
r"autor(?:en)?:?|"
|
||||
r"text(?:e)?\s+von:?|"
|
||||
r"geschrieben\s+von:?|"
|
||||
r"verfasst\s+von:?|"
|
||||
r"auteur(?:s)?:?|"
|
||||
r"autore(?:i)?:?|"
|
||||
r"autor(?:es)?:?|"
|
||||
r"escritor(?:es|as)?:?"
|
||||
r")\s*:?\s*([^\n.,;]+)",
|
||||
self.comment,
|
||||
re.IGNORECASE,
|
||||
)
|
||||
if not m:
|
||||
logger.trace(f"No artist found in comment for {self.bookPath}")
|
||||
return
|
||||
if len(m.group(1).strip()) < 5:
|
||||
logger.debug(f"Match group {m.group(1)} found but discarded")
|
||||
return
|
||||
logger.trace(f"Match groups: {m.group()}, Book: {self.name}")
|
||||
self.changed = True
|
||||
artist = re.sub(r"\s*\([^)]*\)", "", m.group(1).strip()).strip()
|
||||
logger.trace(f"Remove {artist} from comment: {self.comment}")
|
||||
self.comment = (self.comment[: m.start()] + self.comment[m.end() :]).strip(
|
||||
" .,;\n"
|
||||
)
|
||||
self.comment = cleanup(self.comment)
|
||||
if not self.artist:
|
||||
self.artist = artist
|
||||
self.changed = True
|
||||
|
||||
elif self.artist != artist:
|
||||
logger.warning(
|
||||
f"{red_tag('Action Required')} artist {artist} found not matching {self.artist} for {self.bookPath}"
|
||||
)
|
||||
self.action_required = True
|
||||
else:
|
||||
logger.debug(f"Artist {artist} matches file metadata for {self.name}")
|
||||
|
||||
def fix_artist_from_path(self, force_artist_from_path):
|
||||
rel_path = self.bookPath.relative_to(self.library_root_path).parts
|
||||
|
||||
if len(rel_path) < 2:
|
||||
logger.trace(f"Artist not visible in folder structure: {rel_path}")
|
||||
return
|
||||
if self.artist == rel_path[0]:
|
||||
return
|
||||
if not self.artist or force_artist_from_path:
|
||||
self.changed = True
|
||||
self.artist = rel_path[0]
|
||||
logger.info(
|
||||
f"[Updated] artist {self.artist} found in path for {self.bookPath}"
|
||||
)
|
||||
|
||||
def fix_composer_from_narrator(self):
|
||||
if not self.metadata.get("narrator"):
|
||||
logger.trace(f"No Narrator found in metadata for {self.name}")
|
||||
return
|
||||
if not self.composer or len(self.composer) < 5:
|
||||
self.composer = self.metadata["narrator"]
|
||||
|
||||
def fix_composer_from_comment(self):
|
||||
m = re.search(
|
||||
r"(?:read\s+by:?|"
|
||||
r"spoken\s+by:?|"
|
||||
r"erzähler:?|"
|
||||
r"narrated\s+by:?|"
|
||||
r"gesprochen\s+von:?|"
|
||||
r"gelesen\s+von)\s+([^\n.,;]+)",
|
||||
self.comment,
|
||||
re.IGNORECASE,
|
||||
)
|
||||
if not m:
|
||||
logger.trace(f"No composer found in comment for {self.name}")
|
||||
return
|
||||
self.changed = True
|
||||
self.comment = (self.comment[: m.start()] + self.comment[m.end() :]).strip(
|
||||
" .,;\n"
|
||||
)
|
||||
self.comment = cleanup(self.comment)
|
||||
if not self.composer or len(self.composer) < 5:
|
||||
logger.info(f"[Updated] composer found in comment for {self.name}")
|
||||
self.composer = str(m.group(1).strip())
|
||||
|
||||
def fix_composer_from_path(self):
|
||||
rel_path = self.bookPath.relative_to(self.library_root_path)
|
||||
m = re.search(
|
||||
r"(?:read\s+by:?|"
|
||||
r"spoken\s+by:?|"
|
||||
r"narrated\s+by:?|"
|
||||
r"gesprochen\s+von:?|"
|
||||
r"gelesen\s+von)\s+([^\n.,;]+)",
|
||||
str(rel_path),
|
||||
re.IGNORECASE,
|
||||
)
|
||||
if not m:
|
||||
logger.trace(f"No composer found in path for {self.bookPath}")
|
||||
return
|
||||
if not self.composer or len(self.composer) < 5:
|
||||
self.changed = True
|
||||
logger.info(f"[Updated] composer found in Path for {self.bookPath}")
|
||||
self.composer = str(m.group(1).strip())
|
||||
|
||||
def fix_name(self):
|
||||
if not self.name:
|
||||
self.name = normalize_name(self.bookPath.name, self.series)
|
||||
self.changed = True
|
||||
logger.info(f"[Updated] name {self.name} found in path for {self.bookPath}")
|
||||
return
|
||||
name = normalize_name(self.name, self.series)
|
||||
if name != self.name:
|
||||
logger.info(f"[Updated] name by cleaning {self.name} to {name}")
|
||||
self.name = name
|
||||
self.changed = True
|
||||
|
||||
def fix_series(self):
|
||||
if self.series_and_num:
|
||||
logger.trace(f"{self.name} already has series: {self.series_and_num}")
|
||||
rel_path = self.bookPath.relative_to(self.library_root_path).parts
|
||||
if not rel_path:
|
||||
logger.trace(f"No series found for {self.name}")
|
||||
return
|
||||
|
||||
series = self.series.strip()
|
||||
if not series and self.series_and_num:
|
||||
series = self.series_and_num.split("#", 1)[0].strip()
|
||||
number = ""
|
||||
if series:
|
||||
match = re.match(
|
||||
rf"^{re.escape(series)}(?:{SEP}|\s+)"
|
||||
rf"(?:Book|Band|Volume|Vol)?\s*#?\s*(\d+)(?:{SEP}.+)?$",
|
||||
rel_path[-1],
|
||||
re.IGNORECASE,
|
||||
)
|
||||
if match:
|
||||
number = match.group(1)
|
||||
|
||||
if not number:
|
||||
for pattern in series_patterns:
|
||||
match = re.match(pattern, rel_path[-1], re.IGNORECASE)
|
||||
if not match:
|
||||
continue
|
||||
if pattern.startswith(r"^(\d+)"):
|
||||
number = match.group(1)
|
||||
else:
|
||||
number = match.group(2)
|
||||
break
|
||||
|
||||
if not series and len(rel_path) > 2:
|
||||
series = rel_path[-2]
|
||||
|
||||
number_str = ""
|
||||
and_number = ""
|
||||
if not number:
|
||||
logger.trace(f"No series number found for {self.name}")
|
||||
else:
|
||||
number_str = " #" + number
|
||||
and_number = " and number"
|
||||
self.series_num = number
|
||||
if not series:
|
||||
return
|
||||
if self.series_and_num != series + number_str:
|
||||
self.series_and_num = series + number_str
|
||||
self.series = series
|
||||
self.changed = True
|
||||
logger.info(
|
||||
f"[Updated] series{and_number} found for {self.name} to {self.series_and_num}"
|
||||
)
|
||||
return
|
||||
|
||||
def fix_genre(self):
|
||||
self.genre = clean_genre(self.genre)
|
||||
self.changed = True
|
||||
|
||||
def move(self, desired_path: Path, desired_name_stem: str, dry_run=False):
|
||||
logger.trace(f"Moving {self.bookPath} to {desired_path}")
|
||||
desired_path.mkdir(parents=True, exist_ok=True)
|
||||
padding = len(str(len(self.files)))
|
||||
once = True
|
||||
for number, file in enumerate(self.files, start=1):
|
||||
if self.singleFile:
|
||||
new_name = desired_path / f"{desired_name_stem}{file.suffix.lower()}"
|
||||
else:
|
||||
new_name = (
|
||||
desired_path
|
||||
/ f"{number:0{padding}d} - {desired_name_stem}{file.suffix}"
|
||||
)
|
||||
|
||||
if file == new_name:
|
||||
continue
|
||||
if once:
|
||||
once = False
|
||||
logger.debug(f"Moving {file} to {new_name}")
|
||||
else:
|
||||
logger.trace(f"Moving {file} to {new_name}")
|
||||
if dry_run:
|
||||
continue
|
||||
self.files[number - 1] = file.rename(new_name)
|
||||
for file in self.files_extra:
|
||||
if file.suffix.lower() in {".cue", ".log"} or file in {
|
||||
self.epub_file,
|
||||
self.pdf_file,
|
||||
}:
|
||||
filename = f"{desired_name_stem}{file.suffix.lower()}"
|
||||
else:
|
||||
filename = file.name
|
||||
|
||||
new_file = desired_path / filename
|
||||
if file == new_file:
|
||||
continue
|
||||
|
||||
logger.trace(f"Moving {file} to {new_file}")
|
||||
if dry_run:
|
||||
continue
|
||||
new_file = file.rename(new_file)
|
||||
if file == self.epub_file:
|
||||
self.epub_file = new_file
|
||||
elif file == self.pdf_file:
|
||||
self.pdf_file = new_file
|
||||
|
||||
if self.bookPath != desired_path:
|
||||
logger.debug(f"Moving {self.bookPath} to {desired_path}")
|
||||
remaining = list(self.bookPath.iterdir())
|
||||
if not remaining and not dry_run:
|
||||
self.bookPath.rmdir()
|
||||
else:
|
||||
logger.warning(
|
||||
f"{red_tag('Action Required')} old path not empty after move: "
|
||||
f"{self.bookPath}: {remaining}"
|
||||
)
|
||||
self.bookPath = desired_path
|
||||
self.files = sorted(self.files, key=self.extract_track_number)
|
||||
self.firstFile = self.get_first_file()
|
||||
|
||||
def generate_dir_from_metadata(self):
|
||||
composer = ""
|
||||
name = self.name
|
||||
if self.composer:
|
||||
composer = f" (by {self.composer})"
|
||||
name = self.name + composer
|
||||
artist = ""
|
||||
if self.artist:
|
||||
artist = re.split(r"[,;]", self.artist)[0].strip().replace("/", "_")
|
||||
desired_path = self.library_root_path / artist / name
|
||||
if self.series_and_num:
|
||||
series = self.series_and_num
|
||||
number = ""
|
||||
if "#" in self.series_and_num:
|
||||
series = self.series_and_num.split("#")
|
||||
number = f"{series[1]} - "
|
||||
series = series[0].rstrip()
|
||||
desired_path = (
|
||||
self.library_root_path
|
||||
/ artist
|
||||
/ series.replace("/", "_")
|
||||
/ f"{number}{name}".replace("/", "_")
|
||||
)
|
||||
desired_name_stem = (
|
||||
f"{self.artist} - {self.name}{composer}{self.bookPath.suffix}"
|
||||
)
|
||||
desired_name_stem = desired_name_stem.replace("/", "_")
|
||||
return desired_path, desired_name_stem
|
||||
|
||||
def create_m4b_from_book(self, creat_m4b_no_delete: bool = False) -> None:
|
||||
output_file_final = self.bookPath / f"{self.bookPath.name}.m4b"
|
||||
if self.action_required:
|
||||
logger.warning("Action required, resolve before creating m4b file")
|
||||
return
|
||||
if output_file_final.exists():
|
||||
logger.info(f"{red_tag('SKIP')} {output_file_final}")
|
||||
logger.info("Book already present")
|
||||
return
|
||||
|
||||
logger.info(f"{blue_tag('create')} {output_file_final}")
|
||||
|
||||
with tempfile.TemporaryDirectory(dir=self.library_root_path.parent) as tmp:
|
||||
tmpdir = Path(tmp)
|
||||
|
||||
output_file_tmp = tmpdir / f"{self.bookPath.name}.m4b"
|
||||
concat_file = tmpdir / "concat.txt"
|
||||
metadata_file = tmpdir / "chapters.txt"
|
||||
|
||||
# Inspect all inputs before deciding how to create chapters.
|
||||
file_info = []
|
||||
has_existing_chapters = False
|
||||
|
||||
for media in self.files:
|
||||
chapters = get_chapters(media)
|
||||
duration_ms = get_duration_ms(media)
|
||||
|
||||
file_info.append(
|
||||
{
|
||||
"media": media,
|
||||
"chapters": chapters,
|
||||
"duration_ms": duration_ms,
|
||||
}
|
||||
)
|
||||
|
||||
if chapters:
|
||||
has_existing_chapters = True
|
||||
|
||||
if has_existing_chapters:
|
||||
logger.debug(
|
||||
"Existing chapter tracks found; preserving chapter metadata"
|
||||
)
|
||||
else:
|
||||
logger.debug(
|
||||
"No existing chapters found; generating chapters from filenames"
|
||||
)
|
||||
|
||||
current_ms = 0
|
||||
|
||||
with (
|
||||
concat_file.open("w", encoding="utf-8") as cf,
|
||||
metadata_file.open("w", encoding="utf-8") as mf,
|
||||
):
|
||||
mf.write(";FFMETADATA1\n")
|
||||
|
||||
for key, value in self.metadata.items():
|
||||
if key == "title":
|
||||
mf.write(
|
||||
f"{ffmetadata_escape(key)}={ffmetadata_escape(self.metadata['album'])}\n"
|
||||
)
|
||||
else:
|
||||
mf.write(
|
||||
f"{ffmetadata_escape(key)}={ffmetadata_escape(value)}\n"
|
||||
)
|
||||
for info in file_info:
|
||||
media = info["media"]
|
||||
media_name = info["media"].name
|
||||
# Remove title
|
||||
media_name = media_name.replace(self.name, "")
|
||||
# Clean separators and whitespace
|
||||
media_name = re.sub(r"[\s._-]+", " ", media_name).strip()
|
||||
# Remove leading/trailing separators again if needed
|
||||
media_name = re.sub(r"^[\s._-]+|[\s._-]+$", "", media_name)
|
||||
info["media"].with_name(media_name)
|
||||
chapters = info["chapters"]
|
||||
duration_ms = info["duration_ms"]
|
||||
|
||||
cf.write(f"file '{ffmpeg_escape(media)}'\n")
|
||||
|
||||
if has_existing_chapters:
|
||||
# Preserve actual chapter boundaries and titles.
|
||||
for chapter in chapters:
|
||||
start_ms = round(float(chapter["start_time"]) * 1000)
|
||||
end_ms = round(float(chapter["end_time"]) * 1000)
|
||||
|
||||
tags = chapter.get("tags", {})
|
||||
title = tags.get("title", media.stem)
|
||||
|
||||
mf.write("[CHAPTER]\n")
|
||||
mf.write("TIMEBASE=1/1000\n")
|
||||
mf.write(f"START={current_ms + start_ms}\n")
|
||||
mf.write(f"END={current_ms + end_ms}\n")
|
||||
mf.write(f"title={ffmetadata_escape(title)}\n")
|
||||
else:
|
||||
# No input contains chapters: one chapter per file.
|
||||
mf.write("[CHAPTER]\n")
|
||||
mf.write("TIMEBASE=1/1000\n")
|
||||
mf.write(f"START={current_ms}\n")
|
||||
mf.write(f"END={current_ms + duration_ms}\n")
|
||||
mf.write(f"title={ffmetadata_escape(media.stem)}\n")
|
||||
|
||||
current_ms += duration_ms
|
||||
|
||||
codec, bitrate_k = get_codec_bitrate(self.firstFile)
|
||||
codec_args = ["-c:a", "copy"]
|
||||
if codec == "mp3":
|
||||
codec_args = ["-c:a", "aac", "-b:a", bitrate_k]
|
||||
elif codec == "flac":
|
||||
codec_args = ["-c:a", "alac", "-b:a", bitrate_k]
|
||||
elif codec not in {"aac", "alac"}:
|
||||
codec_args = ["-c:a", "aac", "-b:a", bitrate_k]
|
||||
cmd = [
|
||||
"ffmpeg",
|
||||
"-y",
|
||||
"-f",
|
||||
"concat",
|
||||
"-safe",
|
||||
"0",
|
||||
"-i",
|
||||
str(concat_file),
|
||||
"-i",
|
||||
str(metadata_file),
|
||||
"-i",
|
||||
str(self.firstFile),
|
||||
# audio from concat
|
||||
"-map",
|
||||
"0:a",
|
||||
# cover image from first media
|
||||
"-map",
|
||||
"2:v?",
|
||||
# Metadata and chapters from our generated FFMETADATA file
|
||||
"-map_metadata",
|
||||
"1",
|
||||
"-map_chapters",
|
||||
"1",
|
||||
*codec_args,
|
||||
"-c:v",
|
||||
"copy",
|
||||
"-disposition:v:0",
|
||||
"attached_pic",
|
||||
str(output_file_tmp),
|
||||
]
|
||||
result = subprocess.run(
|
||||
cmd,
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
logger.trace(result.stdout)
|
||||
if result.returncode == 0:
|
||||
output_file_tmp.rename(output_file_final)
|
||||
for media in self.files:
|
||||
if creat_m4b_no_delete:
|
||||
continue
|
||||
media.unlink()
|
||||
self.files = [output_file_final]
|
||||
self.firstFile = output_file_final
|
||||
self.fileConunt = 1
|
||||
self.singleFile = True
|
||||
self.changed = False
|
||||
self.size = Path(output_file_final).stat().st_size
|
||||
logger.info(
|
||||
f"{green_tag('SUCCESS')} - {self.bookPath.name} - delete media files"
|
||||
)
|
||||
else:
|
||||
logger.error(
|
||||
f"{red_tag('ERROR')} - {self.bookPath.name} - Code: {result.returncode}, Stderr: {result.stderr}"
|
||||
)
|
||||
|
||||
def write_metadata(self, keys=None, dry_run=False):
|
||||
if self.action_required:
|
||||
logger.warning("Action required, resolve before writing metadata file")
|
||||
return
|
||||
self.write_metadata_from_fields()
|
||||
if keys is None:
|
||||
keys = []
|
||||
for key, value in self.metadata.items():
|
||||
if self.metadata_original.get(key) != value and not isinstance(
|
||||
value, list
|
||||
):
|
||||
keys.append(key)
|
||||
self.metadata_original = self.metadata.copy()
|
||||
values = [self.metadata[key] for key in keys]
|
||||
if (not keys or not values) and self.metadata_original.get(
|
||||
"title"
|
||||
) != self.title:
|
||||
logger.trace(f"Nothing to write to file for {self.name}")
|
||||
return
|
||||
if keys:
|
||||
for file in self.files:
|
||||
write_metadata(file, keys, values, dry_run)
|
||||
if len(self.title_list) == len(self.files):
|
||||
for title, file in zip(self.title_list, self.files):
|
||||
write_metadata(file, ["title"], [title], dry_run)
|
||||
|
||||
self.changed = False
|
||||
|
||||
def fix_title(self):
|
||||
if not self.title:
|
||||
if self.singleFile:
|
||||
self.title = self.name
|
||||
else:
|
||||
padding = len(str(len(self.files)))
|
||||
for idx, file in enumerate(self.files):
|
||||
self.title_list.append(f"{self.name} - {idx + 1:0{padding}d}")
|
||||
@@ -0,0 +1,402 @@
|
||||
import json
|
||||
import logging
|
||||
import re
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
from mutagen import File
|
||||
from mutagen.id3 import (
|
||||
COMM,
|
||||
ID3,
|
||||
TALB,
|
||||
TCOM,
|
||||
TCON,
|
||||
TIT1,
|
||||
TIT2,
|
||||
TPE1,
|
||||
TPE2,
|
||||
)
|
||||
from mutagen.mp4 import MP4, MP4Tags
|
||||
from mutagen.oggopus import OggOpus
|
||||
from serverlibrary import (
|
||||
CustomLogger,
|
||||
score_match_jaccard,
|
||||
words,
|
||||
)
|
||||
|
||||
ID3_FRAME_CLASSES = {
|
||||
"TIT2": TIT2,
|
||||
"TALB": TALB,
|
||||
"TPE1": TPE1,
|
||||
"TPE2": TPE2,
|
||||
"TCON": TCON,
|
||||
"TCOM": TCOM,
|
||||
"TIT1": TIT1,
|
||||
}
|
||||
|
||||
logging.setLoggerClass(CustomLogger)
|
||||
logger: CustomLogger = logging.getLogger(__name__) # type: ignore[assignment]
|
||||
MP4_MAP = {
|
||||
"artist": "\xa9ART",
|
||||
"album": "\xa9alb",
|
||||
"title": "\xa9nam",
|
||||
"genre": "\xa9gen",
|
||||
"comment": "\xa9cmt",
|
||||
"composer": "\xa9wrt",
|
||||
"albumartist": "aART",
|
||||
"grouping": "\xa9grp",
|
||||
"description": "desc",
|
||||
}
|
||||
|
||||
ID3_MAP = {
|
||||
"artist": "TPE1",
|
||||
"album": "TALB",
|
||||
"title": "TIT2",
|
||||
"genre": "TCON",
|
||||
"composer": "TCOM",
|
||||
"albumartist": "TPE2",
|
||||
"grouping": "TIT1",
|
||||
}
|
||||
|
||||
metadata_fields = [
|
||||
"artist",
|
||||
"album",
|
||||
"composer",
|
||||
"comment",
|
||||
"genre",
|
||||
"grouping",
|
||||
"albumartist",
|
||||
"description",
|
||||
"title",
|
||||
]
|
||||
SEP = r"\s*[-_:,.]+\s*"
|
||||
series_patterns = [
|
||||
rf"^(.+?){SEP}(?:Book|Band|Volume|Vol)\s+(\d+)(?:{SEP}(.+))$",
|
||||
rf"^(.+?){SEP}(?:Book|Band|Volume|Vol)\s+(\d+)$",
|
||||
rf"^(\d+){SEP}(.+)$",
|
||||
rf"^(.+?){SEP}(\d+)$",
|
||||
]
|
||||
|
||||
|
||||
def ffmpeg_escape(path: Path) -> str:
|
||||
return str(path.resolve()).replace("'", r"'\''")
|
||||
|
||||
|
||||
def clean_genre(genre):
|
||||
if not genre:
|
||||
return ""
|
||||
genre_old = genre
|
||||
# genre = genre.lower()
|
||||
genre = re.sub(r"(?i)^audio\s*books?$", "", genre)
|
||||
genre = re.sub(r"(?i)^audiobooks?;?$", "", genre)
|
||||
genre = re.sub(r"(?i)\b(hörb(uch|ücher)|hoerb(uch|uecher))\b", "", genre)
|
||||
genre = re.sub(r"(?i)^(hörspiele?|hoerspiele?)$", "", genre)
|
||||
genre = re.sub(r"(?i)^spoken\s*word$", "", genre)
|
||||
genre = re.sub(r"(?i)gesprochene\s*inhalte$", "", genre)
|
||||
genre = re.sub(r"(?i)^speech$", "", genre)
|
||||
genre = re.sub(r"Fanasie", "Fantasie", genre)
|
||||
genre = re.sub(r"Mit Videospiel-?", "Videospielbezug", genre)
|
||||
genre = re.sub(r"(?i)nonfiction", "NonFiction", genre)
|
||||
|
||||
genre = re.sub(r"(?i)^speech$", "", genre)
|
||||
genre = re.sub(r"(?i)^vocal$", "", genre)
|
||||
genre = re.sub(r"(?i)^retail$", "", genre)
|
||||
genre = re.sub(r"(?i)^other$", "", genre)
|
||||
genre = re.sub(r"(?i)^misc$", "", genre)
|
||||
|
||||
genre = re.sub(r"(?i)^(sci[- ]?fi|sf)$", "Science Fiction", genre)
|
||||
genre = re.sub(r"(?i)^\(?science fiction\)?$", "Science Fiction", genre)
|
||||
genre = re.sub(r"Thrillers", "Thriller", genre)
|
||||
genre = re.sub(r"(?i)\bchildren'?s audiobooks?\b", "", genre)
|
||||
genre = re.sub(r"^-\s*|\s*-$", "", genre)
|
||||
genre = re.sub(r"(?i)Engelske\s*\sLydbånd", "", genre)
|
||||
genre = re.sub(r"^FIC028000.*$", "", genre)
|
||||
genre = re.sub(r"^800.*$", "", genre)
|
||||
genre = re.sub(r"^Fantastic Beasts.*$", "", genre)
|
||||
genre = re.sub(r"^and thei.*$", "", genre)
|
||||
genre = re.sub(r"^those you.*$", "", genre)
|
||||
# Normalize separators
|
||||
genre = re.sub(r"\s*[,:/]\s*", ";", genre)
|
||||
genre = re.sub(r"\s*;\s*", "; ", genre)
|
||||
|
||||
# Trim punctuation / whitespace
|
||||
genre = re.sub(r"^[\s,;:\-]+", "", genre)
|
||||
genre = re.sub(r"[\s,;\-]+$", "", genre)
|
||||
|
||||
genre = genre.strip()
|
||||
genre = genre.lstrip()
|
||||
if genre != genre_old:
|
||||
logger.debug(f"Update genre from {genre_old} to {genre}")
|
||||
return genre
|
||||
|
||||
|
||||
def ffmetadata_escape(value: str) -> str:
|
||||
return (
|
||||
value.replace("\\", "\\\\")
|
||||
.replace("=", "\\=")
|
||||
.replace(";", "\\;")
|
||||
.replace("#", "\\#")
|
||||
.replace("\n", "\\\n")
|
||||
)
|
||||
|
||||
|
||||
def get_chapters(media: Path) -> list[dict]:
|
||||
result = subprocess.run(
|
||||
[
|
||||
"ffprobe",
|
||||
"-v",
|
||||
"error",
|
||||
"-show_chapters",
|
||||
"-of",
|
||||
"json",
|
||||
str(media),
|
||||
],
|
||||
capture_output=True,
|
||||
text=True,
|
||||
check=True,
|
||||
)
|
||||
|
||||
data = json.loads(result.stdout)
|
||||
return data.get("chapters", [])
|
||||
|
||||
|
||||
def _to_str(value) -> str:
|
||||
if value is None:
|
||||
return ""
|
||||
|
||||
if hasattr(value, "text"):
|
||||
value = value.text
|
||||
|
||||
if isinstance(value, (list, tuple)):
|
||||
return "; ".join(str(v) for v in value)
|
||||
|
||||
return str(value)
|
||||
|
||||
|
||||
def get_metadata_all(file: Path) -> dict[str, str]:
|
||||
metadata = dict.fromkeys(metadata_fields, "")
|
||||
|
||||
try:
|
||||
audio = File(file)
|
||||
|
||||
if audio is None or audio.tags is None:
|
||||
return metadata
|
||||
|
||||
# MP4/M4A/M4B
|
||||
if isinstance(audio.tags, MP4Tags):
|
||||
for field, tag in MP4_MAP.items():
|
||||
value = audio.tags.get(tag)
|
||||
if value:
|
||||
metadata[field] = _to_str(value)
|
||||
|
||||
# ID3 (MP3 or mislabeled .m4b)
|
||||
elif isinstance(audio.tags, ID3):
|
||||
for field, frame_id in ID3_MAP.items():
|
||||
frame = audio.tags.get(frame_id)
|
||||
if frame:
|
||||
metadata[field] = _to_str(frame)
|
||||
|
||||
comments = audio.tags.getall("COMM")
|
||||
if comments:
|
||||
metadata["comment"] = _to_str(comments[0])
|
||||
|
||||
# Optional fallback
|
||||
if not metadata["description"]:
|
||||
metadata["description"] = metadata["comment"]
|
||||
|
||||
# FLAC / Opus / Vorbis
|
||||
else:
|
||||
for field in metadata_fields:
|
||||
value = audio.tags.get(field)
|
||||
if value:
|
||||
metadata[field] = _to_str(value)
|
||||
|
||||
except Exception:
|
||||
logger.exception(f"Error getting metadata for {file}")
|
||||
|
||||
return metadata
|
||||
|
||||
|
||||
def write_metadata(file, fields, values, dry_run=False):
|
||||
changes = {
|
||||
field.lower().replace(" ", ""): str(value)
|
||||
for field, value in zip(fields, values)
|
||||
}
|
||||
|
||||
logger.debug(f"Writing metadata for {file}: {changes}")
|
||||
|
||||
if dry_run:
|
||||
return
|
||||
|
||||
try:
|
||||
suffix = file.suffix.lower()
|
||||
|
||||
# MP3 / ID3
|
||||
if suffix == ".mp3":
|
||||
tags = ID3(file)
|
||||
|
||||
for field, value in changes.items():
|
||||
if field == "comment":
|
||||
tags.delall("COMM")
|
||||
|
||||
if value:
|
||||
tags.add(
|
||||
COMM(
|
||||
encoding=3,
|
||||
lang="eng",
|
||||
desc="",
|
||||
text=[value],
|
||||
)
|
||||
)
|
||||
continue
|
||||
|
||||
frame_id = ID3_MAP.get(field)
|
||||
if not frame_id:
|
||||
continue
|
||||
|
||||
tags.delall(frame_id)
|
||||
|
||||
if value:
|
||||
frame_cls = ID3_FRAME_CLASSES[frame_id]
|
||||
tags.add(frame_cls(encoding=3, text=[value]))
|
||||
|
||||
tags.save(file)
|
||||
|
||||
# M4A / M4B / MP4
|
||||
elif suffix in {".m4a", ".m4b", ".mp4"}:
|
||||
tags = MP4(file)
|
||||
|
||||
for field, value in changes.items():
|
||||
mp4_key = MP4_MAP.get(field)
|
||||
|
||||
if not mp4_key:
|
||||
logger.debug(f"Unsupported MP4 tag: {field}")
|
||||
continue
|
||||
|
||||
if value:
|
||||
tags[mp4_key] = [value]
|
||||
else:
|
||||
tags.pop(mp4_key, None)
|
||||
|
||||
tags.save()
|
||||
|
||||
# Opus
|
||||
elif suffix == ".opus":
|
||||
tags = OggOpus(file)
|
||||
|
||||
for field, value in changes.items():
|
||||
if value:
|
||||
tags[field] = [value]
|
||||
else:
|
||||
tags.pop(field, None)
|
||||
|
||||
tags.save()
|
||||
|
||||
else:
|
||||
logger.warning(f"Unsupported file type: {file}")
|
||||
|
||||
except Exception:
|
||||
logger.exception(f"Error writing metadata for {file}")
|
||||
|
||||
|
||||
def get_duration_ms(media: Path) -> int:
|
||||
duration = subprocess.check_output(
|
||||
[
|
||||
"ffprobe",
|
||||
"-v",
|
||||
"error",
|
||||
"-show_entries",
|
||||
"format=duration",
|
||||
"-of",
|
||||
"default=noprint_wrappers=1:nokey=1",
|
||||
str(media),
|
||||
],
|
||||
text=True,
|
||||
).strip()
|
||||
|
||||
return int(float(duration) * 1000)
|
||||
|
||||
|
||||
def normalize_name(name: str, series: str) -> str:
|
||||
# Remove anything in (), [], {}
|
||||
name_out = ""
|
||||
|
||||
# name = re.sub(
|
||||
# rf"^(?:{re.escape(series)}){SEP}|{SEP}(?:{re.escape(series)})$",
|
||||
# "", name, flags=re.IGNORECASE, ).strip()
|
||||
name = re.sub(r"\s*[(\[{].*?[)\]}]\s*", " ", name).strip()
|
||||
name = re.sub(r"\s+", " ", name)
|
||||
|
||||
for pattern in series_patterns:
|
||||
match = re.match(pattern, name, re.IGNORECASE)
|
||||
if match:
|
||||
if pattern.startswith(r"^(\d+)"):
|
||||
name_out = match.group(2).strip()
|
||||
else:
|
||||
name_out = match.group(1).strip()
|
||||
break
|
||||
else:
|
||||
name_out = name
|
||||
|
||||
pattern = rf"^(.+?){SEP}(?:Book|Band|Volume)\s+(\d+){SEP}(.+)$"
|
||||
match = re.match(pattern, name, re.IGNORECASE)
|
||||
if match:
|
||||
name_out1 = match.group(1).strip()
|
||||
name_out3 = match.group(3).strip()
|
||||
if score_match_jaccard(words(name_out1), words(series)) > score_match_jaccard(
|
||||
words(name_out3), words(series)
|
||||
):
|
||||
return name_out3
|
||||
else:
|
||||
return name_out1
|
||||
return name_out
|
||||
|
||||
|
||||
def cleanup(text: str) -> str:
|
||||
# Collapse repeated punctuation groups like ", ,", ". .", "! !", "? ?"
|
||||
while True:
|
||||
new_text = re.sub(r"([.,!?;:-])(?:\s+\1)+", r"\1", text)
|
||||
if new_text == text:
|
||||
break
|
||||
text = new_text
|
||||
|
||||
# Optional: normalize multiple spaces
|
||||
text = re.sub(r"\s{2,}", " ", text)
|
||||
|
||||
return text.strip()
|
||||
|
||||
|
||||
def get_empty_keys(data: dict) -> str:
|
||||
empty_keys = [str(key) for key, value in data.items() if not value]
|
||||
|
||||
return f"Empty: {', '.join(empty_keys)}" if empty_keys else ""
|
||||
|
||||
|
||||
def get_codec_bitrate(file: Path | None) -> tuple[str, str]:
|
||||
if not file:
|
||||
raise ValueError
|
||||
info = json.loads(
|
||||
subprocess.check_output(
|
||||
[
|
||||
"ffprobe",
|
||||
"-v",
|
||||
"error",
|
||||
"-select_streams",
|
||||
"a:0",
|
||||
"-show_entries",
|
||||
"stream=codec_name,bit_rate",
|
||||
"-of",
|
||||
"json",
|
||||
str(file),
|
||||
],
|
||||
text=True,
|
||||
)
|
||||
)
|
||||
|
||||
stream = info["streams"][0]
|
||||
|
||||
bitrate = int(stream.get("bit_rate") or 128000)
|
||||
bitrate_k = f"{bitrate // 1000}k"
|
||||
return stream["codec_name"].lower(), bitrate_k # codec, bits/s
|
||||
|
||||
|
||||
@@ -0,0 +1,169 @@
|
||||
import logging
|
||||
from collections import defaultdict
|
||||
from concurrent.futures import ThreadPoolExecutor, as_completed
|
||||
from pathlib import Path
|
||||
|
||||
from serverlibrary import AUDIO_SUFFIXES
|
||||
|
||||
from .audiobook import Audiobook
|
||||
from .audiobook_helpers import CustomLogger, logger
|
||||
from .audiobookshelf_api import AudiobookshelfApi
|
||||
from .sql_database import SqlDatabase
|
||||
|
||||
|
||||
class AudiobookLibrary:
|
||||
SqlDatabase = SqlDatabase
|
||||
AudiobookshelfApi = AudiobookshelfApi
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
library_path: Path,
|
||||
api_url: str,
|
||||
api_key: str,
|
||||
sql_database_path: Path,
|
||||
dry_run: bool,
|
||||
path_filter: str = "",
|
||||
logfilename: str = "audiobook_library.log",
|
||||
):
|
||||
self.path_filter = path_filter
|
||||
self.sql_database_instance = SqlDatabase(sql_database_path)
|
||||
self.api_instance = AudiobookshelfApi(api_url,api_key)
|
||||
self.dry_run = dry_run
|
||||
logging.setLoggerClass(CustomLogger)
|
||||
logger: CustomLogger = logging.getLogger(__name__) # type: ignore[assignment]
|
||||
logger.info("Started")
|
||||
self.libraryPath: Path = Path(library_path)
|
||||
self.audiobooks: list[Audiobook] = []
|
||||
self._by_path = {}
|
||||
self._by_name = defaultdict(list)
|
||||
self._by_artist = defaultdict(list)
|
||||
self._by_composer = defaultdict(list)
|
||||
|
||||
self.load_audiobooks_from_dir()
|
||||
self.size = sum(
|
||||
audiobook.size for audiobook in self.audiobooks
|
||||
) # size in bytes
|
||||
def add(self, book: Audiobook):
|
||||
self.audiobooks.append(book)
|
||||
|
||||
self._by_path[book.bookPath] = book
|
||||
self._by_name[book.name].append(book)
|
||||
|
||||
if book.artist:
|
||||
self._by_artist[book.artist].append(book)
|
||||
if book.composer:
|
||||
self._by_composer[book.composer].append(book)
|
||||
def print_name(self, books):
|
||||
if not isinstance(books, list):
|
||||
books = [books]
|
||||
for book in books:
|
||||
if book.name:
|
||||
logger.info(book.name)
|
||||
else:
|
||||
logger.info(f"No name in {book.bookPath.name}")
|
||||
def get_by_path(self, path):
|
||||
return self._by_path.get(Path(path))
|
||||
def get_by_name(self, name):
|
||||
return self._by_name.get(name, [])
|
||||
def get_by_artist(self, artist):
|
||||
return self._by_artist.get(artist, [])
|
||||
def get_by_composer(self, composer):
|
||||
return self._by_composer.get(composer, [])
|
||||
def find_path_contains(self, path) -> list[Audiobook]:
|
||||
return [
|
||||
book
|
||||
for book in self.audiobooks
|
||||
if book.bookPath == path or book.bookPath.is_relative_to(path)
|
||||
]
|
||||
def find_name_contains(self, text):
|
||||
text = text.lower()
|
||||
return [book for book in self.audiobooks if text in book.name.lower()]
|
||||
def find_artist_contains(self, text):
|
||||
text = text.lower()
|
||||
return [
|
||||
book
|
||||
for book in self.audiobooks
|
||||
if book.artist and text in book.artist.lower()
|
||||
]
|
||||
def load_audiobooks_from_dir(self):
|
||||
"""
|
||||
A book directory is any directory containing more than one
|
||||
audiobook file (.mp3, .m4a, .m4b)
|
||||
"""
|
||||
media_files = [
|
||||
file
|
||||
for file in self.libraryPath.rglob("*")
|
||||
if file.is_file()
|
||||
and file.suffix.lower() in AUDIO_SUFFIXES
|
||||
and self.path_filter in str(file)
|
||||
]
|
||||
dirs = {file.parent for file in media_files}
|
||||
for directory in dirs:
|
||||
self.add(Audiobook(directory, self.libraryPath))
|
||||
for audiobook in self.audiobooks:
|
||||
audiobook.init_book()
|
||||
def load_metadata(self):
|
||||
for audiobook in self.audiobooks:
|
||||
audiobook.load_metadata()
|
||||
def write_metadata(self, keys=None):
|
||||
for audiobook in self.audiobooks:
|
||||
if audiobook.changed:
|
||||
logger.trace(f"Writing metadata: {audiobook.name}")
|
||||
audiobook.write_metadata(keys, dry_run=self.dry_run)
|
||||
def fix_artist_dir(self):
|
||||
for book in self.audiobooks:
|
||||
book.fix_artist_dir()
|
||||
def create_structured_directories(self, dry_run=False):
|
||||
for book in self.audiobooks:
|
||||
desired_path, desired_name = book.generate_dir_from_metadata()
|
||||
book.move(desired_path, desired_name, dry_run)
|
||||
def fix_artists(self, force_artist_from_path=False):
|
||||
for book in self.audiobooks:
|
||||
book.fix_artist_from_comment()
|
||||
book.fix_artist_from_path(force_artist_from_path)
|
||||
def fix_composers(self):
|
||||
for book in self.audiobooks:
|
||||
book.fix_composer_from_narrator()
|
||||
book.fix_composer_from_comment()
|
||||
book.fix_composer_from_path()
|
||||
def fix_names(self):
|
||||
for book in self.audiobooks:
|
||||
book.fix_name()
|
||||
def fix_comments(self):
|
||||
for book in self.audiobooks:
|
||||
if book.comment and len(book.comment) < 40:
|
||||
logger.info(f"Remove short comment of {book.name}: {book.comment}")
|
||||
book.comment = ""
|
||||
book.changed = True
|
||||
def fix_genres(self):
|
||||
for book in self.audiobooks:
|
||||
book.fix_genre()
|
||||
def fix_titles(self):
|
||||
for book in self.audiobooks:
|
||||
book.fix_title()
|
||||
def fix_series(self):
|
||||
for book in self.audiobooks:
|
||||
book.fix_series()
|
||||
def create_m4b_from_dir(self, keep_originals: bool = False) -> None:
|
||||
audiobooks = self.audiobooks
|
||||
jobs = [audiobook for audiobook in audiobooks if not audiobook.singleFile]
|
||||
for audiobook in jobs:
|
||||
logger.debug(f"Create m4b file for {audiobook.name}")
|
||||
|
||||
if not self.dry_run:
|
||||
with ThreadPoolExecutor(max_workers=8) as executor:
|
||||
futures = {
|
||||
executor.submit(
|
||||
audiobook.create_m4b_from_book,
|
||||
keep_originals,
|
||||
): audiobook
|
||||
for audiobook in jobs
|
||||
}
|
||||
|
||||
for future in as_completed(futures):
|
||||
audiobook = futures[future]
|
||||
try:
|
||||
future.result()
|
||||
except Exception:
|
||||
logger.exception(f"Failed to create m4b for {audiobook.name}")
|
||||
raise
|
||||
@@ -0,0 +1,140 @@
|
||||
from pathlib import Path
|
||||
from typing import Any
|
||||
|
||||
import requests
|
||||
|
||||
from .audiobook_helpers import logger
|
||||
|
||||
|
||||
class AudiobookshelfApi:
|
||||
def __init__(self, url: str, api_key: str, timeout: int = 30):
|
||||
self.url = url.rstrip("/")
|
||||
self.timeout = timeout
|
||||
self.session = requests.Session()
|
||||
self.session.headers["Authorization"] = f"Bearer {api_key}"
|
||||
self.books = []
|
||||
|
||||
def _request(self, method: str, endpoint: str, **kwargs) -> Any:
|
||||
resp = self.session.request(
|
||||
method,
|
||||
f"{self.url}{endpoint}",
|
||||
timeout=self.timeout,
|
||||
**kwargs,
|
||||
)
|
||||
|
||||
try:
|
||||
resp.raise_for_status()
|
||||
except requests.exceptions.HTTPError:
|
||||
logger.error(f"{method} {endpoint}")
|
||||
logger.error(resp)
|
||||
if not resp.content or resp.status_code != 200:
|
||||
logger.error(f"Request failed: {resp}")
|
||||
return None
|
||||
# No content
|
||||
if not resp.content:
|
||||
return None
|
||||
|
||||
# Only parse JSON if response claims to be JSON
|
||||
content_type = resp.headers.get("Content-Type", "")
|
||||
|
||||
if "application/json" in content_type:
|
||||
return resp.json()
|
||||
|
||||
# Return raw text otherwise
|
||||
return resp.text
|
||||
|
||||
def get(self, endpoint: str, **kwargs):
|
||||
return self._request("GET", endpoint, params=kwargs)
|
||||
|
||||
def post(self, endpoint: str, data: dict, **kwargs):
|
||||
return self._request("POST", endpoint, json=data, params=kwargs)
|
||||
|
||||
def put(self, endpoint: str, data: dict):
|
||||
return self._request("PUT", endpoint, json=data)
|
||||
|
||||
def delete(self, endpoint: str):
|
||||
return self._request("DELETE", endpoint)
|
||||
|
||||
def load_books(self) -> list[dict]:
|
||||
"""Load all books from all libraries into self.books."""
|
||||
self.books = []
|
||||
|
||||
libraries = self.get("/api/libraries")["libraries"]
|
||||
|
||||
for library in libraries:
|
||||
library_id = library["id"]
|
||||
|
||||
response = self.get(
|
||||
f"/api/libraries/{library_id}/items",
|
||||
minified="0"
|
||||
)
|
||||
|
||||
self.books.extend(response["results"])
|
||||
return self.books
|
||||
|
||||
def embed_metadata_for_book(self, item_id: str) -> None:
|
||||
book = next((b for b in self.books if b["id"] == item_id), None)
|
||||
|
||||
if book:
|
||||
title = (
|
||||
book.get("media", {})
|
||||
.get("metadata", {})
|
||||
.get("title", item_id)
|
||||
)
|
||||
if book.get("media", {}).get("numAudioFiles", 0) > 0:
|
||||
logger.info(f"Embedding metadata: {title}")
|
||||
self.post(
|
||||
f"/api/tools/item/{item_id}/embed-metadata",
|
||||
data={},
|
||||
backup=False,
|
||||
)
|
||||
else:
|
||||
logger.info(f"{title} is an epub only book")
|
||||
|
||||
else:
|
||||
logger.info(f"Book not found: {item_id}")
|
||||
|
||||
def embed_metadata_for_all_books(self, args) -> None:
|
||||
for book in self.books:
|
||||
item_id = book["id"]
|
||||
|
||||
book_name = (
|
||||
book.get("media", {})
|
||||
.get("metadata", {})
|
||||
.get("title", item_id)
|
||||
)
|
||||
|
||||
book_path = book.get("path", "")
|
||||
|
||||
logger.info(f"Embedding metadata: {book_name} ({book_path})")
|
||||
|
||||
if args.dry_run:
|
||||
continue
|
||||
|
||||
try:
|
||||
self.embed_metadata_for_book(item_id)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed: {book_name}: {e}")
|
||||
raise
|
||||
|
||||
def embed_metadata_from_file(self, filename: str) -> None:
|
||||
resolved_path = Path(filename).expanduser().resolve()
|
||||
with open(resolved_path, encoding="utf-8") as f:
|
||||
item_ids = [
|
||||
line.strip()
|
||||
for line in f
|
||||
if line.strip() and not line.startswith("#")
|
||||
]
|
||||
|
||||
logger.info(f"Loaded {len(item_ids)} item IDs from {resolved_path}")
|
||||
|
||||
for item_id in item_ids:
|
||||
_books = next(
|
||||
(b for b in self.books if b["id"] == item_id),
|
||||
None
|
||||
)
|
||||
try:
|
||||
self.embed_metadata_for_book(item_id)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed: {item_id}: {e}")
|
||||
raise
|
||||
@@ -0,0 +1,66 @@
|
||||
|
||||
from serverlibrary import setup_logging
|
||||
|
||||
from .argparser import parse_args
|
||||
from .audiobook_helpers import logger
|
||||
from .audiobook_library import AudiobookLibrary
|
||||
|
||||
|
||||
def main(argv: list[str] | None = None) -> int:
|
||||
args = parse_args(argv)
|
||||
setup_logging(args.log_level, "audiobook_library")
|
||||
library_dir = args.library.expanduser().resolve()
|
||||
if not library_dir.exists():
|
||||
logger.error(f"Library directory does not exist: {library_dir}")
|
||||
return 1
|
||||
|
||||
database_path = args.sql_database.expanduser().resolve()
|
||||
library = AudiobookLibrary(
|
||||
library_dir,
|
||||
args.api_url,
|
||||
args.api_key,
|
||||
database_path,
|
||||
args.dry_run,
|
||||
path_filter=args.path_filter,
|
||||
)
|
||||
if args.encode_meta:
|
||||
library.api_instance.load_books()
|
||||
library.api_instance.embed_metadata_from_file("~/embed_ids.txt")
|
||||
if "artist_dir" in args.actions:
|
||||
library.fix_artist_dir()
|
||||
if "artists" in args.actions:
|
||||
library.fix_artists(args.force_artist_from_path)
|
||||
if "composers" in args.actions:
|
||||
library.fix_composers()
|
||||
if "series" in args.actions:
|
||||
library.fix_series()
|
||||
if "names" in args.actions:
|
||||
library.fix_names()
|
||||
if "comments" in args.actions:
|
||||
library.fix_comments()
|
||||
if "genres" in args.actions:
|
||||
library.fix_genres()
|
||||
if "titles" in args.actions:
|
||||
library.fix_titles()
|
||||
|
||||
if args.fix_db:
|
||||
if not database_path.is_file():
|
||||
logger.error(f"Database is not a file: {database_path}")
|
||||
return 1
|
||||
library.sql_database_instance.init()
|
||||
library.sql_database_instance.fix_genres()
|
||||
library.sql_database_instance.fix_comments()
|
||||
if not args.dry_run:
|
||||
library.sql_database_instance.update_books()
|
||||
library.sql_database_instance.commit()
|
||||
library.sql_database_instance.close()
|
||||
|
||||
if args.create_m4b:
|
||||
library.create_m4b_from_dir(keep_originals=args.keep_originals)
|
||||
|
||||
library.write_metadata()
|
||||
if args.move:
|
||||
library.create_structured_directories(args.dry_run)
|
||||
|
||||
logger.info("All Operations completed successfully")
|
||||
return 0
|
||||
@@ -0,0 +1,157 @@
|
||||
import json
|
||||
import sqlite3
|
||||
from pathlib import Path
|
||||
|
||||
from .audiobook_helpers import clean_genre, logger
|
||||
|
||||
|
||||
class SqlDatabase:
|
||||
def __init__(self, sql_database_path: Path):
|
||||
self.tables = []
|
||||
self.data = {}
|
||||
self.db = None
|
||||
self.path = sql_database_path
|
||||
self.books = []
|
||||
|
||||
def connect(self):
|
||||
if not self.path.is_file():
|
||||
logger.error(f"{self.path} does not exist")
|
||||
raise FileExistsError
|
||||
self.db = sqlite3.connect(self.path)
|
||||
self.db.row_factory = sqlite3.Row
|
||||
return True
|
||||
|
||||
def cursor(self):
|
||||
if not self.db:
|
||||
raise ValueError
|
||||
return self.db.cursor()
|
||||
|
||||
def commit(self):
|
||||
if not self.db:
|
||||
raise ValueError
|
||||
self.db.commit()
|
||||
|
||||
def close(self):
|
||||
if not self.db:
|
||||
raise ValueError
|
||||
self.db.close()
|
||||
|
||||
def init(self):
|
||||
if not self.connect():
|
||||
return False
|
||||
logger.info("Database initialized successfully")
|
||||
|
||||
return self.load_database_data()
|
||||
|
||||
def load_database_data(self) -> bool:
|
||||
logger.info("Load Database data")
|
||||
if not self.db:
|
||||
raise ValueError
|
||||
self.tables = self.db.execute(
|
||||
"SELECT name FROM sqlite_master WHERE type='table'"
|
||||
).fetchall()
|
||||
for table in self.tables:
|
||||
table_name = table["name"]
|
||||
rows = []
|
||||
for row in self.db.execute(f'SELECT * FROM "{table_name}"'):
|
||||
record = dict(row)
|
||||
# Auto-decode JSON columns
|
||||
for key, value in record.items():
|
||||
if isinstance(value, str) and value[:1] in "[{":
|
||||
try:
|
||||
record[key] = json.loads(value)
|
||||
except json.JSONDecodeError:
|
||||
pass
|
||||
|
||||
rows.append(record)
|
||||
|
||||
self.data[table_name] = rows
|
||||
self.books = self.data["books"]
|
||||
return True
|
||||
|
||||
def update_books(self):
|
||||
for book in self.books:
|
||||
self._save_book(book)
|
||||
|
||||
def _save_book(self, book):
|
||||
book = book.copy()
|
||||
|
||||
for key, value in book.items():
|
||||
if isinstance(value, (list, dict)):
|
||||
book[key] = json.dumps(value, ensure_ascii=False)
|
||||
|
||||
columns = [c for c in book if c != "id"]
|
||||
|
||||
sql = f"""
|
||||
UPDATE books
|
||||
SET {", ".join(f'"{c}" = ?' for c in columns)}
|
||||
WHERE id = ?
|
||||
"""
|
||||
|
||||
values = [book[c] for c in columns]
|
||||
values.append(book["id"])
|
||||
|
||||
if not self.db:
|
||||
raise ValueError
|
||||
self.db.execute(sql, values)
|
||||
|
||||
# commit once after all updates
|
||||
|
||||
def fix_genres(self):
|
||||
logger.info("Fix genres in database")
|
||||
for book in self.books:
|
||||
genres = book.get("genres")
|
||||
if not genres or not any(g.strip() for g in genres):
|
||||
continue
|
||||
new_genres = []
|
||||
for genre in genres:
|
||||
genre = clean_genre(genre)
|
||||
if "," in genre:
|
||||
genre = genre.split(",")
|
||||
elif ";" in genre:
|
||||
genre = genre.split(";")
|
||||
elif " - " in genre:
|
||||
genre = genre.split(" - ")
|
||||
elif "Historical Adventure Thriller Mystery" in genre:
|
||||
genre = genre.split(" ")
|
||||
|
||||
if isinstance(genre, str):
|
||||
if len(genre) > 50 or (5 > len(genre) > 0):
|
||||
genre = ""
|
||||
logger.trace(f"Too long or too short: {genre}")
|
||||
genre = genre.strip()
|
||||
genre = genre.lstrip()
|
||||
if genre:
|
||||
new_genres.append(genre)
|
||||
elif isinstance(genre, list):
|
||||
genre_buf = genre
|
||||
if len(genre) > 1:
|
||||
genre_buf = [g.strip() for g in genre if g]
|
||||
new_genres.extend(genre_buf)
|
||||
|
||||
new_genres = sorted(set(new_genres))
|
||||
logger.trace(f"{new_genres}")
|
||||
list_difference = False
|
||||
if len(new_genres) < len(genres):
|
||||
list_difference = True
|
||||
for old, new in zip(genres, new_genres):
|
||||
if old != new:
|
||||
list_difference = True
|
||||
break
|
||||
|
||||
if not list_difference:
|
||||
logger.trace("No difference: Dont Commit to Database")
|
||||
continue
|
||||
|
||||
logger.debug(f"{genres} -> {new_genres}")
|
||||
book["genres"] = new_genres
|
||||
|
||||
def fix_comments(self):
|
||||
logger.info("Fix comments in database")
|
||||
for book in self.books:
|
||||
for file in book.get("audioFiles"):
|
||||
comment = file.get("metaTags").get("tagComment")
|
||||
if comment and len(comment) < 40:
|
||||
logger.debug(f"Fix short comment for {book.get('title')}")
|
||||
comment = ""
|
||||
file["metaTags"]["tagComment"] = comment
|
||||
@@ -0,0 +1,29 @@
|
||||
"""Generate non-sensitive database fixtures for CI."""
|
||||
|
||||
import json
|
||||
import sqlite3
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
def create_fixtures(assets: Path) -> None:
|
||||
assets.mkdir(parents=True, exist_ok=True)
|
||||
with sqlite3.connect(assets / "absdatabase.sqlite_test") as db:
|
||||
db.execute(
|
||||
"CREATE TABLE books (id INTEGER PRIMARY KEY, title TEXT, genres TEXT, audioFiles TEXT)"
|
||||
)
|
||||
db.execute("CREATE TABLE libraries (id INTEGER PRIMARY KEY, name TEXT)")
|
||||
db.execute("INSERT INTO libraries VALUES (1, 'Test Library')")
|
||||
db.execute(
|
||||
"INSERT INTO books VALUES (?, ?, ?, ?)",
|
||||
(
|
||||
1,
|
||||
"Test Book",
|
||||
json.dumps(["Sci-Fi"]),
|
||||
json.dumps([{"metaTags": {"tagComment": "short"}}]),
|
||||
),
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
create_fixtures(Path(sys.argv[1]))
|
||||
@@ -0,0 +1,221 @@
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from unittest.mock import patch
|
||||
|
||||
from audiobook_library import Audiobook
|
||||
from audiobook_library import audiobook as audiobook_module
|
||||
from audiobook_library import audiobook_helpers as helpers
|
||||
|
||||
|
||||
class AudiobookTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tempdir = tempfile.TemporaryDirectory()
|
||||
self.root = Path(self.tempdir.name)
|
||||
|
||||
def tearDown(self):
|
||||
self.tempdir.cleanup()
|
||||
|
||||
def make_book(self):
|
||||
book_dir = self.root / "Artist" / "Book"
|
||||
book_dir.mkdir(parents=True)
|
||||
files = [book_dir / "02 - track.mp3", book_dir / "01 - track.mp3"]
|
||||
for file in files:
|
||||
file.touch()
|
||||
book = Audiobook(book_dir, self.root)
|
||||
book.files = files
|
||||
book.firstFile = files[0]
|
||||
book.fileConunt = 2
|
||||
book.singleFile = False
|
||||
book.metadata = {
|
||||
"artist": "Artist",
|
||||
"album": "Book",
|
||||
"composer": "Reader",
|
||||
"comment": "comment",
|
||||
"genre": "Fantasy",
|
||||
"grouping": "Series #1",
|
||||
"albumartist": "",
|
||||
"description": "description",
|
||||
"title": "Book",
|
||||
}
|
||||
book.write_fields_from_metadata()
|
||||
return book
|
||||
|
||||
def test_helper_functions(self):
|
||||
self.assertEqual(
|
||||
helpers.ffmpeg_escape(Path("a'b")),
|
||||
str(Path("a'b").resolve()).replace("'", r"'\''"),
|
||||
)
|
||||
self.assertEqual(helpers.clean_genre(" audio books "), "audio books")
|
||||
self.assertEqual(helpers.clean_genre("Sci-Fi"), "Science Fiction")
|
||||
self.assertEqual(
|
||||
helpers.ffmetadata_escape(r"a\=b;c#d\n"),
|
||||
r"a\\\=b\;c\#d\\n",
|
||||
)
|
||||
self.assertEqual(helpers._to_str(None), "")
|
||||
self.assertEqual(helpers._to_str(["a", "b"]), "a; b")
|
||||
self.assertEqual(helpers.cleanup("a, , b c"), "a, b c")
|
||||
self.assertEqual(helpers.get_empty_keys({"a": "", "b": "x"}), "Empty: a")
|
||||
self.assertEqual(helpers.get_empty_keys({"a": "x"}), "")
|
||||
self.assertEqual(
|
||||
helpers.normalize_name("Series - Book 2 - Title", "Series"), "Title"
|
||||
)
|
||||
|
||||
result = SimpleNamespace(stdout=json.dumps({"chapters": [{"title": "x"}]}))
|
||||
with patch.object(helpers.subprocess, "run", return_value=result):
|
||||
self.assertEqual(
|
||||
helpers.get_chapters(self.root / "book.mp3"), [{"title": "x"}]
|
||||
)
|
||||
with patch.object(helpers.subprocess, "check_output", return_value="12.5"):
|
||||
self.assertEqual(helpers.get_duration_ms(self.root / "book.mp3"), 12500)
|
||||
with patch.object(
|
||||
helpers.subprocess,
|
||||
"check_output",
|
||||
return_value=json.dumps(
|
||||
{"streams": [{"codec_name": "MP3", "bit_rate": "96000"}]}
|
||||
),
|
||||
):
|
||||
self.assertEqual(
|
||||
helpers.get_codec_bitrate(self.root / "book.mp3"), ("mp3", "96k")
|
||||
)
|
||||
with self.assertRaises(ValueError):
|
||||
helpers.get_codec_bitrate(None)
|
||||
|
||||
def test_metadata_read_write_boundaries(self):
|
||||
class Tags:
|
||||
def __init__(self):
|
||||
self.saved = False
|
||||
|
||||
def save(self, *args):
|
||||
self.saved = True
|
||||
|
||||
def delall(self, _):
|
||||
pass
|
||||
|
||||
def add(self, _):
|
||||
pass
|
||||
|
||||
tags = Tags()
|
||||
with patch.object(helpers, "ID3", return_value=tags), patch.object(
|
||||
helpers, "File", return_value=None
|
||||
):
|
||||
self.assertEqual(
|
||||
helpers.get_metadata_all(self.root / "x.mp3")["title"], ""
|
||||
)
|
||||
helpers.write_metadata(
|
||||
self.root / "x.mp3", ["title"], ["Book"], dry_run=True
|
||||
)
|
||||
helpers.write_metadata(self.root / "x.mp3", ["title"], ["Book"])
|
||||
self.assertTrue(tags.saved)
|
||||
|
||||
def test_metadata_and_track_methods(self):
|
||||
book = self.make_book()
|
||||
self.assertEqual(book.get_first_file(), book.files[0])
|
||||
self.assertEqual(book.extract_track_number(Path("CD2-03.mp3")), 1003)
|
||||
self.assertEqual(book.extract_track_number(Path("Track 07.mp3")), 7)
|
||||
self.assertEqual(book.extract_track_number(Path("unknown.mp3")), 0)
|
||||
self.assertIn("Book", repr(book))
|
||||
|
||||
book.write_metadata_from_fields()
|
||||
self.assertEqual(book.metadata["albumartist"], "Artist")
|
||||
book.metadata["grouping"] = "Series #2"
|
||||
book.write_fields_from_metadata()
|
||||
self.assertEqual((book.series, book.series_num), ("Series", "2"))
|
||||
|
||||
with patch.object(audiobook_module, "get_metadata_all", return_value=book.metadata):
|
||||
book.load_metadata()
|
||||
book.fix_artist_from_comment()
|
||||
book.comment = "Narrated by Reader, extra"
|
||||
book.fix_composer_from_comment()
|
||||
self.assertEqual(book.composer, "Reader")
|
||||
book.fix_composer_from_path()
|
||||
book.fix_composer_from_narrator()
|
||||
|
||||
book.name = ""
|
||||
book.fix_name()
|
||||
book.genre = "Sci-Fi"
|
||||
book.fix_genre()
|
||||
self.assertEqual(book.genre, "Science Fiction")
|
||||
book.title = ""
|
||||
book.singleFile = True
|
||||
book.fix_title()
|
||||
self.assertEqual(book.title, book.name)
|
||||
book.series_and_num = ""
|
||||
book.fix_series()
|
||||
self.assertTrue(book.generate_dir_from_metadata()[0].is_relative_to(self.root))
|
||||
|
||||
def test_fix_series_from_series_number_title_path(self):
|
||||
examples = [
|
||||
("Jack Reacher 10: The Hard Way (by Dick Hill)", "10"),
|
||||
("Jack Reacher 1: Killing Floor (by Dick Hill)", "1"),
|
||||
("Jack Reacher 28: The Secret (by Jeff Harding)", "28"),
|
||||
("Jack Reacher 10 - The Hard Way", "10"),
|
||||
("Jack Reacher #10: The Hard Way", "10"),
|
||||
("Jack Reacher - #10 - The Hard Way", "10"),
|
||||
("Jack Reacher - 10 - The Hard Way", "10"),
|
||||
("Jack Reacher - Book 10 - The Hard Way", "10"),
|
||||
("Jack Reacher Book 10 - The Hard Way", "10"),
|
||||
("Jack Reacher: Book 10: The Hard Way", "10"),
|
||||
("Jack Reacher - Band 10 - The Hard Way", "10"),
|
||||
("Jack Reacher - Volume 10 - The Hard Way", "10"),
|
||||
("Jack Reacher - Vol 10 - The Hard Way", "10"),
|
||||
("Jack Reacher - Book 10", "10"),
|
||||
("10 - The Hard Way", "10"),
|
||||
("Jack Reacher - 10", "10"),
|
||||
]
|
||||
|
||||
for path_name, number in examples:
|
||||
with self.subTest(path_name=path_name):
|
||||
book_dir = self.root / "Author" / path_name
|
||||
book_dir.mkdir(parents=True)
|
||||
book = Audiobook(book_dir, self.root)
|
||||
book.series_and_num = "Jack Reacher"
|
||||
book.fix_series()
|
||||
|
||||
self.assertEqual(book.series, "Jack Reacher")
|
||||
self.assertEqual(book.series_num, number)
|
||||
self.assertEqual(book.series_and_num, f"Jack Reacher #{number}")
|
||||
|
||||
def test_file_operations(self):
|
||||
book = self.make_book()
|
||||
destination = self.root / "new"
|
||||
book.move(destination, "Artist - Book", dry_run=True)
|
||||
self.assertEqual(book.bookPath, destination)
|
||||
self.assertTrue(book.files[0].exists())
|
||||
|
||||
book.action_required = True
|
||||
book.create_m4b_from_book()
|
||||
book.write_metadata()
|
||||
book.action_required = False
|
||||
with patch.object(audiobook_module, "write_metadata"):
|
||||
book.changed = True
|
||||
book.write_metadata(keys=["title"], dry_run=True)
|
||||
book.fix_artist_dir()
|
||||
book.fix_artist_from_path(False)
|
||||
|
||||
def test_create_m4b_from_audio_assets(self):
|
||||
assets = Path(os.environ.get("AUDIOBOOK_TEST_ASSETS", Path(__file__).resolve().parents[2] /\
|
||||
"testassets" / "audiobook_library"))
|
||||
source_book = next(assets.glob("*/*"))
|
||||
expected_track_count = len(list(source_book.glob("*.mp3")))
|
||||
self.assertGreater(expected_track_count, 0)
|
||||
book_dir = self.root / source_book.name
|
||||
shutil.copytree(source_book, book_dir)
|
||||
|
||||
book = Audiobook(book_dir, self.root)
|
||||
book.init_book()
|
||||
book.create_m4b_from_book(creat_m4b_no_delete=True)
|
||||
|
||||
output = book_dir / f"{book_dir.name}.m4b"
|
||||
self.assertTrue(output.is_file())
|
||||
self.assertEqual(len(list(book_dir.glob("*.mp3"))), expected_track_count)
|
||||
self.assertEqual(book.files, [output])
|
||||
self.assertTrue(book.singleFile)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,103 @@
|
||||
import tempfile
|
||||
import unittest
|
||||
from collections import defaultdict
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
from audiobook_library import Audiobook, AudiobookLibrary
|
||||
from audiobook_library import audiobook_library as library_module
|
||||
|
||||
|
||||
class AudiobookLibraryTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tempdir = tempfile.TemporaryDirectory()
|
||||
self.root = Path(self.tempdir.name)
|
||||
|
||||
def tearDown(self):
|
||||
self.tempdir.cleanup()
|
||||
|
||||
def make_book(self):
|
||||
book_dir = self.root / "Artist" / "Book"
|
||||
book_dir.mkdir(parents=True)
|
||||
files = [book_dir / "02 - track.mp3", book_dir / "01 - track.mp3"]
|
||||
for file in files:
|
||||
file.touch()
|
||||
book = Audiobook(book_dir, self.root)
|
||||
book.files = files
|
||||
book.firstFile = files[0]
|
||||
book.fileConunt = 2
|
||||
book.singleFile = False
|
||||
book.metadata = {
|
||||
"artist": "Artist",
|
||||
"album": "Book",
|
||||
"composer": "Reader",
|
||||
"comment": "comment",
|
||||
"genre": "Fantasy",
|
||||
"grouping": "Series #1",
|
||||
"albumartist": "",
|
||||
"description": "description",
|
||||
"title": "Book",
|
||||
}
|
||||
book.write_fields_from_metadata()
|
||||
return book
|
||||
|
||||
def test_indexing_and_orchestration(self):
|
||||
library = object.__new__(AudiobookLibrary)
|
||||
library.audiobooks = []
|
||||
library._by_path = {}
|
||||
library._by_name = defaultdict(list)
|
||||
library._by_artist = defaultdict(list)
|
||||
library._by_composer = defaultdict(list)
|
||||
book = self.make_book()
|
||||
library.add(book)
|
||||
self.assertIs(library.get_by_path(book.bookPath), book)
|
||||
self.assertEqual(library.get_by_name(book.name), [book])
|
||||
self.assertEqual(library.get_by_artist(book.artist), [book])
|
||||
self.assertEqual(library.get_by_composer(book.composer), [book])
|
||||
self.assertEqual(library.find_name_contains("book"), [book])
|
||||
self.assertEqual(library.find_artist_contains("art"), [book])
|
||||
self.assertEqual(library.find_path_contains(self.root), [book])
|
||||
library.print_name(book)
|
||||
|
||||
calls = []
|
||||
for name in (
|
||||
"fix_artist_dir",
|
||||
"fix_artists",
|
||||
"fix_composers",
|
||||
"fix_names",
|
||||
"fix_comments",
|
||||
"fix_genres",
|
||||
"fix_titles",
|
||||
"fix_series",
|
||||
):
|
||||
setattr(book, name, lambda name=name, **kwargs: calls.append(name))
|
||||
library.fix_artist_dir()
|
||||
library.fix_artists()
|
||||
library.fix_composers()
|
||||
library.fix_names()
|
||||
library.fix_comments()
|
||||
library.fix_genres()
|
||||
library.fix_titles()
|
||||
library.fix_series()
|
||||
self.assertTrue(calls)
|
||||
|
||||
library.dry_run = True
|
||||
library.create_structured_directories()
|
||||
library.write_metadata()
|
||||
library.create_m4b_from_dir()
|
||||
|
||||
def test_loading_and_init(self):
|
||||
(self.root / "Artist" / "Book").mkdir(parents=True)
|
||||
(self.root / "Artist" / "Book" / "01.mp3").touch()
|
||||
with patch.object(Audiobook, "init_book", lambda self: setattr(self, "size", 1)), patch.object(
|
||||
library_module, "SqlDatabase", return_value=object()
|
||||
), patch.object(library_module, "AudiobookshelfApi", return_value=object()):
|
||||
library = AudiobookLibrary(
|
||||
self.root, "https://example.test", "key", self.root / "db.sqlite", True
|
||||
)
|
||||
self.assertEqual(library.size, 1)
|
||||
self.assertEqual(len(library.audiobooks), 1)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,62 @@
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
from types import SimpleNamespace
|
||||
from typing import ClassVar
|
||||
from unittest.mock import patch
|
||||
|
||||
from audiobook_library import AudiobookshelfApi
|
||||
|
||||
|
||||
class AudiobookshelfApiTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tempdir = tempfile.TemporaryDirectory()
|
||||
self.root = Path(self.tempdir.name)
|
||||
|
||||
def tearDown(self):
|
||||
self.tempdir.cleanup()
|
||||
|
||||
def test_api_methods(self):
|
||||
api = AudiobookshelfApi("https://example.test/", "key")
|
||||
|
||||
class Response:
|
||||
status_code = 200
|
||||
content = b"{}"
|
||||
headers: ClassVar[dict[str, str]] = {"Content-Type": "application/json"}
|
||||
text = ""
|
||||
|
||||
def raise_for_status(self):
|
||||
return None
|
||||
|
||||
def json(self):
|
||||
return {"ok": True}
|
||||
|
||||
with patch.object(api.session, "request", return_value=Response()):
|
||||
self.assertEqual(api.get("/x"), {"ok": True})
|
||||
self.assertEqual(api.post("/x", {}), {"ok": True})
|
||||
self.assertEqual(api.put("/x", {}), {"ok": True})
|
||||
self.assertEqual(api.delete("/x"), {"ok": True})
|
||||
|
||||
responses = iter(
|
||||
[
|
||||
{"libraries": [{"id": "l1"}]},
|
||||
{"results": [{"id": "b1", "media": {"metadata": {"title": "Book"}}}]},
|
||||
]
|
||||
)
|
||||
with patch.object(api, "get", side_effect=lambda *args, **kwargs: next(responses)):
|
||||
self.assertEqual(
|
||||
api.load_books(),
|
||||
[{"id": "b1", "media": {"metadata": {"title": "Book"}}}],
|
||||
)
|
||||
api.post = lambda *args, **kwargs: {"ok": True}
|
||||
api.embed_metadata_for_book("b1")
|
||||
api.embed_metadata_for_book("missing")
|
||||
api.embed_metadata_for_all_books(SimpleNamespace(dry_run=True))
|
||||
|
||||
ids = self.root / "ids.txt"
|
||||
ids.write_text("# comment\nb1\n")
|
||||
api.embed_metadata_from_file(str(ids))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -0,0 +1,81 @@
|
||||
import os
|
||||
import shutil
|
||||
import sqlite3
|
||||
import tempfile
|
||||
import unittest
|
||||
from pathlib import Path
|
||||
|
||||
from audiobook_library import SqlDatabase
|
||||
|
||||
|
||||
class SqlDatabaseTests(unittest.TestCase):
|
||||
def setUp(self):
|
||||
self.tempdir = tempfile.TemporaryDirectory()
|
||||
self.root = Path(self.tempdir.name)
|
||||
|
||||
def tearDown(self):
|
||||
self.tempdir.cleanup()
|
||||
|
||||
def test_database_methods(self):
|
||||
db_path = self.root / "books.sqlite"
|
||||
connection = sqlite3.connect(db_path)
|
||||
connection.execute(
|
||||
"CREATE TABLE books (id INTEGER PRIMARY KEY, title TEXT, genres TEXT, audioFiles TEXT)"
|
||||
)
|
||||
connection.execute(
|
||||
"INSERT INTO books VALUES (1, 'Book', '[\"Sci-Fi\"]', '[]')"
|
||||
)
|
||||
connection.commit()
|
||||
connection.close()
|
||||
|
||||
database = SqlDatabase(db_path)
|
||||
self.assertTrue(database.connect())
|
||||
self.assertIsNotNone(database.cursor())
|
||||
self.assertTrue(database.load_database_data())
|
||||
self.assertEqual(database.books[0]["genres"], ["Sci-Fi"])
|
||||
database.books[0]["title"] = "Updated"
|
||||
database._save_book(database.books[0])
|
||||
database.update_books()
|
||||
database.fix_genres()
|
||||
database.fix_comments()
|
||||
database.commit()
|
||||
database.close()
|
||||
|
||||
with self.assertRaises(ValueError):
|
||||
SqlDatabase(db_path).cursor()
|
||||
with self.assertRaises(FileExistsError):
|
||||
SqlDatabase(self.root / "missing.sqlite").connect()
|
||||
|
||||
def test_asset_fixture(self):
|
||||
assets = Path(os.environ.get("AUDIOBOOK_TEST_ASSETS", Path(__file__).resolve().parents[2] /\
|
||||
"testassets" / "audiobook_library"))
|
||||
database_fixture = os.environ.get("AUDIOBOOK_TEST_DATABASE")
|
||||
fixture = (
|
||||
Path(database_fixture)
|
||||
if database_fixture
|
||||
else assets / "absdatabase.sqlite_test"
|
||||
)
|
||||
with sqlite3.connect(fixture.resolve().as_uri() + "?mode=ro", uri=True) as source:
|
||||
expected_books = source.execute("SELECT COUNT(*) FROM books").fetchone()[0]
|
||||
self.assertGreater(expected_books, 0)
|
||||
database_path = self.root / "absdatabase.sqlite"
|
||||
shutil.copyfile(fixture, database_path)
|
||||
|
||||
database = SqlDatabase(database_path)
|
||||
self.assertTrue(database.init())
|
||||
self.assertEqual(len(database.books), expected_books)
|
||||
self.assertTrue(database.data["libraries"])
|
||||
database.fix_genres()
|
||||
database.fix_comments()
|
||||
database.update_books()
|
||||
database.commit()
|
||||
database.close()
|
||||
|
||||
reopened = SqlDatabase(database_path)
|
||||
self.assertTrue(reopened.init())
|
||||
self.assertEqual(len(reopened.books), expected_books)
|
||||
reopened.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
@@ -1,231 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
from __future__ import annotations
|
||||
from concurrent.futures import ProcessPoolExecutor, as_completed
|
||||
|
||||
import argparse
|
||||
import subprocess
|
||||
import tempfile
|
||||
from pathlib import Path
|
||||
import time
|
||||
from typing import Any
|
||||
|
||||
RED = "\033[91m"
|
||||
GREEN = "\033[92m"
|
||||
YELLOW = "\033[93m"
|
||||
BLUE = "\033[94m"
|
||||
RESET = "\033[0m"
|
||||
logfile=Path(f"media_{time.strftime("%Y%m%d_%H%M%S")}.log")
|
||||
|
||||
def log_message(message):
|
||||
with open(logfile, "a") as log:
|
||||
log.write(f"{message}\n")
|
||||
print(message)
|
||||
|
||||
def get_duration_ms(media: Path) -> int:
|
||||
duration = subprocess.check_output(
|
||||
[
|
||||
"ffprobe",
|
||||
"-v",
|
||||
"error",
|
||||
"-show_entries",
|
||||
"format=duration",
|
||||
"-of",
|
||||
"default=noprint_wrappers=1:nokey=1",
|
||||
str(media),
|
||||
],
|
||||
text=True,
|
||||
).strip()
|
||||
|
||||
return int(float(duration) * 1000)
|
||||
|
||||
def ffmpeg_escape(path: Path) -> str:
|
||||
return str(path.resolve()).replace("'", r"'\''")
|
||||
|
||||
def create_m4b(root_path: Path, book_dir: Path) -> None:
|
||||
media_files = sorted(list(book_dir.glob("*.mp3"))
|
||||
+ list(book_dir.glob("*.m4a"))
|
||||
+ list(book_dir.glob("*.m4b"))
|
||||
+ list(book_dir.glob("*.opus")))
|
||||
if not media_files:
|
||||
return
|
||||
|
||||
output_file_final = book_dir / f"{book_dir.name}.m4b"
|
||||
|
||||
if output_file_final.exists():
|
||||
log_message(f"{RED}[SKIP]{RESET} {output_file_final}")
|
||||
log_message("Book already present")
|
||||
return
|
||||
|
||||
log_message(f"[CREATE] {output_file_final}")
|
||||
|
||||
with (tempfile.TemporaryDirectory(dir=root_path.parent) as tmp):
|
||||
tmpdir = Path(tmp)
|
||||
|
||||
output_file_tmp = tmpdir / f"{book_dir.name}.m4b"
|
||||
concat_file = tmpdir / "concat.txt"
|
||||
metadata_file = tmpdir / "chapters.txt"
|
||||
|
||||
current_ms = 0
|
||||
|
||||
with concat_file.open("w", encoding="utf-8") as cf, \
|
||||
metadata_file.open("w", encoding="utf-8") as mf:
|
||||
mf.write(";FFMETADATA1\n")
|
||||
|
||||
for media in media_files:
|
||||
cf.write(f"file '{ffmpeg_escape(media)}'\n")
|
||||
|
||||
duration_ms = get_duration_ms(media)
|
||||
|
||||
mf.write("[CHAPTER]\n")
|
||||
mf.write("TIMEBASE=1/1000\n")
|
||||
mf.write(f"START={current_ms}\n")
|
||||
mf.write(f"END={current_ms + duration_ms}\n")
|
||||
mf.write(f"title={media.stem}\n")
|
||||
|
||||
current_ms += duration_ms
|
||||
cmd_backup = [ "ffmpeg","-y","-f","concat","-safe","0",
|
||||
"-i",str(concat_file),"-i",str(metadata_file),
|
||||
# cover from first media
|
||||
"-i",str(media_files[0]),
|
||||
# audio from concat
|
||||
"-map","0:a",
|
||||
# cover image from first media
|
||||
"-map","2:v?",
|
||||
# copy artist/album/composer/etc from first media file
|
||||
"-map_metadata", "2",
|
||||
# copy chapters from ffmetadata
|
||||
"-map_chapters", "1",
|
||||
|
||||
"-c:a","copy",
|
||||
"-c:a", "aac",
|
||||
"-b:a", "128k",
|
||||
# copy cover image without re-encoding
|
||||
"-c:v","copy","-disposition:v:0","attached_pic",
|
||||
str(output_file_tmp),
|
||||
]
|
||||
cmd_default = ["ffmpeg", "-y", "-f", "concat", "-safe", "0",
|
||||
"-i", str(concat_file), "-i", str(metadata_file),
|
||||
# cover from first media
|
||||
"-i", str(media_files[0]),
|
||||
# audio from concat
|
||||
"-map", "0:a",
|
||||
# cover image from first media
|
||||
"-map", "2:v?",
|
||||
|
||||
# copy artist/album/composer/etc from first media file
|
||||
"-map_metadata", "2",
|
||||
# copy chapters from ffmetadata
|
||||
"-map_chapters", "1",
|
||||
"-c:a", "copy",
|
||||
# copy cover image without re-encoding
|
||||
"-c:v", "copy", "-disposition:v:0", "attached_pic",
|
||||
str(output_file_tmp),
|
||||
]
|
||||
with logfile.open("a", encoding="utf-8") as log:
|
||||
result = subprocess.run(
|
||||
cmd_default,
|
||||
stdout=log,
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True,
|
||||
)
|
||||
if result.returncode == 234:
|
||||
log_message(f"{YELLOW}[WARNING]{RESET} - {book_dir.name} - {result.returncode} retrying with aac encoder")
|
||||
result = subprocess.run(
|
||||
cmd_backup,
|
||||
stdout=log,
|
||||
stderr=subprocess.STDOUT,
|
||||
text=True,
|
||||
)
|
||||
if result.returncode == 0:
|
||||
output_file_tmp.rename(output_file_final)
|
||||
for media in media_files:
|
||||
media.unlink()
|
||||
log_message(f"{GREEN}[SUCCESS]{RESET} - {book_dir.name} - delete media files")
|
||||
else:
|
||||
log_message(f"{RED}[ERROR]{RESET} - {book_dir.name} - Code: {result.returncode}, Stderr: {result.stderr}")
|
||||
|
||||
def find_book_dirs(root: Path) -> tuple[list[Any], int]:
|
||||
"""
|
||||
A book directory is any directory containing more than one
|
||||
audiobook file (.mp3, .m4a, .m4b)
|
||||
"""
|
||||
|
||||
media_files = (
|
||||
list(root.rglob("*.mp3"))
|
||||
+ list(root.rglob("*.m4a"))
|
||||
+ list(root.rglob("*.m4b"))
|
||||
+ list(root.rglob("*.opus"))
|
||||
)
|
||||
|
||||
counts: dict[Path, int] = {}
|
||||
|
||||
for file in media_files:
|
||||
if counts.get(file.parent, 0) > 1:
|
||||
continue
|
||||
counts[file.parent] = counts.get(file.parent, 0) + 1
|
||||
|
||||
directories = []
|
||||
size = 0
|
||||
for directory, count in counts.items():
|
||||
if count > 1:
|
||||
directories.append(directory)
|
||||
size += sum(file.stat().st_size for pattern in ("*.mp3", "*.m4a", "*.m4b", "*.opus") for file in directory.glob(pattern))
|
||||
|
||||
|
||||
return sorted(directories), size
|
||||
|
||||
def process_book(args):
|
||||
target, book_dir = args
|
||||
try:
|
||||
create_m4b(target, book_dir)
|
||||
return book_dir, None
|
||||
except Exception as exc:
|
||||
return book_dir, str(exc)
|
||||
|
||||
def main() -> None:
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"path",
|
||||
type=Path,
|
||||
help="Book folder or root folder",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
target = args.path.resolve()
|
||||
|
||||
if not target.exists():
|
||||
raise SystemExit(f"Path does not exist: {target}")
|
||||
|
||||
# Direct book folder
|
||||
if any(list(target.glob("*.mp3"))
|
||||
+ list(target.glob("*.m4a"))
|
||||
+ list(target.glob("*.m4b"))
|
||||
+ list(target.glob("*.opus"))):
|
||||
create_m4b(target.parent,target)
|
||||
return
|
||||
|
||||
book_dir_set, library_size = find_book_dirs(target)
|
||||
|
||||
for book_dir in book_dir_set:
|
||||
log_message(f"Found Media: {book_dir}")
|
||||
|
||||
print("Proceed? y/n")
|
||||
name = input()
|
||||
if name != "y":
|
||||
log_message(f"Aborted")
|
||||
exit(0)
|
||||
|
||||
# Root folder containing many books
|
||||
with ProcessPoolExecutor(max_workers=8) as executor:
|
||||
for book_dir, error in executor.map(
|
||||
process_book,
|
||||
((target, book_dir) for book_dir in book_dir_set),
|
||||
):
|
||||
if error:
|
||||
log_message(f"{RED}[ERROR]{RESET} {book_dir}: {error}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,60 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import subprocess
|
||||
from pathlib import Path
|
||||
|
||||
|
||||
ROOT = Path(sys.argv[1]) if len(sys.argv) > 1 else Path(".")
|
||||
|
||||
audio_extensions = {
|
||||
".m4b",
|
||||
".m4a",
|
||||
".mp3",
|
||||
".flac",
|
||||
".ogg",
|
||||
}
|
||||
|
||||
|
||||
def get_metadata(field, file):
|
||||
try:
|
||||
result = subprocess.run(
|
||||
["kid3-cli", "-c", f"get {field}", str(file)],
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.DEVNULL,
|
||||
text=True,
|
||||
)
|
||||
return result.stdout.strip()
|
||||
|
||||
except (OSError, subprocess.SubprocessError):
|
||||
return ""
|
||||
|
||||
|
||||
# Include ROOT itself, matching find "$ROOT" -type d
|
||||
for directory in [ROOT] + [p for p in ROOT.rglob("*") if p.is_dir()]:
|
||||
audio_files = sorted(
|
||||
(
|
||||
file
|
||||
for file in directory.iterdir()
|
||||
if file.is_file()
|
||||
and file.suffix.lower() in audio_extensions
|
||||
),
|
||||
key=lambda p: str(p),
|
||||
)
|
||||
|
||||
if not audio_files:
|
||||
continue
|
||||
|
||||
first_file = audio_files[0]
|
||||
|
||||
artist = get_metadata("artist", first_file)
|
||||
album = get_metadata("album", first_file)
|
||||
composer = get_metadata("composer", first_file)
|
||||
comment = get_metadata("comment", first_file)
|
||||
|
||||
print("====≠===============================")
|
||||
print(f"Folder: {directory.name}")
|
||||
print(f"Album: {album}")
|
||||
print(f"Artist: {artist}")
|
||||
print(f"Narrator: {composer}")
|
||||
print(f"Comment: {comment}")
|
||||
@@ -1,90 +0,0 @@
|
||||
import json
|
||||
import re
|
||||
import sqlite3
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
def load_genre(conn, unique=False):
|
||||
"""
|
||||
Return all genres from the books table.
|
||||
|
||||
Args:
|
||||
conn: sqlite3 connection
|
||||
unique: if True, return unique genres only
|
||||
|
||||
Returns:
|
||||
list[str]
|
||||
"""
|
||||
genres = []
|
||||
|
||||
for (genres_json,) in conn.execute("SELECT genres FROM books"):
|
||||
if not genres_json:
|
||||
continue
|
||||
|
||||
try:
|
||||
genres.extend(json.loads(genres_json))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if unique:
|
||||
return sorted(set(genres))
|
||||
|
||||
return genres
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"database",
|
||||
type=Path,
|
||||
help="SQL Database Path",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
database = args.database.resolve()
|
||||
|
||||
if not database.is_file():
|
||||
parser.error(f"Database is not a file: {database}")
|
||||
|
||||
db = sqlite3.connect(database)
|
||||
cur = db.cursor()
|
||||
|
||||
list_genres = load_genre(cur,True)
|
||||
|
||||
for genre in list_genres:
|
||||
print(genre)
|
||||
|
||||
for book_id, genres_json in cur.execute("SELECT id, genres FROM books"):
|
||||
if not genres_json:
|
||||
continue
|
||||
|
||||
genres = json.loads(genres_json)
|
||||
new_genres = []
|
||||
|
||||
for genre in genres:
|
||||
genre = re.sub(r'(?i)^audio\s*books?$', '', genre)
|
||||
genre = re.sub(r'(?i)^audiobooks?$', '', genre)
|
||||
genre = re.sub(r'(?i)^hörb(uch|ücher)$', '', genre)
|
||||
genre = re.sub(r'(?i)^hörspiele?$', '', genre)
|
||||
genre = re.sub(r'(?i)^spoken\s*word$', '', genre)
|
||||
genre = re.sub(r'(?i)^speech$', '', genre)
|
||||
|
||||
genre = re.sub(r'(?i)^(sci[- ]?fi|sf)$', 'Science Fiction', genre)
|
||||
genre = re.sub(r'(?i)^nonfiction$', 'NonFiction', genre)
|
||||
|
||||
genre = genre.strip()
|
||||
|
||||
if genre:
|
||||
new_genres.append(genre)
|
||||
|
||||
new_genres = sorted(set(new_genres))
|
||||
|
||||
cur.execute(
|
||||
"UPDATE books SET genres=? WHERE id=?",
|
||||
(json.dumps(new_genres), book_id),
|
||||
)
|
||||
|
||||
db.commit()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -1,27 +0,0 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
ROOT="${1:-.}"
|
||||
|
||||
find "$ROOT" -type d | while read -r dir; do
|
||||
first_file=$(
|
||||
find "$dir" -maxdepth 1 -type f \
|
||||
\( -iname "*.m4b" -o -iname "*.m4a" -o -iname "*.mp3" \
|
||||
-o -iname "*.flac" -o -iname "*.ogg" \) |
|
||||
sort |
|
||||
head -n1
|
||||
)
|
||||
|
||||
[[ -z "$first_file" ]] && continue
|
||||
|
||||
artist=$(kid3-cli -c "get artist" "$first_file" 2>/dev/null)
|
||||
album=$(kid3-cli -c "get album" "$first_file" 2>/dev/null)
|
||||
composer=$(kid3-cli -c "get composer" "$first_file" 2>/dev/null)
|
||||
comment=$(kid3-cli -c "get comment" "$first_file" 2>/dev/null)
|
||||
echo "====≠==============================="
|
||||
echo "Folder: $(basename "$dir")"
|
||||
echo "Album: $album"
|
||||
echo "Artist: $artist"
|
||||
echo "Narrator: $composer"
|
||||
echo "Comment: $comment"
|
||||
done
|
||||
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+172
@@ -0,0 +1,172 @@
|
||||
#!/usr/bin/python3
|
||||
import json
|
||||
import re
|
||||
import sqlite3
|
||||
import argparse
|
||||
from pathlib import Path
|
||||
|
||||
def load_genre(conn, unique=False):
|
||||
"""
|
||||
Return all genres from the books table.
|
||||
|
||||
Args:
|
||||
conn: sqlite3 connection
|
||||
unique: if True, return unique genres only
|
||||
|
||||
Returns:
|
||||
list[str]
|
||||
"""
|
||||
genres = []
|
||||
|
||||
for (genres_json,) in conn.execute("SELECT genres FROM books"):
|
||||
if not genres_json:
|
||||
continue
|
||||
|
||||
try:
|
||||
genres.extend(json.loads(genres_json))
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
if unique:
|
||||
return sorted(set(genres))
|
||||
|
||||
return genres
|
||||
|
||||
def main():
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument(
|
||||
"-p", "--print-only",
|
||||
action="store_true",
|
||||
help="Print data only",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--print-all",
|
||||
action="store_true",
|
||||
help="Print all data only",
|
||||
)
|
||||
parser.add_argument(
|
||||
"database",
|
||||
type=Path,
|
||||
help="SQL Database Path",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
database = args.database.resolve()
|
||||
|
||||
if not database.is_file():
|
||||
parser.error(f"Database is not a file: {database}")
|
||||
|
||||
db = sqlite3.connect(database)
|
||||
cur = db.cursor()
|
||||
|
||||
list_genres = load_genre(cur,True)
|
||||
if args.print_all:
|
||||
for genre in list_genres:
|
||||
print(genre)
|
||||
return
|
||||
|
||||
rows = cur.execute(
|
||||
"SELECT id, genres FROM books"
|
||||
).fetchall()
|
||||
|
||||
for book_id, genres_json in rows:
|
||||
if not genres_json:
|
||||
continue
|
||||
genres = json.loads(genres_json)
|
||||
genres_new = []
|
||||
new_genres = []
|
||||
print("=================================")
|
||||
print(f"Before sed: {genres}")
|
||||
for genre in genres:
|
||||
if "Drachen" in genre:
|
||||
pass
|
||||
if "Fantastic" in genre:
|
||||
pass
|
||||
genre = re.sub(r'(?i)^audio\s*books?$', '', genre)
|
||||
genre = re.sub(r'(?i)^audiobooks?$', '', genre)
|
||||
genre = re.sub(r'(?i)\b(hörb(uch|ücher)|hoerb(uch|uecher))\b', '', genre)
|
||||
genre = re.sub(r'(?i)^(hörspiele?|hoerspiele?)$', '', genre)
|
||||
genre = re.sub(r'(?i)^spoken\s*word$', '', genre)
|
||||
genre = re.sub(r'(?i)gesprochene\s*inhalte$', '', genre)
|
||||
genre = re.sub(r'(?i)^speech$', '', genre)
|
||||
genre = re.sub(r'Fanasie', 'Fantasie', genre)
|
||||
genre = re.sub(r'Mit Videospiel', 'Videospielbezug', genre)
|
||||
genre = re.sub(r'(?i)nonfiction', 'NonFiction', genre)
|
||||
|
||||
genre = re.sub(r'(?i)^speech$', '', genre)
|
||||
genre = re.sub(r'(?i)^vocal$', '', genre)
|
||||
genre = re.sub(r'(?i)^retail$', '', genre)
|
||||
genre = re.sub(r'(?i)^other$', '', genre)
|
||||
genre = re.sub(r'(?i)^misc$', '', genre)
|
||||
|
||||
genre = re.sub(r'(?i)^(sci[- ]?fi|sf)$', 'Science Fiction', genre)
|
||||
genre = re.sub(r'(?i)^\(?science fiction\)?$', 'Science Fiction', genre)
|
||||
genre = re.sub(r'Thrillers', 'Thriller', genre)
|
||||
genre = re.sub(r"(?i)\bchildren'?s audiobooks?\b", "",genre)
|
||||
genre = re.sub(r'^-\s*|\s*-$', '', genre)
|
||||
genre = re.sub(r'(?i)Engelske\s*\sLydbånd','',genre)
|
||||
genre = re.sub(r'^FIC028000.*$', '', genre)
|
||||
genre = re.sub(r'^800.*$', '', genre)
|
||||
genre = re.sub(r'^Fantastic Beasts.*$', '', genre)
|
||||
genre = re.sub(r'^and thei.*$', '', genre)
|
||||
genre = re.sub(r'^those you.*$', '', genre)
|
||||
genre = genre.strip()
|
||||
genre = genre.lstrip()
|
||||
|
||||
if "," in genre:
|
||||
genre = genre.split(",")
|
||||
elif " - " in genre:
|
||||
genre = genre.split(" - ")
|
||||
elif "Historical Adventure Thriller Mystery" in genre:
|
||||
genre = genre.split(" ")
|
||||
|
||||
if isinstance(genre, str):
|
||||
if len(genre) > 50 or (5 > len(genre) > 0):
|
||||
genre = ""
|
||||
print(f"Too long or too short: {genre}")
|
||||
|
||||
genre = genre.strip()
|
||||
genre = genre.lstrip()
|
||||
|
||||
new_genres.append(genre)
|
||||
elif isinstance(genre, list):
|
||||
if len(genres) > 1:
|
||||
genres = [g for g in genres if g]
|
||||
new_genres.extend(genre)
|
||||
|
||||
new_genres = sorted(set(new_genres))
|
||||
|
||||
print(f"After sed: {new_genres}")
|
||||
|
||||
list_difference = False
|
||||
print("Write to Database")
|
||||
if len(new_genres) < len(genres):
|
||||
list_difference = True
|
||||
for old,new in zip(genres,new_genres):
|
||||
if old != new:
|
||||
list_difference = True
|
||||
break
|
||||
|
||||
if not list_difference:
|
||||
print("No difference: Dont Commit to Database")
|
||||
continue
|
||||
|
||||
if args.print_only:
|
||||
print("Print only: Dont Commit to database")
|
||||
continue
|
||||
|
||||
print("Write to Database")
|
||||
|
||||
|
||||
print("=================================")
|
||||
cur.execute(
|
||||
"UPDATE books SET genres=? WHERE id=?",
|
||||
(json.dumps(new_genres), book_id),
|
||||
)
|
||||
print("Database Updated")
|
||||
|
||||
db.commit()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
-9
@@ -6,15 +6,6 @@ import subprocess
|
||||
from pathlib import Path
|
||||
from difflib import SequenceMatcher
|
||||
|
||||
AUDIO_EXTENSIONS = {
|
||||
".mp3",
|
||||
".m4b",
|
||||
".m4a",
|
||||
}
|
||||
|
||||
RED = "\033[31m"
|
||||
GREEN = "\033[32m"
|
||||
RESET = "\033[0m"
|
||||
USE_KID3 = True
|
||||
def normalize(text: str) -> str:
|
||||
return re.sub(r"[^a-z0-9]", "", text.lower())
|
||||
+1
-1
@@ -27,7 +27,7 @@ fi
|
||||
list="$1"
|
||||
|
||||
while IFS= read -r file; do
|
||||
|
||||
book
|
||||
[[ -z "$file" ]] && continue
|
||||
|
||||
if [[ ! -e "$file" ]]; then
|
||||
File renamed without changes.
+2
-2
@@ -41,8 +41,8 @@ for file in "${FILES[@]}"; do
|
||||
[[ -z "$genre" ]] && continue
|
||||
cleaned=$(printf '%s\n' "$genre" | sed -E '
|
||||
s/[Aa]udio[[:space:]]*[Bb]ooks?//g
|
||||
s/\b(Hörb(uch|ücher)|Hoerb(uch|uecher)|Hörspiel(e)?|Hoerspiel(e)?)\b//Ig
|
||||
|
||||
s/-?(Hörb(uch|ücher)|Hoerb(uch|uecher)|Hörspiel(e)?|Hoerspiel(e)?)\b//Ig
|
||||
|
||||
s/[Gg]esprochene[[:space:]]*[Ii]nhalte//g
|
||||
s/[Ss]poken[[:space:]]*[Ww]ord//g
|
||||
s/[Ss]peech//g
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
-27
@@ -1,27 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ $# -lt 2 ]]; then
|
||||
echo "Usage: $0 <dir1> <dir2> [del]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
dir1="$1"
|
||||
dir2="$2"
|
||||
|
||||
find "$dir1" -mindepth 2 -maxdepth 2 -type d -printf '%P\n' |
|
||||
while IFS= read -r rel; do
|
||||
if [[ -d "$dir2/$rel" ]]; then
|
||||
# Exists in both
|
||||
if [[ "$3" == "del" ]]; then
|
||||
echo "Deleting: $dir1/$rel"
|
||||
rm -rf -- "$dir1/$rel"
|
||||
|
||||
# Remove empty author directory
|
||||
author="${rel%%/*}"
|
||||
rmdir --ignore-fail-on-non-empty "$dir1/$author" 2>/dev/null
|
||||
fi
|
||||
else
|
||||
# Only exists in $1
|
||||
echo "$rel"
|
||||
fi
|
||||
done
|
||||
@@ -1,63 +0,0 @@
|
||||
#!/bin/bash
|
||||
USER="lucas"
|
||||
DEST="~/Downloads"
|
||||
|
||||
get_config() {
|
||||
while [[ ${1:0:1} == - ]]; do
|
||||
echo "Param: $1"
|
||||
[[ $1 == -h ]] && {
|
||||
if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi
|
||||
HOST="$2"
|
||||
shift 2;
|
||||
continue;
|
||||
};
|
||||
[[ $1 == -f ]] && {
|
||||
if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi
|
||||
file="$2"
|
||||
shift 2;
|
||||
continue;
|
||||
};
|
||||
[[ $1 == -o ]] && {
|
||||
if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi
|
||||
opt="$2"
|
||||
shift 2;
|
||||
continue;
|
||||
};
|
||||
[[ $1 == -d ]] && {
|
||||
if [ "$2" == "" ]; then echo "Too few arguments"; usage; exit; fi
|
||||
DEST="$2"
|
||||
shift 2;
|
||||
continue;
|
||||
};
|
||||
[[ $1 == -p ]] && {
|
||||
DEST="~/Videos/.stuff"
|
||||
shift 1;
|
||||
continue;
|
||||
};
|
||||
[[ $1 == --help ]] && {
|
||||
usage
|
||||
exit
|
||||
};
|
||||
echo "Parameter $1 discarded"
|
||||
usage
|
||||
exit
|
||||
done
|
||||
}
|
||||
usage() {
|
||||
printf "Usage:
|
||||
-h <hostname>\tRemote Hostname
|
||||
-f <filename>\tPath of local file
|
||||
-o <options>\tGive additional Options
|
||||
-d <dest>\tChoose other Destination Folder
|
||||
-p\t\tChange Destination
|
||||
--help\t\tDisplay Usage\n"
|
||||
exit
|
||||
}
|
||||
get_config "$@"
|
||||
if [ "${HOST}" == "deluge" ]; then
|
||||
HOST="serverhost"
|
||||
USER="deluge-user"
|
||||
DEST="/home/deluge-user/Downloads/Torrents/"
|
||||
fi
|
||||
echo "Copy ${file} to ${HOST}:${DEST}"
|
||||
scp -r ${opt} "${file}" ${USER}@${HOST}:${DEST}
|
||||
@@ -1,4 +0,0 @@
|
||||
#!/bin/bash
|
||||
scp lucas@serverhost:/etc/update-motd.d/10-help-text ~/Documents/Dokumente/Dokumente/Projekte/Server/motd.serverhost.10-help-text
|
||||
scp lucas@raspberry:~/.profile ~/Documents/Dokumente/Dokumente/Projekte/Server/motd.raspberry.profile
|
||||
rm 0
|
||||
@@ -1,30 +0,0 @@
|
||||
#!/usr/bin/expect -f
|
||||
#Copy Crontab of raspberry and serverhost
|
||||
set host "raspberry"
|
||||
array set user { 0 "root" 1 "lucas"}
|
||||
set port "1160"
|
||||
for {set j 0} {$j < 2} {incr j 1} {
|
||||
spawn ssh -p $port lucas@$host
|
||||
expect {
|
||||
"No route to host" {
|
||||
puts "spawn ssh -p $port SendEnv=TERM lucas@$host failed."
|
||||
exit 0
|
||||
}
|
||||
"Login Sucsessfull" {
|
||||
if {$user($j)=="root"} {
|
||||
send "sudo crontab -l >> crontab.buf\r"
|
||||
expect "lucas: "
|
||||
send "Gina\&1994\&Nonna\r"
|
||||
} else {
|
||||
send "crontab -l >> crontab.buf\r"
|
||||
}
|
||||
#expect "$ "
|
||||
#send "cat crontab.buf\r"
|
||||
expect "$ "
|
||||
send "scp -P 3032 crontab.buf lucas@serverhost:~/Documents/Dokumente/Dokumente/Projekte/Server/crontab.$host.$user($j)\r"
|
||||
expect "$ "
|
||||
send "rm crontab.buf\r"
|
||||
puts "crontab.$host.$user($j) created."
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
#!/usr/bin/expect -f
|
||||
#Copy Crontab of raspberry and serverhost
|
||||
array set host { 0 "serverhost" 1 "raspberry"}
|
||||
array set user { 0 "root" 1 "lucas"}
|
||||
array set port { 0 "3032" 1 "1160"}
|
||||
|
||||
for {set i 0} {$i < 2} {incr i 1} {
|
||||
for {set j 0} {$j < 2} {incr j 1} {
|
||||
spawn ssh -p $port($i) lucas@$host($i)
|
||||
expect {
|
||||
"No route to host" {
|
||||
puts "spawn ssh -p $port($i) lucas@$host($i) failed."
|
||||
exit 0
|
||||
}
|
||||
"Login Sucsessfull" {
|
||||
if {$user($j)=="root"} {
|
||||
send "sudo crontab -l >> crontab.buf\r"
|
||||
expect "lucas: "
|
||||
send "Gina\&1994\&Nonna\r"
|
||||
} else {
|
||||
send "crontab -l >> crontab.buf\r"
|
||||
}
|
||||
#expect "$ "
|
||||
#send "cat crontab.buf\r"
|
||||
expect "$ "
|
||||
send "scp -P 1160 crontab.buf lucas@workhost:~/Documents/Dokumente/Dokumente/Projekte/Server/crontab.$host($i).$user($j)\r"
|
||||
expect "$ "
|
||||
send "rm crontab.buf\r"
|
||||
puts "crontab.$host($i).$user($j) created."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -0,0 +1,9 @@
|
||||
#!/usr/bin/env xdg-open
|
||||
[Desktop Entry]
|
||||
Version=1.0
|
||||
Type=Application
|
||||
Terminal=false
|
||||
Exec=sudo systemctl hibernate
|
||||
Name=Hibernate
|
||||
Comment=Hibernate GW
|
||||
Icon=/home/lucas/Documents/Dokumente/Projekte/Icons/hibernate.png
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 8.5 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 22 KiB |
Executable
+9
@@ -0,0 +1,9 @@
|
||||
#!/bin/bash
|
||||
cd /docker
|
||||
find . -maxdepth 3 -type f \( -name "*.yaml" -o -name "*.yml" -o -name "*.conf" -o -name "*.sh" -o -name "*.py" \) \
|
||||
-print0 2>/dev/null | rsync -aR --files-from=- --from0 ./ /home/lucas/scripts/docker_compose/$(hostname)
|
||||
crontab -l > /home/lucas/scripts/docker_compose/$(hostname)/crontab.bak
|
||||
cp /etc/fstab /home/lucas/scripts/docker_compose/$(hostname)
|
||||
if [ -f /etc/exports ]; then
|
||||
cp /etc/exports /home/lucas/scripts/docker_compose/$(hostname)
|
||||
fi
|
||||
@@ -0,0 +1,189 @@
|
||||
#!/usr/bin/env bash
|
||||
set -uo pipefail
|
||||
|
||||
CONTAINER="${1:-}"
|
||||
COMPOSE_FILE="${2:-}"
|
||||
|
||||
if [ -z "$CONTAINER" ]; then
|
||||
echo "Usage:"
|
||||
echo " $0 <container-name> [docker-compose.yml]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
|
||||
OUTDIR="/tmp/${CONTAINER}-debug-${TIMESTAMP}"
|
||||
|
||||
mkdir -p "$OUTDIR"
|
||||
|
||||
echo "[*] Collecting debug data for container: $CONTAINER"
|
||||
|
||||
# --------------------------------------------------
|
||||
# Docker info
|
||||
# --------------------------------------------------
|
||||
|
||||
docker inspect "$CONTAINER" \
|
||||
> "$OUTDIR/docker-inspect.json" 2>&1 || true
|
||||
|
||||
docker inspect "$CONTAINER" --format '{{.Config.Image}}' \
|
||||
> "$OUTDIR/image.txt" 2>&1 || true
|
||||
|
||||
# --------------------------------------------------
|
||||
# Logs
|
||||
# --------------------------------------------------
|
||||
|
||||
docker logs "$CONTAINER" --tail=10000 \
|
||||
> "$OUTDIR/container.log" 2>&1 || true
|
||||
|
||||
# --------------------------------------------------
|
||||
# Environment
|
||||
# --------------------------------------------------
|
||||
|
||||
docker exec "$CONTAINER" env \
|
||||
> "$OUTDIR/container-env.txt" 2>&1 || true
|
||||
|
||||
# --------------------------------------------------
|
||||
# Host information
|
||||
# --------------------------------------------------
|
||||
|
||||
{
|
||||
echo "=== HOST ==="
|
||||
|
||||
if command -v lsb_release >/dev/null 2>&1; then
|
||||
lsb_release -a
|
||||
fi
|
||||
|
||||
uname -a
|
||||
|
||||
echo
|
||||
echo "=== DOCKER ==="
|
||||
docker --version
|
||||
|
||||
} > "$OUTDIR/host.txt" 2>&1
|
||||
|
||||
PROGRAMS=(
|
||||
"yt-dlp"
|
||||
"ffmpeg"
|
||||
"ffprobe"
|
||||
"node"
|
||||
"npm"
|
||||
"python"
|
||||
"python3"
|
||||
"java"
|
||||
"curl"
|
||||
"wget"
|
||||
"git"
|
||||
)
|
||||
|
||||
# --------------------------------------------------
|
||||
# Common program versions
|
||||
# --------------------------------------------------
|
||||
|
||||
{
|
||||
echo "=== PROGRAM VERSIONS ==="
|
||||
echo
|
||||
|
||||
for prog in "${PROGRAMS[@]}"; do
|
||||
echo "----- $prog -----"
|
||||
|
||||
if docker exec "$CONTAINER" sh -c "command -v '$prog'" \
|
||||
>/dev/null 2>&1; then
|
||||
|
||||
docker exec "$CONTAINER" sh -c "
|
||||
$prog --version 2>/dev/null ||
|
||||
$prog -version 2>/dev/null ||
|
||||
$prog -V 2>/dev/null ||
|
||||
true
|
||||
" | head -n 5
|
||||
|
||||
else
|
||||
echo "not installed"
|
||||
fi
|
||||
|
||||
echo
|
||||
done
|
||||
|
||||
} > "$OUTDIR/versions.txt" 2>&1
|
||||
|
||||
# --------------------------------------------------
|
||||
# Compose snippet
|
||||
# --------------------------------------------------
|
||||
|
||||
if [ -n "$COMPOSE_FILE" ] && [ -f "$COMPOSE_FILE" ]; then
|
||||
|
||||
SERVICE=$(docker inspect "$CONTAINER" \
|
||||
--format '{{ index .Config.Labels "com.docker.compose.service" }}' \
|
||||
2>/dev/null)
|
||||
|
||||
if [ -n "$SERVICE" ]; then
|
||||
yq ".services.\"$SERVICE\"" "$COMPOSE_FILE" \
|
||||
> "$OUTDIR/compose-service.yaml" 2>&1 || true
|
||||
fi
|
||||
fi
|
||||
|
||||
# --------------------------------------------------
|
||||
# Summary
|
||||
# --------------------------------------------------
|
||||
|
||||
{
|
||||
echo "================================="
|
||||
echo "Debug Summary"
|
||||
echo "================================="
|
||||
echo
|
||||
|
||||
echo "Container:"
|
||||
echo " $CONTAINER"
|
||||
echo
|
||||
|
||||
echo "Image:"
|
||||
cat "$OUTDIR/image.txt" 2>/dev/null
|
||||
echo
|
||||
|
||||
echo "Host:"
|
||||
uname -a
|
||||
lsb_release -a
|
||||
docker --version
|
||||
echo
|
||||
|
||||
echo "Compose Service:"
|
||||
|
||||
docker inspect "$CONTAINER" \
|
||||
--format '{{ index .Config.Labels "com.docker.compose.service" }}' \
|
||||
2>/dev/null || echo "unknown"
|
||||
|
||||
if [ -n "$SERVICE" ]; then
|
||||
echo "Docker Compose Config"
|
||||
yq ".services.\"$SERVICE\"" "$COMPOSE_FILE"
|
||||
fi
|
||||
echo
|
||||
echo "Programs found:"
|
||||
|
||||
for prog in "${PROGRAMS[@]}"; do
|
||||
if docker exec "$CONTAINER" sh -c "command -v '$prog'" \
|
||||
>/dev/null 2>&1; then
|
||||
echo "$prog: $(
|
||||
$prog --version 2>/dev/null ||
|
||||
$prog -version 2>/dev/null ||
|
||||
$prog -V 2>/dev/null ||
|
||||
true
|
||||
)" | head -n1
|
||||
fi
|
||||
done
|
||||
|
||||
} | tee "$OUTDIR/summary.txt"
|
||||
|
||||
# --------------------------------------------------
|
||||
# Archive
|
||||
# --------------------------------------------------
|
||||
|
||||
ARCHIVE="${OUTDIR}.tar.gz"
|
||||
|
||||
tar czf "$ARCHIVE" \
|
||||
-C "$(dirname "$OUTDIR")" \
|
||||
"$(basename "$OUTDIR")"
|
||||
|
||||
echo
|
||||
echo "[OK] Debug report created:"
|
||||
echo "$ARCHIVE"
|
||||
|
||||
echo
|
||||
ls -lh "$ARCHIVE"
|
||||
Executable
+3
@@ -0,0 +1,3 @@
|
||||
#!/bin/bash
|
||||
/usr/bin/docker compose -f /docker/nginx/docker-compose.yaml run --rm certbot renew && \
|
||||
/usr/bin/docker compose -f /docker/nginx/docker-compose.yaml exec nginx nginx -s reload
|
||||
Executable
+2
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
/usr/bin/docker exec -u www-data nextcloud /usr/local/bin/php -f /var/www/html/cron.php
|
||||
@@ -0,0 +1,41 @@
|
||||
# Edit this file to introduce tasks to be run by cron.
|
||||
#
|
||||
# Each task to run has to be defined through a single line
|
||||
# indicating with different fields when the task will be run
|
||||
# and what command to run for the task
|
||||
#
|
||||
# To define the time you can provide concrete values for
|
||||
# minute (m), hour (h), day of month (dom), month (mon),
|
||||
# and day of week (dow) or use '*' in these fields (for 'any').
|
||||
#
|
||||
# Notice that tasks will be started based on the cron's system
|
||||
# daemon's notion of time and timezones.
|
||||
#
|
||||
# Output of the crontab jobs (including errors) is sent through
|
||||
# email to the user the crontab file belongs to (unless redirected).
|
||||
#
|
||||
# For example, you can run a backup of all your user accounts
|
||||
# at 5 a.m every week with:
|
||||
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
|
||||
#
|
||||
# For more information see the manual pages of crontab(5) and cron(8)
|
||||
#
|
||||
# Example of job definition:
|
||||
# .---------------- minute (0 - 59)
|
||||
# | .------------- hour (0 - 23)
|
||||
# | | .---------- day of month (1 - 31)
|
||||
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
|
||||
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
|
||||
# | | | | |
|
||||
# * * * * * user-name command to be executed
|
||||
|
||||
*/5 * * * * /home/lucas/scripts/docker_compose/docker_update_nextcloud.sh && logger "CRON_SUCCESS nextcloud" || logger "CRON_FAILURE nextcloud"
|
||||
*/5 * * * * /home/lucas/scripts/docker_compose/node-exporter-pubip-docker-states.sh && logger "CRON_SUCCESS pubip" || logger "CRON_FAILURE pubip"
|
||||
#0 * * * * /home/lucas/scripts/media_editing/convert_heic.sh && logger "CRON_SUCCESS conv_heic" || logger "CRON_FAILURE conv_heic"
|
||||
0 * * * * /home/lucas/scripts/file_processing/rename_memes_folder.sh && logger "CRON_SUCCESS rename_mem" || logger "CRON_FAILURE rename_mem"
|
||||
0 * * * * /home/lucas/scripts/file_processing/sync_dropfolder_to_immich.sh && logger "CRON_SUCCESS immich" || logger "CRON_FAILURE immich"
|
||||
#10 * * * * /home/lucas/scripts/file_processing/rename_camera_folder.py && logger "CRON_SUCCESS rename_cam" || logger "CRON_FAILURE rename_cam"
|
||||
0 3 * * * /home/lucas/scripts/docker_compose/docker_renew_certbot.sh && logger "CRON_SUCCESS renew_cert" || logger "CRON_FAILURE renew_cert"
|
||||
0 3 * * 0 /home/lucas/scripts/utils/download_latest_ubuntu.sh && logger "CRON_SUCCESS ubuntu" || logger "CRON_FAILURE ubuntu"
|
||||
0 3 * * 0 /home/lucas/scripts/utils/rotate_logs.py && logger "CRON_SUCCESS logs" || logger "CRON_FAILURE logs"
|
||||
0 0 1 * * /home/lucas/scripts/network/wol.sh quiethost && logger "CRON_SUCCESS quietwake" || logger "CRON_FAILURE quietwake"
|
||||
@@ -17,17 +17,27 @@ services:
|
||||
DIUN_PROVIDERS_DOCKER: "true"
|
||||
DIUN_PROVIDERS_DOCKER_WATCHBYDEFAULT: "true"
|
||||
|
||||
# Email notifications
|
||||
DIUN_NOTIF_MAIL_HOST: smtp.web.de
|
||||
DIUN_NOTIF_MAIL_PORT: 587
|
||||
DIUN_NOTIF_MAIL_USERNAME: ll_m@web.de
|
||||
DIUN_NOTIF_MAIL_PASSWORD: Mira2012
|
||||
DIUN_NOTIF_MAIL_FROM: ll_m@web.de
|
||||
DIUN_NOTIF_MAIL_TO: ll_m@web.de
|
||||
DIUN_NOTIF_MAIL_INSECURESKIPVERIFY: "false"
|
||||
# Metrics
|
||||
|
||||
DIUN_METRICS_ENABLED: "true"
|
||||
DIUN_METRICS_ADDR: ":9090"
|
||||
DIUN_METRICS_TOKEN: "Qj#8C!@Uz3uRWm@mCd@KH6Bo7nfQ4K"
|
||||
# # Email notifications
|
||||
# DIUN_NOTIF_MAIL_HOST: smtp.web.de
|
||||
# DIUN_NOTIF_MAIL_PORT: 587
|
||||
# DIUN_NOTIF_MAIL_USERNAME: ll_m@web.de
|
||||
# DIUN_NOTIF_MAIL_PASSWORD: Mira2012
|
||||
# DIUN_NOTIF_MAIL_FROM: ll_m@web.de
|
||||
# DIUN_NOTIF_MAIL_TO: ll_m@web.de
|
||||
# DIUN_NOTIF_MAIL_INSECURESKIPVERIFY: "false"
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
networks:
|
||||
- shared-prometheus-services
|
||||
networks:
|
||||
shared-prometheus-services:
|
||||
external: true
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
# /etc/exports: the access control list for filesystems which may be exported
|
||||
# to NFS clients. See exports(5).
|
||||
#
|
||||
# Example for NFSv2 and NFSv3:
|
||||
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
|
||||
#
|
||||
# Example for NFSv4:
|
||||
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
|
||||
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
|
||||
#
|
||||
/data/torrent/qbittorrent/mediahost 192.168.0.2(rw,sync,no_subtree_check)
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
# /etc/fstab: static file system information.
|
||||
#
|
||||
# Use 'blkid' to print the universally unique identifier for a
|
||||
# device; this may be used with UUID= as a more robust way to name devices
|
||||
# that works even if disks are added and removed. See fstab(5).
|
||||
#
|
||||
# <file system> <mount point> <type> <options> <dump> <pass>
|
||||
# / was on /dev/ubuntu-vg/ubuntu-lv during curtin installation
|
||||
/dev/disk/by-id/dm-uuid-LVM-r8YfWcv5quj81USd5JVq2hhAsFYHSOzApd2lI7XnRXm9tFwB4UaNsO2f5le5eX0f / ext4 defaults 0 1
|
||||
# /boot was on /dev/nvme0n1p2 during curtin installation
|
||||
/dev/disk/by-uuid/d88641c2-0c6a-47a6-b3e6-af4b6bbd9b05 /boot ext4 defaults 0 1
|
||||
# /boot/efi was on /dev/nvme0n1p1 during curtin installation
|
||||
/dev/disk/by-uuid/CEA1-EE2F /boot/efi vfat defaults 0 1
|
||||
# /docker was on /dev/ubuntu-vg/docker-vg during curtin installation
|
||||
/dev/disk/by-id/dm-uuid-LVM-r8YfWcv5quj81USd5JVq2hhAsFYHSOzAoaSA1n5zU8GkQuzTSQ9OBbNTaAoY2giE /docker ext4 defaults 0 1
|
||||
/swap.img none swap sw 0 0
|
||||
192.168.0.2:/torrent/qbittorrent-private/downloads /data/torrent/qbittorrent-private/downloads nfs defaults,_netdev 0 0
|
||||
192.168.0.2:/torrent/qbittorrent-public/downloads /data/torrent/qbittorrent-public/downloads nfs defaults,_netdev 0 0
|
||||
192.168.0.2:/special-torrent/torrent /data/torrent/qbittorrent-special/downloads nfs defaults,_netdev 0 0
|
||||
#192.168.0.2:/torrent/qbittorrent/downloads /torrent/qbittorrent/downloads nfs defaults,_netdev,uid=1000,gid=1000 0 0
|
||||
|
||||
# Backup
|
||||
/dev/disk/by-uuid/8a602724-8401-4b4b-8b54-7e9d2f633a9c /backup ext4 defaults 0 1
|
||||
@@ -0,0 +1,2 @@
|
||||
container:
|
||||
network: gitea-network
|
||||
@@ -16,4 +16,44 @@ services:
|
||||
- /data/gitea:/data
|
||||
- /etc/timezone:/etc/timezone:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
networks:
|
||||
- gitea-network
|
||||
- shared-proxy-services
|
||||
gitea-runner:
|
||||
image: docker.io/gitea/act_runner:latest
|
||||
container_name: gitea-runner
|
||||
restart: unless-stopped
|
||||
environment:
|
||||
GITEA_INSTANCE_URL: http://gitea:3000
|
||||
GITEA_RUNNER_REGISTRATION_TOKEN: ${GITEA_RUNNER_TOKEN}
|
||||
GITEA_RUNNER_NAME: docker-runner
|
||||
GITEA_RUNNER_LABELS: ubuntu-latest:docker://node:20-bookworm
|
||||
CONFIG_FILE: /config.yaml
|
||||
volumes:
|
||||
- ./runner-data:/data
|
||||
- ./config.yaml:/config.yaml:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock
|
||||
networks:
|
||||
- gitea-network
|
||||
# gitea-runner:
|
||||
# image: docker.io/gitea/runner:5-dind
|
||||
# container_name: gitea-runner
|
||||
# restart: unless-stopped
|
||||
# privileged: true
|
||||
# environment:
|
||||
# GITEA_INSTANCE_URL: http://gitea:3000
|
||||
# GITEA_RUNNER_REGISTRATION_TOKEN: ${GITEA_RUNNER_TOKEN}
|
||||
# GITEA_RUNNER_NAME: docker-runner
|
||||
# GITEA_RUNNER_LABELS: ubuntu-latest:docker://node:20-bookworm
|
||||
#
|
||||
# volumes:
|
||||
# - ./runner-data:/data
|
||||
# - ./config.yaml:/config.yaml
|
||||
# networks:
|
||||
# - gitea-network
|
||||
|
||||
networks:
|
||||
gitea-network:
|
||||
external: true
|
||||
shared-proxy-services:
|
||||
external: true
|
||||
@@ -9,6 +9,11 @@ services:
|
||||
TZ: Europe/Vienna
|
||||
volumes:
|
||||
- /srv/homeassistant:/config
|
||||
devices:
|
||||
- /dev/bus/usb:/dev/bus/usb
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
- NET_RAW
|
||||
|
||||
mosquitto:
|
||||
container_name: mosquitto
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
#
|
||||
# WARNING: To install Immich, follow our guide: https://docs.immich.app/install/docker-compose
|
||||
#
|
||||
# Make sure to use the docker-compose.yml of the current release:
|
||||
#
|
||||
# https://github.com/immich-app/immich/releases/latest/download/docker-compose.yml
|
||||
#
|
||||
# The compose file on main may not be compatible with the latest release.
|
||||
|
||||
name: immich
|
||||
|
||||
services:
|
||||
immich-server:
|
||||
container_name: immich_server
|
||||
image: ghcr.io/immich-app/immich-server:${IMMICH_VERSION:-release}
|
||||
# extends:
|
||||
# file: hwaccel.transcoding.yml
|
||||
# service: cpu # set to one of [nvenc, quicksync, rkmpp, vaapi, vaapi-wsl] for accelerated transcoding
|
||||
volumes:
|
||||
# Do not edit the next line. If you want to change the media storage location on your system, edit the value of UPLOAD_LOCATION in the .env file
|
||||
- ${UPLOAD_LOCATION}:/data
|
||||
- /data/immich/pictures:/library
|
||||
- /data/immich/dropfolder:/library_dropfolder
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
env_file:
|
||||
- .env
|
||||
ports:
|
||||
- '2283:2283'
|
||||
depends_on:
|
||||
- database
|
||||
restart: always
|
||||
healthcheck:
|
||||
disable: false
|
||||
networks:
|
||||
- immich
|
||||
- shared-redis-services
|
||||
- shared-proxy-services
|
||||
|
||||
immich-machine-learning:
|
||||
container_name: immich_machine_learning
|
||||
# For hardware acceleration, add one of -[armnn, cuda, rocm, openvino, rknn] to the image tag.
|
||||
# Example tag: ${IMMICH_VERSION:-release}-cuda
|
||||
image: ghcr.io/immich-app/immich-machine-learning:${IMMICH_VERSION:-release}
|
||||
# extends: # uncomment this section for hardware acceleration - see https://docs.immich.app/features/ml-hardware-acceleration
|
||||
# file: hwaccel.ml.yml
|
||||
# service: cpu # set to one of [armnn, cuda, rocm, openvino, openvino-wsl, rknn] for accelerated inference - use the `-wsl` version for WSL2 where applicable
|
||||
volumes:
|
||||
- model-cache:/cache
|
||||
env_file:
|
||||
- .env
|
||||
restart: always
|
||||
healthcheck:
|
||||
disable: false
|
||||
networks:
|
||||
- immich
|
||||
|
||||
database:
|
||||
container_name: immich_postgres
|
||||
image: ghcr.io/immich-app/postgres:14-vectorchord0.4.3-pgvectors0.2.0@sha256:bcf63357191b76a916ae5eb93464d65c07511da41e3bf7a8416db519b40b1c23
|
||||
environment:
|
||||
POSTGRES_PASSWORD: ${DB_PASSWORD}
|
||||
POSTGRES_USER: ${DB_USERNAME}
|
||||
POSTGRES_DB: ${DB_DATABASE_NAME}
|
||||
POSTGRES_INITDB_ARGS: '--data-checksums'
|
||||
# Uncomment the DB_STORAGE_TYPE: 'HDD' var if your database isn't stored on SSDs
|
||||
DB_STORAGE_TYPE: 'HDD'
|
||||
volumes:
|
||||
# Do not edit the next line. If you want to change the database storage location on your system, edit the value of DB_DATA_LOCATION in the .env file
|
||||
- ${DB_DATA_LOCATION}:/var/lib/postgresql/data
|
||||
shm_size: 128mb
|
||||
restart: always
|
||||
healthcheck:
|
||||
disable: false
|
||||
networks:
|
||||
- immich
|
||||
immich-power-tools:
|
||||
container_name: immich_power_tools
|
||||
image: ghcr.io/immich-power-tools/immich-power-tools:latest
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8001:3000"
|
||||
env_file:
|
||||
- .env
|
||||
volumes:
|
||||
- immich-power-tools-data:/app/data
|
||||
environment:
|
||||
IMMICH_URL: http://immich_server:2283
|
||||
EXTERNAL_IMMICH_URL: https://fotos.someoneslinux.selfhost.eu
|
||||
IMMICH_API_KEY: "ROCfyJGLFBJSxKYXBcdfEfec7P80FVkvyr6fk8hThg"
|
||||
DB_HOST: database
|
||||
DB_PORT: 5432
|
||||
DB_USERNAME: ${DB_USERNAME}
|
||||
DB_PASSWORD: ${DB_PASSWORD}
|
||||
DB_DATABASE_NAME: ${DB_DATABASE_NAME}
|
||||
networks:
|
||||
- immich
|
||||
volumes:
|
||||
model-cache:
|
||||
immich-power-tools-data:
|
||||
networks:
|
||||
immich:
|
||||
shared-redis-services:
|
||||
external: true
|
||||
shared-proxy-services:
|
||||
external: true
|
||||
@@ -7,6 +7,8 @@ services:
|
||||
- /docker/jellyfin/config:/config
|
||||
- /docker/jellyfin/cache:/cache
|
||||
- /data/jellyfin/media:/media
|
||||
devices:
|
||||
- /dev/dri:/dev/dri
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8096:8096"
|
||||
@@ -15,7 +17,6 @@ services:
|
||||
networks:
|
||||
- default
|
||||
- shared-proxy-services
|
||||
|
||||
seerr:
|
||||
image: ghcr.io/seerr-team/seerr:latest
|
||||
container_name: seerr
|
||||
@@ -29,6 +30,7 @@ services:
|
||||
networks:
|
||||
- default
|
||||
- shared-proxy-services
|
||||
|
||||
networks:
|
||||
default:
|
||||
external: true
|
||||
|
||||
@@ -1,7 +1,29 @@
|
||||
|
||||
services:
|
||||
sonarr-de:
|
||||
# image: lscr.io/linuxserver/sonarr:latest
|
||||
image: ghcr.io/hotio/sonarr:latest
|
||||
container_name: sonarr-de
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8990:8989"
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
- TZ=Europe/Berlin
|
||||
volumes:
|
||||
- ./sonarr_DE:/config
|
||||
- /data/jellyfin/media/series-german:/JellyfinSeriesGerman
|
||||
- /data/jellyfin/media/anime-german:/JellyfinAnimeGerman
|
||||
- /data/jellyfin/media/series-kids:/JellyfinKinder
|
||||
- /data/jellyfin/media/documentaries-german:/JellyfinDocusGerman
|
||||
- /data/jellyfin/buffer:/buffer
|
||||
- /torrent/qbittorrent-private/downloads:/downloads-private
|
||||
- /torrent/qbittorrent-public/downloads:/downloads-public
|
||||
- /torrent/rundfunkarr-de:/downloads-rundfunkarr
|
||||
sonarr-en:
|
||||
image: lscr.io/linuxserver/sonarr:latest
|
||||
# image: lscr.io/linuxserver/sonarr:latest
|
||||
image: ghcr.io/hotio/sonarr:latest
|
||||
container_name: sonarr-en
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
@@ -16,25 +38,8 @@ services:
|
||||
- /data/jellyfin/media/anime-english:/JellyfinAnimeEnglish
|
||||
- /data/jellyfin/media/documentaries-english:/JellyfinDocus
|
||||
- /data/jellyfin/buffer:/buffer
|
||||
- /torrent/qbittorrent/downloads:/downloads
|
||||
sonarr-de:
|
||||
image: lscr.io/linuxserver/sonarr:latest
|
||||
container_name: sonarr-de
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "8990:8989"
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
- TZ=Europe/Berlin
|
||||
volumes:
|
||||
- ./sonarr_DE:/config
|
||||
- /data/jellyfin/media/series-german:/JellyfinSeriesGerman
|
||||
- /data/jellyfin/media/anime-german:/JellyfinAnimeGerman
|
||||
- /data/jellyfin/media/series-kids:/JellyfinKinder
|
||||
- /data/jellyfin/buffer:/buffer
|
||||
- /torrent/qbittorrent/downloads:/downloads
|
||||
- /torrent/rundfunkarr:/downloads-rundfunkarr
|
||||
- /torrent/qbittorrent-private/downloads:/downloads-private
|
||||
- /torrent/qbittorrent-public/downloads:/downloads-public
|
||||
radarr-en:
|
||||
image: lscr.io/linuxserver/radarr:latest
|
||||
container_name: radarr-en
|
||||
@@ -49,7 +54,8 @@ services:
|
||||
- ./radarr_EN:/config
|
||||
- /data/jellyfin/media/movies-english:/JellyfinMoviesEnglish
|
||||
- /data/jellyfin/media/comedy-english:/JellyfinComedy
|
||||
- /torrent/qbittorrent/downloads:/downloads
|
||||
- /torrent/qbittorrent-private/downloads:/downloads-private
|
||||
- /torrent/qbittorrent-public/downloads:/downloads-public
|
||||
- /data/jellyfin/buffer:/buffer
|
||||
radarr-de:
|
||||
image: lscr.io/linuxserver/radarr:latest
|
||||
@@ -66,8 +72,9 @@ services:
|
||||
- /data/jellyfin/media/movies-german:/JellyfinMoviesGerman
|
||||
- /data/jellyfin/media/movies-kids:/JellyfinKinder
|
||||
- /data/jellyfin/buffer:/buffer
|
||||
- /torrent/qbittorrent/downloads:/downloads
|
||||
- /torrent/rundfunkarr:/downloads-rundfunkarr
|
||||
- /torrent/qbittorrent-private/downloads:/downloads-private
|
||||
- /torrent/qbittorrent-public/downloads:/downloads-public
|
||||
- /torrent/rundfunkarr-de:/downloads-rundfunkarr
|
||||
prowlarr:
|
||||
image: lscr.io/linuxserver/prowlarr:latest
|
||||
container_name: prowlarr
|
||||
@@ -80,25 +87,36 @@ services:
|
||||
- TZ=Europe/Vienna
|
||||
volumes:
|
||||
- ./prowlarr:/config
|
||||
|
||||
gluetun-rundfunkarr-de:
|
||||
image: qmcgaw/gluetun
|
||||
image: qmcgaw/gluetun:latest
|
||||
container_name: gluetun-rundfunkarr-de
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
- ./gluetun-de:/gluetun/wireguard
|
||||
|
||||
environment:
|
||||
- VPN_SERVICE_PROVIDER=custom
|
||||
- VPN_TYPE=wireguard
|
||||
ports:
|
||||
- "6767:6767" # Rundfunkarr UI
|
||||
|
||||
# rundfunkarr-at:
|
||||
# image: rundfunkarr:local
|
||||
# container_name: rundfunkarr-at
|
||||
# environment:
|
||||
# - TZ=Europe/Berlin
|
||||
# - PUID=1000 # User ID (id -u)
|
||||
# - PGID=1000 # Group ID (id -g)
|
||||
# - DOWNLOAD_FOLDER_PATH=/downloads-rundfunkarr
|
||||
# volumes:
|
||||
# - ./rundfunkarr-at:/app/prisma/data
|
||||
# - /torrent/rundfunkarr-at:/downloads-rundfunkarr
|
||||
# ports:
|
||||
# - 6768:6767
|
||||
# restart: unless-stopped
|
||||
rundfunkarr-de:
|
||||
image: ghcr.io/rundfunkarr/rundfunkarr:latest
|
||||
# image: ghcr.io/rundfunkarr/rundfunkarr:latest
|
||||
image: rundfunkarr:local
|
||||
container_name: rundfunkarr-de
|
||||
environment:
|
||||
- TZ=Europe/Berlin
|
||||
@@ -114,18 +132,14 @@ services:
|
||||
network_mode: "service:gluetun-rundfunkarr-de"
|
||||
depends_on:
|
||||
- gluetun-rundfunkarr-de
|
||||
|
||||
gluetun-at:
|
||||
image: qmcgaw/gluetun:latest
|
||||
container_name: gluetun-at
|
||||
restart: unless-stopped
|
||||
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
|
||||
devices:
|
||||
- /dev/net/tun:/dev/net/tun
|
||||
|
||||
ports:
|
||||
- "8888:8888" # HTTP Proxy
|
||||
- "1080:1080" # SOCKS5 Proxy
|
||||
@@ -134,10 +148,12 @@ services:
|
||||
- VPN_TYPE=wireguard
|
||||
- SOCKS5_ENABLED=on
|
||||
- HTTPPROXY=on
|
||||
- HTTP_LISTENING_ADDRESS:=8888
|
||||
- SOCKSPROXY=on
|
||||
|
||||
- TZ=Europe/Vienna
|
||||
|
||||
- DNS_SERVER=on
|
||||
- DNS_UPSTREAM_RESOLVER_TYPE=plain
|
||||
- DNS_UPSTREAM_PLAIN_ADDRESSES=1.1.1.1:53,8.8.8.8:53
|
||||
volumes:
|
||||
- ./gluetun-at:/gluetun/wireguard
|
||||
# lazylibrarian:
|
||||
@@ -154,7 +170,7 @@ services:
|
||||
# - ./lazylibrarian:/config
|
||||
# - /data/audiobookshelf/podcasts:/podcasts
|
||||
# - /data/audiobookshelf/audiobooks-englisch:/audiobooks
|
||||
# - /torrent/qbittorrent/downloads:/downloads
|
||||
# - /torrent/qbittorrent-private/downloads:/downloads
|
||||
|
||||
flaresolverr:
|
||||
image: ghcr.io/flaresolverr/flaresolverr:latest
|
||||
@@ -169,7 +185,7 @@ services:
|
||||
- "8191:8191"
|
||||
|
||||
lidarr:
|
||||
image: lscr.io/linuxserver/lidarr:latest
|
||||
image: lscr.io/linuxserver/lidarr:develop #latest
|
||||
container_name: lidarr
|
||||
environment:
|
||||
- PUID=1000
|
||||
@@ -177,8 +193,9 @@ services:
|
||||
- TZ=Europe/Berlin
|
||||
volumes:
|
||||
- ./lidarr:/config
|
||||
- /data/navidrome/music:/music
|
||||
- /torrent/qbittorrent/downloads:/downloads
|
||||
- /data/navidrome/music/music:/music
|
||||
- /torrent/qbittorrent-private/downloads:/downloads-private
|
||||
- /torrent/qbittorrent-public/downloads:/downloads-public
|
||||
|
||||
ports:
|
||||
- 8686:8686
|
||||
@@ -232,44 +249,129 @@ services:
|
||||
- /data/audiobookshelf/data/audiobooks-englisch:/audiobooks-english
|
||||
- /data/audiobookshelf/data/audiobooks-deutsch:/audiobooks-german
|
||||
- /data/audiobookshelf/data/audiobooks-kinder:/audiobooks-kinder
|
||||
- /torrent/qbittorrent/downloads:/downloads
|
||||
- /torrent/qbittorrent-public/downloads:/downloads-public
|
||||
- /torrent/qbittorrent-private/downloads:/downloads-private
|
||||
restart: unless-stopped
|
||||
upload-assistant:
|
||||
image: ghcr.io/audionut/upload-assistant:latest
|
||||
container_name: upload-assistant
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "5000:5000"
|
||||
jackett:
|
||||
image: lscr.io/linuxserver/jackett:latest
|
||||
container_name: jackett
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
# Paths visible in the file browser
|
||||
- UA_BROWSE_ROOTS=/downloads,/data
|
||||
|
||||
command: ["--webui", "0.0.0.0:5000"]
|
||||
|
||||
- TZ=Europe/Vienna
|
||||
volumes:
|
||||
- ./upload-assistant:/Upload-Assistant/data
|
||||
# Sonarr/Radarr libraries
|
||||
- /data/jellyfin/media/series-english:/data/series-english:ro
|
||||
- /data/jellyfin/media/anime-english:/data/anime-english:ro
|
||||
- /data/jellyfin/media/documentaries-english:/docus-english:ro
|
||||
- /data/jellyfin/media/series-german:/series-german:ro
|
||||
- /data/jellyfin/media/anime-german:/anime-german:ro
|
||||
- /data/jellyfin/media/series-kids:/series-kids:ro
|
||||
- /data/jellyfin/media/movies-english:/data/movies-english:ro
|
||||
- /data/jellyfin/media/comedy-english:/data/comedy-english:ro
|
||||
- /data/jellyfin/media/movies-german:/data/movies-german:ro
|
||||
- /data/jellyfin/media/movies-kids:/data/movies-kids:ro
|
||||
# - /data/audiobookshelf/podcasts:/podcasts
|
||||
# - /data/audiobookshelf/audiobooks-englisch:/audiobooks
|
||||
- /data/navidrome/music:/data/music:ro
|
||||
- /data/audiobookshelf/data/audiobooks-englisch:/data/audiobooks-english:ro
|
||||
- /data/audiobookshelf/data/audiobooks-deutsch:/data/audiobooks-german:ro
|
||||
- /data/audiobookshelf/data/audiobooks-kinder:/data/audiobooks-kinder:ro
|
||||
# Download location
|
||||
- /torrent/qbittorrent/downloads:/downloads
|
||||
|
||||
- ./jackett/config:/config
|
||||
- ./jackett/downloads:/downloads
|
||||
ports:
|
||||
- "9117:9117"
|
||||
restart: unless-stopped
|
||||
gluetun-proxy:
|
||||
image: qmcgaw/gluetun:latest
|
||||
container_name: gluetun-proxy
|
||||
cap_add:
|
||||
- NET_ADMIN
|
||||
ports:
|
||||
- "8889:8888" # HTTP proxy
|
||||
- "8388:8388" # SOCKS5 proxy
|
||||
volumes:
|
||||
- ./gluetun-proxy:/gluetun/wireguard
|
||||
- /dev/net/tun:/dev/net/tun
|
||||
environment:
|
||||
- VPN_SERVICE_PROVIDER=custom
|
||||
- VPN_TYPE=wireguard
|
||||
- SOCKS5_ENABLED=on
|
||||
- HTTPPROXY=on
|
||||
- SOCKSPROXY=on
|
||||
restart: unless-stopped
|
||||
#cleanuparr:
|
||||
# image: ghcr.io/cleanuparr/cleanuparr:latest
|
||||
# container_name: cleanuparr
|
||||
# restart: unless-stopped
|
||||
# ports:
|
||||
# - "11011:11011"
|
||||
# volumes:
|
||||
# - ./cleanuparr:/config
|
||||
# - /torrent/qbittorrent-private/downloads:/downloads-private
|
||||
# - /torrent/qbittorrent-public/downloads:/downloads-public
|
||||
# - /torrent/qbittorrent-private/orphaned:/orphaned
|
||||
# environment:
|
||||
# - PORT=11011
|
||||
# - BASE_PATH=
|
||||
# - PUID=1000
|
||||
# - PGID=1000
|
||||
# - UMASK=022
|
||||
# - TZ=Europe/Vienna
|
||||
whisparr:
|
||||
image: ghcr.io/thespad/whisparr:latest
|
||||
container_name: whisparr
|
||||
environment:
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
- TZ=Europe/Vienna
|
||||
ports:
|
||||
- "6969:6969"
|
||||
volumes:
|
||||
- ./whisparr:/config
|
||||
- /data/whisparr:/data
|
||||
- /torrent/qbittorrent-private/downloads:/downloads-private
|
||||
- /torrent/qbittorrent-public/downloads:/downloads-public
|
||||
restart: unless-stopped
|
||||
unpackerr:
|
||||
image: golift/unpackerr
|
||||
container_name: unpackerr
|
||||
volumes:
|
||||
- /torrent/qbittorrent-private/downloads:/downloads-private
|
||||
- ./unpackerr:/config
|
||||
restart: always
|
||||
user: 1000:1000
|
||||
environment:
|
||||
- TZ=America/New_York
|
||||
- PUID=1000
|
||||
- PGID=1000
|
||||
## Global Settings
|
||||
- UN_DEBUG=true
|
||||
- UN_LOG_FILE=/config/unpackerr.log
|
||||
- UN_LOG_FILES=10
|
||||
- UN_LOG_FILE_MB=10
|
||||
- UN_INTERVAL=10m
|
||||
- UN_PROGRESS=15s
|
||||
- UN_START_DELAY=1m
|
||||
- UN_RETRY_DELAY=5m
|
||||
- UN_MAX_RETRIES=2
|
||||
- UN_REMNANT_ACTION=rename
|
||||
- UN_PARALLEL=1
|
||||
- UN_FILE_MODE=0644
|
||||
- UN_DIR_MODE=0755
|
||||
# Sonarr-de
|
||||
- UN_SONARR_0_URL=http://sonarr-de:8989
|
||||
- UN_SONARR_0_API_KEY=707d4fcbb3d74822ba990c6a8b7278e9
|
||||
- UN_SONARR_0_PATHS_0=/downloads-private/tv-sonarr-de
|
||||
- UN_SONARR_0_DELETE_DELAY=5m
|
||||
# Sonarr-en
|
||||
- UN_SONARR_1_URL=http://sonarr-en:8989
|
||||
- UN_SONARR_1_API_KEY=e2005c5c204840878f8eb37d1ac6aa0e
|
||||
- UN_SONARR_1_PATHS_0=/downloads-private/tv-sonarr-en
|
||||
- UN_SONARR_1_DELETE_DELAY=5m
|
||||
# Radarr-de
|
||||
- UN_RADARR_0_URL=http://radarr-de:7878
|
||||
- UN_RADARR_0_API_KEY=29f67f0ac8894357b22ea3f7fc1abfdf
|
||||
- UN_RADARR_0_PATHS_0=/downloads-private/radarr-de
|
||||
- UN_RADARR_0_DELETE_DELAY=5m
|
||||
# Radarr-en
|
||||
- UN_RADARR_1_URL=http://radarr-en:7878
|
||||
- UN_RADARR_1_API_KEY=4332aee075c748f2acee41aa26f06007
|
||||
- UN_RADARR_1_PATHS_0=/downloads-private/radarr-en
|
||||
- UN_RADARR_1_DELETE_DELAY=5m
|
||||
# Lidarr
|
||||
- UN_LIDARR_0_URL=http://lidarr:8686
|
||||
- UN_LIDARR_0_API_KEY=bb41cbf2b17e439290f90ecfaeb24dff
|
||||
- UN_LIDARR_0_PATHS_0=/downloads-private/lidarr
|
||||
- UN_LIDARR_0_DELETE_DELAY=5m
|
||||
# Whisparr
|
||||
- UN_WHISPARR_0_URL=http://whisparr:6969
|
||||
- UN_WHISPARR_0_API_KEY=3a5403b7a36f4e679398d959cdd39b1b
|
||||
- UN_WHISPARR_0_PATHS_0=/downloads-private/whisparr
|
||||
- UN_WHISPARR_0_DELETE_DELAY=5m
|
||||
networks:
|
||||
default:
|
||||
external: true
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
#
|
||||
# Use this configuration with WireGuard client
|
||||
#
|
||||
[Interface]
|
||||
Address = 10.14.0.2/16
|
||||
PrivateKey = mKeDQdxtM1iFJS7WLlb2jPGabZIt3NkoA/nGCcNOU1I=
|
||||
DNS = 162.252.172.57, 149.154.159.92
|
||||
[Peer]
|
||||
PublicKey = dPZe8Jq3Hu0k07MDk+Y4+AS2XHSLYalyg91TSFXRYEA=
|
||||
AllowedIPs = 0.0.0.0/0
|
||||
Endpoint = 87.249.133.4:51820
|
||||
@@ -0,0 +1,566 @@
|
||||
#######################################################
|
||||
## Unpackerr Example Configuration File ##
|
||||
#######################################################
|
||||
## The values are a mix of defaults and examples. ##
|
||||
## Env vars overlay the process, not this file. ##
|
||||
## More configuration help: https://unpackerr.zip ##
|
||||
## Config Generator: https://notifiarr.com/unpackerr ##
|
||||
#######################################################
|
||||
|
||||
## Turn on debug messages in the output. Do not wrap this in quotes.
|
||||
## Recommend trying this so you know what it looks like. I personally leave it on.
|
||||
#debug = false
|
||||
|
||||
## Disable writing messages to stdout/stderr. This silences the app. Set a log
|
||||
## file below if you set this to true. Recommended when starting with systemctl.
|
||||
#quiet = false
|
||||
|
||||
## Send error output to stderr instead of stdout by setting error_stderr to true.
|
||||
## Recommend leaving this at false. Ignored if quiet (above) is true.
|
||||
#error_stderr = false
|
||||
|
||||
## Setting activity to true will silence all app queue log lines with only zeros.
|
||||
## Set this to true when you want less log spam.
|
||||
#activity = false
|
||||
|
||||
## The Starr-application activity queue is logged on an interval.
|
||||
## Adjust that interval with this setting.
|
||||
## Default is a minute. 2m, 5m, 10m, 30m, 1h are also perfectly acceptable.
|
||||
#log_queues = "1m"
|
||||
|
||||
## Write messages to a log file. This is the same data that is normally output to stdout.
|
||||
## This setting is great for Docker users that want to export their logs to a file.
|
||||
## The alternative is to use syslog to log the output of the application to a file.
|
||||
## Default is no log file; this is unset.
|
||||
## Except on macOS and Windows, the log file gets set to "~/.unpackerr/unpackerr.log"
|
||||
## log_files=0 turns off auto-rotation so logrotate can own the file.
|
||||
## After logrotate renames the live file, send SIGHUP (`systemctl reload unpackerr`)
|
||||
## to close and reopen it. Use logrotate `create` plus postrotate HUP, not copytruncate.
|
||||
## Default files is 10 and size(mb) is 10 Megabytes.
|
||||
#log_file = ''
|
||||
#log_files = 10
|
||||
#log_file_mb = 10
|
||||
#log_file_mode = "0600"
|
||||
|
||||
## How many completed or failed items to keep in unpackerr.history.jsonl
|
||||
## (next to the log file, or the config file if logs go to stdout).
|
||||
## With neither a log file nor a config file, history stays in memory
|
||||
## for this process and is not written to disk, so it does not survive
|
||||
## a restart. Set `log_file` or use a config file to persist it.
|
||||
## In-progress extracts are also written so a restart can resume them
|
||||
## for 72 hours (Starr waiting for import, folders waiting on
|
||||
## delete_after). Those in-progress rows do not count against this
|
||||
## number. Imported and failed rows do. The history API still lists
|
||||
## only completed or failed rows.
|
||||
## `0` disables history and restart resume.
|
||||
#keep_history = 400
|
||||
|
||||
## How often to poll starr apps (sonarr, radarr, etc).
|
||||
## Recommend 1m-5m. Uses Go Duration.
|
||||
#interval = "2m"
|
||||
|
||||
## How often status is logged for in-progress extractions.
|
||||
## `0` uses the default `15s`. Uses Go Duration.
|
||||
#progress = "15s"
|
||||
|
||||
## How long an item must be queued (download complete) before extraction will start.
|
||||
## One minute is the historic default and works well. Set higher if your downloads
|
||||
## take longer to finalize (or transfer locally). Uses Go Duration.
|
||||
#start_delay = "1m"
|
||||
|
||||
## How long to wait before removing the history for a failed extraction.
|
||||
## Once the history is deleted the item will be recognized as new and
|
||||
## extraction will start again. Uses Go Duration.
|
||||
#retry_delay = "5m"
|
||||
|
||||
## How many times to retry a failed extraction after the first try. Default is 2
|
||||
## (3 attempts total). `0` uses that default. Pauses retry_delay between attempts.
|
||||
#max_retries = 2
|
||||
|
||||
## Applies to Starr apps and to watched folders with `move_back` enabled
|
||||
## (the default folder config extracts into a sidecar tree and does not
|
||||
## classify leftovers there). When an extracted file cannot be moved into
|
||||
## place because the destination already exists, Unpackerr checks whether
|
||||
## that name was present before extraction. Names that arrived with the
|
||||
## download are kept; names that were not (leftovers from an interrupted
|
||||
## extraction) are handled by this setting. `rename` (default) moves the
|
||||
## leftover to a sibling named with a `.remnant` suffix and retries the
|
||||
## extract. `delete` removes it and retries. `off` leaves the leftover
|
||||
## in place and fails the extract without retrying. The item stays failed
|
||||
## until it leaves the Starr queue (folders are untracked). Bounded by
|
||||
## max_retries; if retries are exhausted the leftover fails the extract
|
||||
## instead of reporting success.
|
||||
#remnant_action = "rename"
|
||||
|
||||
## How many files may be extracted in parallel. 1 works fine.
|
||||
## Do not wrap the number in quotes. Raise this only if you have fast disks and CPU.
|
||||
#parallel = 1
|
||||
|
||||
## Extracted files are created with this mode. The process umask still
|
||||
## applies, so 0666 becomes 0644 under umask 0022. Use 0644, or 0660 or
|
||||
## 0666 when another user must write the extracted files. Archive
|
||||
## execute bits are kept only for a watched folder with preserve_exec
|
||||
## enabled.
|
||||
#file_mode = "0644"
|
||||
|
||||
## Extracted directories are created with this mode. The process umask
|
||||
## still applies.
|
||||
#dir_mode = "0755"
|
||||
|
||||
## List of passwords to use for encrypted archives. Must be a list of strings.
|
||||
## Use this special format as a password to read more passwords from a file:
|
||||
## passwords = [ "filepath:/path/to/passwords.txt" ]
|
||||
#passwords = []
|
||||
|
||||
[webserver]
|
||||
## Expose Prometheus metrics at /metrics. The HTTP server starts whenever listen_addr is set;
|
||||
## this only controls the /metrics route. Scrapes must send an API key with
|
||||
## system:metrics:read via Authorization: Bearer or X-Api-Key.
|
||||
# metrics = false
|
||||
## Expose Go pprof handlers at /debug/pprof/. Leave this false unless you
|
||||
## are debugging the running process.
|
||||
# pprof = false
|
||||
## This may be set to a port or an ip:port to bind a specific IP. 0.0.0.0 binds ALL IPs.
|
||||
## Set this to an empty string to disable the HTTP server.
|
||||
# listen_addr = "0.0.0.0:5656"
|
||||
## Local UI login. Use user:pass (hashed on startup), !!cryptd!!user:$2a$...
|
||||
## for a stored hash, webauth:X-Webauth-User for a reverse-proxy header, or
|
||||
## noauth. The HTTP API does not accept plaintext; send user:<PBKDF2 hex>
|
||||
## (same digest as login) and uiCurrentKdf when changing a live password.
|
||||
## filepath:/path reads that file for the live password and keeps filepath: in the
|
||||
## config. Empty generates a temporary password when the HTTP server is enabled.
|
||||
## Reset with --reset. Do not set an empty
|
||||
## UN_WEBSERVER_UI_PASSWORD; a present empty env value wipes a stored hash.
|
||||
ui_password = "!!cryptd!!admin:$2a$10$t8pChUtJw.VZW2DO47Lh/.2nE9J.jHnx.MH5VncjCZ2LADfso64oe"
|
||||
## Used with webauth (proxy header auth). Empty keeps those proxy users
|
||||
## as admin. Ignored for noauth and local password login. Set this to a
|
||||
## header the reverse proxy fills, for example X-Webauth-Role or
|
||||
## X-Authentik-Groups. Matching names are a built-in admin or a custom
|
||||
## [webserver.roles] name. Comma, semicolon, pipe, or space separated
|
||||
## lists are unioned; extra IdP groups are ignored. A selected header
|
||||
## that is missing, empty, or has no matching role is access denied,
|
||||
## not admin.
|
||||
## example: ui_role_header = "X-Webauth-Role"
|
||||
# ui_role_header = ""
|
||||
## Recommend setting a log file for HTTP requests. Otherwise, they go with other logs.
|
||||
# log_file = ''
|
||||
## This app automatically rotates logs. Set these to the size and number to keep.
|
||||
## log_files=0 disables auto-rotation; SIGHUP reopens the HTTP log too.
|
||||
# log_files = 10
|
||||
# log_file_mb = 10
|
||||
## Set both of these to valid file paths to enable HTTPS/TLS.
|
||||
# ssl_cert_file = ''
|
||||
# ssl_key_file = ''
|
||||
## Base URL from which to serve content.
|
||||
# urlbase = "/"
|
||||
## Upstreams should be set to the IP or CIDR of your trusted upstream proxy.
|
||||
## Setting this correctly allows X-Forwarded-For to be used in logs.
|
||||
## In the future it may control auth proxy trust. Must be a list of strings.
|
||||
## example: upstreams = [ "127.0.0.1/32", "10.1.2.0/24" ]
|
||||
# upstreams = []
|
||||
## Empty keeps the library same-origin check (the embedded UI). Add hosts
|
||||
## when a browser on another origin should open GET /ws, for example
|
||||
## localhost:5173 or https://ui.example.com. Patterns use path.Match;
|
||||
## a URI scheme is matched as scheme://host. Do not set * unless you
|
||||
## intend to allow every origin.
|
||||
## example: ws_origins = [ "localhost:5173" ]
|
||||
# ws_origins = []
|
||||
## Nested [[webserver.api_keys]] tables, not an inline array. Each key is 60–150 ASCII
|
||||
## characters. Names and key values must be unique. Built-in role `admin` grants every
|
||||
## permission. Custom roles are listed under [webserver.roles].
|
||||
## Env uses UN_WEBSERVER_API_KEYS_0_NAME, _KEY, and _ROLES_0.
|
||||
## Nested [webserver.roles.<name>] tables. Names are letters, digits, _ or -.
|
||||
## Built-in admin cannot be redefined. `*` is reserved for that built-in role.
|
||||
## Each custom role needs at least one known permission.
|
||||
## File browser is system:browse:read (list) and system:browse:write (create folder).
|
||||
## Env works but is picky: do not set UN_WEBSERVER_ROLES itself. Role names are
|
||||
## case-sensitive and may contain underscores. Index permissions from 0:
|
||||
## UN_WEBSERVER_ROLES_stats_PERMISSIONS_0=system:stats:read
|
||||
## UN_WEBSERVER_ROLES_read_only_PERMISSIONS_0=system:stats:read
|
||||
## [webserver.roles.stats]
|
||||
## permissions = ["system:stats:read"]
|
||||
|
||||
[[webserver.api_keys]]
|
||||
name = "admin"
|
||||
key = "Gv7I8Y0wY7-KFjZxeRD_mVvSm8Ca2sxvo267DY9GG5YKD34BBMGIeudHQy_tI7gq"
|
||||
roles = ["admin"]
|
||||
|
||||
## Global Folder configuration that affects all watched folders.
|
||||
[folders]
|
||||
## How many new folder events can be immediately queued. Don't change this.
|
||||
# buffer = 20000
|
||||
|
||||
###############################################################################
|
||||
##-IMPORTANT-#######-READ THIS!!!-################ Seriously, read this. ######
|
||||
###############################################################################
|
||||
## The following sections can be repeated if you have more than one Sonarr, ##
|
||||
## Radarr, Lidarr, Readarr, Folder, Webhook, and/or Command Hook. ##
|
||||
## Identify each instance with a short key: [sonarr.uhd], [folder.tv]. ##
|
||||
## Changed in v1.0.0 (October 2026): map keys, not [[array]] list rows. ##
|
||||
## You MUST uncomment the [header.0], url and api_key for any Starr app. ##
|
||||
## Uncomment [sonarr.0], [radarr.0], [lidarr.0], and/or [readarr.0] plus the ##
|
||||
## url and api_key if that app is in use. ##
|
||||
## Do not set a bare UN_SONARR / UN_FOLDER / UN_WEBHOOK / UN_CMDHOOK. ##
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
## ALL LINES BEGINNING WITH A HASH # ARE IGNORED COMMENTS ##
|
||||
## REMOVE THE HASH # FROM CONFIG LINES YOU WANT TO CHANGE ##
|
||||
###############################################################################
|
||||
###############################################################################
|
||||
|
||||
#[sonarr.0]
|
||||
## Empty uses the app name (Sonarr, Radarr, and so on). Set this for a
|
||||
## Sonarr-compatible app such as Sportarr so logs and Discord are not
|
||||
## tagged Sonarr. Add Whisparr as a Radarr instance with name = "Whisparr".
|
||||
## Hook exclude matches this name or the app dialect.
|
||||
## Names must be printable and cannot contain quotes, braces, or angle brackets.
|
||||
# name = ""
|
||||
# url = "http://127.0.0.1:8989"
|
||||
# api_key = "0123456789abcdef0123456789abcdef"
|
||||
## Username for HTTP basic authentication on the Starr app, if enabled.
|
||||
# http_user = ""
|
||||
## Password for HTTP basic authentication on the Starr app, if enabled.
|
||||
# http_pass = ""
|
||||
## Username for Starr native (forms) authentication, if enabled.
|
||||
# username = ""
|
||||
## Password for Starr native (forms) authentication, if enabled.
|
||||
# password = ""
|
||||
## List of paths where content is downloaded for this app.
|
||||
## Used as fallback if the path the Starr app reports does not exist or is not accessible.
|
||||
# paths = ['/downloads']
|
||||
## Protocols to process from the download queue. Starr apps historically
|
||||
## used "torrent" and "usenet" as the protocol strings, but newer versions
|
||||
## emit the full class names "TorrentDownloadProtocol" and
|
||||
## "UsenetDownloadProtocol" instead. List every string your app may return,
|
||||
## separated by commas. The default covers both the legacy and new torrent
|
||||
## strings. Add "usenet,UsenetDownloadProtocol" if you use a Usenet client.
|
||||
# protocols = "torrent,TorrentDownloadProtocol"
|
||||
## How long to wait for a reply from the backend.
|
||||
# timeout = "10s"
|
||||
## How long to wait after import before deleting the extracted items.
|
||||
# delete_delay = "5m"
|
||||
## If you use this app with NZB you may wish to delete archives after extraction.
|
||||
## General recommendation is: do not enable this for torrent use.
|
||||
## Setting this to true deletes the entire original download folder after import.
|
||||
# delete_orig = false
|
||||
## If you use Syncthing, setting this to true will make unpackerr wait for syncs to finish.
|
||||
# syncthing = false
|
||||
## When true, Unpackerr verifies the Starr app HTTPS certificate.
|
||||
## The default is false for backward compatibility.
|
||||
# valid_ssl = false
|
||||
## Per-archive uncompressed-byte cap. Empty uses the app default:
|
||||
## Sonarr 20GB, Radarr 75GB, Lidarr 4GB, Readarr 1GB.
|
||||
## `0` or `0B` disables the cap for this instance.
|
||||
# max_bytes = ""
|
||||
|
||||
#[radarr.0]
|
||||
## Empty uses the app name (Sonarr, Radarr, and so on). Set this for a
|
||||
## Sonarr-compatible app such as Sportarr so logs and Discord are not
|
||||
## tagged Sonarr. Add Whisparr as a Radarr instance with name = "Whisparr".
|
||||
## Hook exclude matches this name or the app dialect.
|
||||
## Names must be printable and cannot contain quotes, braces, or angle brackets.
|
||||
# name = ""
|
||||
# url = "http://127.0.0.1:7878"
|
||||
# api_key = "0123456789abcdef0123456789abcdef"
|
||||
## Username for HTTP basic authentication on the Starr app, if enabled.
|
||||
# http_user = ""
|
||||
## Password for HTTP basic authentication on the Starr app, if enabled.
|
||||
# http_pass = ""
|
||||
## Username for Starr native (forms) authentication, if enabled.
|
||||
# username = ""
|
||||
## Password for Starr native (forms) authentication, if enabled.
|
||||
# password = ""
|
||||
## List of paths where content is downloaded for this app.
|
||||
## Used as fallback if the path the Starr app reports does not exist or is not accessible.
|
||||
# paths = ['/downloads']
|
||||
## Protocols to process from the download queue. Starr apps historically
|
||||
## used "torrent" and "usenet" as the protocol strings, but newer versions
|
||||
## emit the full class names "TorrentDownloadProtocol" and
|
||||
## "UsenetDownloadProtocol" instead. List every string your app may return,
|
||||
## separated by commas. The default covers both the legacy and new torrent
|
||||
## strings. Add "usenet,UsenetDownloadProtocol" if you use a Usenet client.
|
||||
# protocols = "torrent,TorrentDownloadProtocol"
|
||||
## How long to wait for a reply from the backend.
|
||||
# timeout = "10s"
|
||||
## How long to wait after import before deleting the extracted items.
|
||||
# delete_delay = "5m"
|
||||
## If you use this app with NZB you may wish to delete archives after extraction.
|
||||
## General recommendation is: do not enable this for torrent use.
|
||||
## Setting this to true deletes the entire original download folder after import.
|
||||
# delete_orig = false
|
||||
## If you use Syncthing, setting this to true will make unpackerr wait for syncs to finish.
|
||||
# syncthing = false
|
||||
## When true, Unpackerr verifies the Starr app HTTPS certificate.
|
||||
## The default is false for backward compatibility.
|
||||
# valid_ssl = false
|
||||
## Per-archive uncompressed-byte cap. Empty uses the app default:
|
||||
## Sonarr 20GB, Radarr 75GB, Lidarr 4GB, Readarr 1GB.
|
||||
## `0` or `0B` disables the cap for this instance.
|
||||
# max_bytes = ""
|
||||
|
||||
#[lidarr.0]
|
||||
## Empty uses the app name (Sonarr, Radarr, and so on). Set this for a
|
||||
## Sonarr-compatible app such as Sportarr so logs and Discord are not
|
||||
## tagged Sonarr. Add Whisparr as a Radarr instance with name = "Whisparr".
|
||||
## Hook exclude matches this name or the app dialect.
|
||||
## Names must be printable and cannot contain quotes, braces, or angle brackets.
|
||||
# name = ""
|
||||
# url = "http://127.0.0.1:8686"
|
||||
# api_key = "0123456789abcdef0123456789abcdef"
|
||||
## Username for HTTP basic authentication on the Starr app, if enabled.
|
||||
# http_user = ""
|
||||
## Password for HTTP basic authentication on the Starr app, if enabled.
|
||||
# http_pass = ""
|
||||
## Username for Starr native (forms) authentication, if enabled.
|
||||
# username = ""
|
||||
## Password for Starr native (forms) authentication, if enabled.
|
||||
# password = ""
|
||||
## List of paths where content is downloaded for this app.
|
||||
## Used as fallback if the path the Starr app reports does not exist or is not accessible.
|
||||
# paths = ['/downloads']
|
||||
## Protocols to process from the download queue. Starr apps historically
|
||||
## used "torrent" and "usenet" as the protocol strings, but newer versions
|
||||
## emit the full class names "TorrentDownloadProtocol" and
|
||||
## "UsenetDownloadProtocol" instead. List every string your app may return,
|
||||
## separated by commas. The default covers both the legacy and new torrent
|
||||
## strings. Add "usenet,UsenetDownloadProtocol" if you use a Usenet client.
|
||||
# protocols = "torrent,TorrentDownloadProtocol"
|
||||
## How long to wait for a reply from the backend.
|
||||
# timeout = "10s"
|
||||
## How long to wait after import before deleting the extracted items.
|
||||
# delete_delay = "5m"
|
||||
## If you use this app with NZB you may wish to delete archives after extraction.
|
||||
## General recommendation is: do not enable this for torrent use.
|
||||
## Setting this to true deletes the entire original download folder after import.
|
||||
# delete_orig = false
|
||||
## If you use Syncthing, setting this to true will make unpackerr wait for syncs to finish.
|
||||
# syncthing = false
|
||||
## When true, Unpackerr verifies the Starr app HTTPS certificate.
|
||||
## The default is false for backward compatibility.
|
||||
# valid_ssl = false
|
||||
## Per-archive uncompressed-byte cap. Empty uses the app default:
|
||||
## Sonarr 20GB, Radarr 75GB, Lidarr 4GB, Readarr 1GB.
|
||||
## `0` or `0B` disables the cap for this instance.
|
||||
# max_bytes = ""
|
||||
## When enabled, FLAC and APE files with CUE sheets are split into
|
||||
## individual track files. ape_format and ape_compression choose what
|
||||
## an APE image becomes.
|
||||
# split_flac = false
|
||||
## ape keeps Monkey's Audio. wav and flac decode the audio.
|
||||
## Empty means ape. FLAC cannot store 32-bit or float PCM.
|
||||
## Compression is ignored unless the format is ape.
|
||||
# ape_format = "ape"
|
||||
## Used only when ape_format is ape (or empty). A default of 0 is set
|
||||
## to 2000. Accepted values are 1000, 2000, 3000, 4000, and 5000.
|
||||
## WAV and FLAC ignore this.
|
||||
# ape_compression = 0
|
||||
|
||||
#[readarr.0]
|
||||
## Empty uses the app name (Sonarr, Radarr, and so on). Set this for a
|
||||
## Sonarr-compatible app such as Sportarr so logs and Discord are not
|
||||
## tagged Sonarr. Add Whisparr as a Radarr instance with name = "Whisparr".
|
||||
## Hook exclude matches this name or the app dialect.
|
||||
## Names must be printable and cannot contain quotes, braces, or angle brackets.
|
||||
# name = ""
|
||||
# url = "http://127.0.0.1:8787"
|
||||
# api_key = "0123456789abcdef0123456789abcdef"
|
||||
## Username for HTTP basic authentication on the Starr app, if enabled.
|
||||
# http_user = ""
|
||||
## Password for HTTP basic authentication on the Starr app, if enabled.
|
||||
# http_pass = ""
|
||||
## Username for Starr native (forms) authentication, if enabled.
|
||||
# username = ""
|
||||
## Password for Starr native (forms) authentication, if enabled.
|
||||
# password = ""
|
||||
## List of paths where content is downloaded for this app.
|
||||
## Used as fallback if the path the Starr app reports does not exist or is not accessible.
|
||||
# paths = ['/downloads']
|
||||
## Protocols to process from the download queue. Starr apps historically
|
||||
## used "torrent" and "usenet" as the protocol strings, but newer versions
|
||||
## emit the full class names "TorrentDownloadProtocol" and
|
||||
## "UsenetDownloadProtocol" instead. List every string your app may return,
|
||||
## separated by commas. The default covers both the legacy and new torrent
|
||||
## strings. Add "usenet,UsenetDownloadProtocol" if you use a Usenet client.
|
||||
# protocols = "torrent,TorrentDownloadProtocol"
|
||||
## How long to wait for a reply from the backend.
|
||||
# timeout = "10s"
|
||||
## How long to wait after import before deleting the extracted items.
|
||||
# delete_delay = "5m"
|
||||
## If you use this app with NZB you may wish to delete archives after extraction.
|
||||
## General recommendation is: do not enable this for torrent use.
|
||||
## Setting this to true deletes the entire original download folder after import.
|
||||
# delete_orig = false
|
||||
## If you use Syncthing, setting this to true will make unpackerr wait for syncs to finish.
|
||||
# syncthing = false
|
||||
## When true, Unpackerr verifies the Starr app HTTPS certificate.
|
||||
## The default is false for backward compatibility.
|
||||
# valid_ssl = false
|
||||
## Per-archive uncompressed-byte cap. Empty uses the app default:
|
||||
## Sonarr 20GB, Radarr 75GB, Lidarr 4GB, Readarr 1GB.
|
||||
## `0` or `0B` disables the cap for this instance.
|
||||
# max_bytes = ""
|
||||
|
||||
##################################################################################
|
||||
### ### STOP HERE ### STOP HERE ### STOP HERE ### STOP HERE #### STOP HERE ### #
|
||||
### Only using Starr apps? The things above. The below configs are OPTIONAL. ### #
|
||||
##################################################################################
|
||||
|
||||
|
||||
##-Folders-#######################################################################
|
||||
## This application can also watch folders for things to extract. If you copy a ##
|
||||
## subfolder into a watched folder (defined below) any extractable items in the ##
|
||||
## folder will be decompressed. This has nothing to do with Starr applications. ##
|
||||
##################################################################################
|
||||
#[folder.0]
|
||||
# path = '/downloads/auto_extract'
|
||||
## How often this folder is scanned for new archives.
|
||||
## Off (`0s`) uses filesystem events (inotify and friends).
|
||||
## Enable a poll interval if files never show up in the queue, which is
|
||||
## common on Docker and CIFS. Polling increases disk reads and is not
|
||||
## recommended when fsnotify works.
|
||||
# interval = "0s"
|
||||
## Paths to ignore while watching this folder. Excluded paths and their
|
||||
## children are not tracked or extracted.
|
||||
## Paths may be absolute, or relative to this folder's `path`.
|
||||
# exclude_paths = []
|
||||
## Path to extract files to. The default (leaving this blank) is the same as `path` (above).
|
||||
# extract_path = ''
|
||||
## Delete extracted or original files this long after extraction.
|
||||
## The default is 10m. Set to 0 to disable all deletes. Deletes also
|
||||
## require `delete_files` and/or `delete_original`. Uses Go Duration.
|
||||
# delete_after = "10m"
|
||||
## Nested archives are extracted by default. Disable recursion to extract only the outer archive.
|
||||
# disable_recursion = false
|
||||
## Per-archive uncompressed-byte cap. Empty is unlimited. `0` or `0B` is also unlimited.
|
||||
# max_bytes = ""
|
||||
## Cap on files, directories, and symlinks created during extract. `0` is unlimited.
|
||||
# max_files = 0
|
||||
## Cap on `bytes written / archive file size`. `0` is unlimited.
|
||||
# max_ratio = 0
|
||||
## Cap on archives extracted from this folder's output (one extras pass). `0` is unlimited.
|
||||
# max_nested = 0
|
||||
## Walk depth for the extras pass. `0` is unlimited.
|
||||
# extras_max_depth = 0
|
||||
## When true, the initial archive search may include symlink-named files.
|
||||
## The extras pass never follows archive-member zip links.
|
||||
# allow_symlinks = false
|
||||
## Delete extracted files after successful extraction? delete_after must be greater than 0.
|
||||
# delete_files = false
|
||||
## Delete original items after successful extraction? delete_after must be greater than 0.
|
||||
# delete_original = false
|
||||
## Disable extraction log (unpackerred.txt) file creation?
|
||||
# disable_log = false
|
||||
## Move extracted files into original folder? If false, files go into an _unpackerred folder.
|
||||
# move_back = false
|
||||
## Set this to true if you want this app to extract ISO files with .iso extension.
|
||||
# extract_isos = false
|
||||
## When true, an execute bit stored in the archive is kept for owner,
|
||||
## group, or other only when file_mode already grants that class access.
|
||||
## A 6 beside an archived 7 becomes 7, a 4 becomes 5, and a 0 stays 0.
|
||||
## Off, extracted files use file_mode only. Starr extracts stay off.
|
||||
## The process umask still applies.
|
||||
# preserve_exec = false
|
||||
## Incomplete-download suffixes such as `.part` or `.crdownload`. Extraction
|
||||
## stays in waiting as long as any matching file is in the watched item's
|
||||
## top folder. Subfolders are not scanned. The UI and config always store
|
||||
## a leading period. Waiting items are rechecked every 5s even without the
|
||||
## poller. Enabling folder poller will double-poll the folder and increase
|
||||
## disk reads. Useful when fsnotify is not available, and not recommended
|
||||
## when it is.
|
||||
# wait_extensions = []
|
||||
## After start delay, skip watched folders that have no extractable archives.
|
||||
## They leave waiting without history or webhooks.
|
||||
# skip_empty = false
|
||||
|
||||
####################
|
||||
### Hook Payload ###
|
||||
####################
|
||||
# Extra IDs and custom event titles shared by every webhook and command hook.
|
||||
[hooks]
|
||||
## Nested [hooks.custom_ids] table, not an inline map.
|
||||
## Webhooks get `customIDs` in JSON (`{{index .CustomIDs "url"}}` in templates).
|
||||
## Command hooks get `UN_CUSTOM_ID_<key>` environment variables.
|
||||
## Env: UN_HOOKS_CUSTOM_IDS_url=https://…
|
||||
## [hooks.custom_ids]
|
||||
## url = "https://unpackerr.example"
|
||||
## Nested [hooks.titles] table with one field per extract event:
|
||||
## waiting, queued, extracting, extractfailed, extracted, imported,
|
||||
## deleting, deletefailed, deleted, extractednothing.
|
||||
## Empty values keep the built-in English title. Built-in Discord, Slack,
|
||||
## Telegram, Gotify, and Pushover templates use this string.
|
||||
## Env: UN_HOOKS_TITLES_EXTRACTING=Archive Found
|
||||
## [hooks.titles]
|
||||
## extracting = "Archive Found"
|
||||
|
||||
################
|
||||
### Webhooks ###
|
||||
################
|
||||
# Sends a webhook when an extraction queues, starts, finishes, and/or is deleted.
|
||||
# Created to integrate with notifiarr.com.
|
||||
# Also works natively with Discord.com, Telegram.org, Slack.com, ntfy, Apprise, and Mattermost webhooks.
|
||||
# Can possibly be used with other services by providing a custom template_path.
|
||||
###### Don't forget to uncomment [webhook.0] and url at a minimum !!!!
|
||||
#[webhook.0]
|
||||
## Notifiarr: https://notifiarr.com/api/v1/notification/unpackerr plus headers.X-Api-Key.
|
||||
## A path API key in a pasted URL is moved to that header.
|
||||
# url = "https://notifiarr.com/api/v1/notification/unpackerr"
|
||||
## Provide an optional name to hide the URL in logs.
|
||||
## If a name is not provided then the URL is used.
|
||||
# name = ""
|
||||
## Do not log success (less log spam).
|
||||
# silent = false
|
||||
## List of event ids to send notification for, [0] for all.
|
||||
## The default is [0] and this is an example:
|
||||
# events = [1, 4, 6]
|
||||
## ===> Advanced Optional Webhook Configuration <===
|
||||
## Discord, Slack, and Mattermost: bot/display name. Telegram: chat_id.
|
||||
## Gotify, ntfy, and Apprise: optional title prefix. Unused by Notifiarr JSON.
|
||||
# nickname = "Unpackerr"
|
||||
## Also passed into templates. Slack and Mattermost optional channel. Pushover user key.
|
||||
# channel = ""
|
||||
## Passed into webhook templates. Pushover requires the application token. ntfy sends Authorization Bearer when set. Unused by Discord, Telegram, and Slack incoming webhooks.
|
||||
# token = ""
|
||||
## Dialect tokens skip every instance of that API. Any other value matches an instance name. None by default. This is an example:
|
||||
# exclude = ["readarr", "lidarr"]
|
||||
## Used when template is empty (automatic). A named template ignores this file.
|
||||
# template_path = ''
|
||||
## Override automatic template detection. Values: notifiarr, discord, telegram, gotify, pushover, slack, ntfy, apprise, mattermost. Empty uses the URL or template_path.
|
||||
# template = ""
|
||||
## Default on for Discord webhooks and Telegram sendMessage. Other templates ignore this. Set false to post a new message for every extract event.
|
||||
# update = true
|
||||
## Set this to true to ignore the SSL certificate on the server.
|
||||
# ignore_ssl = false
|
||||
## You can adjust how long to wait for a server response.
|
||||
# timeout = "10s"
|
||||
## If your custom template uses another MIME type, set this.
|
||||
# content_type = "application/json"
|
||||
## Nested [webhook.0.headers] table. Header names are letters, digits, underscore, or hyphen.
|
||||
## Applied first; Content-Type and ntfy Authorization Bearer from token still win.
|
||||
## Notifiarr client key: X-Api-Key. Env: UN_WEBHOOK_0_HEADERS_X-Api-Key=api_key_from_notifiarr_com
|
||||
## [webhook.0.headers]
|
||||
## X-Api-Key = "api_key_from_notifiarr_com"
|
||||
|
||||
#####################
|
||||
### Command Hooks ###
|
||||
#####################
|
||||
# Executes a script or command when an extraction queues, starts, finishes, and/or is deleted.
|
||||
# All data is passed in as environment variables. Try /usr/bin/env to see what variables are available.
|
||||
###### Don't forget to uncomment [cmdhook.0] at a minimum !!!!
|
||||
#[cmdhook.0]
|
||||
# command = '/downloads/scripts/command.sh'
|
||||
## Provide an optional name to hide the URL in logs.
|
||||
## If a name is not provided the first word in the command is used.
|
||||
# name = ""
|
||||
## Runs the command inside /bin/sh ('nix) or cmd.exe (Windows).
|
||||
# shell = false
|
||||
## Do not log command's output.
|
||||
# silent = false
|
||||
## List of event ids to run command for, [0] for all.
|
||||
## The default is [0] and this is an example:
|
||||
# events = [1, 4, 7]
|
||||
## ===> Optional Command Hook Configuration <===
|
||||
## Dialect tokens skip every instance of that API. Any other value matches an instance name. None by default. This is an example:
|
||||
# exclude = ["readarr", "lidarr"]
|
||||
## You can adjust how long to wait for the command to run.
|
||||
# timeout = "10s"
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
modules:
|
||||
http_2xx:
|
||||
prober: http
|
||||
timeout: 5s
|
||||
http:
|
||||
valid_status_codes: []
|
||||
method: GET
|
||||
preferred_ip_protocol: ip4
|
||||
@@ -8,14 +8,17 @@ services:
|
||||
volumes:
|
||||
- ./prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
||||
- prometheus-data:/prometheus
|
||||
|
||||
networks:
|
||||
- default
|
||||
- shared-prometheus-services
|
||||
extra_hosts:
|
||||
- "host.docker.internal:host-gateway"
|
||||
grafana:
|
||||
image: grafana/grafana:latest
|
||||
container_name: grafana
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3000:3000"
|
||||
|
||||
environment:
|
||||
GF_SECURITY_ADMIN_USER: lucas
|
||||
GF_SECURITY_ADMIN_PASSWORD: Mira2012
|
||||
@@ -47,9 +50,9 @@ services:
|
||||
volumes:
|
||||
- '/:/host:ro,rslave'
|
||||
- ./node_exporter/textfile_collector:/textfile:ro
|
||||
ports:
|
||||
- '9100:9100'
|
||||
|
||||
# ports:
|
||||
# - '9100:9100'
|
||||
network_mode: host
|
||||
cadvisor:
|
||||
image: gcr.io/cadvisor/cadvisor:latest
|
||||
container_name: cadvisor
|
||||
@@ -58,9 +61,65 @@ services:
|
||||
- "8080:8080"
|
||||
volumes:
|
||||
- /:/rootfs:ro
|
||||
- /data:/data:ro
|
||||
- /docker:/docker:ro
|
||||
|
||||
# - /data:/data:ro
|
||||
# - /docker:/docker:ro
|
||||
- /var/run:/var/run:ro
|
||||
- /sys:/sys:ro
|
||||
- /var/lib/docker:/var/lib/docker:ro
|
||||
- /dev/disk:/dev/disk:ro
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
command:
|
||||
- "--disable_metrics=percpu,tcp,udp,process,sched"
|
||||
- "--housekeeping_interval=30s"
|
||||
- "--housekeeping_interval=1m"
|
||||
- "--docker_only=true"
|
||||
cap_add:
|
||||
- SYS_ADMIN
|
||||
blackbox-exporter:
|
||||
image: prom/blackbox-exporter:latest
|
||||
container_name: blackbox-exporter
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "9115:9115"
|
||||
volumes:
|
||||
- ./blackbox.yml:/etc/blackbox_exporter/config.yml:ro
|
||||
# build: listenarr-exporter
|
||||
# container_name: listenarr-exporter
|
||||
# restart: unless-stopped
|
||||
# environment:
|
||||
# LISTENARR_URL: http://listenarr:4545
|
||||
# LISTENARR_APIKEY: FtKkg30FLbORoaJXXBx4oHJL2r1/3kPtZXKlxqSloWs
|
||||
# ports:
|
||||
# - "9712:9712"
|
||||
# networks:
|
||||
# - default
|
||||
# - mediarr-services
|
||||
|
||||
loki:
|
||||
image: grafana/loki:3.0.0
|
||||
container_name: loki
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "3100:3100"
|
||||
command: -config.file=/etc/loki/local-config.yaml
|
||||
|
||||
alloy:
|
||||
image: grafana/alloy:latest
|
||||
container_name: alloy
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- "12345:12345"
|
||||
command: >
|
||||
run /etc/alloy/config.alloy
|
||||
--server.http.listen-addr=0.0.0.0:12345
|
||||
volumes:
|
||||
- ./alloy/config.alloy:/etc/alloy/config.alloy:ro
|
||||
- /var/log:/var/log:ro
|
||||
- /var/log/journal:/var/log/journal:ro
|
||||
- /run/log/journal:/run/log/journal:ro
|
||||
- /etc/machine-id:/etc/machine-id:ro
|
||||
- /var/lib/docker/containers:/var/lib/docker/containers:ro
|
||||
|
||||
volumes:
|
||||
prometheus-data:
|
||||
grafana-data:
|
||||
@@ -68,3 +127,6 @@ networks:
|
||||
default:
|
||||
shared-proxy-services:
|
||||
external: true
|
||||
shared-prometheus-services:
|
||||
external: true
|
||||
|
||||
@@ -0,0 +1,100 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import os
|
||||
import requests
|
||||
from prometheus_client import start_http_server, Gauge
|
||||
from time import sleep
|
||||
from datetime import datetime
|
||||
|
||||
LISTENARR_URL = os.getenv("LISTENARR_URL", "http://localhost:4545")
|
||||
API_KEY = os.getenv("LISTENARR_APIKEY", "")
|
||||
HTTP_PORT = int(os.getenv("EXPORTER_PORT", "9712"))
|
||||
|
||||
HEADERS = {"X-Api-Key": API_KEY}
|
||||
|
||||
up = Gauge("listenarr_up", "Listenarr API reachable")
|
||||
queue_items = Gauge("listenarr_queue_items", "Items in queue")
|
||||
health_issues = Gauge("listenarr_health_issues", "Health issues")
|
||||
books_total = Gauge("listenarr_books_total", "Total monitored books")
|
||||
|
||||
|
||||
def log(msg):
|
||||
print(
|
||||
f"[{datetime.now().strftime('%Y-%m-%d %H:%M:%S')}] {msg}",
|
||||
flush=True,
|
||||
)
|
||||
|
||||
|
||||
def fetch_json(endpoint):
|
||||
url = f"{LISTENARR_URL}/api/v1/{endpoint}"
|
||||
|
||||
log(f"GET {url}")
|
||||
|
||||
response = requests.get(
|
||||
url,
|
||||
headers=HEADERS,
|
||||
timeout=10,
|
||||
)
|
||||
|
||||
log(f"Response: {response.status_code}")
|
||||
|
||||
response.raise_for_status()
|
||||
|
||||
return response.json()
|
||||
|
||||
|
||||
def update_metrics():
|
||||
reachable = False
|
||||
|
||||
try:
|
||||
data = fetch_json("queue")
|
||||
queue_items.set(len(data))
|
||||
reachable = True
|
||||
log(f"Queue items: {len(data)}")
|
||||
|
||||
except Exception as e:
|
||||
queue_items.set(-1)
|
||||
log(f"ERROR queue endpoint: {e}")
|
||||
|
||||
try:
|
||||
data = fetch_json("health")
|
||||
health_issues.set(len(data))
|
||||
reachable = True
|
||||
log(f"Health issues: {len(data)}")
|
||||
|
||||
except Exception as e:
|
||||
health_issues.set(-1)
|
||||
log(f"ERROR health endpoint: {e}")
|
||||
|
||||
try:
|
||||
data = fetch_json("book")
|
||||
books_total.set(len(data))
|
||||
reachable = True
|
||||
log(f"Books total: {len(data)}")
|
||||
|
||||
except Exception as e:
|
||||
books_total.set(-1)
|
||||
log(f"ERROR book endpoint: {e}")
|
||||
|
||||
up.set(1 if reachable else 0)
|
||||
|
||||
log(f"listenarr_up={1 if reachable else 0}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
log("Starting Listenarr exporter")
|
||||
log(f"Listenarr URL: {LISTENARR_URL}")
|
||||
log(f"Metrics port: {HTTP_PORT}")
|
||||
log(f"API key configured: {'yes' if API_KEY else 'no'}")
|
||||
|
||||
start_http_server(HTTP_PORT)
|
||||
|
||||
log("Prometheus endpoint started")
|
||||
|
||||
while True:
|
||||
try:
|
||||
update_metrics()
|
||||
except Exception as e:
|
||||
log(f"FATAL ERROR: {e}")
|
||||
|
||||
sleep(60)
|
||||
@@ -1,6 +1,6 @@
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 15s
|
||||
scrape_interval: 30s
|
||||
evaluation_interval: 30s
|
||||
|
||||
scrape_configs:
|
||||
|
||||
@@ -8,6 +8,31 @@ scrape_configs:
|
||||
static_configs:
|
||||
- targets:
|
||||
- "prometheus:9090"
|
||||
- job_name: blackbox_https
|
||||
metrics_path: /probe
|
||||
params:
|
||||
module: [http_2xx]
|
||||
|
||||
static_configs:
|
||||
- targets:
|
||||
- https://cloud.someoneslinux.selfhost.eu
|
||||
- https://media.someoneslinux.selfhost.eu
|
||||
- https://audiobooks.someoneslinux.selfhost.eu
|
||||
# - https://login.someoneslinux.selfhost.eu
|
||||
- https://auto.someoneslinux.selfhost.eu
|
||||
- https://music.someoneslinux.selfhost.eu
|
||||
- https://passwd.someoneslinux.selfhost.eu
|
||||
- https://requests.someoneslinux.selfhost.eu
|
||||
# - https://torrent.someoneslinux.selfhost.eu
|
||||
- https://status.someoneslinux.selfhost.eu
|
||||
|
||||
relabel_configs:
|
||||
- source_labels: [__address__]
|
||||
target_label: __param_target
|
||||
- source_labels: [__param_target]
|
||||
target_label: instance
|
||||
- target_label: __address__
|
||||
replacement: blackbox-exporter:9115
|
||||
|
||||
- job_name: "node-exporter"
|
||||
static_configs:
|
||||
@@ -16,22 +41,57 @@ scrape_configs:
|
||||
labels:
|
||||
host: serverhost
|
||||
- targets:
|
||||
- "node-exporter:9100"
|
||||
- "192.168.0.4:9100"
|
||||
labels:
|
||||
host: "mediahost"
|
||||
|
||||
- targets:
|
||||
- "192.168.0.39:9100"
|
||||
labels:
|
||||
host: "quiethost"
|
||||
- job_name: "cadvisor"
|
||||
static_configs:
|
||||
- targets:
|
||||
- "cadvisor:8080"
|
||||
labels:
|
||||
host: mediahost
|
||||
- targets:
|
||||
- "192.168.0.2:8081"
|
||||
labels:
|
||||
host: serverhost
|
||||
- job_name: "smartctl"
|
||||
static_configs:
|
||||
- targets:
|
||||
- "192.168.0.2:9633"
|
||||
labels:
|
||||
host: serverhost
|
||||
- targets:
|
||||
- "192.168.0.39:9633"
|
||||
labels:
|
||||
host: "quiethost"
|
||||
- targets:
|
||||
- "192.168.0.4:9633"
|
||||
labels:
|
||||
host: "mediahost"
|
||||
|
||||
- job_name: diun
|
||||
metrics_path: /metrics
|
||||
authorization:
|
||||
credentials: "Qj#8C!@Uz3uRWm@mCd@KH6Bo7nfQ4K"
|
||||
static_configs:
|
||||
- targets:
|
||||
- diun:9090
|
||||
labels:
|
||||
host: "mediahost"
|
||||
- targets:
|
||||
- "192.168.0.39:9090"
|
||||
labels:
|
||||
host: "quiethost"
|
||||
- targets:
|
||||
- "192.168.0.2:9090"
|
||||
labels:
|
||||
host: "serverhost"
|
||||
- job_name: 'crowdsec'
|
||||
static_configs:
|
||||
- targets:
|
||||
- host.docker.internal:6060
|
||||
labels:
|
||||
host: "mediahost"
|
||||
@@ -23,6 +23,7 @@ services:
|
||||
- /data/navidrome/music/kamerun:/kamerun:ro
|
||||
- /data/navidrome/music/weihnachten:/weihnachten:ro
|
||||
- /data/navidrome/music/playlists:/playlists:ro
|
||||
- /data/navidrome/music/playlists-export:/playlists-export
|
||||
networks:
|
||||
- shared-proxy-services
|
||||
- default
|
||||
|
||||
@@ -27,7 +27,8 @@ services:
|
||||
- OVERWRITEPROTOCOL=https
|
||||
- OVERWRITECLIURL=https://${NEXTCLOUD_DOMAIN}
|
||||
- OVERWRITEHOST=${NEXTCLOUD_DOMAIN}
|
||||
- TRUSTED_PROXIES=nginx 172.16.0.0/12
|
||||
- TRUSTED_PROXIES=172.16.0.0/12
|
||||
- DEFAULT_PHONE_REGION=AT
|
||||
# SMTP
|
||||
- SMTP_HOST=${SMTP_HOST}
|
||||
- SMTP_PORT=${SMTP_PORT}
|
||||
|
||||
@@ -16,8 +16,11 @@ server {
|
||||
music.someoneslinux.selfhost.eu
|
||||
passwd.someoneslinux.selfhost.eu
|
||||
requests.someoneslinux.selfhost.eu
|
||||
torrent.someoneslinux.selfhost.eu
|
||||
status.someoneslinux.selfhost.eu;
|
||||
status.someoneslinux.selfhost.eu
|
||||
fotos.someoneslinux.selfhost.eu
|
||||
code.someoneslinux.selfhost.eu
|
||||
aiapi.someoneslinux.selfhost.eu
|
||||
ai.someoneslinux.selfhost.eu;
|
||||
#ssl_conf_command Groups X25519:secp256r1:secp384r1;
|
||||
# ssl_conf_command Groups X25519:prime256v1:secp384r1;
|
||||
location /.well-known/acme-challenge/ {
|
||||
@@ -27,12 +30,28 @@ server {
|
||||
|
||||
location / {
|
||||
return 301 https://$host$request_uri;
|
||||
|
||||
}
|
||||
|
||||
listen 8080;
|
||||
location /nginx_status {
|
||||
stub_status;
|
||||
allow 172.16.0.0/12;
|
||||
deny all;
|
||||
}
|
||||
}
|
||||
|
||||
# Common SSL settings
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_prefer_server_ciphers on;
|
||||
server {
|
||||
listen 443 ssl default_server;
|
||||
server_name _;
|
||||
|
||||
ssl_certificate /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/fullchain.pem;
|
||||
ssl_certificate_key /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/privkey.pem;
|
||||
return 404;
|
||||
}
|
||||
|
||||
###################
|
||||
# NEXTCLOUD
|
||||
@@ -51,6 +70,8 @@ server {
|
||||
|
||||
location / {
|
||||
proxy_pass http://nextcloud:80;
|
||||
# Do not try another upstream on errors
|
||||
proxy_next_upstream off;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
@@ -76,6 +97,8 @@ server {
|
||||
|
||||
location / {
|
||||
proxy_pass http://jellyfin:8096;
|
||||
# Do not try another upstream on errors
|
||||
proxy_next_upstream off;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
@@ -103,6 +126,8 @@ server {
|
||||
|
||||
location / {
|
||||
proxy_pass http://audiobookshelf:80;
|
||||
# Do not try another upstream on errors
|
||||
proxy_next_upstream off;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
@@ -112,40 +137,14 @@ server {
|
||||
}
|
||||
}
|
||||
|
||||
###################
|
||||
# AUTHENTIK
|
||||
###################
|
||||
server {
|
||||
listen 443 ssl;http2 on;
|
||||
server_name login.someoneslinux.selfhost.eu;
|
||||
|
||||
add_header Content-Security-Policy "frame-ancestors 'self';" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
|
||||
ssl_certificate /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/fullchain.pem;
|
||||
ssl_certificate_key /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/privkey.pem;
|
||||
|
||||
location / {
|
||||
proxy_pass http://authentik-server-1:9000;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header X-Forwarded-Host $host;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
}
|
||||
}
|
||||
|
||||
####################
|
||||
## HOME ASSISTANT
|
||||
## AUTHENTIK
|
||||
####################
|
||||
#server {
|
||||
# listen 443 ssl;http2 on;
|
||||
# server_name auto.someoneslinux.selfhost.eu;
|
||||
# server_name login.someoneslinux.selfhost.eu;
|
||||
#
|
||||
# add_header Content-Security-Policy "default-src 'self'; frame-ancestors 'self';" always;
|
||||
# add_header Content-Security-Policy "frame-ancestors 'self';" always;
|
||||
# add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
# add_header X-Content-Type-Options "nosniff" always;
|
||||
# add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
@@ -155,17 +154,45 @@ server {
|
||||
# ssl_certificate_key /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/privkey.pem;
|
||||
#
|
||||
# location / {
|
||||
# proxy_pass http://192.168.0.4:8123;
|
||||
# proxy_pass http://authentik-server-1:9000;
|
||||
# proxy_http_version 1.1;
|
||||
#
|
||||
# proxy_set_header Host $host;
|
||||
# proxy_set_header Upgrade $http_upgrade;
|
||||
# proxy_set_header Connection $connection_upgrade;
|
||||
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
#
|
||||
# proxy_set_header X-Forwarded-Proto https;
|
||||
# proxy_set_header X-Forwarded-Host $host;
|
||||
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
# }
|
||||
#}
|
||||
|
||||
###################
|
||||
# HOME ASSISTANT
|
||||
###################
|
||||
server {
|
||||
listen 443 ssl;http2 on;
|
||||
server_name auto.someoneslinux.selfhost.eu;
|
||||
|
||||
# add_header Content-Security-Policy "default-src 'self'; frame-ancestors 'self';" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
|
||||
ssl_certificate /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/fullchain.pem;
|
||||
ssl_certificate_key /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/privkey.pem;
|
||||
|
||||
location / {
|
||||
proxy_pass http://192.168.0.4:8123;
|
||||
# Do not try another upstream on errors
|
||||
proxy_next_upstream off;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
}
|
||||
}
|
||||
|
||||
###################
|
||||
# NAVIDROME
|
||||
###################
|
||||
@@ -184,6 +211,8 @@ server {
|
||||
location / {
|
||||
proxy_pass http://navidrome:4533;
|
||||
|
||||
# Do not try another upstream on errors
|
||||
proxy_next_upstream off;
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
@@ -208,6 +237,8 @@ server {
|
||||
|
||||
location / {
|
||||
proxy_pass http://vaultwarden:80;
|
||||
# Do not try another upstream on errors
|
||||
proxy_next_upstream off;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
@@ -216,6 +247,8 @@ server {
|
||||
|
||||
location /notifications/hub {
|
||||
proxy_pass http://vaultwarden:3012;
|
||||
# Do not try another upstream on errors
|
||||
proxy_next_upstream off;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
@@ -240,6 +273,8 @@ server {
|
||||
|
||||
location / {
|
||||
proxy_pass http://seerr:5055;
|
||||
# Do not try another upstream on errors
|
||||
proxy_next_upstream off;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
@@ -249,33 +284,36 @@ server {
|
||||
}
|
||||
}
|
||||
|
||||
###################
|
||||
# QBITTORRENT
|
||||
###################
|
||||
server {
|
||||
listen 443 ssl;http2 on;
|
||||
server_name torrent.someoneslinux.selfhost.eu;
|
||||
|
||||
add_header Content-Security-Policy "frame-ancestors 'self';" always;
|
||||
# add_header Content-Security-Policy "default-src 'self'; frame-ancestors 'self';" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
|
||||
ssl_certificate /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/fullchain.pem;
|
||||
ssl_certificate_key /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/privkey.pem;
|
||||
|
||||
location / {
|
||||
proxy_pass http://192.168.0.2:8080;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
}
|
||||
}
|
||||
####################
|
||||
## QBITTORRENT
|
||||
####################
|
||||
#server {
|
||||
# listen 443 ssl;http2 on;
|
||||
# server_name torrent.someoneslinux.selfhost.eu;
|
||||
#
|
||||
# add_header Content-Security-Policy "frame-ancestors 'self';" always;
|
||||
## add_header Content-Security-Policy "default-src 'self'; frame-ancestors 'self';" always;
|
||||
# add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
# add_header X-Content-Type-Options "nosniff" always;
|
||||
# add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
# add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
#
|
||||
# ssl_certificate /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/fullchain.pem;
|
||||
# ssl_certificate_key /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/privkey.pem;
|
||||
#
|
||||
# location / {
|
||||
# proxy_pass http://192.168.0.2:8080;
|
||||
# # Do not try another upstream on errors
|
||||
# proxy_next_upstream off;
|
||||
# proxy_http_version 1.1;
|
||||
#
|
||||
# proxy_set_header Host $host;
|
||||
# proxy_set_header Upgrade $http_upgrade;
|
||||
# proxy_set_header Connection $connection_upgrade;
|
||||
# proxy_set_header X-Forwarded-Proto https;
|
||||
# }
|
||||
#
|
||||
#}
|
||||
|
||||
###################
|
||||
# GRFANA
|
||||
@@ -294,6 +332,8 @@ server {
|
||||
|
||||
location / {
|
||||
proxy_pass http://grafana:3000;
|
||||
# Do not try another upstream on errors
|
||||
proxy_next_upstream off;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
@@ -302,3 +342,124 @@ server {
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
}
|
||||
}
|
||||
|
||||
###################
|
||||
# GITEA
|
||||
###################
|
||||
server {
|
||||
listen 443 ssl;http2 on;
|
||||
server_name code.someoneslinux.selfhost.eu;
|
||||
|
||||
add_header Content-Security-Policy "frame-ancestors 'self';" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
|
||||
ssl_certificate /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/fullchain.pem;
|
||||
ssl_certificate_key /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/privkey.pem;
|
||||
|
||||
client_max_body_size 10G;
|
||||
location / {
|
||||
proxy_pass http://gitea:3000;
|
||||
# Do not try another upstream on errors
|
||||
proxy_next_upstream off;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
}
|
||||
}
|
||||
###################
|
||||
# IMMICH
|
||||
###################
|
||||
server {
|
||||
listen 443 ssl;http2 on;
|
||||
server_name fotos.someoneslinux.selfhost.eu;
|
||||
|
||||
add_header Content-Security-Policy "frame-ancestors 'self';" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
|
||||
ssl_certificate /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/fullchain.pem;
|
||||
ssl_certificate_key /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/privkey.pem;
|
||||
|
||||
client_max_body_size 10G;
|
||||
location / {
|
||||
proxy_pass http://immich_server:2283;
|
||||
# Do not try another upstream on errors
|
||||
proxy_next_upstream off;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
}
|
||||
}
|
||||
###################
|
||||
# OLLAMA
|
||||
###################
|
||||
server {
|
||||
listen 443 ssl;http2 on;
|
||||
server_name ai.someoneslinux.selfhost.eu;
|
||||
|
||||
add_header Content-Security-Policy "frame-ancestors 'self';" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
|
||||
ssl_certificate /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/fullchain.pem;
|
||||
ssl_certificate_key /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/privkey.pem;
|
||||
|
||||
client_max_body_size 10G;
|
||||
location / {
|
||||
proxy_pass http://192.168.0.39:3000;
|
||||
# Do not try another upstream on errors
|
||||
proxy_next_upstream off;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
}
|
||||
}
|
||||
###################
|
||||
# OLLAMA API
|
||||
###################
|
||||
server {
|
||||
listen 443 ssl;http2 on;
|
||||
server_name aiapi.someoneslinux.selfhost.eu;
|
||||
|
||||
add_header Content-Security-Policy "frame-ancestors 'self';" always;
|
||||
add_header X-Frame-Options "SAMEORIGIN" always;
|
||||
add_header X-Content-Type-Options "nosniff" always;
|
||||
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
|
||||
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
|
||||
|
||||
ssl_certificate /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/fullchain.pem;
|
||||
ssl_certificate_key /etc/nginx/certs/live/cloud.someoneslinux.selfhost.eu/privkey.pem;
|
||||
|
||||
client_max_body_size 10G;
|
||||
location / {
|
||||
proxy_pass http://192.168.0.39:11434;
|
||||
# Do not try another upstream on errors
|
||||
proxy_next_upstream off;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
proxy_set_header Host $host;
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
}
|
||||
}
|
||||
@@ -3,11 +3,9 @@ services:
|
||||
image: nginx:stable
|
||||
container_name: nginx
|
||||
restart: unless-stopped
|
||||
|
||||
ports:
|
||||
- "80:80"
|
||||
- "443:443"
|
||||
|
||||
volumes:
|
||||
- ./conf.d:/etc/nginx/conf.d
|
||||
- ./certs:/etc/nginx/certs
|
||||
@@ -15,8 +13,23 @@ services:
|
||||
# Access and error logs
|
||||
- ./logs:/var/log/nginx
|
||||
networks:
|
||||
- default
|
||||
- shared-proxy-services
|
||||
|
||||
nginx-exporter:
|
||||
image: nginx/nginx-prometheus-exporter:latest
|
||||
container_name: nginx-exporter
|
||||
restart: unless-stopped
|
||||
command:
|
||||
- --nginx.scrape-uri=http://nginx:8080/nginx_status
|
||||
ports:
|
||||
- "9113:9113"
|
||||
depends_on:
|
||||
- nginx
|
||||
networks:
|
||||
- default
|
||||
- shared-proxy-services
|
||||
|
||||
crowdsec:
|
||||
image: crowdsecurity/crowdsec:latest
|
||||
container_name: crowdsec
|
||||
@@ -29,7 +42,8 @@ services:
|
||||
- crowdsec-db:/var/lib/crowdsec/data
|
||||
- ./logs:/var/log/nginx:ro
|
||||
- /etc/localtime:/etc/localtime:ro
|
||||
|
||||
networks:
|
||||
- default
|
||||
|
||||
certbot:
|
||||
image: certbot/certbot:latest
|
||||
@@ -41,7 +55,9 @@ services:
|
||||
- shared-proxy-services
|
||||
|
||||
networks:
|
||||
default:
|
||||
shared-proxy-services:
|
||||
external: true
|
||||
|
||||
volumes:
|
||||
crowdsec-db:
|
||||
@@ -3,7 +3,7 @@ services:
|
||||
image: redis:7
|
||||
container_name: redis
|
||||
restart: unless-stopped
|
||||
command: redis-server --appendonly yes --requirepass PerCent7heStorySp0tInOrd3r
|
||||
command: redis-server --appendonly yes --requirepass ${REDIS_PASSWORD}
|
||||
|
||||
healthcheck:
|
||||
test:
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
|
||||
# Note: Do not edit this file directly.
|
||||
# Your changes will be overwritten!
|
||||
|
||||
# Server
|
||||
[Interface]
|
||||
PrivateKey = 6CXCZMoH8bj7Ku//g0vyXms2IIffHR18K8RnOklzgnc=
|
||||
Address = 10.8.0.1/24
|
||||
ListenPort = 51820
|
||||
PreUp =
|
||||
PostUp = iptables -t nat -A POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE; iptables -A INPUT -p udp -m udp --dport 51820 -j ACCEPT; iptables -A FORWARD -i wg0 -j ACCEPT; iptables -A FORWARD -o wg0 -j ACCEPT;
|
||||
PreDown =
|
||||
PostDown = iptables -t nat -D POSTROUTING -s 10.8.0.0/24 -o eth0 -j MASQUERADE; iptables -D INPUT -p udp -m udp --dport 51820 -j ACCEPT; iptables -D FORWARD -i wg0 -j ACCEPT; iptables -D FORWARD -o wg0 -j ACCEPT;
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
OUT=/docker/monitoring/node_exporter/textfile_collector/custom.prom
|
||||
TS=$(date +%s%3N)
|
||||
if [[ "$(hostname)" == "mediahost" ]]; then
|
||||
DOCKER_CONTAINER_NUM=50
|
||||
elif [[ "$(hostname)" == "serverhost" ]]; then
|
||||
DOCKER_CONTAINER_NUM=4
|
||||
elif [[ "$(hostname)" == "quiethost" ]]; then
|
||||
DOCKER_CONTAINER_NUM=1
|
||||
fi
|
||||
{
|
||||
# Docker container states
|
||||
docker ps -a --format '{{.Names}}' | while read -r name; do
|
||||
if docker inspect -f '{{.State.Running}}' "$name" 2>/dev/null | grep -q true; then
|
||||
echo "docker_container_state{name=\"$name\"} 1"
|
||||
else
|
||||
echo "docker_container_state{name=\"$name\"} 0"
|
||||
fi
|
||||
done
|
||||
|
||||
echo docker_container_number $DOCKER_CONTAINER_NUM
|
||||
|
||||
docker ps -a --format '{{.Names}}' | grep -E '^qbittorrent' | while read -r qbit_host; do
|
||||
IP_JSON=$(docker exec "$qbit_host" curl -fsSL http://ip-api.com/json) || continue
|
||||
|
||||
IP=$(jq -r '.query' <<<"$IP_JSON")
|
||||
COUNTRY=$(jq -r '.country' <<<"$IP_JSON")
|
||||
CITY=$(jq -r '.city' <<<"$IP_JSON")
|
||||
ISP=$(jq -r '.isp' <<<"$IP_JSON" | sed 's/"/\\"/g')
|
||||
COUNTRYCODE=$(jq -r '.countryCode' <<<"$IP_JSON")
|
||||
LAT=$(jq -r '.lat' <<<"$IP_JSON")
|
||||
LON=$(jq -r '.lon' <<<"$IP_JSON")
|
||||
|
||||
echo "public_ip_info{ip=\"$IP\",country=\"$COUNTRY\",city=\"$CITY\",isp=\"$ISP\",countrycode=\"$COUNTRYCODE\",lat=\"$LAT\",lon=\"$LON\",exported_host=\"$qbit_host\"} 1"
|
||||
done
|
||||
|
||||
|
||||
# Public IP information
|
||||
IP_JSON=$(curl -fsSL http://ip-api.com/json)
|
||||
IP=$(jq -r '.query' <<< "$IP_JSON")
|
||||
COUNTRY=$(jq -r '.country' <<< "$IP_JSON")
|
||||
CITY=$(jq -r '.city' <<< "$IP_JSON")
|
||||
ISP=$(jq -r '.isp' <<< "$IP_JSON" | sed 's/"/\\"/g')
|
||||
COUNTRYCODE=$(jq -r '.countryCode' <<< "$IP_JSON")
|
||||
LAT=$(jq -r '.lat' <<< "$IP_JSON")
|
||||
LON=$(jq -r '.lon' <<< "$IP_JSON")
|
||||
|
||||
echo "public_ip_info{ip=\"$IP\",country=\"$COUNTRY\",city=\"$CITY\",isp=\"$ISP\",countrycode=\"$COUNTRYCODE\",lat=\"$LAT\",lon=\"$LON\",exported_host=\"$(hostname)\"} 1"
|
||||
|
||||
if [ -f /var/run/reboot-required ]; then
|
||||
# HELP reboot_required Reboot required
|
||||
# TYPE reboot_required gauge
|
||||
echo reboot_required 1
|
||||
else
|
||||
# HELP reboot_required Reboot required
|
||||
# TYPE reboot_required gauge
|
||||
echo reboot_required 0
|
||||
fi
|
||||
echo "custom_metrics_last_update_timestamp_seconds $(date +%s)"
|
||||
} > "$OUT.$$"
|
||||
|
||||
mv "$OUT.$$" "$OUT"
|
||||
|
||||
Executable
+41
@@ -0,0 +1,41 @@
|
||||
#!/bin/bash
|
||||
|
||||
OUT="/docker/monitoring/node_exporter/textfile_collector/smart_selftest.prom"
|
||||
|
||||
> "$OUT"
|
||||
|
||||
for dev in $(smartctl --scan-open | awk '{print $1}'); do
|
||||
name=$(basename "$dev")
|
||||
LAST=0
|
||||
if [[ "$dev" == *nvme* ]]; then
|
||||
POWER_ON=$(smartctl -a "$dev" | awk -F': *' '/Power On Hours:/ {print $2}')
|
||||
LAST=$(smartctl -l selftest "$dev" 2>/dev/null \
|
||||
| grep "Completed" \
|
||||
| head -1 \
|
||||
| awk '{print $(NF-5)}')
|
||||
elif [[ "$dev" == *sd* ]]; then
|
||||
POWER_ON=$(smartctl -a "$dev" | awk '/Power_On_Hours/ {print $10}')
|
||||
LAST=$(smartctl -l selftest "$dev" 2>/dev/null \
|
||||
| grep "Completed" \
|
||||
| head -1 \
|
||||
| awk '{print $(NF-1)}')
|
||||
MODEL=$(smartctl -i "$dev" | awk -F': *' '/Device Model/ {print $2}')
|
||||
# ST2000LM003 self-test hour counter rolls over at 65536
|
||||
if [[ "$MODEL" == "ST2000LM003 HN-M201RAD" ]] && \
|
||||
[[ "$LAST" =~ ^[0-9]+$ ]] && \
|
||||
[[ "$POWER_ON" =~ ^[0-9]+$ ]] && \
|
||||
(( POWER_ON > 65535 && LAST < 65536 )); then
|
||||
LAST=$((LAST + 65536))
|
||||
fi
|
||||
else
|
||||
POWER_ON=99999999999
|
||||
echo $dev
|
||||
fi
|
||||
# Skip devices without self-test history
|
||||
echo $name: Last: ${LAST}, PowerOn: ${POWER_ON}
|
||||
echo "smart_last_selftest_poweron_hours{device=\"$name\"} $LAST" >> "$OUT"
|
||||
|
||||
done
|
||||
|
||||
upgradable=$(apt update > /dev/null 2>&1 && apt list --upgradable 2>/dev/null | wc -l)
|
||||
echo "apt_upgradable $upgradable" >> "$OUT"
|
||||
@@ -0,0 +1,25 @@
|
||||
# Edit this file to introduce tasks to be run by cron.
|
||||
#
|
||||
# Each task to run has to be defined through a single line
|
||||
# indicating with different fields when the task will be run
|
||||
# and what command to run for the task
|
||||
#
|
||||
# To define the time you can provide concrete values for
|
||||
# minute (m), hour (h), day of month (dom), month (mon),
|
||||
# and day of week (dow) or use '*' in these fields (for 'any').
|
||||
#
|
||||
# Notice that tasks will be started based on the cron's system
|
||||
# daemon's notion of time and timezones.
|
||||
#
|
||||
# Output of the crontab jobs (including errors) is sent through
|
||||
# email to the user the crontab file belongs to (unless redirected).
|
||||
#
|
||||
# For example, you can run a backup of all your user accounts
|
||||
# at 5 a.m every week with:
|
||||
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
|
||||
#
|
||||
# For more information see the manual pages of crontab(5) and cron(8)
|
||||
#
|
||||
# m h dom mon dow command
|
||||
*/5 * * * * /home/lucas/scripts/docker_compose/node-exporter-pubip-docker-states.sh && logger "CRON_SUCCESS smartmon" || logger "CRON_FAILURE smartmon"
|
||||
*/1 * * * * /home/lucas/scripts/docker_compose/node-exporter-rocm-exporter.sh && logger "CRON_SUCCESS rocm" || logger "CRON_FAILURE rocm"
|
||||
@@ -0,0 +1,41 @@
|
||||
services:
|
||||
diun:
|
||||
image: crazymax/diun:latest
|
||||
container_name: diun
|
||||
restart: unless-stopped
|
||||
|
||||
volumes:
|
||||
- /var/run/docker.sock:/var/run/docker.sock:ro
|
||||
- ./data:/data
|
||||
|
||||
environment:
|
||||
TZ: Europe/Vienna
|
||||
|
||||
# General
|
||||
DIUN_WATCH_WORKERS: 20
|
||||
DIUN_WATCH_SCHEDULE: "0 0 * * *"
|
||||
DIUN_PROVIDERS_DOCKER: "true"
|
||||
DIUN_PROVIDERS_DOCKER_WATCHBYDEFAULT: "true"
|
||||
# Metrics
|
||||
|
||||
DIUN_METRICS_ENABLED: "true"
|
||||
DIUN_METRICS_ADDR: ":9090"
|
||||
DIUN_METRICS_TOKEN: "Qj#8C!@Uz3uRWm@mCd@KH6Bo7nfQ4K"
|
||||
|
||||
# # Email notifications
|
||||
# DIUN_NOTIF_MAIL_HOST: smtp.web.de
|
||||
# DIUN_NOTIF_MAIL_PORT: 587
|
||||
# DIUN_NOTIF_MAIL_USERNAME: ll_m@web.de
|
||||
# DIUN_NOTIF_MAIL_PASSWORD: Mira2012
|
||||
# DIUN_NOTIF_MAIL_FROM: ll_m@web.de
|
||||
# DIUN_NOTIF_MAIL_TO: ll_m@web.de
|
||||
# DIUN_NOTIF_MAIL_INSECURESKIPVERIFY: "false"
|
||||
ports:
|
||||
- 9090:9090
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
max-size: "10m"
|
||||
max-file: "3"
|
||||
labels:
|
||||
- diun.enable=false
|
||||
@@ -0,0 +1,17 @@
|
||||
# /etc/fstab: static file system information.
|
||||
#
|
||||
# Use 'blkid' to print the universally unique identifier for a
|
||||
# device; this may be used with UUID= as a more robust way to name devices
|
||||
# that works even if disks are added and removed. See fstab(5).
|
||||
#
|
||||
# <file system> <mount point> <type> <options> <dump> <pass>
|
||||
# / was on /dev/nvme0n1p2 during curtin installation
|
||||
/dev/disk/by-uuid/7bc9c1f7-6d4b-431f-b213-9de3a98a7ab5 / ext4 defaults 0 1
|
||||
/dev/disk/by-uuid/e75f0b67-c158-40e9-b155-f08af89a82a9 none swap sw 0 0
|
||||
# /home was on /dev/nvme0n1p4 during curtin installation
|
||||
/dev/disk/by-uuid/96ecc248-410d-4c34-a664-7bbefb2b5ec8 /home ext4 defaults 0 1
|
||||
# /boot/efi was on /dev/nvme0n1p1 during curtin installation
|
||||
/dev/disk/by-uuid/9F46-5BD7 /boot/efi vfat defaults 0 1
|
||||
UUID=1729d425-17c9-4032-b8bd-98d60ca564ab /games ext4 defaults,nofail 0 2
|
||||
UUID=C28E92B18E929E0B /data ntfs defaults 0 2
|
||||
UUID=cc633125-60bc-4180-a53e-43015a4b6180 /stable ext4 defaults 0 2
|
||||
@@ -0,0 +1,16 @@
|
||||
services:
|
||||
node-exporter:
|
||||
container_name: node-exporter
|
||||
image: prom/node-exporter:latest
|
||||
restart: unless-stopped
|
||||
pid: host
|
||||
command:
|
||||
- '--path.rootfs=/host'
|
||||
- '--collector.textfile.directory=/textfile'
|
||||
volumes:
|
||||
- '/:/host:ro,rslave'
|
||||
- ./node_exporter/textfile_collector:/textfile:ro
|
||||
# ports:
|
||||
# - '9100:9100'
|
||||
network_mode: host
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
services:
|
||||
ollama:
|
||||
image: ollama/ollama:latest
|
||||
container_name: ollama
|
||||
restart: unless-stopped
|
||||
|
||||
ports:
|
||||
- "11434:11434"
|
||||
|
||||
environment:
|
||||
OLLAMA_HOST: 0.0.0.0:11434
|
||||
OLLAMA_VULKAN: "1"
|
||||
OLLAMA_KEEP_ALIVE: "10m"
|
||||
|
||||
devices:
|
||||
- /dev/dri:/dev/dri
|
||||
- /dev/kfd:/dev/kfd
|
||||
|
||||
group_add:
|
||||
- "44"
|
||||
- "990"
|
||||
|
||||
volumes:
|
||||
- /stable/ollama:/root/.ollama
|
||||
open-webui:
|
||||
image: ghcr.io/open-webui/open-webui:main
|
||||
container_name: open-webui
|
||||
restart: unless-stopped
|
||||
|
||||
depends_on:
|
||||
- ollama
|
||||
|
||||
ports:
|
||||
- "3000:8080"
|
||||
|
||||
environment:
|
||||
OLLAMA_BASE_URL: http://ollama:11434
|
||||
WEBUI_SECRET_KEY: "eae4639d2f8d5d8afee8cf65fe4d4f3b970b32cfd6c68f0455c9721ccd04d324"
|
||||
|
||||
volumes:
|
||||
- open_webui_data:/app/backend/data
|
||||
|
||||
volumes:
|
||||
ollama_data:
|
||||
open_webui_data:
|
||||
@@ -0,0 +1,12 @@
|
||||
# Example of job definition:
|
||||
# .---------------- minute (0 - 59)
|
||||
# | .------------- hour (0 - 23)
|
||||
# | | .---------- day of month (1 - 31)
|
||||
# | | | .------- month (1 - 12) OR jan,feb,mar,apr ...
|
||||
# | | | | .---- day of week (0 - 6) (Sunday=0 or 7) OR sun,mon,tue,wed,thu,fri,sat
|
||||
# | | | | |
|
||||
# * * * * * user-name command to be executed
|
||||
|
||||
*/5 * * * * /home/lucas/scripts/docker_compose/node-exporter-pubip-docker-states.sh
|
||||
0 0 */2 * * /home/lucas/scripts/network/wg-randomize.sh /docker/qbittorrent/gluetun/ && /usr/bin/docker restart gluetun qbittorrent-public
|
||||
|
||||
@@ -16,15 +16,22 @@ services:
|
||||
DIUN_WATCH_SCHEDULE: "0 0 * * *"
|
||||
DIUN_PROVIDERS_DOCKER: "true"
|
||||
DIUN_PROVIDERS_DOCKER_WATCHBYDEFAULT: "true"
|
||||
# Metrics
|
||||
|
||||
DIUN_METRICS_ENABLED: "true"
|
||||
DIUN_METRICS_ADDR: ":9090"
|
||||
DIUN_METRICS_TOKEN: "Qj#8C!@Uz3uRWm@mCd@KH6Bo7nfQ4K"
|
||||
|
||||
# Email notifications
|
||||
DIUN_NOTIF_MAIL_HOST: smtp.web.de
|
||||
DIUN_NOTIF_MAIL_PORT: 587
|
||||
DIUN_NOTIF_MAIL_USERNAME: ll_m@web.de
|
||||
DIUN_NOTIF_MAIL_PASSWORD: Mira2012
|
||||
DIUN_NOTIF_MAIL_FROM: ll_m@web.de
|
||||
DIUN_NOTIF_MAIL_TO: ll_m@web.de
|
||||
DIUN_NOTIF_MAIL_INSECURESKIPVERIFY: "false"
|
||||
# # Email notifications
|
||||
# DIUN_NOTIF_MAIL_HOST: smtp.web.de
|
||||
# DIUN_NOTIF_MAIL_PORT: 587
|
||||
# DIUN_NOTIF_MAIL_USERNAME: ll_m@web.de
|
||||
# DIUN_NOTIF_MAIL_PASSWORD: Mira2012
|
||||
# DIUN_NOTIF_MAIL_FROM: ll_m@web.de
|
||||
# DIUN_NOTIF_MAIL_TO: ll_m@web.de
|
||||
# DIUN_NOTIF_MAIL_INSECURESKIPVERIFY: "false"
|
||||
ports:
|
||||
- 9090:9090
|
||||
logging:
|
||||
driver: json-file
|
||||
options:
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
# /etc/exports: the access control list for filesystems which may be exported
|
||||
# to NFS clients. See exports(5).
|
||||
#
|
||||
# Example for NFSv2 and NFSv3:
|
||||
# /srv/homes hostname1(rw,sync,no_subtree_check) hostname2(ro,sync,no_subtree_check)
|
||||
#
|
||||
# Example for NFSv4:
|
||||
# /srv/nfs4 gss/krb5i(rw,sync,fsid=0,crossmnt,no_subtree_check)
|
||||
# /srv/nfs4/homes gss/krb5i(rw,sync,no_subtree_check)
|
||||
#
|
||||
/torrent/qbittorrent-private/downloads 192.168.0.4(rw,sync,no_subtree_check)
|
||||
/torrent/qbittorrent-public/downloads/ 192.168.0.4(rw,sync,no_subtree_check)
|
||||
/special-torrent/torrent/ 192.168.0.4(rw,sync,no_subtree_check)
|
||||
#/backup/homeassistant 192.168.0.4(rw,sync,no_subtree_check)
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# /etc/fstab: static file system information.
|
||||
#
|
||||
# Use 'blkid' to print the universally unique identifier for a
|
||||
# device; this may be used with UUID= as a more robust way to name devices
|
||||
# that works even if disks are added and removed. See fstab(5).
|
||||
#
|
||||
# <file system> <mount point> <type> <options> <dump> <pass>
|
||||
# / was on /dev/sdb3 during curtin installation
|
||||
/dev/disk/by-uuid/78ad42f7-ea96-4979-9d97-ebed17e8e794 / ext4 defaults 0 1
|
||||
# /boot/efi was on /dev/sdb1 during curtin installation
|
||||
/dev/disk/by-uuid/B2BA-82AA /boot/efi vfat defaults 0 1
|
||||
# /docker was on /dev/sdb4 during curtin installation
|
||||
/dev/disk/by-uuid/91e3f4d6-cb10-4627-9e3f-59382832b489 /docker ext4 defaults 0 1
|
||||
# /data was on /dev/sdb5 during curtin installation
|
||||
/dev/disk/by-uuid/97e0ba27-0cf7-4502-9f8d-d2fac39cc941 /special-torrent ext4 defaults 0 1
|
||||
/swap.img none swap sw 0 0
|
||||
/dev/disk/by-uuid/98695b57-1d90-484d-9347-c886c6395050 /torrent ext4 defaults 0 1
|
||||
192.168.0.4:/data/torrent/qbittorrent/mediahost /torrent/qbittorrent/mediahost nfs defaults,nofail,x-systemd.automount,x-systemd.mount-timeout=30,_netdev 0 0
|
||||
@@ -10,6 +10,19 @@ services:
|
||||
volumes:
|
||||
- '/:/host:ro,rslave'
|
||||
- ./node_exporter/textfile_collector:/textfile:ro
|
||||
# ports:
|
||||
# - '9100:9100'
|
||||
network_mode: host
|
||||
cadvisor:
|
||||
image: gcr.io/cadvisor/cadvisor:latest
|
||||
container_name: cadvisor
|
||||
restart: unless-stopped
|
||||
ports:
|
||||
- '9100:9100'
|
||||
|
||||
- "8081:8080"
|
||||
volumes:
|
||||
- /:/rootfs:ro
|
||||
- /data:/data:ro
|
||||
- /docker:/docker:ro
|
||||
- /var/run:/var/run:ro
|
||||
- /sys:/sys:ro
|
||||
- /var/lib/docker:/var/lib/docker:ro
|
||||
Loaded 100 of 379 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user