drop usage of async

This commit is contained in:
Niko Storni 2020-03-12 21:54:51 +01:00
parent 167b591d21
commit 2b2607df61

View file

@ -1,18 +1,27 @@
const { Lbryio } = require('lbryinc');
const { URL, LBRY_TV_STREAMING_API } = require('../../config');
async function generateStreamUrl(claimName, claimId, apiUrl) {
function generateStreamUrl(claimName, claimId, apiUrl) {
let prefix = LBRY_TV_STREAMING_API || apiUrl;
try {
let localeResponse = await Lbryio.call('locale', 'get', {}, 'post');
if (prefix.split('//').length > 1) {
prefix = prefix.replace('//', '//' + localeResponse.continent + '.');
}
} catch (err) {
console.error(err.stack || err);
if (prefix.includes('localhost')) {
return `${prefix}/content/claims/${claimName}/${claimId}/stream`;
}
console.log(`${prefix}/content/claims/${claimName}/${claimId}/stream`);
return `${prefix}/content/claims/${claimName}/${claimId}/stream`;
new Promise((resolve, reject) => {
Lbryio.call('locale', 'get', {}, 'post').then(result => {
if (prefix.split('//').length > 1) {
prefix = prefix.replace('//', '//' + result.continent + '.');
}
resolve(prefix);
});
})
.then(p => {
console.log(`${p}/content/claims/${claimName}/${claimId}/stream`);
return `${p}/content/claims/${claimName}/${claimId}/stream`;
})
.catch(err => {
console.error(err.stack || err);
return `${prefix}/content/claims/${claimName}/${claimId}/stream`;
});
}
function generateEmbedUrl(claimName, claimId) {