Revert "Localized player urls for lbry.tv"
This commit is contained in:
parent
5a2d96f2e1
commit
48a441aae8
2 changed files with 3 additions and 28 deletions
|
@ -1,35 +1,10 @@
|
|||
const { Lbryio } = require('lbryinc');
|
||||
const { URL, LBRY_TV_STREAMING_API } = require('../../config');
|
||||
const { getCookie, setCookie } = require('../../ui/util/saved-passwords');
|
||||
|
||||
const CONTINENT_COOKIE = 'continent';
|
||||
|
||||
function generateStreamUrl(claimName, claimId, apiUrl) {
|
||||
let prefix = LBRY_TV_STREAMING_API || apiUrl;
|
||||
const continent = getCookie(CONTINENT_COOKIE);
|
||||
|
||||
if (continent && prefix.split('//').length > 1) {
|
||||
prefix = prefix.replace('//', '//' + continent + '.');
|
||||
} else {
|
||||
Lbryio.call('locale', 'get', {}, 'post').then(result => {
|
||||
const userContinent = getSupportedCDN(result.continent);
|
||||
setCookie(CONTINENT_COOKIE, userContinent, 1);
|
||||
});
|
||||
}
|
||||
|
||||
const prefix = LBRY_TV_STREAMING_API || apiUrl;
|
||||
return `${prefix}/content/claims/${claimName}/${claimId}/stream`;
|
||||
}
|
||||
|
||||
function getSupportedCDN(continent) {
|
||||
switch (continent) {
|
||||
case 'NA':
|
||||
case 'EU':
|
||||
return continent;
|
||||
default:
|
||||
return 'NA';
|
||||
}
|
||||
}
|
||||
|
||||
function generateEmbedUrl(claimName, claimId) {
|
||||
return `${URL}/$/embed/${claimName}/${claimId}`;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@ const isProduction = process.env.NODE_ENV === 'production';
|
|||
const maxExpiration = 2147483647;
|
||||
let sessionPassword;
|
||||
|
||||
export function setCookie(name: string, value: string, expirationDaysOnWeb: number) {
|
||||
function setCookie(name: string, value: string, expirationDaysOnWeb: number) {
|
||||
let expires = '';
|
||||
if (expirationDaysOnWeb) {
|
||||
let date = new Date();
|
||||
|
@ -27,7 +27,7 @@ export function setCookie(name: string, value: string, expirationDaysOnWeb: numb
|
|||
document.cookie = cookie;
|
||||
}
|
||||
|
||||
export function getCookie(name: string) {
|
||||
function getCookie(name: string) {
|
||||
const nameEQ = name + '=';
|
||||
const cookies = document.cookie.split(';');
|
||||
|
||||
|
|
Loading…
Reference in a new issue