Skip to content

Commit f448c35

Browse files
committed
Add src/sill-create-latest-xml.clj script
1 parent 82ca3c0 commit f448c35

File tree

3 files changed

+33
-1
lines changed

3 files changed

+33
-1
lines changed

README.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ Fusionner les données des prestataires SILL venant de l'ADULLACT et du CNLL.
3434

3535
`bbin install https://git.sr.ht/~codegouvfr/codegouvfr-outils/blob/main/src/sill-prestataires.clj`
3636

37+
## `sill-create-latest-xml.clj`
38+
39+
Exporter le flux RSS `latest-sill.xml` à partir de https://code.gouv.fr/sill/api/sill.json.
40+
41+
`bbin install https://git.sr.ht/~codegouvfr/codegouvfr-outils/blob/main/src/sill-create-latest-xml.clj`
42+
3743
## `annuaire-service-public-enrichi`
3844

3945
Enrichi le `.json` de l'annuaire des services publics en ajoutant les

bb.edn

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22
:description "Utilitaires pour code.gouv.fr"
33
:url "https://git.sr.ht/~codegouvfr/codegouvfr-outils"
44
:license {:name "Eclipse Public License - v 2.0"
5-
:url "http://www.eclipse.org/legal/epl-v20.html"}}
5+
:url "http://www.eclipse.org/legal/epl-v20.html"}
6+
:deps {clj-rss/clj-rss {:mvn/version "0.4.0"}}}

src/sill-create-latest-xml.clj

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
#!/usr/bin/env bb
2+
3+
(require '[clj-rss.core :as rss])
4+
5+
(if-let [sill (try (:body (curl/get "https://code.gouv.fr/sill/api/sill.json"))
6+
(catch Exception e (println (.getMessage e))))]
7+
(do (->> sill
8+
json/parse-string
9+
(sort-by #(java.util.Date. (get % "referencedSinceTime")))
10+
reverse
11+
(take 10)
12+
(map (fn [item]
13+
(let [link (str "https://code.gouv.fr/sill/detail?name=" (get item "name"))]
14+
{:title (str "Nouveau logiciel au SILL : " (get item "name"))
15+
:link link
16+
:guid link
17+
:description (get item "function")
18+
:pubDate (.toInstant (java.util.Date. (get item "referencedSinceTime")))})))
19+
(rss/channel-xml
20+
{:title "code.gouv.fr - Nouveaux logiciels libres au SILL - New SILL entries"
21+
:link "https://code.gouv.fr/data/latest-sill.xml"
22+
:description "code.gouv.fr - Nouveaux logiciels libres au SILL - New SILL entries"})
23+
(spit "latest-sill.xml"))
24+
(println "Exported latest-sill.xml"))
25+
(println "Count not get SILL data"))

0 commit comments

Comments
 (0)