|
|
|
@ -4,11 +4,15 @@ import concat from 'lodash/concat' |
|
|
|
|
|
|
|
|
|
|
|
import type { Episodes } from 'requests/getMatchPlaylists' |
|
|
|
import type { Episodes } from 'requests/getMatchPlaylists' |
|
|
|
|
|
|
|
|
|
|
|
import type { Chapters } from 'features/StreamPlayer/types' |
|
|
|
import type { Chapters, Chapter } from 'features/StreamPlayer/types' |
|
|
|
|
|
|
|
|
|
|
|
import type { MatchPlaylistOption, PlaylistOption } from '../../types' |
|
|
|
import type { MatchPlaylistOption, PlaylistOption } from '../../types' |
|
|
|
import { FULL_GAME_KEY } from '../../helpers/buildPlaylists' |
|
|
|
import { FULL_GAME_KEY } from '../../helpers/buildPlaylists' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Формирует эпизоды плейлиста Полный матч |
|
|
|
|
|
|
|
* API не выдает полный матч как плейлист, формируем на фронте |
|
|
|
|
|
|
|
* */ |
|
|
|
const getFullMatchChapters = (url: string, playlist: MatchPlaylistOption) => { |
|
|
|
const getFullMatchChapters = (url: string, playlist: MatchPlaylistOption) => { |
|
|
|
const duration = (playlist.duration ?? 0) * 1000 |
|
|
|
const duration = (playlist.duration ?? 0) * 1000 |
|
|
|
return [ |
|
|
|
return [ |
|
|
|
@ -17,6 +21,7 @@ const getFullMatchChapters = (url: string, playlist: MatchPlaylistOption) => { |
|
|
|
endMs: duration, |
|
|
|
endMs: duration, |
|
|
|
endOffsetMs: duration, |
|
|
|
endOffsetMs: duration, |
|
|
|
index: 0, |
|
|
|
index: 0, |
|
|
|
|
|
|
|
isFullMatchChapter: true, |
|
|
|
startMs: 0, |
|
|
|
startMs: 0, |
|
|
|
startOffsetMs: 0, |
|
|
|
startOffsetMs: 0, |
|
|
|
url, |
|
|
|
url, |
|
|
|
@ -24,6 +29,9 @@ const getFullMatchChapters = (url: string, playlist: MatchPlaylistOption) => { |
|
|
|
] |
|
|
|
] |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Формирует эпизоды плейлистов матча и игроков |
|
|
|
|
|
|
|
* */ |
|
|
|
const getPlaylistChapters = (url: string, episodes: Episodes) => reduce( |
|
|
|
const getPlaylistChapters = (url: string, episodes: Episodes) => reduce( |
|
|
|
episodes, |
|
|
|
episodes, |
|
|
|
( |
|
|
|
( |
|
|
|
@ -35,7 +43,7 @@ const getPlaylistChapters = (url: string, episodes: Episodes) => reduce( |
|
|
|
|
|
|
|
|
|
|
|
const episodeDuration = (episode.e - episode.s) * 1000 |
|
|
|
const episodeDuration = (episode.e - episode.s) * 1000 |
|
|
|
const prevVideoEndMs = last(acc)?.endMs || 0 |
|
|
|
const prevVideoEndMs = last(acc)?.endMs || 0 |
|
|
|
const nextChapter = { |
|
|
|
const nextChapter: Chapter = { |
|
|
|
duration: episodeDuration, |
|
|
|
duration: episodeDuration, |
|
|
|
endMs: prevVideoEndMs + episodeDuration, |
|
|
|
endMs: prevVideoEndMs + episodeDuration, |
|
|
|
endOffsetMs: episode.e * 1000, |
|
|
|
endOffsetMs: episode.e * 1000, |
|
|
|
@ -54,6 +62,9 @@ type Args = { |
|
|
|
url: string, |
|
|
|
url: string, |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Формирует список эпизодов из выбранного плейлиста для плеера |
|
|
|
|
|
|
|
*/ |
|
|
|
export const buildChapters = ({ |
|
|
|
export const buildChapters = ({ |
|
|
|
selectedPlaylist, |
|
|
|
selectedPlaylist, |
|
|
|
url, |
|
|
|
url, |
|
|
|
|