@tricoteuses/senat 2.19.2 → 2.19.3

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.
@@ -1 +1 @@
1
- export {};
1
+ export declare function buildSenatVodMasterM3u8FromNvs(nvsText: string): string | null;
@@ -158,38 +158,13 @@ function parseDataNvs(nvs) {
158
158
  const firstChapterLabel = firstChapterLabelMatch ? decodeHtmlEntities(firstChapterLabelMatch[1]).trim() : undefined;
159
159
  return { epoch, organes, firstChapterLabel };
160
160
  }
161
- function buildSenatVodMasterM3u8FromNvs(nvsText, finalText) {
162
- // 1) Base Akamai from data.nvs (mp4 "serverfiles://senat/YYYY/MM/encoderX_YYYYMMDDHHMMSS_1.mp4")
163
- const baseMatch = nvsText.match(/serverfiles:\/\/senat\/(\d{4})\/(\d{2})\/(encoder\d)_(\d{14})/i);
164
- if (!baseMatch)
161
+ export function buildSenatVodMasterM3u8FromNvs(nvsText) {
162
+ // serverfiles://senat/2025/10/encoder10_20251022084451_2.mp4
163
+ const m = nvsText.match(/serverfiles:\/\/senat\/(\d{4})\/(\d{2})\/(encoder\d+)_([0-9]{14})/i);
164
+ if (!m)
165
165
  return null;
166
- const [, yyyy, mm, encoder, stamp] = baseMatch;
166
+ const [, yyyy, mm, encoder, stamp] = m;
167
167
  const base = `https://vodsenat.akamaized.net/senat/${yyyy}/${mm}/${encoder}_${stamp}`;
168
- // 2) start/end from finalplayer.nvs
169
- let start = null, end = null;
170
- const playerAttr = finalText.match(/player[^>]*\bstarttime="(\d+)"[^>]*\bendtime="(\d+)"/i);
171
- if (playerAttr) {
172
- start = parseInt(playerAttr[1], 10);
173
- end = parseInt(playerAttr[2], 10);
174
- }
175
- else {
176
- // fallback: take smallest timecode of <synchro timecode="...">
177
- const tc = Array.from(finalText.matchAll(/timecode="(\d+)"/g)).map((m) => parseInt(m[1], 10));
178
- if (tc.length)
179
- start = Math.min(...tc);
180
- }
181
- if (end == null) {
182
- const durMeta = nvsText.match(/<metadata[^>]*\bname="duree"[^>]*\bvalue="(\d+)"[^>]*>/i);
183
- if (durMeta && start != null) {
184
- const durMs = parseInt(durMeta[1], 10) * 1000; // sec → ms
185
- end = start + durMs;
186
- }
187
- }
188
- // 4) Construct URL
189
- if (start != null && end != null && end > start) {
190
- const pd = end - start;
191
- return `${base}_ps${start}_pd${pd}.smil/master.m3u8`;
192
- }
193
168
  return `${base}.smil/master.m3u8`;
194
169
  }
195
170
  function score(agenda, agendaTs, sameOrg, videoTitle, videoEpoch, videoOrganes) {
@@ -429,17 +404,23 @@ async function processGroupedReunion(agenda, session, dataDir) {
429
404
  await fsp.writeFile(path.join(baseDir, "data.nvs"), dataTxt, "utf-8");
430
405
  if (finalTxt)
431
406
  await fsp.writeFile(path.join(baseDir, "finalplayer.nvs"), finalTxt, "utf-8");
432
- if (dataTxt && finalTxt)
433
- master = buildSenatVodMasterM3u8FromNvs(dataTxt, finalTxt);
407
+ if (dataTxt) {
408
+ master = buildSenatVodMasterM3u8FromNvs(dataTxt);
409
+ }
410
+ else {
411
+ console.log("Cannot download data nvs");
412
+ }
434
413
  }
435
414
  else {
436
415
  // Skipped download, but need to read data.nvs for urlVideo
437
416
  try {
438
417
  const dataTxt = await fsp.readFile(path.join(baseDir, "data.nvs"), "utf-8");
439
418
  const finalTxt = await fsp.readFile(path.join(baseDir, "finalplayer.nvs"), "utf-8");
440
- master = buildSenatVodMasterM3u8FromNvs(dataTxt, finalTxt);
419
+ master = buildSenatVodMasterM3u8FromNvs(dataTxt);
420
+ }
421
+ catch (e) {
422
+ console.warn(e);
441
423
  }
442
- catch { }
443
424
  }
444
425
  // ==== 4) Update agenda file (only if accepted + m3u8) ====
445
426
  if ((accepted || skipDownload) && master) {
@@ -469,6 +450,9 @@ async function processGroupedReunion(agenda, session, dataDir) {
469
450
  console.warn(`[warn] agenda file not found for update: ${agendaJsonPath}`);
470
451
  }
471
452
  }
453
+ else {
454
+ console.warn(`[warn] The video url could not be built`);
455
+ }
472
456
  }
473
457
  async function processAll(dataDir, sessions) {
474
458
  console.log("Process all Agendas and fetch video's url");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tricoteuses/senat",
3
- "version": "2.19.2",
3
+ "version": "2.19.3",
4
4
  "description": "Handle French Sénat's open data",
5
5
  "keywords": [
6
6
  "France",