feat(providers): phases 7.3/7.4/7.6/8.1 — provenance, health, NDJSON, contrat unique
CI / build-and-test (push) Successful in 14m43s
CI / build-and-test (push) Successful in 14m43s
7.3: capturedAt/source au registre + 6 adaptateurs + module provenance.ts + ?debug=1 (search-transport.mjs). 7.4: ProviderHealthService + badge source degradee. 7.6: squelettes par provider + snapshots progressifs + transport NDJSON /api/search. 8.1: ProviderAdapter unifie (search enveloppe + channelContent/channelMeta/capabilities) via getProviderAdapter + test de contrat offline.
This commit is contained in:
@@ -3,6 +3,9 @@ import { firstValueFrom } from 'rxjs';
|
||||
import type { ProviderAdapter, ProviderSearchParams, SearchResult } from '../models';
|
||||
import { VideoItem } from 'src/app/shared/models/video-item.model';
|
||||
import { withFilterParams } from './filter-params';
|
||||
import { readSearchGroup } from '../search-contract';
|
||||
import { mapProvenance } from './provenance';
|
||||
import { serverRefValue } from '../../shared/providers/channel-ref';
|
||||
|
||||
// TODO: Make SearchResult generic
|
||||
export class DmAdapter implements ProviderAdapter<VideoItem> {
|
||||
@@ -17,8 +20,11 @@ export class DmAdapter implements ProviderAdapter<VideoItem> {
|
||||
// le sait, affinés en post-traitement sinon.
|
||||
httpParams = withFilterParams(httpParams, params.filters);
|
||||
const res = await firstValueFrom(this.http.get<any>(`/api/search`, { params: httpParams }));
|
||||
const providerError = typeof res?.errors?.dm?.message === 'string' ? res.errors.dm.message : undefined;
|
||||
const items: VideoItem[] = (res?.groups?.dm || []).map((it: any) => ({
|
||||
const { items: rawItems, providerError } = readSearchGroup(res, 'dm');
|
||||
const items: VideoItem[] = rawItems.map((it: any) => ({
|
||||
// Phase 7.3 — provenance (instant de collecte + voie) : propriété de la
|
||||
// donnée, pas d'un provider — mapping commun aux 6 adaptateurs.
|
||||
...mapProvenance(it),
|
||||
id: it.id,
|
||||
provider: 'dailymotion',
|
||||
title: it.title,
|
||||
@@ -27,7 +33,7 @@ export class DmAdapter implements ProviderAdapter<VideoItem> {
|
||||
thumbnailUrl: it.thumbnail,
|
||||
viewCount: undefined, // Dailymotion API does not provide view count in search results
|
||||
publishedAt: undefined, // Dailymotion API does not provide published date in search results
|
||||
channelExternalId: it.channelId || undefined,
|
||||
channelExternalId: serverRefValue(it.channelRef, 'dm') || it.channelId || undefined,
|
||||
channelAvatarUrl: it.uploaderAvatar || undefined,
|
||||
// Signaux de type pour le raffinement client des filtres.
|
||||
type: typeof it.type === 'string' ? it.type : undefined,
|
||||
@@ -36,6 +42,6 @@ export class DmAdapter implements ProviderAdapter<VideoItem> {
|
||||
width: typeof it.width === 'number' ? it.width : undefined,
|
||||
height: typeof it.height === 'number' ? it.height : undefined,
|
||||
} as VideoItem));
|
||||
return { items, total: Array.isArray(res?.groups?.dm) ? res.groups.dm.length : 0, providerError };
|
||||
return { items, total: rawItems.length, providerError };
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user