Download pool/shard002/JavaScript/0012714_msi.js from Variable-role/sajaniemi_variable_dataset_large: direct link, hf CLI and curl.
- Browser
- Download file 2.15 kB
-
https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard002/JavaScript/0012714_msi.js
- Command line
-
hf download hf://datasets/Variable-role/sajaniemi_variable_dataset_large/pool/shard002/JavaScript/0012714_msi.js
-
curl -L -o 0012714_msi.js https://huggingface.co/datasets/Variable-role/sajaniemi_variable_dataset_large/resolve/main/pool/shard002/JavaScript/0012714_msi.js
2.15 kB
| import fetch from 'node-fetch'; | |
| import Promise from 'bluebird'; | |
| import logger from '../utils/logger'; | |
| async function getSongDetails(songKeys, songtype) { | |
| const msiSongDetailsEndpoint = 'http://msidb.org/WS/MSIDb.php?auth=and01&uc=0&format=json'; | |
| const songDetailRequestArr = []; | |
| const songDetailsResponseArr = []; | |
| songKeys.map((songKey) => { | |
| songDetailRequestArr.push( | |
| fetch(`${msiSongDetailsEndpoint}&id=${songKey}&api=${songtype === 'ms' ? 's' : 'as'}`)); | |
| }); | |
| await Promise.all(songDetailRequestArr).then(responses => | |
| Promise.all(responses.map(res => res.json())).then((jsonResponses) => { | |
| jsonResponses.map((jsonData) => { | |
| jsonData.details[0].details.SONG_URL = jsonData.details[0].details.LYRICS_URL | |
| .replace('http://en.msidb.org/Lyrics', 'http://gaanam.info/MSI/Audio') | |
| .replace('html', 'mp3'); | |
| songDetailsResponseArr.push(jsonData.details[0].details); | |
| }); | |
| }) | |
| .catch((error) => { | |
| console.log(error); | |
| throw error; | |
| })) | |
| .catch((error) => { | |
| logger.error(`Error occurred : ${error}`); | |
| throw error; | |
| }); | |
| return songDetailsResponseArr; | |
| } | |
| async function getSongIDInfo(params) { | |
| try { | |
| const songKeys = []; | |
| let msiSongIdEndpoint = 'http://msidb.org/WS/MSIDb.php?auth=and01&api=srch&format=json'; | |
| msiSongIdEndpoint = msiSongIdEndpoint.concat(`&db=${params.songtype}&fuzzy=${params.fuzzy}&kwd=${params.songname}`); | |
| const songIDResponse = await fetch(msiSongIdEndpoint); | |
| const songIDJSONResponse = await songIDResponse.json(); | |
| songIDJSONResponse.details.map(songKey => songKeys.push(songKey.details.S_ID)); | |
| logger.info(`${songKeys.length} songs found`); | |
| const songDetailsResponse = await getSongDetails(songKeys, params.songtype); | |
| return songDetailsResponse; | |
| } catch (error) { | |
| logger.error(`Error occurred : ${error}`); | |
| throw error; | |
| } | |
| } | |
| export { | |
| getSongIDInfo | |
| }; | |