feat: update Angular cache with latest TypeScript definitions
This commit is contained in:
@@ -1,25 +1,27 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import type { ProviderAdapter, ProviderSearchParams, SearchResult } from '../models';
|
||||
import { VideoItem } from 'src/app/shared/models/video-item.model';
|
||||
|
||||
export class DmAdapter implements ProviderAdapter {
|
||||
// TODO: Make SearchResult generic
|
||||
export class DmAdapter implements ProviderAdapter<VideoItem> {
|
||||
key = 'dm' as const;
|
||||
label = 'Dailymotion';
|
||||
constructor(private http: HttpClient) {}
|
||||
async search(params: ProviderSearchParams, _signal: AbortSignal): Promise<SearchResult> {
|
||||
const res = await firstValueFrom(this.http.get<any>(`/api/search`, { params: { q: params.q, providers: 'dm' } }));
|
||||
const items = (res?.groups?.dm || []).map((it: any) => ({
|
||||
async search(params: ProviderSearchParams, _signal: AbortSignal): Promise<SearchResult<VideoItem>> {
|
||||
let httpParams = new HttpParams().set('q', params.q).set('providers', 'dm');
|
||||
if (params.pageToken) httpParams = httpParams.set('page', params.pageToken);
|
||||
if (params.sort) httpParams = httpParams.set('sort', params.sort);
|
||||
const res = await firstValueFrom(this.http.get<any>(`/api/search`, { params: httpParams }));
|
||||
const items: VideoItem[] = (res?.groups?.dm || []).map((it: any) => ({
|
||||
id: it.id,
|
||||
provider: this.key,
|
||||
provider: 'dailymotion',
|
||||
title: it.title,
|
||||
channel: it.uploaderName,
|
||||
channelName: it.uploaderName,
|
||||
durationSec: it.duration,
|
||||
thumbUrl: it.thumbnail,
|
||||
watchUrl: it.url || '',
|
||||
views: undefined,
|
||||
publishedAt: undefined,
|
||||
isLive: it.type === 'live',
|
||||
isShort: it.isShort === true
|
||||
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
|
||||
}));
|
||||
return { items, total: Array.isArray(res?.groups?.dm) ? res.groups.dm.length : 0 };
|
||||
}
|
||||
|
||||
@@ -1,26 +1,37 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import type { ProviderAdapter, ProviderSearchParams, SearchResult } from '../models';
|
||||
import { VideoItem } from 'src/app/shared/models/video-item.model';
|
||||
|
||||
export class OdAdapter implements ProviderAdapter {
|
||||
export class OdAdapter implements ProviderAdapter<VideoItem> {
|
||||
key = 'od' as const;
|
||||
label = 'Odysee';
|
||||
constructor(private http: HttpClient) {}
|
||||
async search(params: ProviderSearchParams, _signal: AbortSignal): Promise<SearchResult> {
|
||||
const res = await firstValueFrom(this.http.get<any>(`/api/search`, { params: { q: params.q, providers: 'od' } }));
|
||||
const items = (res?.groups?.od || []).map((it: any) => ({
|
||||
id: it.id,
|
||||
provider: this.key,
|
||||
title: it.title,
|
||||
channel: it.uploaderName,
|
||||
durationSec: it.duration,
|
||||
thumbUrl: it.thumbnail,
|
||||
watchUrl: it.url || '',
|
||||
views: undefined,
|
||||
publishedAt: undefined,
|
||||
isLive: false,
|
||||
isShort: it.isShort === true
|
||||
}));
|
||||
async search(params: ProviderSearchParams, _signal: AbortSignal): Promise<SearchResult<VideoItem>> {
|
||||
let httpParams = new HttpParams().set('q', params.q).set('providers', 'od');
|
||||
if (params.pageToken) httpParams = httpParams.set('page', params.pageToken);
|
||||
if (params.sort) httpParams = httpParams.set('sort', params.sort);
|
||||
const res = await firstValueFrom(this.http.get<any>(`/api/search`, { params: httpParams }));
|
||||
const items: VideoItem[] = (res?.groups?.od || []).map((it: any) => {
|
||||
let slug: string | undefined;
|
||||
try {
|
||||
const url: string | undefined = it?.url;
|
||||
if (url && /^https?:\/\/odysee\.com\//i.test(url)) {
|
||||
slug = url.replace(/^https?:\/\/odysee\.com\//i, '').replace(/^\//, '');
|
||||
}
|
||||
} catch {}
|
||||
return {
|
||||
id: it.id,
|
||||
provider: 'odysee',
|
||||
title: it.title,
|
||||
channelName: it.uploaderName,
|
||||
durationSec: it.duration,
|
||||
thumbnailUrl: it.thumbnail,
|
||||
viewCount: undefined,
|
||||
publishedAt: undefined,
|
||||
slug,
|
||||
} as VideoItem;
|
||||
});
|
||||
return { items, total: Array.isArray(res?.groups?.od) ? res.groups.od.length : 0 };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import type { ProviderAdapter, ProviderSearchParams, SearchResult } from '../models';
|
||||
import { VideoItem } from 'src/app/shared/models/video-item.model';
|
||||
|
||||
export class PtAdapter implements ProviderAdapter {
|
||||
export class PtAdapter implements ProviderAdapter<VideoItem> {
|
||||
key = 'pt' as const;
|
||||
label = 'PeerTube';
|
||||
constructor(private http: HttpClient) {}
|
||||
async search(params: ProviderSearchParams, _signal: AbortSignal): Promise<SearchResult> {
|
||||
const res = await firstValueFrom(this.http.get<any>(`/api/search`, { params: { q: params.q, providers: 'pt' } }));
|
||||
const items = (res?.groups?.pt || []).map((it: any) => ({
|
||||
async search(params: ProviderSearchParams, _signal: AbortSignal): Promise<SearchResult<VideoItem>> {
|
||||
let httpParams = new HttpParams().set('q', params.q).set('providers', 'pt');
|
||||
if (params.pageToken) httpParams = httpParams.set('page', params.pageToken);
|
||||
if (params.sort) httpParams = httpParams.set('sort', params.sort);
|
||||
const res = await firstValueFrom(this.http.get<any>(`/api/search`, { params: httpParams }));
|
||||
const items: VideoItem[] = (res?.groups?.pt || []).map((it: any) => ({
|
||||
id: it.id,
|
||||
provider: this.key,
|
||||
provider: 'peertube',
|
||||
title: it.title,
|
||||
channel: it.uploaderName,
|
||||
channelName: it.uploaderName,
|
||||
durationSec: it.duration,
|
||||
thumbUrl: it.thumbnail,
|
||||
watchUrl: it.url || '',
|
||||
views: undefined,
|
||||
thumbnailUrl: it.thumbnail,
|
||||
viewCount: undefined,
|
||||
publishedAt: undefined,
|
||||
isLive: false,
|
||||
isShort: false
|
||||
}));
|
||||
return { items, total: Array.isArray(res?.groups?.pt) ? res.groups.pt.length : 0 };
|
||||
}
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import type { ProviderAdapter, ProviderSearchParams, SearchResult } from '../models';
|
||||
import { VideoItem } from 'src/app/shared/models/video-item.model';
|
||||
|
||||
export class RuAdapter implements ProviderAdapter {
|
||||
export class RuAdapter implements ProviderAdapter<VideoItem> {
|
||||
key = 'ru' as const;
|
||||
label = 'Rumble';
|
||||
constructor(private http: HttpClient) {}
|
||||
async search(params: ProviderSearchParams, _signal: AbortSignal): Promise<SearchResult> {
|
||||
const res = await firstValueFrom(this.http.get<any>(`/api/search`, { params: { q: params.q, providers: 'ru' } }));
|
||||
const items = (res?.groups?.ru || []).map((it: any) => ({
|
||||
async search(params: ProviderSearchParams, _signal: AbortSignal): Promise<SearchResult<VideoItem>> {
|
||||
let httpParams = new HttpParams().set('q', params.q).set('providers', 'ru');
|
||||
if (params.pageToken) httpParams = httpParams.set('page', params.pageToken);
|
||||
if (params.sort) httpParams = httpParams.set('sort', params.sort);
|
||||
const res = await firstValueFrom(this.http.get<any>(`/api/search`, { params: httpParams }));
|
||||
const items: VideoItem[] = (res?.groups?.ru || []).map((it: any) => ({
|
||||
id: it.id,
|
||||
provider: this.key,
|
||||
provider: 'rumble',
|
||||
title: it.title,
|
||||
channel: it.uploaderName,
|
||||
channelName: it.uploaderName,
|
||||
durationSec: it.duration,
|
||||
thumbUrl: it.thumbnail,
|
||||
watchUrl: it.url || '',
|
||||
views: undefined,
|
||||
publishedAt: undefined,
|
||||
isLive: false,
|
||||
isShort: false
|
||||
thumbnailUrl: it.thumbnail,
|
||||
viewCount: typeof it.views === 'number' ? it.views : undefined,
|
||||
publishedAt: it.publishedAt,
|
||||
}));
|
||||
return { items, total: Array.isArray(res?.groups?.ru) ? res.groups.ru.length : 0 };
|
||||
}
|
||||
|
||||
@@ -1,26 +1,31 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import type { ProviderAdapter, ProviderSearchParams, SearchResult } from '../models';
|
||||
import { VideoItem } from 'src/app/shared/models/video-item.model';
|
||||
|
||||
export class TwAdapter implements ProviderAdapter {
|
||||
export class TwAdapter implements ProviderAdapter<VideoItem> {
|
||||
key = 'tw' as const;
|
||||
label = 'Twitch';
|
||||
constructor(private http: HttpClient) {}
|
||||
async search(params: ProviderSearchParams, _signal: AbortSignal): Promise<SearchResult> {
|
||||
const res = await firstValueFrom(this.http.get<any>(`/api/search`, { params: { q: params.q, providers: 'tw' } }));
|
||||
const items = (res?.groups?.tw || []).map((it: any) => ({
|
||||
id: it.id,
|
||||
provider: this.key,
|
||||
title: it.title,
|
||||
channel: it.uploaderName,
|
||||
durationSec: it.duration,
|
||||
thumbUrl: it.thumbnail,
|
||||
watchUrl: it.url || '',
|
||||
views: undefined,
|
||||
publishedAt: undefined,
|
||||
isLive: it.type === 'live',
|
||||
isShort: false
|
||||
}));
|
||||
async search(params: ProviderSearchParams, _signal: AbortSignal): Promise<SearchResult<VideoItem>> {
|
||||
let httpParams = new HttpParams().set('q', params.q).set('providers', 'tw');
|
||||
if (params.pageToken) httpParams = httpParams.set('page', params.pageToken);
|
||||
if (params.sort) httpParams = httpParams.set('sort', params.sort);
|
||||
const res = await firstValueFrom(this.http.get<any>(`/api/search`, { params: httpParams }));
|
||||
const items: VideoItem[] = (res?.groups?.tw || []).map((it: any) => {
|
||||
const isChannel = String(it?.type || '').toLowerCase() === 'channel';
|
||||
return {
|
||||
id: it.id,
|
||||
provider: 'twitch',
|
||||
title: it.title,
|
||||
channelName: it.uploaderName,
|
||||
durationSec: it.duration,
|
||||
thumbnailUrl: it.thumbnail,
|
||||
viewCount: typeof it.views === 'number' ? it.views : undefined,
|
||||
publishedAt: it.publishedAt,
|
||||
channel: isChannel ? it.id : undefined,
|
||||
} as VideoItem;
|
||||
});
|
||||
return { items, total: Array.isArray(res?.groups?.tw) ? res.groups.tw.length : 0 };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,25 +1,26 @@
|
||||
import { HttpClient } from '@angular/common/http';
|
||||
import { HttpClient, HttpParams } from '@angular/common/http';
|
||||
import { firstValueFrom } from 'rxjs';
|
||||
import type { ProviderAdapter, ProviderSearchParams, SearchResult } from '../models';
|
||||
import { VideoItem } from 'src/app/shared/models/video-item.model';
|
||||
|
||||
export class YtAdapter implements ProviderAdapter {
|
||||
export class YtAdapter implements ProviderAdapter<VideoItem> {
|
||||
key = 'yt' as const;
|
||||
label = 'YouTube';
|
||||
constructor(private http: HttpClient) {}
|
||||
async search(params: ProviderSearchParams, _signal: AbortSignal): Promise<SearchResult> {
|
||||
const res = await firstValueFrom(this.http.get<any>(`/api/search`, { params: { q: params.q, providers: 'yt' } }));
|
||||
const items = (res?.groups?.yt || []).map((it: any) => ({
|
||||
async search(params: ProviderSearchParams, _signal: AbortSignal): Promise<SearchResult<VideoItem>> {
|
||||
let httpParams = new HttpParams().set('q', params.q).set('providers', 'yt');
|
||||
if (params.pageToken) httpParams = httpParams.set('page', params.pageToken);
|
||||
if (params.sort) httpParams = httpParams.set('sort', params.sort);
|
||||
const res = await firstValueFrom(this.http.get<any>(`/api/search`, { params: httpParams }));
|
||||
const items: VideoItem[] = (res?.groups?.yt || []).map((it: any) => ({
|
||||
id: it.id,
|
||||
provider: this.key,
|
||||
provider: 'youtube',
|
||||
title: it.title,
|
||||
channel: it.uploaderName,
|
||||
channelName: it.uploaderName,
|
||||
durationSec: it.duration,
|
||||
thumbUrl: it.thumbnail,
|
||||
watchUrl: it.url || '',
|
||||
views: undefined,
|
||||
publishedAt: undefined,
|
||||
isLive: it.type === 'live',
|
||||
isShort: it.isShort === true
|
||||
thumbnailUrl: it.thumbnail,
|
||||
viewCount: typeof it.views === 'number' ? it.views : (typeof it.viewCount === 'number' ? it.viewCount : undefined),
|
||||
publishedAt: it.publishedAt,
|
||||
}));
|
||||
return { items, total: Array.isArray(res?.groups?.yt) ? res.groups.yt.length : 0 };
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user