Spaces:
Sleeping
Sleeping
Download src/sources/http.js from Pappu100Code/nodelinktest: direct link, hf CLI and curl.
- Browser
- Download file 1.49 kB
-
https://huggingface.co/spaces/Pappu100Code/nodelinktest/resolve/main/src/sources/http.js
- Command line
-
hf download hf://spaces/Pappu100Code/nodelinktest/src/sources/http.js
-
curl -L -o http.js https://huggingface.co/spaces/Pappu100Code/nodelinktest/resolve/main/src/sources/http.js
1.49 kB
| import { debugLog, makeRequest, encodeTrack } from '../utils.js' | |
| async function loadFrom(uri) { | |
| const type = uri.startsWith('http://') ? 'http' : 'https' | |
| debugLog('loadtracks', 4, { type: 1, loadType: 'track', sourceName: type, query: uri }) | |
| const data = await makeRequest(uri, { method: 'HEAD' }) | |
| if (data.error) { | |
| debugLog('loadtracks', 4, { type: 3, loadType: 'track', sourceName: type, query: uri, message: 'Not possible to connect to the URL.', }) | |
| return { | |
| message: 'Not possible to connect to the URL.', | |
| severity: 'fault', | |
| cause: 'Unknown' | |
| } | |
| } | |
| if (!data.headers || !data.headers['content-type']?.startsWith('audio/')) { | |
| debugLog('loadtracks', 4, { type: 2, loadType: 'error', sourceName: type, query: uri, message: 'Url is not a playable stream.' }) | |
| return { | |
| loadType: 'error', | |
| data: { | |
| message: 'URL is not a playable stream.', | |
| severity: 'common', | |
| cause: 'Invalid URL' | |
| } | |
| } | |
| } | |
| const track = { | |
| identifier: 'unknown', | |
| isSeekable: false, | |
| author: 'unknown', | |
| length: -1, | |
| isStream: false, | |
| position: 0, | |
| title: 'unknown', | |
| uri, | |
| artworkUrl: null, | |
| isrc: null, | |
| sourceName: type | |
| } | |
| debugLog('loadtracks', 4, { type: 2, loadType: 'track', sourceName: type, track, query: uri }) | |
| return { | |
| loadType: 'track', | |
| data: { | |
| encoded: encodeTrack(track), | |
| info: track, | |
| pluginInfo: {} | |
| } | |
| } | |
| } | |
| export default { | |
| loadFrom | |
| } |