radiomanifest.js 819 B

1234567891011121314151617181920212223242526272829303132
  1. import radiomanifest from 'radiomanifest'
  2. const cachedRadiomanifest = {}
  3. const RM = {
  4. radio: {
  5. 'ROR': { name: 'Radio Onda Rossa', description: 'un segnale che disturba', url: 'https://www.ondarossa.info' },
  6. 'Spore': { name: 'Radio Spore', description: 'una voce senza padrone', url: 'https://radiospore.oziosi.org' },
  7. // 'RBO': { }
  8. },
  9. currentRadio : null,
  10. async get (id) {
  11. // check if this radio id exists
  12. if (!RM.radio[id]) {
  13. throw new Error('This radio id does not exists!')
  14. }
  15. // check if is cached, load it otherwise
  16. if (!cachedRadiomanifest[id]) {
  17. const radio = RM.radio[id]
  18. cachedRadiomanifest[id] = await radiomanifest.get(radio.url)
  19. }
  20. this.currentRadio = cachedRadiomanifest[id]
  21. return cachedRadiomanifest[id]
  22. }
  23. }
  24. export default RM