A music player that connects to your cloud/distributed storage.
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fallback tags

+29 -7
+29 -7
src/Javascript/processing.js
··· 11 11 function processContext(context) { 12 12 const initialPromise = Promise.resolve([]) 13 13 14 - return context.urlsForTags.reduce((accumulator, urls) => { 14 + return context.urlsForTags.reduce((accumulator, urls, idx) => { 15 15 let getUrl 16 16 let headUrl 17 17 18 - return accumulator.then(col => 19 - transformUrl(urls.getUrl) 18 + return accumulator.then(col => { 19 + const filename = context 20 + .receivedFilePaths[idx] 21 + .split("/") 22 + .reverse()[0] 23 + .replace(/\.\w+$/, "") 24 + 25 + return transformUrl(urls.getUrl) 20 26 .then(url => { getUrl = url; return transformUrl(urls.headUrl) }) 21 - .then(url => { headUrl = url; return getTags(getUrl, headUrl) }) 27 + .then(url => { headUrl = url; return getTags(getUrl, headUrl, filename) }) 22 28 .then(r => col.concat(r)) 23 29 .catch(e => { 24 30 console.error(e) 25 31 return col.concat(null) 26 32 }) 27 - ) 33 + }) 28 34 29 35 }, initialPromise).then(col => { 30 36 context.receivedTags = col ··· 52 58 53 59 54 60 55 - function getTags(getUrl, headUrl) { 61 + function getTags(getUrl, headUrl, filename) { 56 62 const reader = new StreamingHttpTokenReader(headUrl, readerConfiguration) 57 63 58 64 return reader.init().then(_ => { ··· 63 69 reader.contentType, 64 70 parserConfiguration 65 71 ) 66 - }).then(pickTags) 72 + }) 73 + .then(pickTags) 74 + .catch(_ => fallbackTags(filename)) 67 75 } 68 76 69 77 ··· 82 90 picture: null 83 91 } 84 92 } 93 + 94 + 95 + function fallbackTags(filename) { 96 + return { 97 + disc: 1, 98 + nr: 1, 99 + album: "Unknown", 100 + artist: "Unknown", 101 + title: filename, 102 + genre: null, 103 + year: null, 104 + picture: null 105 + } 106 + }