Skip to content

Instantly share code, notes, and snippets.

@clementlecorre
Created June 3, 2019 20:50
Show Gist options
  • Save clementlecorre/bede1ea9ee0da2aefe2fe0cdc1a52999 to your computer and use it in GitHub Desktop.
Save clementlecorre/bede1ea9ee0da2aefe2fe0cdc1a52999 to your computer and use it in GitHub Desktop.
Import GitHub Star project to tiny tiny RSS via rest API
#!/bin/bash
#
# Script to import GitHub releases feed to tt rss
# Get Categories
# curl -s -X GET -d \
# "$(jq -n --arg sid $(curl -s -d '{"op":"login","user":"","password":""}' https://rss.domain.com/api/ | jq -r '.content.session_id') --arg op getCategories '{"sid": $sid, "op": $op}')"
# https://rss.domain.com/api/ | jq -r
# {
# "seq": 0,
# "status": 0,
# "content": [
# {
# "id": "1",
# "title": "giithub",
# "unread": 0,
# "order_id": 1
# },
# {
# "id": -1,
# "title": "Special",
# "unread": 9
# },
# {
# "id": 0,
# "title": "Uncategorized",
# "unread": 9
# }
# ]
# }
GITHUB_USER=clementlecorre
TINY_DOMAIN=
TINY_USER=
TINY_PASSWORD=
PAGES=$((658/100+1))
TINY_SID=$(curl -s -d "{\"op\":\"login\",\"user\":\"${TINY_USER}\",\"password\":\"${TINY_PASSWORD}\"}" "https://${TINY_DOMAIN}/api/" | jq -r '.content.session_id')
echo "Session token (TINY) : ${TINY_SID}"
for PAGE in `seq $PAGES`; do
curl -sH "Accept: application/vnd.github.v3.star+json" "https://api.github.com/users/$GITHUB_USER/starred?per_page=100&page=$PAGE" | jq -r '.[] | .repo.full_name' | while read repo; do
TINY_RESPONSE=$(curl -s -X GET -d "$(jq -n \
--arg sid ${TINY_SID} \
--arg op subscribeToFeed \
--arg feed_url "https://github.com/${repo}/releases.atom" \
--arg category_id 1 \
'{"sid": $sid, "op": $op, "feed_url": $feed_url, "category_id": $category_id}')" \
"https://${TINY_DOMAIN}/api/" | jq -r)
if [[ "$(echo ${TINY_RESPONSE} | jq -r -c '.content.status.code')" == "1" ]]
then
echo "New project: ${repo}"
else
echo -ne "."
fi
done
done
echo
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment