Refac move sponsorblock into video endpoint (#787)

This commit is contained in:
Merlin
2024-08-23 18:42:13 +02:00
committed by GitHub
parent 6d27b69799
commit 37389e91f5
7 changed files with 33 additions and 58 deletions

View File

@@ -1,23 +0,0 @@
import defaultHeaders from '../../configuration/defaultHeaders';
import getApiUrl from '../../configuration/getApiUrl';
import getFetchCredentials from '../../configuration/getFetchCredentials';
import isDevEnvironment from '../../functions/isDevEnvironment';
const loadSponsorblockByVideoId = async (youtubeId: string) => {
const apiUrl = getApiUrl();
const response = await fetch(`${apiUrl}/api/video/${youtubeId}/sponsor/`, {
headers: defaultHeaders,
credentials: getFetchCredentials(),
});
const videos = await response.json();
if (isDevEnvironment()) {
console.log('loadSponsorblockByVideoId', videos);
}
return videos;
};
export default loadSponsorblockByVideoId;

View File

@@ -2,8 +2,9 @@ import defaultHeaders from '../../configuration/defaultHeaders';
import getApiUrl from '../../configuration/getApiUrl';
import getFetchCredentials from '../../configuration/getFetchCredentials';
import isDevEnvironment from '../../functions/isDevEnvironment';
import { VideoResponseType } from '../../pages/Video';
const loadVideoById = async (youtubeId: string) => {
const loadVideoById = async (youtubeId: string): Promise<VideoResponseType> => {
const apiUrl = getApiUrl();
const response = await fetch(`${apiUrl}/api/video/${youtubeId}/`, {

View File

@@ -2,7 +2,14 @@ import defaultHeaders from '../../configuration/defaultHeaders';
import getApiUrl from '../../configuration/getApiUrl';
import getFetchCredentials from '../../configuration/getFetchCredentials';
import isDevEnvironment from '../../functions/isDevEnvironment';
import { SortByType, SortOrderType } from '../../pages/Home';
import { ConfigType, SortByType, SortOrderType, VideoType } from '../../pages/Home';
import { PaginationType } from '../../components/Pagination';
export type VideoListByFilterResponseType = {
data?: VideoType[];
config?: ConfigType;
paginate?: PaginationType;
};
type WatchTypes = 'watched' | 'unwatched' | 'continue';
type VideoTypes = 'videos' | 'streams' | 'shorts';
@@ -17,7 +24,9 @@ type FilterType = {
type?: VideoTypes;
};
const loadVideoListByFilter = async (filter: FilterType) => {
const loadVideoListByFilter = async (
filter: FilterType,
): Promise<VideoListByFilterResponseType> => {
const apiUrl = getApiUrl();
const searchParams = new URLSearchParams();