Skip to content

Instantly share code, notes, and snippets.

@ptzn
Created February 5, 2023 13:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ptzn/0adc5ed09576554a9eb9386a7308a7cd to your computer and use it in GitHub Desktop.
Save ptzn/0adc5ed09576554a9eb9386a7308a7cd to your computer and use it in GitHub Desktop.
#!/bin/sh
# Extracting URLs from the exported HTML from getpocket.com/export
# In the following line $1 is the exported HTML from pocket
# Which will be passed to this script as a CLI parameter
# copied from https://gist.github.com/fmartingr/88a258bfad47fb00a3ef9d6c38e5699e?permalink_comment_id=4324412#gistcomment-4324412
grep -Eoi '<a [^>]+>' $1 | tac > pocket2shiori.txt
# Reading the URLs one by one and adding to shiori, with tags, if they exist
while IFS= read -r line; do
tags=$(echo "$line" | grep -Eoi 'tags="[^\"]+"' | cut -d'=' -f 2- | tr -d '"')
link=$(echo "$line" | grep -Eo 'href="[^\"]+"' | cut -d'=' -f 2- | tr -d '"' | sed 's/ /,/g')
if [ -n "$tags" ]
then
shiori add "$link" -t "$tags"
else
shiori add "$link"
fi
done < pocket2shiori.txt
rm pocket2shiori.txt
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment