Last active
September 29, 2025 15:33
-
-
Save Aerex/01499c66f6b36a5d997f97ca1b0ab5b1 to your computer and use it in GitHub Desktop.
Import wallabag json file into a shiori instance.
This file contains hidden or 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 | |
| help() { | |
| cat <<HELP | |
| wallbag2shiori [options] <JSON_FILE> | |
| Import wallabag json file into shiori instance. | |
| -h Print the help menu | |
| -v Enable verbose mode | |
| HELP | |
| exit; | |
| } | |
| while getopts :hv arg; do | |
| case "$arg" in | |
| h) | |
| help | |
| ;; | |
| v) | |
| set -x | |
| ;; | |
| ?) | |
| echo "ERROR: Unknown option $OPTARG" | |
| exit 2 | |
| ;; | |
| esac | |
| done | |
| # Get file path from arg | |
| shift $((OPTIND - 1)) | |
| FILE=$1 | |
| if [ -z $FILE ]; then | |
| help | |
| fi | |
| if [ ! -f $FILE ]; then | |
| echo "ERROR: Cannot find $FILE to import" | |
| exit 2 | |
| fi | |
| if [[ $FILE != *.json* ]]; then | |
| echo "ERROR: $FILE must be a json file" | |
| exit 2 | |
| fi | |
| while IFS= read -r wall; do | |
| title=$(echo $wall | jq -r '.title') | |
| url=$(echo $wall | jq -r '.url') | |
| num_tags=$(echo $wall | jq '.tags | length') | |
| if [[ $num_tags != 0 ]]; then | |
| tags=$(echo $wall | jq -r '.tags | tostring' | tr -d '\[\]' | tr -d '"') | |
| shiori add "$url" -i "$title" -t $tags | |
| else | |
| shiori add "$url" -i "$title" | |
| fi | |
| done < <(jq -c '. | reverse | .[]' < $FILE) |
Author
Sure thing, thanks again for publishing this gist, I appreciate it.
Author
No problem and thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@appel Thanks for the tip. Updated.