@tricoteuses/senat 2.18.10 → 2.18.11
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.
- package/lib/scripts/retrieve_videos.js +15 -11
- package/package.json +1 -1
|
@@ -65,10 +65,19 @@ function epochToParisDateTime(epochSec) {
|
|
|
65
65
|
startTime: `${hh}:${mi}:${ss}.${ms}${offsetStr}`,
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
|
-
function toTargetEpoch(time) {
|
|
68
|
+
function toTargetEpoch(time, date) {
|
|
69
69
|
if (!time)
|
|
70
70
|
return null;
|
|
71
|
-
|
|
71
|
+
let dtLocal;
|
|
72
|
+
if (time.includes("T")) {
|
|
73
|
+
dtLocal = DateTime.fromISO(time, { zone: "Europe/Paris" });
|
|
74
|
+
}
|
|
75
|
+
else if (date) {
|
|
76
|
+
dtLocal = DateTime.fromISO(`${date}T${time}`, { zone: "Europe/Paris" });
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
72
81
|
if (!dtLocal.isValid)
|
|
73
82
|
return null;
|
|
74
83
|
return Math.floor(dtLocal.toUTC().toSeconds());
|
|
@@ -198,6 +207,8 @@ function score(agenda, agendaTs, sameOrg, videoTitle, videoEpoch, videoOrganes)
|
|
|
198
207
|
const titleScore = Math.max(objetS, titleS);
|
|
199
208
|
let timeScore = 0;
|
|
200
209
|
if (agendaTs && videoEpoch) {
|
|
210
|
+
console.log("agendaTs", agendaTs);
|
|
211
|
+
console.log("videoEpoch", videoEpoch);
|
|
201
212
|
const deltaMin = Math.abs(videoEpoch - agendaTs) / 60;
|
|
202
213
|
timeScore = Math.exp(-deltaMin / 60);
|
|
203
214
|
}
|
|
@@ -276,7 +287,7 @@ async function processGroupedReunion(agenda, session, dataDir) {
|
|
|
276
287
|
// if (!options["silent"]) console.log(`[skip] ${agenda.uid} date/hour missing`)
|
|
277
288
|
return;
|
|
278
289
|
}
|
|
279
|
-
const agendaTs = toTargetEpoch(agenda.startTime);
|
|
290
|
+
const agendaTs = toTargetEpoch(agenda.startTime, agenda.date);
|
|
280
291
|
const now = Date.now();
|
|
281
292
|
if (agendaTs && agendaTs * 1000 > now) {
|
|
282
293
|
return;
|
|
@@ -322,13 +333,6 @@ async function processGroupedReunion(agenda, session, dataDir) {
|
|
|
322
333
|
if (!dataBuf)
|
|
323
334
|
continue;
|
|
324
335
|
const meta = parseDataNvs(dataBuf.toString("utf-8"));
|
|
325
|
-
let sessionStart;
|
|
326
|
-
const finalBuf = await fetchBuffer(finalUrl);
|
|
327
|
-
if (finalBuf) {
|
|
328
|
-
const finalMeta = parseFinalNvs(finalBuf.toString("utf-8"));
|
|
329
|
-
sessionStart = finalMeta.sessionStart;
|
|
330
|
-
}
|
|
331
|
-
const videoEpoch = meta.epoch ?? sessionStart;
|
|
332
336
|
let sameOrg = false;
|
|
333
337
|
// If organes are too different, go to next candidates
|
|
334
338
|
if (agenda.organe && meta.organes?.length) {
|
|
@@ -358,7 +362,7 @@ async function processGroupedReunion(agenda, session, dataDir) {
|
|
|
358
362
|
if (c.isSeancePublique && meta.firstChapterLabel) {
|
|
359
363
|
videoTitle = meta.firstChapterLabel;
|
|
360
364
|
}
|
|
361
|
-
const s = score(agenda, agendaTs, sameOrg, videoTitle,
|
|
365
|
+
const s = score(agenda, agendaTs, sameOrg, videoTitle, meta.epoch, meta.organes);
|
|
362
366
|
if (!best || s > best.score) {
|
|
363
367
|
best = {
|
|
364
368
|
id: c.id,
|