20 lines
No EOL
579 B
JavaScript
20 lines
No EOL
579 B
JavaScript
export function parseFiles(files) {
|
|
for (let i = 0; i < files.length; i++) {
|
|
parseFile(files[i])
|
|
}
|
|
return files
|
|
}
|
|
|
|
export function parseFile(file) {
|
|
file.url = 'https://cdn.nfp.is' + file.path
|
|
file.magnet = null
|
|
file.meta = JSON.parse(file.meta || '{}') || {}
|
|
if (file.meta.torrent) {
|
|
file.magnet = 'magnet:?'
|
|
+ 'xl=' + file.size
|
|
+ '&dn=' + encodeURIComponent(file.meta.torrent.name)
|
|
+ '&xt=urn:btih:' + file.meta.torrent.hash
|
|
+ file.meta.torrent.announce.map(item => ('&tr=' + encodeURIComponent(item))).join('')
|
|
}
|
|
return file
|
|
} |