summaryrefslogtreecommitdiffstats
path: root/rssdownload
blob: 689b8d5a6b5578c826ffe38b3d43bf74b0e56153 (plain)
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
#!/bin/zsh
setopt multios
limit=${1:-10}
DB="$HOME/.local/share/newsbeuter/cache.db"

filters="megaupload"

results="$HOME/Downloads/list"
typeset -A patterns
#patterns=(stonerobi releaselog megarelease)
patterns=(stonerobi 1  megarelease 0 releaselog 0)
#patterns=(megarelease)


file1=/tmp/rss1
file2=/tmp/rss2
ids=/tmp/tmprss


for pat in ${(k)patterns}
do
        sqlite3 -list $DB    \
            "select id,url from rss_item where feedurl like '%$pat%' ORDER BY pubDate DESC LIMIT $limit;" >| $ids

        for line in "${(f)$(< $ids)}"
        do
            id=$line[(ws:|:)1]
            sqlite3  $DB "select title from rss_item where id == $id" >|$file1

            if [[ $patterns[$pat] == 1 ]];then
                  sqlite3  $DB "select content from rss_item where id == $id" | urifind | /bin/grep -E $filters | perl -pe 'if (!eof()) { s/\n/ | /g }' >|$file2
             else
                  url=$line[(ws:|:)2]
                  #filters=(/usr/share/plowshare/modules/*)
                  #filters=($filters:t:r)
                  /usr/bin/w3m -no-cookie -dump $url | urifind | /bin/grep -E $filters | perl -pe 'if (!eof()) { s/\n/ | /g }' >|$file2
             fi
        paste -d '|' $file1 $file2  >>| $results

        done
done

rm $file1 $file2 $ids

# vim:set ft=sh: