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