ramda#mergeAll TypeScript Examples
The following examples show how to use
ramda#mergeAll.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: songFetcher.ts From radiopanel with GNU General Public License v3.0 | 5 votes |
fetchSongData = async (streamUrl: string, streamType: string) => {
const userAgent = new UserAgent();
if(streamType == "icecast"){
const radioServerResponse = await got.get(streamUrl ,{
resolveBodyOnly: true,
responseType: 'json',
timeout: 5000,
headers: {
'User-Agent': userAgent.toString()
}
}).catch((e) => {});
if (Array.isArray(path(['icestats', 'source'])(radioServerResponse))) {
const source = mergeAll<any>(path<object[]>(['icestats', 'source'])(radioServerResponse));
return (prop('title')(source) as string);
} else {
return pathOr('', ['icestats', 'source', 'title'])(radioServerResponse);
}
};
if(streamType == "shoutcast"){
const radioServerResponse = await got.get(streamUrl ,{
resolveBodyOnly: true,
responseType: 'json',
timeout: 5000,
headers: {
'User-Agent': userAgent.toString()
}
}).catch(() => {});
return pathOr('', ['songtitle'])(radioServerResponse);
};
if(streamType == "zeno"){
const radioServerResponse = await got.get(streamUrl, {
resolveBodyOnly: true,
responseType: 'json',
timeout: 5000,
headers: {
'User-Agent': userAgent.toString()
}
}).catch(() => {});
return pathOr('', ['artist'])(radioServerResponse) + ' - ' + pathOr('', ['title'])(radioServerResponse);
};
}