-
Notifications
You must be signed in to change notification settings - Fork 2
243 lines (242 loc) · 16.3 KB
/
latest-news-pt.yml
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
name: Fetch News Digest PT
on:
repository_dispatch:
#workflow_dispatch:
#schedule:
# - cron: '*/5 6-23 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- name: Check out repo
uses: actions/checkout@v2
with:
fetch-depth: 0
#- name: Download Google Trends xml
# run: |-
# curl -o google-trends.xml "https://trends.google.com/trends/trendingsearches/daily/rss?geo=PT&$(date +%s)"
#- name: Build
# run: npm install
- name: Scrape ECO
run: node ecoScraper.js
continue-on-error: true
- name: Scrape CM
run: node cmScraper.js
continue-on-error: true
- name: RSS to JSON Expresso
run: node rss-to-json--expresso.js
continue-on-error: true
- name: RSS to JSON SIC Notícias
run: node rss-to-json--sicn.js
continue-on-error: true
- name: RSS to JSON CNN Portugal
run: node rss-to-json--cnn.js
continue-on-error: true
- name: RSS to JSON Notícias ao Minuto
run: node rss-to-json--noticiasaominuto.js
continue-on-error: true
- name: RSS to JSON RTP Notícas
run: node rss-to-json--rtp.js
continue-on-error: true
- name: RSS to JSON Jornal i
run: node rss-to-json--i.js
continue-on-error: true
- name: RSS to JSON Renascença
run: node rss-to-json--renascenca.js
continue-on-error: true
- name: RSS to JSON Novo
run: node rss-to-json--novo.js
continue-on-error: true
- name: RSS to JSON Económico
run: node rss-to-json--economico.js
continue-on-error: true
#- name: Download RR xml
# run: |-
# curl -o rr.xml https://rr.sapo.pt/rss/rssfeed.aspx?section=section_noticias
# continue-on-error: true
#- name: Download Jornal i xml
# run: |-
# curl -o jornali.xml https://ionline.sapo.pt/rss.xml
# continue-on-error: true
#- name: Download CM xml
# run: |-
# curl -o cm.xml https://www.cmjornal.pt/rss?$(date +%s)
#- name: Download CNN Portugal xml
# run: |-
# curl -o cnnportugal.xml https://cnnportugal.iol.pt/rss.xml
#- name: Delete GMT from rr.xml
# run: |-
# sed -i 's/GMT+1//g' rr.xml
# continue-on-error: true
#- name: Change +01:00 to +00:00from jornali.xml
# run: |-
# sed -i 's/+01:00/+00:00/g' jornali.xml
# continue-on-error: true
#- name: Insert UTF8 line in cm.xml
# run: |-
# sed -i 's/<rss xmlns:atom="http:\/\/www.w3.org\/2005\/Atom" version="2.0">/<?xml version="1.0" encoding="ISO-8859-1"?><rss xmlns:atom="http:\/\/www.w3.org\/2005\/Atom" version="2.0">/g' cm.xml
- name: Fix Timezone Offset in eco.json
run: |-
sed -i 's/.000Z/+00:00/g' eco.json
continue-on-error: true
- name: Download Público Feed
run: |-
curl "https://www.publico.pt/api/list/ultimas?size=12?$(date +%s)" | jq '.[:10] | map(.title = .titulo | .date_published = .data | del(.titulo, .data)) | map({title, url, date_published, media: "Público"})' | jq -r tostring > digest/latest--publico.json
continue-on-error: true
- name: Download Observador Feed
run: |-
curl "https://api.observador.pt/wp/lists/latest/?$(date +%s)" | jq '.[:10] | map(.date_published = .pubDate | del(.pubDate)) | map({title, links, date_published, media: "Observador"})' | jq -r tostring > digest/latest--observador.json
continue-on-error: true
#- name: Download Expresso Feed
# run: |-
# curl "https://www.toptal.com/developers/feed2json/convert?url=https%3A%2F%2Frss.impresa.pt%2Ffeed%2Flatest%2Fexpresso.rss%3F$(date +%s)%26type%3DARTICLE%2CVIDEO%2CGALLERY%2CSTREAM%2CPLAYLIST%2CEVENT%26limit%3D20%26pubsubhub%3Dtrue&minify=on" | jq '.items[:10] | map({title, url, date_published, media: "Expresso"})' | jq -r tostring > digest/latest--expresso.json
# continue-on-error: true
#- name: Download SIC Notícias Feed
# run: |-
# curl "https://www.toptal.com/developers/feed2json/convert?url=https%3A%2F%2Frss.impresa.pt%2Ffeed%2Flatest%2Fsicnot.rss%3F$(date +%s)%26type%3DARTICLE%2CVIDEO%2CGALLERY%2CSTREAM%2CPLAYLIST%2CEVENT%26limit%3D20%26pubsubhub%3Dtrue&minify=on" | jq '.items[:10] | map({title, url, date_published, media: "SIC Notícias"})' | jq -r tostring > digest/latest--sicnoticias.json
# continue-on-error: true
#- name: Download DN Feed
# run: |-
# curl "https://www.toptal.com/developers/feed2json/convert?url=http%3A%2F%2Ffeeds.dn.pt%2FDN-Ultimas?v=$(date +%s)&minify=on" | jq '.items[:10] | map({title, url, date_published, media: "DN"})' | jq -r tostring > digest/latest--dn.json
#- name: Download JN Feed
# run: |-
# curl "https://www.toptal.com/developers/feed2json/convert?url=http%3A%2F%2Ffeeds.dn.pt%2FJN-Ultimas?v=$(date +%s)&minify=on" | jq '.items[:10] | map({title, url, date_published, media: "JN"})' | jq -r tostring > digest/latest--jn.json
#- name: Download RTP Feed
# run: |-
# curl "https://www.toptal.com/developers/feed2json/convert?url=https%3A%2F%2Fwww.rtp.pt%2Fnoticias%2Frss?v=$(date +%s)&minify=on" | jq '.items[:10] | map({title, url, date_published, media: "RTP Notícias"})' | jq -r tostring > digest/latest--rtp.json
# continue-on-error: true
#- name: Download Económico Feed
# run: |-
# curl "https://www.toptal.com/developers/feed2json/convert?url=https%3A%2F%2Fjornaleconomico.sapo.pt%2Ffeed?v=$(date +%s)&minify=on" | jq '.items[:10] | map({title, url, date_published, media: "Económico"})' | jq -r tostring > digest/latest--economico.json
# continue-on-error: true
#- name: Download Dinheiro Vivo Feed
# run: |-
# curl "https://www.toptal.com/developers/feed2json/convert?url=http%3A%2F%2Ffeeds.dinheirovivo.pt%2FDV-Ultimas?v=$(date +%s)&minify=on" | jq '.items[:10] | map({title, url, date_published, media: "Dinheiro Vivo"})' | jq -r tostring > digest/latest--dinheirovivo.json
#- name: Download Correio da Manhã Feed
# run: |-
# curl "https://www.toptal.com/developers/feed2json/convert?url=https://raw.githubusercontent.com/alexmsantos/data/main/cm.xml" | jq '.items[:20] | map({title, url, date_published, media: "Correio da Manhã"})' | jq -r tostring > digest/latest--cm.json
#- name: Download Negócios xml
# run: |-
# curl -o negocios.xml https://www.jornaldenegocios.pt/rss?v=$(date +%s)
#- name: Download Negócios Feed 1
# run: |-
# curl "https://api.rss2json.com/v1/api.json?rss_url=https://www.jornaldenegocios.pt/rss?v=$(date +%s)" | jq -r tostring > negocios.json
#- name: Download Negócios Feed 2
# run: |-
# curl "https://www.toptal.com/developers/feed2json/convert?url=https://www.jornaldenegocios.pt/rss?v=$(date +%s)" | jq '.items[:10] | map({title, url, date_published, media: "Negócios"})' | jq -r tostring > digest/latest--negocios.json
#- name: Change Date format in digest/latest--negocios.json
# run: |-
# sed -e "s/^\(.*\)\([0-9]\{4\}-[0-9]\{2\}-[0-9]\{2\}\) \([0-9]\{2\}:[0-9]\{2\}:[0-9]\{2\}[.][0-9]\{1,3\}\)\(.*\)$/\1\2T\3Z\4/" digest/latest--negocios.json
#- name: Download Rádio Renascença Feed
# run: |-
# curl "https://www.toptal.com/developers/feed2json/convert?url=https://raw.githubusercontent.com/alexmsantos/data/main/rr.xml?v=$(date +%s)" | jq '.items[:10] | map({title, url, date_published, media: "Renascença"})' | jq -r tostring > digest/latest--rr.json
# continue-on-error: true
#- name: Download Notícias ao Minuto Feed
# run: |-
# curl "https://www.toptal.com/developers/feed2json/convert?url=https%3A%2F%2Fwww.noticiasaominuto.com%2Frss%2Fultima-hora?v=$(date +%s)&minify=on" | jq '.items[:10] | map({title, url, date_published, media: "Notícias ao Minuto"})' | jq -r tostring > digest/latest--noticiasaominuto.json
# continue-on-error: true
#- name: Download Novo Feed
# run: |-
# curl "https://www.toptal.com/developers/feed2json/convert?url=https://onovo.sapo.pt/feed/?v=$(date +%s)" | jq '.items[:10] | map({title, url, date_published, media: "Novo"})' | jq -r tostring > digest/latest--novo.json
# continue-on-error: true
#- name: Download TSF Feed
# run: |-
# curl "https://www.toptal.com/developers/feed2json/convert?url=http://feeds.tsf.pt/TSF-Ultimas?v=$(date +%s)" | jq '.items[:10] | map({title, url, date_published, media: "TSF"})' | jq -r tostring > digest/latest--tsf.json
- name: Edit eco.json
run: |-
jq '[{title: ."0", url: ."1", date_published: ."2", media: "Eco"},{title: ."3", url: ."4", date_published: ."5", media: "Eco"},{title: ."6", url: ."7", date_published: ."8", media: "Eco"},{title: ."9", url: ."10", date_published: ."11", media: "Eco"},{title: ."12", url: ."13", date_published: ."14", media: "Eco"},{title: ."15", url: ."16", date_published: ."17", media: "Eco"},{title: ."18", url: ."19", date_published: ."20", media: "Eco"},{title: ."21", url: ."22", date_published: ."23", media: "Eco"},{title: ."24", url: ."25", date_published: ."26", media: "Eco"},{title: ."27", url: ."28", date_published: ."29", media: "Eco"}]' eco.json >digest/latest--eco.json
continue-on-error: true
- name: Edit cm.json
run: |-
jq '[{title: ."0", url: ."1", date_published: ."2", media: "Correio da Manhã"},{title: ."3", url: ."4", date_published: ."5", media: "Correio da Manhã"},{title: ."6", url: ."7", date_published: ."8", media: "Correio da Manhã"},{title: ."9", url: ."10", date_published: ."11", media: "Correio da Manhã"},{title: ."12", url: ."13", date_published: ."14", media: "Correio da Manhã"},{title: ."15", url: ."16", date_published: ."17", media: "Correio da Manhã"},{title: ."18", url: ."19", date_published: ."20", media: "Correio da Manhã"},{title: ."21", url: ."22", date_published: ."23", media: "Correio da Manhã"}]' cm.json >digest/latest--cm.json
continue-on-error: true
- name: Edit expresso.json
run: |-
jq '.items[:10] | map(.date_published = .published | .url = .link | del(.published, .link)) | map({title, url, date_published: (if .date_published then (.date_published / 1000 | strftime("%Y-%m-%dT%H:%M:%S+00:00")) else empty end), media: "Expresso"})' expresso.json >digest/latest--expresso.json
continue-on-error: true
- name: Edit sicnoticias.json
run: |-
jq '.items[:10] | map(.date_published = .published | .url = .link | del(.published, .link)) | map({title, url, date_published: (if .date_published then (.date_published / 1000 | strftime("%Y-%m-%dT%H:%M:%S+00:00")) else empty end), media: "SIC Notícias"})' sicnoticias.json >digest/latest--sicnoticias.json
continue-on-error: true
- name: Edit cnnportugal.json
run: |-
jq '.items[:10] | map(.date_published = .published | .url = .link | del(.published, .link)) | map({title, url, date_published: (if .date_published then (.date_published / 1000 | strftime("%Y-%m-%dT%H:%M:%S+00:00")) else empty end), media: "CNN Portugal"})' cnnportugal.json >digest/latest--cnnportugal.json
continue-on-error: true
- name: Edit jornali.json
run: |-
jq '.items[:10] | map(.date_published = .published | .url = .link | del(.published, .link)) | map({title, url, date_published: (if .date_published then (.date_published / 1000 | strftime("%Y-%m-%dT%H:%M:%S+00:00")) else empty end), media: "Jornal i"})' jornali.json >digest/latest--jornali.json
continue-on-error: true
- name: Edit noticiasaominuto.json
run: |-
jq '.items[:10] | map(.date_published = .published | .url = .link | del(.published, .link)) | map({title, url, date_published: (if .date_published then (.date_published / 1000 | strftime("%Y-%m-%dT%H:%M:%S+00:00")) else empty end), media: "Notícias ao Minuto"})' noticiasaominuto.json >digest/latest--noticiasaominuto.json
continue-on-error: true
- name: Edit rtp.json
run: |-
jq '.items[:10] | map(.date_published = .published | .url = .link | del(.published, .link)) | map({title, url, date_published: (if .date_published then (.date_published / 1000 | strftime("%Y-%m-%dT%H:%M:%S+00:00")) else empty end), media: "RTP Notícias"})' rtp.json >digest/latest--rtp.json
continue-on-error: true
- name: Edit ecnomico.json
run: |-
jq '.items[:10] | map(.date_published = .published | .url = .link | del(.published, .link)) | map({title, url, date_published: (if .date_published then (.date_published / 1000 | strftime("%Y-%m-%dT%H:%M:%S+00:00")) else empty end), media: "Económico"})' economico.json >digest/latest--economico.json
continue-on-error: true
- name: Edit renascenca.json
run: |-
jq '.items[:10] | map(.date_published = .published | .url = .link | del(.published, .link)) | map({title, url, date_published: (if .date_published then (.date_published / 1000 + 3600 | strftime("%Y-%m-%dT%H:%M:%S+00:00")) else empty end), media: "Renascença"})' renascenca.json >digest/latest--rr.json
continue-on-error: true
- name: Edit novo.json
run: |-
jq '.items[:10] | map(.date_published = .published | .url = .link | del(.published, .link)) | map({title, url, date_published: (if .date_published then (.date_published / 1000 | strftime("%Y-%m-%dT%H:%M:%S+00:00")) else empty end), media: "Novo"})' novo.json >digest/latest--novo.json
continue-on-error: true
#- name: Download Jornal i Feed
# run: |-
# curl "https://www.toptal.com/developers/feed2json/convert?url=https://raw.githubusercontent.com/alexmsantos/data/main/jornali.xml?v=$(date +%s)" | jq '.items[:10] | map({title, url, date_published, media: "Jornal i"})' | jq -r tostring > digest/latest--jornali.json
# continue-on-error: true
#- name: Change Yes to No in google-trends.xml
# run: |-
# sed -i 's/yes/no/g' google-trends.xml
#- name: Change property name in google-trends.xml
# run: |-
# sed -i 's/ht:approx_traffic/approx_traffic/g' google-trends.xml
#- name: Download Google Trends Feed
# run: |-
# curl "https://www.toptal.com/developers/feed2json/convert?url=https://raw.githubusercontent.com/alexmsantos/data/main/google-trends.xml?v=$(date +%s)" | jq '.items[:10] | map({title, url, date_published, media: "Google Trends"})' | jq -r tostring > digest/google-trends.json
#- name: Download Eco Feed
# run: |-
# curl "https://eco.sapo.pt/wp-json/eco/v1/items" | jq '.[:10] | map(.date_published = .pubDate | del(.pubDate)) | map({title, links, date_published, media: "Eco"})' | jq -r tostring > digest/latest--eco.json
#- name: Download CNN Portugal Feed
# run: |-
# curl "https://api.rss2json.com/v1/api.json?rss_url=https%3A%2F%2Fcnnportugal.iol.pt%2Frss.xml?v=$(date +%s)" | jq '.items[:10] | map(.date_published = .pubDate | .url = .link | del(.pubDate, .link)) | map({title, url, date_published, media: "CNN Portugal"})' | jq '[.[] | .date_published |= (.[:10] + "T" + .[11:] + "Z")]' | jq -r tostring > digest/latest--cnnportugal.json
#- name: Parse date
# run: |-
# jq '.[].date_published |= strflocaltime' digest/latest--cnnportugal.json
- name: Sed links to url in observador.json
run: |-
sed -i 's/"links":{"webUri":/"url":/g' digest/latest--observador.json
continue-on-error: true
- name: Sed links close tab in observador.json
run: |-
sed -i 's/},"date_published":/,"date_published":/g' digest/latest--observador.json
continue-on-error: true
#- name: Find and Replace Links
# uses: jacobtomlinson/gha-find-replace@v3
# with:
# find: '"links":{"webUri":'
# replace: '"url":'
# include: "digest/latest--observador.json"
#- name: Find and Replace links close tag
# uses: jacobtomlinson/gha-find-replace@v3
# with:
# find: '},"date_published":'
# replace: ',"date_published":'
# include: "digest/latest--observador.json"
- name: Merge files
run: |-
jq -s . digest/latest--publico.json digest/latest--observador.json digest/latest--expresso.json digest/latest--rtp.json digest/latest--economico.json digest/latest--noticiasaominuto.json digest/latest--sicnoticias.json digest/latest--rr.json digest/latest--jornali.json digest/latest--eco.json digest/latest--cm.json digest/latest--cnnportugal.json | jq -r tostring > digest/digestpt.json
- name: Commit and push changes
run: |-
git diff
git config user.name "Automated"
git config user.email "---"
git pull
git diff --quiet || (git add -A && git commit -m "Updated News Digest PT")
git push