2020-01-24 11:25:31 -05:00
|
|
|
const { URL, LBRY_TV_STREAMING_API } = require('../../config');
|
2020-04-08 13:10:33 -04:00
|
|
|
const { getCookie } = require('../../ui/util/saved-passwords');
|
2020-03-17 14:58:34 -04:00
|
|
|
|
|
|
|
const CONTINENT_COOKIE = 'continent';
|
2019-12-16 12:44:31 -05:00
|
|
|
|
2020-04-08 14:49:37 -04:00
|
|
|
function generateStreamUrl(claimName, claimId, apiUrl, streamingContinent, useDefaultServer) {
|
2020-03-17 14:58:34 -04:00
|
|
|
let prefix = LBRY_TV_STREAMING_API || apiUrl;
|
2020-04-08 14:49:37 -04:00
|
|
|
const continent = useDefaultServer ? undefined : streamingContinent || getCookie(CONTINENT_COOKIE);
|
2020-03-17 14:58:34 -04:00
|
|
|
|
|
|
|
if (continent && prefix.split('//').length > 1) {
|
|
|
|
prefix = prefix.replace('//', '//' + continent + '.');
|
|
|
|
}
|
|
|
|
|
2020-03-12 17:46:37 -04:00
|
|
|
return `${prefix}/content/claims/${claimName}/${claimId}/stream`;
|
2019-10-21 10:50:34 -04:00
|
|
|
}
|
2019-10-22 10:40:57 -04:00
|
|
|
|
2019-12-16 12:44:31 -05:00
|
|
|
function generateEmbedUrl(claimName, claimId) {
|
2019-12-20 11:26:55 -05:00
|
|
|
return `${URL}/$/embed/${claimName}/${claimId}`;
|
2019-12-16 12:44:31 -05:00
|
|
|
}
|
|
|
|
|
2020-03-25 17:49:14 -04:00
|
|
|
function generateDownloadUrl(claimName, claimId) {
|
2020-03-30 09:14:01 -04:00
|
|
|
return `${URL}/$/download/${claimName}/${claimId}`;
|
2020-01-07 13:17:43 -05:00
|
|
|
}
|
|
|
|
|
2020-03-27 14:57:03 -04:00
|
|
|
function generateDirectUrl(claimName, claimId) {
|
|
|
|
return `${URL}/$/stream/${claimName}/${claimId}`;
|
|
|
|
}
|
|
|
|
|
2019-11-07 14:39:22 -05:00
|
|
|
// module.exports needed since the web server imports this function
|
2020-03-27 14:57:03 -04:00
|
|
|
module.exports = { generateStreamUrl, generateEmbedUrl, generateDownloadUrl, generateDirectUrl, CONTINENT_COOKIE };
|