Remove old apis
This commit is contained in:
parent
e4a88a5e9b
commit
a6106f7427
3 changed files with 8 additions and 52 deletions
|
@ -1,6 +1,6 @@
|
|||
// @flow
|
||||
import * as ICONS from 'constants/icons';
|
||||
import { LIVESTREAM_LIVE_API } from 'constants/livestream';
|
||||
import { NEW_LIVESTREAM_LIVE_API } from 'constants/livestream';
|
||||
import React from 'react';
|
||||
import Icon from 'component/common/icon';
|
||||
import Spinner from 'component/spinner';
|
||||
|
@ -14,7 +14,7 @@ export default function LivestreamList() {
|
|||
|
||||
React.useEffect(() => {
|
||||
function checkCurrentLivestreams() {
|
||||
fetch(LIVESTREAM_LIVE_API)
|
||||
fetch(`${NEW_LIVESTREAM_LIVE_API}/all`)
|
||||
.then((res) => res.json())
|
||||
.then((res) => {
|
||||
setLoading(false);
|
||||
|
@ -26,7 +26,7 @@ export default function LivestreamList() {
|
|||
const livestreamMap = res.data.reduce((acc, curr) => {
|
||||
return {
|
||||
...acc,
|
||||
[curr.claimId]: curr,
|
||||
[curr.ChannelClaimID]: curr,
|
||||
};
|
||||
}, {});
|
||||
|
||||
|
@ -53,7 +53,6 @@ export default function LivestreamList() {
|
|||
<Spinner delayed />
|
||||
</div>
|
||||
)}
|
||||
|
||||
{livestreamMap && Object.keys(livestreamMap).length > 0 && (
|
||||
<ClaimTilesDiscover
|
||||
showNoSourceClaims
|
||||
|
@ -67,7 +66,7 @@ export default function LivestreamList() {
|
|||
|
||||
return (
|
||||
<span className="livestream__viewer-count">
|
||||
{livestream.viewCount} <Icon icon={ICONS.EYE} />
|
||||
{livestream.ViewerCount} <Icon icon={ICONS.EYE} />
|
||||
</span>
|
||||
);
|
||||
}}
|
||||
|
|
|
@ -1,9 +1,3 @@
|
|||
export const LIVESTREAM_CDN_DOMAIN = 'cdn.odysee.live';
|
||||
export const LIVESTREAM_STREAM_DOMAIN = 'stream.odysee.com';
|
||||
export const LIVESTREAM_STREAM_X_PULL = 'bitwaveCDN';
|
||||
|
||||
export const LIVESTREAM_EMBED_URL = 'https://player.odysee.live/odysee';
|
||||
export const LIVESTREAM_LIVE_API = 'https://api.live.odysee.com/v1/odysee/live';
|
||||
export const LIVESTREAM_REPLAY_API = 'https://api.live.odysee.com/v1/replays/odysee';
|
||||
export const LIVESTREAM_RTMP_URL = 'rtmp://stream.odysee.com/live';
|
||||
export const LIVESTREAM_KILL = 'https://api.odysee.live/streams/kill?app=live&';
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
// @flow
|
||||
import {
|
||||
LIVESTREAM_LIVE_API,
|
||||
NEW_LIVESTREAM_LIVE_API,
|
||||
LIVESTREAM_KILL,
|
||||
LIVESTREAM_STARTS_SOON_BUFFER,
|
||||
} from 'constants/livestream';
|
||||
import { NEW_LIVESTREAM_LIVE_API, LIVESTREAM_KILL, LIVESTREAM_STARTS_SOON_BUFFER } from 'constants/livestream';
|
||||
import { toHex } from 'util/hex';
|
||||
import Lbry from 'lbry';
|
||||
import moment from 'moment';
|
||||
|
@ -82,20 +77,6 @@ export function getTipValues(superChatsByAmount: Array<Comment>) {
|
|||
return { superChatsChannelUrls, superChatsFiatAmount, superChatsLBCAmount };
|
||||
}
|
||||
|
||||
const transformLivestreamData = (data: Array<any>): LivestreamInfo => {
|
||||
return data.reduce((acc, curr) => {
|
||||
acc[curr.claimId] = {
|
||||
url: curr.url,
|
||||
type: curr.type,
|
||||
live: curr.live,
|
||||
viewCount: curr.viewCount,
|
||||
creatorId: curr.claimId,
|
||||
startedStreaming: moment(curr.timestamp),
|
||||
};
|
||||
return acc;
|
||||
}, {});
|
||||
};
|
||||
|
||||
const transformNewLivestreamData = (data: Array<any>): LivestreamInfo => {
|
||||
return data.reduce((acc, curr) => {
|
||||
acc[curr.ChannelClaimID] = {
|
||||
|
@ -114,15 +95,8 @@ export const fetchLiveChannels = async (): Promise<LivestreamInfo> => {
|
|||
const newApiResponse = await fetch(`${NEW_LIVESTREAM_LIVE_API}/all`);
|
||||
const newApiData = (await newApiResponse.json()).data;
|
||||
if (!newApiData) throw new Error();
|
||||
const newTranslatedData = transformNewLivestreamData(newApiData);
|
||||
|
||||
const oldApiResponse = await fetch(`${LIVESTREAM_LIVE_API}`);
|
||||
const oldApiData = (await oldApiResponse.json()).data;
|
||||
if (!oldApiData) throw new Error();
|
||||
const oldTranslatedData = transformLivestreamData(oldApiData);
|
||||
const mergedData = { ...oldTranslatedData, ...newTranslatedData };
|
||||
|
||||
return mergedData;
|
||||
return transformNewLivestreamData(newApiData);
|
||||
};
|
||||
|
||||
/**
|
||||
|
@ -132,21 +106,10 @@ export const fetchLiveChannels = async (): Promise<LivestreamInfo> => {
|
|||
*/
|
||||
export const fetchLiveChannel = async (channelId: string): Promise<LiveChannelStatus> => {
|
||||
const newApiEndpoint = NEW_LIVESTREAM_LIVE_API;
|
||||
const oldApiEndpoint = LIVESTREAM_LIVE_API;
|
||||
const newApiResponse = await fetch(`${newApiEndpoint}/is_live?channel_claim_id=${channelId}`);
|
||||
const newApiData = (await newApiResponse.json()).data;
|
||||
let isLive = newApiData.Live;
|
||||
let translatedData;
|
||||
// transform data to old API standard
|
||||
if (isLive) {
|
||||
translatedData = transformNewLivestreamData([newApiData]);
|
||||
} else {
|
||||
const oldApiResponse = await fetch(`${oldApiEndpoint}/${channelId}`);
|
||||
const oldApiData = (await oldApiResponse.json()).data;
|
||||
|
||||
isLive = oldApiData.live;
|
||||
translatedData = transformLivestreamData([oldApiData]);
|
||||
}
|
||||
const isLive = newApiData.Live;
|
||||
const translatedData = transformNewLivestreamData([newApiData]);
|
||||
|
||||
try {
|
||||
if (isLive === false) {
|
||||
|
|
Loading…
Reference in a new issue