PageSourceSearch

https://radiorcu.fr/js/orbapi.js

js radiorcu.fr collected 2026-10-06 08:59:59 UTC 2,946 bytes, 120 lines download raw bytes

1// https://onlineradiobox.com/json/fr/rcu/playlist
2// https://onlineradiobox.com/json/fr/rcu
3// https://scraper.onlineradiobox.com/fr.rcu
4// https://onlineradiobox.com/json/fr/rcu/top?size=10&tz=-60&rnd=0.9362414987352538
5// Spot-pub, Spot-rcu
6
7function ORBAPI() {
8	this.top10url = function() {return "https://onlineradiobox.com/json/fr/rcu/top?size=10&tz=-60&rnd=" + Math.random()};
9	this.songURL = function(id) {return `https://onlineradiobox.com/track/${id}/?cs=fr.rcu`};
10	this.scraperURL = function() {return "https://scraper.onlineradiobox.com/fr.rcu"};
11
12	this.fetchTop10 = async function () {
13		let url = ORBAPI.top10url();
14	
15		var json = (await (await fetch(url)).json());
16
17		var songs = [];
18		for(entry of json.top) {
19			var songSplit = entry.name.split(" - ");
20			var songData = {
21				name: null,
22				artist: null,
23				id: entry.id,
24				img: entry.img != null ? entry.img : "/img/covers/default.png",
25				change: entry.change
26			};
27
28			if (songSplit.length < 2) {
29				songData.name = entry.name;
30			} else {
31				songData.artist = songSplit[0];
32				songData.name = songSplit[1];
33			}
34			songs.push(songData);
35		}
36
37		return songs;
38	};
39
40	this.applyToEntry = function(entry, data) {
41		var song = entry.querySelector(".song_name");
42		var artist = entry.querySelector(".song_artist");
43		var img = entry.querySelector("img");
44		var a = entry.querySelector("a");
45		
46		handleDataSpecialCase(data);
47
48		img.src = data.img;
49		song.innerText = data.name;
50		artist.innerText = data.artist;
51		if (data.id != null) {
52			a.setAttribute("href", ORBAPI.songURL(data.id));
53		} else {
54			a.removeAttribute("href");
55		}
56	};
57
58	this.getCurrentPlayingSong = async function() {
59		var json = (await (await fetch(ORBAPI.scraperURL())).json());
60
61		var data = {
62			img: "/img/covers/default.png",
63			updated: json.updated
64		};
65
66		if (json.title != null) {
67			var songSplit = json.title.split(" - ");
68
69			if (songSplit.length < 2) {
70				data.name = json.title;
71			} else {
72				data.artist = songSplit[0];
73				data.name = songSplit[1];
74			}
75		}
76
77		if (handleDataSpecialCase(data) && json.iName != null) {
78			data.name = json.iName;
79			if (json.iArtist != null)
80				data.artist = json.iArtist;
81			if (json.iImg != null)
82				data.img = json.iImg;
83		}
84
85		data.id = json.trackId;
86
87		return data;
88	};
89
90	this.startUpdateCycle = function(callback) {
91		var needsRefresh = false;
92
93		var lastUpdate = null;
94
95		async function refreshPlaying() {
96			if (document.hidden) {
97				needsRefresh = true;
98				return;
99			}
100			var data = await ORBAPI.getCurrentPlayingSong();
101
102			if (lastUpdate == data.updated)
103				return;
104			lastUpdate = data.updated;
105
106			callback(data);
107		}
108		
109		// prevent overloading servers in case tab isn't focused
110		document.addEventListener("visibilitychange", () => {
111			if (!document.hidden && needsRefresh) {
112				refreshPlaying();
113				needsRefresh = false;
114			}
115		});
116		setInterval(refreshPlaying, 30000);
117		refreshPlaying();
118	}
119};
120window.ORBAPI = new ORBAPI();

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.