diff --git a/config.js b/config.js index 8e827b7db..dd5700c60 100644 --- a/config.js +++ b/config.js @@ -6,7 +6,7 @@ const config = { URL: 'https://lbry.tv', SITE_TITLE: 'lbry.tv', LBRY_TV_API: 'https://api.lbry.tv', - LBRY_TV_STREAMING_API: 'https://lbryplayer.xyz', + LBRY_TV_STREAMING_API: 'https://cdn.lbryplayer.xyz', WELCOME_VERSION: 1.0, }; diff --git a/lbrytv/src/html.js b/lbrytv/src/html.js index 2f288d61b..9ba7f7ba1 100644 --- a/lbrytv/src/html.js +++ b/lbrytv/src/html.js @@ -67,7 +67,7 @@ function buildClaimOgMetadata(uri, claim, overrideOptions = {}) { let imageThumbnail; if (Number(claim.fee) <= 0 && claim.source_media_type && claim.source_media_type.startsWith('image/')) { - imageThumbnail = generateStreamUrl(claim.name, claim.claim_id, undefined, undefined, true); + imageThumbnail = generateStreamUrl(claim.name, claim.claim_id); } const claimThumbnail = escapeHtmlProperty(claim.thumbnail_url) || imageThumbnail || `${URL}/v2-og.png`; diff --git a/lbrytv/src/routes.js b/lbrytv/src/routes.js index 1f602ce37..3568eaf43 100644 --- a/lbrytv/src/routes.js +++ b/lbrytv/src/routes.js @@ -1,6 +1,5 @@ const { getHtml } = require('./html'); -const { Lbryio } = require('lbryinc/dist/bundle.es.js'); -const { generateStreamUrl, CONTINENT_COOKIE } = require('../../ui/util/lbrytv'); +const { generateStreamUrl } = require('../../ui/util/lbrytv'); const fetch = require('node-fetch'); const Router = require('@koa/router'); @@ -12,32 +11,10 @@ const router = new Router(); function getStreamUrl(ctx) { const { claimName, claimId } = ctx.params; - // hack to get around how we managing the continent cookie - // defaulting to "NA" becasue saved-passwords.js assumes it's in the browser and won't work properly - // changes need to be made to that to better work with the server - const streamingContinentCookie = ctx.cookies.get(CONTINENT_COOKIE) || 'NA'; - const streamUrl = generateStreamUrl(claimName, claimId, undefined, streamingContinentCookie); + const streamUrl = generateStreamUrl(claimName, claimId); return streamUrl; } -function getSupportedCDN(continent) { - switch (continent) { - case 'NA': - case 'AS': - case 'EU': - return continent; - default: - return 'NA'; - } -} - -async function fetchContinentCookie(ip) { - return Lbryio.call('locale', 'get', { ip }, 'post').then(result => { - const userContinent = getSupportedCDN(result.continent); - return userContinent; - }); -} - router.get(`/$/download/:claimName/:claimId`, async ctx => { const streamUrl = getStreamUrl(ctx); const downloadUrl = `${streamUrl}?download=1`; @@ -50,15 +27,6 @@ router.get(`/$/stream/:claimName/:claimId`, async ctx => { }); router.get('*', async ctx => { - const hasContinentCookie = ctx.cookies.get(CONTINENT_COOKIE); - const ip = ctx.ip; - - if (!hasContinentCookie) { - try { - const continentValue = await fetchContinentCookie(ip); - ctx.cookies.set(CONTINENT_COOKIE, continentValue, { httpOnly: false }); - } catch (e) {} - } const html = await getHtml(ctx); ctx.body = html; }); diff --git a/ui/util/lbrytv.js b/ui/util/lbrytv.js index b1297d033..9ff34c085 100644 --- a/ui/util/lbrytv.js +++ b/ui/util/lbrytv.js @@ -1,17 +1,9 @@ const { URL, LBRY_TV_STREAMING_API } = require('../../config'); -const { getCookie } = require('../../ui/util/saved-passwords'); const CONTINENT_COOKIE = 'continent'; -function generateStreamUrl(claimName, claimId, apiUrl, streamingContinent, useDefaultServer) { - let prefix = LBRY_TV_STREAMING_API || apiUrl; - const continent = useDefaultServer ? undefined : streamingContinent || getCookie(CONTINENT_COOKIE); - - if (continent && prefix.split('//').length > 1) { - prefix = prefix.replace('//', '//' + continent + '.'); - } - - return `${prefix}/content/claims/${claimName}/${claimId}/stream`; +function generateStreamUrl(claimName, claimId) { + return `${LBRY_TV_STREAMING_API}/content/claims/${claimName}/${claimId}/stream`; } function generateEmbedUrl(claimName, claimId) {