misc.anonradio: add openmic dj time
This commit is contained in:
		
							parent
							
								
									2e843f0c04
								
							
						
					
					
						commit
						fe7d7b86d3
					
				
					 1 changed files with 17 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -281,6 +281,9 @@ anonradio.callback = async function (msg, line) {
 | 
			
		|||
  const schedule = await fetch("https://anonradio.net/schedule/").then((res) =>
 | 
			
		||||
    res.text()
 | 
			
		||||
  );
 | 
			
		||||
  const icecast = await fetch("http://anonradio.net:8010/status-json.xsl").then(
 | 
			
		||||
    (res) => res.json()
 | 
			
		||||
  );
 | 
			
		||||
 | 
			
		||||
  let lines = schedule.split("\n");
 | 
			
		||||
  lines = lines.slice(4, lines.length - 2);
 | 
			
		||||
| 
						 | 
				
			
			@ -345,6 +348,19 @@ anonradio.callback = async function (msg, line) {
 | 
			
		|||
    subtitle = `${current} listening with a daily peak of ${peakDay} and ${peakMonth} peak for the month.`;
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  let openmicTime = "";
 | 
			
		||||
  if (liveNow.id == "openmic") {
 | 
			
		||||
    const streamData = icecast.icestats.source.find(
 | 
			
		||||
      (src) => src.listenurl == "http://anonradio.net:8010/openmic"
 | 
			
		||||
    );
 | 
			
		||||
    if (streamData && streamData.stream_start_iso8601) {
 | 
			
		||||
      const startTime = new Date(streamData.stream_start_iso8601).getTime();
 | 
			
		||||
      openmicTime = `-*- OpenMIC DJ has been streaming for ${formatTime(
 | 
			
		||||
        Date.now() - startTime
 | 
			
		||||
      )} -*-\n`;
 | 
			
		||||
    }
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  return {
 | 
			
		||||
    embeds: [
 | 
			
		||||
      {
 | 
			
		||||
| 
						 | 
				
			
			@ -353,7 +369,7 @@ anonradio.callback = async function (msg, line) {
 | 
			
		|||
          name: title,
 | 
			
		||||
          url: "http://anonradio.net:8000/anonradio",
 | 
			
		||||
        },
 | 
			
		||||
        description: "__Schedule:__",
 | 
			
		||||
        description: openmicTime + "__Schedule:__",
 | 
			
		||||
        fields: parsedLines.map((line) => ({
 | 
			
		||||
          inline: true,
 | 
			
		||||
          name: `${line.name} (\`${line.id}\`)`,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue