drop usage of async
This commit is contained in:
parent
167b591d21
commit
2b2607df61
1 changed files with 19 additions and 10 deletions
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue