You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
spa_instat_tv/src/requests/getVideos.tsx

40 lines
879 B

import isEmpty from 'lodash/isEmpty'
import filter from 'lodash/filter'
import { API_ROOT } from 'config'
import { callApi } from 'helpers'
const filterByIds = (videos: Videos) => {
const zeroIdVideos = filter(videos, { abc: '0' })
return isEmpty(zeroIdVideos) ? videos : zeroIdVideos
}
export type Video = {
/** id дорожки */
abc: string,
duration: number,
period: number,
quality: string,
start_ms: number,
url: string,
}
export type Videos = Array<Video>
export const getVideos = (
sportType: number,
matchId: number,
): Promise<Videos> => {
const config = {
body: {
match_id: matchId,
sport_id: sportType,
},
}
return callApi({
config,
// эндпоинт удалили со стейджинга, временно ссылаемся на прод
url: `${API_ROOT}/videoapi`,
}).then(filterByIds)
}