-
Notifications
You must be signed in to change notification settings - Fork 0
/
rsstodiaspora.sh
94 lines (69 loc) · 2.19 KB
/
rsstodiaspora.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/bash
# Shell script for automated posting from rss feeds into Diaspora
# Author hanuman http://ablog.gratun.am
# Githab https://github.com/hanumanum/RSS-To-Diaspora
# Required:1 clispora http://freeshell.de/~mk/projects/cliaspora.html
# Required:2 xmlstarlet http://xmlstar.sourceforge.net/
#HOW TO USE
#STEP 0։ Install clispora and xmlstarlet before use this script
#STEP 1։ Change cd /path/to/script/RSS-To-Diaspora to your value
#STEP 2։ Change "[email protected]" and "yourpassword" with your real credentials
#STEP 3։ Replace rsslist file content with your rss list
#STEP 4։ Run this script from console or add it to cron
#STEP 5։ Enjoy :Ճ
cliaspora session close
rm ~/.cliasporarc
cd /path/to/script/RSS-To-Diaspora
HANCLTEMP=/tmp/han_cl_tmp
cliaspora session new [email protected] yourpassword || exit
rssArray=($(< rsslist))
declare -a postedArray
let i=0
while IFS=$'\n' read -r line_data; do
postedArray[i]="$line_data"
((++i))
done < posted
for rsss in "${rssArray[@]}"
{
wget ${rsss} -O - 2>/dev/null | xmlstarlet sel -t -m "/rss/channel/item" -v "guid" -n -v "title" -n -v "category" -n >> $HANCLTEMP
}
cat $HANCLTEMP | while read LINE
do
#echo "$LINE"
http="${LINE:0:4}"
if [ "$http" == "http" ]; then
linenumber=1
url=$LINE;
fi
if [ $linenumber == 2 ]; then
title=$LINE;
fi
if [ $linenumber -ne 2 ] && [ $linenumber -ne 1 ] && [ $linenumber -ne 0 ] && [ "$LINE" != "" ]; then
tags="$tags #$LINE"
fi
linenumber=`expr $linenumber + 1`
if [ "$http" == "" ] && [ "$url" != "" ]; then
isnew=1
for link in "${postedArray[@]}"
{
if [ "$link" == "$url" ]; then
isnew=0
fi
}
if [ $isnew -eq 1 ]; then
poststring="$title <br> $url <br> $tags"
echo $poststring > /tmp/han_clias_post
cliaspora post public < /tmp/han_clias_post
echo "Posting $title"
echo "$url">> posted
fi
tags=""
url=""
title=""
poststring=""
let linenumber=0
fi
done
rm $HANCLTEMP
cliaspora session close
rm ~/.cliasporarc