feat: détection short par orientation vidéo
CI / build-and-test (push) Successful in 14m6s

Règle partagée front/back : flag natif, verticale stricte (ratio ≤ 0.8, ≤ 90 s), verticale sans durée jamais short, repli durée (70 YT / 75 autres). Dimensions alimentées par Dailymotion/Odysee/PeerTube, flag maison Rumble supprimé, condition innertube morte simplifiée. Shorts : langues utilisateur (UI + transcripts) via relevanceLanguage/languageOneOf/Twitch language, son activé par défaut.
This commit is contained in:
2026-09-29 12:17:10 -04:00
parent 3f4cd56f14
commit f443a470f9
22 changed files with 454 additions and 73 deletions
+22 -14
View File
@@ -20,7 +20,7 @@ const handler = {
page: Math.max(1, Number(page || 1)).toString(),
// Map our sort to Dailymotion API sort: relevance | visited (views) | recent (date)
sort: (sort === 'date' ? 'recent' : (sort === 'views' ? 'visited' : 'relevance')),
fields: 'id,title,thumbnail_url,thumbnail_360_url,thumbnail_480_url,thumbnail_720_url,duration,views_total,owner.id,owner.screenname,owner.avatar_80_url,created_time'
fields: 'id,title,thumbnail_url,thumbnail_360_url,thumbnail_480_url,thumbnail_720_url,duration,views_total,width,height,owner.id,owner.screenname,owner.avatar_80_url,created_time'
})
);
@@ -30,19 +30,27 @@ const handler = {
const data = await response.json();
return (data.list || []).map(item => ({
title: item.title || '',
id: item.id || '',
url: `https://www.dailymotion.com/video/${item.id}`,
thumbnail: item.thumbnail_720_url || item.thumbnail_480_url || item.thumbnail_360_url || item.thumbnail_url || '',
uploaderName: item['owner.screenname'] || item['owner.username'] || '',
channelId: item['owner.id'] || item['owner.username'] || undefined,
uploaderAvatar: item['owner.avatar_80_url'] || '',
duration: Number(item.duration || 0),
views: Number(item.views_total || 0),
uploadedDate: item.created_time ? new Date(item.created_time * 1000).toISOString() : '',
type: 'video'
}));
return (data.list || []).map(item => {
// Dimensions d'origine (signal d'orientation pour isShortItem).
// Défensif : le champ n'est pas garanti sur toutes les réponses.
const w = Number(item.width);
const h = Number(item.height);
return {
title: item.title || '',
id: item.id || '',
url: `https://www.dailymotion.com/video/${item.id}`,
thumbnail: item.thumbnail_720_url || item.thumbnail_480_url || item.thumbnail_360_url || item.thumbnail_url || '',
uploaderName: item['owner.screenname'] || item['owner.username'] || '',
channelId: item['owner.id'] || item['owner.username'] || undefined,
uploaderAvatar: item['owner.avatar_80_url'] || '',
duration: Number(item.duration || 0),
views: Number(item.views_total || 0),
uploadedDate: item.created_time ? new Date(item.created_time * 1000).toISOString() : '',
type: 'video',
...(Number.isFinite(w) && w > 0 ? { width: w } : {}),
...(Number.isFinite(h) && h > 0 ? { height: h } : {}),
};
});
} catch (error) {
console.error('Dailymotion search error:', error);
return [];
+7 -1
View File
@@ -40,6 +40,10 @@ const handler = {
const name = item.name || '';
const claimId = item.claimId || item.claim_id || '';
const urlSegment = claimId ? `${encodeURIComponent(name)}:${claimId}` : encodeURIComponent(name);
// Dimensions vidéo (signal d'orientation pour isShortItem) quand
// lighthouse les expose — lecture défensive, aucun appel en plus.
const vw = Number(item.video?.width ?? item.video?.video_width ?? item.width);
const vh = Number(item.video?.height ?? item.video?.video_height ?? item.height);
return {
title: item.title || name,
@@ -50,7 +54,9 @@ const handler = {
type: 'video',
duration: typeof item.duration === 'number' && item.duration > 0
? Math.round(item.duration)
: (typeof item.video?.duration === 'number' && item.video.duration > 0 ? Math.round(item.video.duration) : undefined)
: (typeof item.video?.duration === 'number' && item.video.duration > 0 ? Math.round(item.video.duration) : undefined),
...(Number.isFinite(vw) && vw > 0 ? { width: vw } : {}),
...(Number.isFinite(vh) && vh > 0 ? { height: vh } : {}),
};
});
} catch (error) {
+17 -1
View File
@@ -37,6 +37,20 @@ const handler = {
? `https:${rawThumb}`
: new URL(rawThumb, item.url || 'https://sepiasearch.org').toString()
: undefined;
// Dimensions max des fichiers (signal d'orientation pour isShortItem).
// Défensif : sepiasearch n'expose pas toujours `files`.
let fw = 0;
let fh = 0;
try {
for (const f of (Array.isArray(item.files) ? item.files : [])) {
const w = Number(f?.width);
const h = Number(f?.height);
if (Number.isFinite(w) && Number.isFinite(h) && w > 0 && h > 0 && w * h >= fw * fh) {
fw = w;
fh = h;
}
}
} catch {}
return {
title: item.name,
@@ -46,7 +60,9 @@ const handler = {
uploaderName: (item.account && (item.account.displayName || item.account.name)) || undefined,
channelId: (item.channel && (item.channel.name || item.channel.uuid)) || (item.account && item.account.name) || undefined,
type: 'video',
duration: typeof item.duration === 'number' && item.duration > 0 ? Math.round(item.duration) : undefined
duration: typeof item.duration === 'number' && item.duration > 0 ? Math.round(item.duration) : undefined,
...(fw > 0 ? { width: fw } : {}),
...(fh > 0 ? { height: fh } : {}),
};
});
} catch (error) {
+2
View File
@@ -11,6 +11,8 @@
* @property {string=} thumbnail
* @property {string=} uploaderName
* @property {string=} type
* @property {number=} width (largeur vidéo en px, quand le provider l'expose)
* @property {number=} height (hauteur vidéo en px, quand le provider l'expose)
*/
/** @typedef {'yt'|'dm'|'tw'|'pt'|'od'|'ru'} ProviderId */
+12 -12
View File
@@ -221,18 +221,18 @@ function parseSearchHtml(html, { limit = 50 } = {}) {
}
const viewsText = $el.find('.video-item--views').first().text().trim();
const views = Number(String(viewsText).replace(/[^\d]/g, '')) || undefined;
items.push({
title: title || url,
id,
url,
thumbnail: normalizeThumb(rawThumbnail),
uploaderName: uploaderName || undefined,
views,
type: 'video',
duration: durationSeconds,
// Pas de flag natif côté Rumble : durée courte (1..75 s) ⇒ Short probable.
isShort: typeof durationSeconds === 'number' && durationSeconds > 0 && durationSeconds <= 75,
});
items.push({
title: title || url,
id,
url,
thumbnail: normalizeThumb(rawThumbnail),
uploaderName: uploaderName || undefined,
views,
type: 'video',
duration: durationSeconds,
// Pas de flag maison ici : le filtre central (isShortItem,
// durée ≤75 s) tranche. Le scraper HTML n'expose pas de dimensions.
});
});
return items;
}
+5 -1
View File
@@ -136,7 +136,11 @@ export function mapVideoNode(n) {
|| bestThumb(n.thumbnail)
|| bestThumb(n.on_tap_endpoint?.payload?.thumbnail?.thumbnails)
|| undefined;
const isShort = /short|reel/i.test(type) || (Number.isFinite(duration) && duration > 0 && duration <= 70 && /short/i.test(title) === false && /reel|short/i.test(type));
// Un ShortsLockupView / ReelItem EST un short par construction. L'ancienne
// disjonction `|| (durée≤70 && titre sans "short" && type reel|short)` était
// morte : subsumée par le premier test (A || (B && C && A) === A), et son
// `!/short/i.test(title)` excluait à tort les shorts titrés « …shorts ».
const isShort = /short|reel/i.test(type);
const badges = Array.isArray(n.badges) ? n.badges.map((b) => b?.label).filter(Boolean) : [];
return {
title: String(title),