Last active
June 1, 2022 00:52
-
-
Save scooterpsu/098479a28ee6329cfa7e1cb7f3ed6644 to your computer and use it in GitHub Desktop.
VictorVonVolume
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This assumes your distro already has inotifywait. | |
Download jq from here (https://stedolan.github.io/jq/), put the binary in the same folder as vvv.sh. | |
Update paths in autorun to point to your comics folder, and location of vvv.sh | |
Be sure to chmod +x both files | |
Use method of choice to run autorun on startup | |
Since this only catches volume "1", Mylar needs to be set to never set volume to null. | |
In Settings > Quality & Post Processing, choose Show Advanced. Check Always set a Volume label. | |
If this setting isn't visible to you, uncheck Use Start Year as Volume and it should become visible. Change it and then re-check Use Start Year. | |
Alternatively, set setdefaultvolume to True in your config.ini | |
This also catches any "null" booktypes, as that makes Komga throw a fit and not load any metadata. | |
The last line in vvv.sh replaces "comicid" with "cid" to work around Komga not properly identifiying series.json changes otherwise. | |
To regenerate all series.json files, use this Mylar API call: | |
http://[path to mylar]/api?cmd=refreshSeriesjson&comicid=all&apikey=[mylar api key] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pattern="series.json" | |
inotifywait -q -m -r -e close_write --format %w%f /path/to/comics | while read FILENAME; do | |
if [[ "$FILENAME" == *${pattern}* ]]; then | |
/path/to/vvv.sh "$FILENAME"; | |
fi | |
done& |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
jsonBody=`cat "$1"` | |
# If series.json already has a "cid" key, it's already been updated with vvv | |
cidCheck=`jq '.metadata | has("cid")' <<< $jsonBody` | |
if [ $cidCheck == "true" ]; then | |
exit 1 | |
fi | |
# If volume = 1, set volume to 0 | |
volumeNum=`jq .metadata.volume <<< $jsonBody` | |
if ([ $volumeNum == "1" ]); then | |
jsonBody=`jq '.metadata.volume = 0' <<< $jsonBody` | |
fi | |
# If booktype is null, set booktype to "Print" | |
bookType=`jq .metadata.booktype <<< $jsonBody` | |
if ([ $bookType == null ]); then | |
jsonBody=`jq '.metadata.booktype = "Print"' <<< $jsonBody` | |
fi | |
# Change "comicid" to "cid" and write to file | |
jq --indent 4 '.metadata |= with_entries(if .key == "comicid" then .key = "cid" else . end)' <<< $jsonBody > "$1" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment