@tricoteuses/senat 2.6.2 → 2.7.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -26,6 +26,29 @@ function getUrlDossierSenat(lienElements) {
26
26
  .find(lienElement => lienElement.textContent?.includes("dossier législatif"));
27
27
  return urlElement ? urlElement.getAttribute("href") : null;
28
28
  }
29
+ function getQuantieme(eventElement, seancesElements) {
30
+ if (eventElement.classList.contains("evt-seance")) {
31
+ const seanceIndex = seancesElements.indexOf(eventElement);
32
+ if (seancesElements.length === 1 && seanceIndex === 0) {
33
+ return "Unique";
34
+ }
35
+ else {
36
+ switch (seanceIndex) {
37
+ case 0:
38
+ return "Première";
39
+ case 1:
40
+ return "Deuxième";
41
+ case 2:
42
+ return "Troisième";
43
+ case 3:
44
+ return "Quatrième";
45
+ case 4:
46
+ return "Cinquième";
47
+ }
48
+ }
49
+ }
50
+ return null;
51
+ }
29
52
  /**
30
53
  * Normalize time string to become a simple start time ("H'h'mm") or a duration ("'de 'H'h'mm' à 'H'h'mm").
31
54
  */
@@ -62,6 +85,8 @@ function getStartAndEndTimes(timeStr) {
62
85
  function transformAgenda(document, fileName) {
63
86
  const agendaEvents = [];
64
87
  const eventElements = document.querySelectorAll(".evt");
88
+ const seanceElements = Array.from(eventElements)
89
+ .filter(eventElement => eventElement.classList.contains("evt-seance"));
65
90
  for (const eventElement of eventElements) {
66
91
  const id = eventElement.previousElementSibling?.getAttribute("name") || null;
67
92
  if (!id) {
@@ -78,7 +103,8 @@ function transformAgenda(document, fileName) {
78
103
  ?.replace(/^- /, "")
79
104
  || null;
80
105
  const lieu = eventElement.querySelector(".lieu")?.textContent || null;
81
- const url_dossier_senat = getUrlDossierSenat(eventElement.querySelectorAll(".lien a"));
106
+ const videoElement = eventElement.querySelector(".video");
107
+ const urlDossierSenat = getUrlDossierSenat(eventElement.querySelectorAll(".lien a"));
82
108
  agendaEvents.push({
83
109
  id,
84
110
  type,
@@ -90,7 +116,9 @@ function transformAgenda(document, fileName) {
90
116
  organe,
91
117
  objet,
92
118
  lieu,
93
- url_dossier_senat,
119
+ captationVideo: videoElement !== null,
120
+ urlDossierSenat: urlDossierSenat,
121
+ quantieme: getQuantieme(eventElement, seanceElements),
94
122
  });
95
123
  }
96
124
  return agendaEvents;
@@ -9,5 +9,7 @@ export interface AgendaEvent {
9
9
  organe: string | null;
10
10
  objet: string | null;
11
11
  lieu: string | null;
12
- url_dossier_senat: string | null;
12
+ captationVideo: boolean;
13
+ urlDossierSenat: string | null;
14
+ quantieme: string | null;
13
15
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tricoteuses/senat",
3
- "version": "2.6.2",
3
+ "version": "2.7.1",
4
4
  "description": "Handle French Sénat's open data",
5
5
  "keywords": [
6
6
  "France",