-
Notifications
You must be signed in to change notification settings - Fork 11
/
auto_add.sh
executable file
·144 lines (128 loc) · 4.28 KB
/
auto_add.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/env bash
source $(dirname "${BASH_SOURCE[0]}")/base.sh
function get-lctt-head()
{
(
cd $(get-lctt-path)
local remote_user=$(git-get-remote-user origin)
local current_branch=$(git-get-current-branch)
echo "${remote_user}:${current_branch}"
)
}
function get-lctt-last-commit-title()
{
(
cd $(get-lctt-path)
git log -1 --format="format:自动%s"|head -n 1
)
}
function get-lctt-operation-file()
{
(
cd $(get-lctt-path)
local current_branch=$(git-get-current-branch)
git-branch-to-file-path "${current_branch}"
)
}
function is-valid-file()
{
(
cd $(get-lctt-path)
local operation_file="$*"
local file_size=$(cat "${operation_file}"|wc -w)
# 文件字数达到300字才认为是有效文章
[[ ${file_size} -gt 300 ]] && grep '^\[#\]: author: ' "${operation_file}" |grep "http"
)
}
function auto-pull-request()
{
local added_file=$(get-lctt-operation-file)
if is-valid-file "${added_file}";then
echo "${added_file} 文件是有效文件,自动提交"
ok.sh create_pull_request "LCTT/TranslateProject" "$(get-lctt-last-commit-title)" "$(get-lctt-head)" "master"
else
echo "${added_file} 文件不是有效文件,不自动提交"
fi
}
# feeds = ("https://feeds.feedburner.com/kerneltalks", "https://www.datamation.com/rss.xml", "http://lukasz.langa.pl/feed/recent/rss-en.xml", "https://feeds.feedburner.com/LinuxUprising", "https://linuxaria.com/feed", )
# tech类别
#feeds="https://www.2daygeek.com/feed/ https://fedoramagazine.org/feed/ https://itsfoss.com/feed/ https://dave.cheney.net/feed https://opensource.com/feed https://jvns.ca/atom.xml https://www.debugpoint.com/feed"
#feeds="https://www.2daygeek.com/feed/ https://fedoramagazine.org/feed/ https://itsfoss.com/feed/ https://dave.cheney.net/feed https://jvns.ca/atom.xml https://www.debugpoint.com/feed"
#feeds="https://www.2daygeek.com/feed/ https://fedoramagazine.org/feed/ https://dave.cheney.net/feed https://jvns.ca/atom.xml https://www.debugpoint.com/feed"
feeds="https://itsfoss.com/rss/ https://www.2daygeek.com/feed/ https://opensource.com/feed https://fedoramagazine.org/feed/ https://dave.cheney.net/feed https://jvns.ca/atom.xml"
for feed in ${feeds};do
echo "auto add ${feed}"
./feed_monitor.py "${feed}" |while read url
do
yes "
"|./1_add_new_article_manual.sh -u "${url}" -c tech -e "echo"
auto-pull-request
./4_finish.sh -d
done
done
# news类别
feeds="https://news.itsfoss.com/latest/rss/"
for feed in ${feeds};do
echo "auto add ${feed}"
./feed_monitor.py "${feed}" |while read url
do
yes "
"|./1_add_new_article_manual.sh -u "${url}" -c news -e "echo"
auto-pull-request
./4_finish.sh -d
done
done
# 自判断类别
# feeds="https://www.networkworld.com/index.rss"
# for feed in ${feeds};do
# ./feed_monitor.py "${feed}" |while read url
# do
# yes "
# "|./1_add_new_article_manual.sh -u "${url}" -e "echo"
# auto-pull-request
# ./4_finish.sh -d
# done
# done
feeds="https://jao.io/blog/rss.xml"
for feed in ${feeds};do
./feed_monitor.py "${feed}" |while read url
do
yes "
"|./1_add_new_article_manual.sh -u "${url}" -e "echo"
auto-pull-request
./4_finish.sh -d
done
done
# feed="http://feeds.feedburner.com/Ostechnix"
# proxychains ./feed_monitor.py "${feed}" |while read url
# do
# yes "
# "|./1_add_new_article_manual.sh -u "${url}" -c tech
# ./4_finish.sh -d
# done
# talk 类别
feeds="https://twobithistory.org/feed.xml"
for feed in ${feeds};do
./feed_monitor.py "${feed}" |while read url
do
yes "
"|./1_add_new_article_manual.sh -u "${url}" -e "echo" -c talk -a 'Two-Bit History'
auto-pull-request
./4_finish.sh -d
done
done
# 手工指定作者
./feed_monitor.py "https://theartofmachinery.com/feed.xml" |while read url
do
yes "
"|./1_add_new_article_manual.sh -u "${url}" -e "echo" -a 'Simon Arneaud'
auto-pull-request
./4_finish.sh -d
done
./feed_monitor.py "https://nicolasparada.netlify.com/index.xml" |while read url
do
yes "
"|./1_add_new_article_manual.sh -u "${url}" -e "echo" -c tech -a 'Nicolás Parada'
auto-pull-request
./4_finish.sh -d
done