Skip to content

Instantly share code, notes, and snippets.

@appel
Forked from Aerex/wallabag2shiori
Last active September 28, 2025 20:21
Show Gist options
  • Save appel/1f0d7a32e608a7fe29fc62ac36a9e5fe to your computer and use it in GitHub Desktop.
Save appel/1f0d7a32e608a7fe29fc62ac36a9e5fe to your computer and use it in GitHub Desktop.
Import wallabag json file into a shiori instance. Reverses import order so that your newest articles remain at the top.
#!/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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment