radiomanifest.js 926 B

123456789101112131415161718192021222324252627282930313233
  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. 'Wombat': { name: 'Radio Wombat', description: 'supporto parziale!', url: 'https://radiowombat.net' },
  8. // 'RBO': { }
  9. },
  10. currentRadio : null,
  11. async get (id) {
  12. // check if this radio id exists
  13. if (!RM.radio[id]) {
  14. throw new Error('This radio id does not exists!')
  15. }
  16. // check if is cached, load it otherwise
  17. if (!cachedRadiomanifest[id]) {
  18. const radio = RM.radio[id]
  19. cachedRadiomanifest[id] = await radiomanifest.get(radio.url)
  20. }
  21. this.currentRadio = cachedRadiomanifest[id]
  22. return cachedRadiomanifest[id]
  23. }
  24. }
  25. export default RM