chore: update Angular cache and TypeScript build info

This commit is contained in:
2025-09-20 22:33:11 -04:00
parent 9c03f5f5fe
commit 3f04191623
25 changed files with 750 additions and 54 deletions
+90 -10
View File
@@ -223,11 +223,56 @@ async function scrapeRumbleVideo(videoIdOrUrl) {
/* ------------------ Scraper de liste (search / browse) ------------------ */
function parseDurationToSeconds(text) {
if (!text) return 0;
// supporte mm:ss ou hh:mm:ss
const m = text.trim().match(/^(\d{1,2}):(\d{2})(?::(\d{2}))?$/);
if (!m) return 0;
const h = parseInt(m[3] || '0', 10), mn = parseInt(m[1] || '0', 10), s = parseInt(m[2] || '0', 10);
return h * 3600 + mn * 60 + s;
// Nettoyer le texte en supprimant les espaces et caractères non numériques inutiles
const cleanText = text.trim().replace(/\s+/g, '');
// Format hh:mm:ss
let m = cleanText.match(/^(\d+):(\d{2}):(\d{2})$/);
if (m) {
const h = parseInt(m[1], 10) || 0;
const mn = parseInt(m[2], 10) || 0;
const s = parseInt(m[3], 10) || 0;
return h * 3600 + mn * 60 + s;
}
// Format mm:ss
m = cleanText.match(/^(\d+):(\d{2})$/);
if (m) {
const mn = parseInt(m[1], 10) || 0;
const s = parseInt(m[2], 10) || 0;
return mn * 60 + s;
}
// Format avec unités (ex: 1h 30m 45s)
m = cleanText.match(/(\d+h)?(\d+m)?(\d+s)?/);
if (m) {
const hours = m[1] ? parseInt(m[1], 10) : 0;
const minutes = m[2] ? parseInt(m[2], 10) : 0;
const seconds = m[3] ? parseInt(m[3], 10) : 0;
return (hours * 3600) + (minutes * 60) + seconds;
}
// Si on arrive ici, on essaie d'extraire tous les nombres et on suppose un format mmss
const numbers = cleanText.match(/\d+/g);
if (numbers && numbers.length > 0) {
// Si un seul nombre, on suppose que c'est en secondes
if (numbers.length === 1) {
return parseInt(numbers[0], 10) || 0;
}
// Si deux nombres, on suppose mm:ss
if (numbers.length === 2) {
return (parseInt(numbers[0], 10) * 60) + (parseInt(numbers[1], 10) || 0);
}
// Si trois nombres, on suppose hh:mm:ss
if (numbers.length >= 3) {
return (parseInt(numbers[0], 10) * 3600) +
(parseInt(numbers[1], 10) * 60) +
(parseInt(numbers[2], 10) || 0);
}
}
return 0; // Par défaut si aucun format n'est reconnu
}
async function scrapeRumbleList({ q, page = 1, limit = 24, sort = 'viral' }) {
@@ -263,12 +308,47 @@ async function scrapeRumbleList({ q, page = 1, limit = 24, sort = 'viral' }) {
|| '';
if (thumb && thumb.startsWith('//')) thumb = 'https:' + thumb;
const durationText =
card.find('.video-item--duration, .video-duration, .duration, .video-item__duration').first().text().trim();
// Essayer plusieurs sélecteurs pour la durée, y compris les attributs data-
let durationText = '';
// Ajout de plus de sélecteurs spécifiques à Rumble
const durationElement = card.find(
'.video-item--duration, .video-duration, .duration, .video-item__duration, ' +
'[data-duration], .videoDuration, .video-time, .time, ' +
'.video-card__duration, .media__duration, .thumb-time, ' +
'.video-listing-entry__duration, .video-item__duration'
).first();
if (durationElement.length) {
// Essayer d'abord les attributs data-
durationText = durationElement.attr('data-duration') ||
durationElement.attr('data-time') ||
// Essayer aussi les attributs style ou autres qui pourraient contenir la durée
durationElement.attr('aria-label') ||
durationElement.attr('title') ||
// Essayer le contenu textuel
durationElement.text().trim();
}
// Si on n'a pas trouvé de durée, essayer de la trouver dans le contenu de la card
if (!durationText) {
// Chercher un élément qui ressemble à une durée (mm:ss ou hh:mm:ss)
const timeMatch = card.html().match(/>\s*([0-9]+:[0-9]{2}(?::[0-9]{2})?)\s*</);
if (timeMatch && timeMatch[1]) {
durationText = timeMatch[1];
}
}
// Nettoyer le texte de durée avant de le parser
const cleanDurationText = durationText.replace(/[^0-9:]/g, '').trim();
// Extraire les vues
const viewsText =
card.find('.video-item--views, .rumbles-views, .views, .video-item__views').first().text().trim();
const duration = parseDurationToSeconds(durationText);
card.find('.video-item--views, .rumbles-views, .views, .video-item__views, [data-views]').first()
.attr('data-views') ||
card.find('.video-item--views, .rumbles-views, .views, .video-item__views, .video-views').first().text().trim();
// Parser la durée
const duration = parseDurationToSeconds(cleanDurationText);
const views = parseInt((viewsText || '').replace(/[^\d]/g, ''), 10) || 0;
// Important: on renvoie TOUJOURS une URL canonique cohérente