Skip to content

Commit

Permalink
Add now playing show and reformat mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
DCRepublic committed Feb 12, 2025
1 parent 3eb0189 commit d0c5382
Show file tree
Hide file tree
Showing 9 changed files with 176 additions and 419 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
FROM node:18-bullseye
ENV NODE_ENV=production
ENV TZ=America/New_York
RUN mkdir /app && chown -R node:node /app
WORKDIR /app
RUN mkdir -p /data/images && chown -R node:node /data/images
Expand Down
1 change: 1 addition & 0 deletions Dockerfile.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
FROM node:18-bullseye
ENV TZ=America/New_York
ENV NODE_ENV=production
WORKDIR /app
RUN chown -R node /app
Expand Down
4 changes: 3 additions & 1 deletion docker-compose-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ services:
volumes:
- .:/app
- ./data/images:/usr/src/app/public
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
environment:
NODE_ENV: development
ports:
Expand All @@ -22,7 +24,7 @@ services:
networks:
- internal

db:
wsrn-website-db:
image: mariadb:10.7
ports:
- 3306:3306
Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ services:
#- ./public/archive:/app/public/archive
- wsrn-archive:/app/public/archive
- wsrn-images:/data/images
- /etc/timezone:/etc/timezone:ro
- /etc/localtime:/etc/localtime:ro
env_file:
- .env.local
build:
Expand Down
73 changes: 73 additions & 0 deletions src/app/api/check_current_show/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
// app/api/stream/route.js
import { NextResponse } from 'next/server';
import axios from 'axios';
import ICAL from 'ical.js';
const fs = require('fs');

//const icsToJson = require('ics-to-json');

let link =
'https://calendar.google.com/calendar/ical/c_20efba3e379cb584e46776735a0ce2f147de6595b8230e2082633a065183a1c0%40group.calendar.google.com/public/basic.ics';
// To handle a GET request to /api

export async function GET(request) {
let date = new Date();
let data = {};
await axios.get(link).then((res) => {
data = res.data;
});

var jcalData = ICAL.parse(data);
var comp = new ICAL.Component(jcalData);
var vevent = comp.getAllSubcomponents('vevent');

let output = [];
let obj = {};

for (var i in vevent) {
let name = vevent[i].getFirstPropertyValue('summary');
let desc = vevent[i].getFirstPropertyValue('description');
let img = vevent[i].getFirstPropertyValue('attach');
let start = vevent[i].getFirstPropertyValue('dtstart');
let end = vevent[i].getFirstPropertyValue('dtend');

if (start.year == date.getFullYear()) {
//filter to current year
if (!output.some((e) => e.Name === name)) {
//console.log(start.year + '-' + start.month + '-' + start.day);
let theStart = new Date(start);
let theEnd = new Date(end);
obj['Name'] = name;
obj['Desc'] = desc;
obj['Start'] = start;
obj['End'] = end;
obj['DOTW'] = theStart.getDay();

//console.log(date.toLocaleString() <= theEnd.toLocaleString());

if (
date.getDay() == obj.DOTW &&
date.getMinutes() - theStart.getMinutes() <= 60 &&
date.getMinutes() - theStart.getMinutes() >= 0 &&
date.getHours() == theStart.getHours()
) {
console.log(date.getMinutes() - theStart.getMinutes());
output.push(obj);
}
obj = {};
}
}
}

//var summary = vevent.getFirstPropertyValue('summary');

return NextResponse.json(output, { status: 200 });
}

// To handle a POST request to /api
export async function POST(request) {
// Do whatever you want
return NextResponse.json({ message: 'Hello World' }, { status: 200 });
}

// Same logic to add a `PATCH`, `DELETE`...
28 changes: 28 additions & 0 deletions src/app/api/now_playing/route.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// app/api/stream/route.js
import { NextResponse } from 'next/server';
import axios from 'axios';

export async function GET(request) {
var nowPlaying;

await axios
.get('https://admin.wsrnfm.com/api/nowplaying/wsrn')
.then((response) => {
// Do something with the Now Playing data.
nowPlaying = response.data;
return NextResponse.json(nowPlaying, { status: 200 });
})
.catch((error) => {
console.error(error);
});

return NextResponse.json(nowPlaying, { status: 200 });
}

// To handle a POST request to /api
export async function POST(request) {
// Do whatever you want
return NextResponse.json({ message: 'Hello World' }, { status: 200 });
}

// Same logic to add a `PATCH`, `DELETE`...
36 changes: 0 additions & 36 deletions src/app/api/states/route.js

This file was deleted.

25 changes: 0 additions & 25 deletions src/app/api/stream/route.js

This file was deleted.

Loading

0 comments on commit d0c5382

Please sign in to comment.