radiomanifest.js 1.1 KB

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