Skip to content

Instantly share code, notes, and snippets.

@fmartingr
Forked from dchakro/pocket2shiori.sh
Last active October 4, 2022 20:05
Show Gist options
  • Save fmartingr/88a258bfad47fb00a3ef9d6c38e5699e to your computer and use it in GitHub Desktop.
Save fmartingr/88a258bfad47fb00a3ef9d6c38e5699e to your computer and use it in GitHub Desktop.
script to import pocket entries into shiori with text, images etc. instead of plain bookmarks.
#!/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
grep -Eoi '<a [^>]+>' $1 | grep -Eo 'href="[^\"]+"' | cut -d'=' -f 2- | tr -d '"' | tac > pocket2shiori.txt
# Reading the URLs one by one and adding to shiori
while IFS= read -r line; do
shiori add $line
done < pocket2shiori.txt
rm pocket2shiori.txt
exit 0
@hedonsec
Copy link

hedonsec commented Oct 4, 2022

This is a little slower, but I have used it to add tags from the export as well.

#!/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

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