radiomanifest.js 895 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. import radiomanifest from "@radiomanifest/radiomanifest";
  2. const knownRadios = {
  3. "https://www.ondarossa.info": {
  4. "name": "ror"
  5. },
  6. "https://radiospore.oziosi.org": {},
  7. // "https://radiowombat.net": {},
  8. // "https://test.radiogramma.org": {},
  9. "https://radioblackout.org": {},
  10. }
  11. class Controller {
  12. constructor() {
  13. this.cache = {}
  14. this.currentRadio = null
  15. for(let r in knownRadios) {
  16. this.get(r);
  17. }
  18. }
  19. async get(url) {
  20. if(this.cache[url]) {
  21. this.currentRadio = this.cache[url];
  22. return this.cache[url];
  23. }
  24. this.cache[url] = knownRadios[url];
  25. // fetch more data in background
  26. radiomanifest.get(url).then((rm) => {
  27. console.log("arrivato", url)
  28. this.cache[url] = rm
  29. })
  30. }
  31. }
  32. const ControllerSingleton = new Controller();
  33. // console.log(ControllerSingleton);
  34. export default ControllerSingleton;