Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dnicolson/random-seinfeld
📺 Apple TV TVML app to play random Seinfeld episodes
https://github.com/dnicolson/random-seinfeld
Last synced: 22 days ago
JSON representation
📺 Apple TV TVML app to play random Seinfeld episodes
- Host: GitHub
- URL: https://github.com/dnicolson/random-seinfeld
- Owner: dnicolson
- License: mit
- Created: 2019-09-30T23:29:08.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2024-08-31T19:58:53.000Z (4 months ago)
- Last Synced: 2024-10-06T02:21:47.478Z (3 months ago)
- Language: JavaScript
- Homepage:
- Size: 3.15 MB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Random Seinfeld
This is based off the [appletv-boilerplate](https://github.com/emadalam/appletv-boilerplate) project which uses [atvjs](https://github.com/emadalam/atvjs).
![Screenshot](https://github.com/dnicolson/Random-Seinfeld/raw/master/screenshot.jpg)
### Installation
```shell
$ npm install -g gulp
$ npm install
```### Running
By default the project will request `http://localhost:9001` for both the application payload and the API endpoints.
The application payload can be generated with the `gulp build` command, the resulting `web/public/app.js` file can be placed in the root directory of an Express server. This server is required for metadata and streaming links, the following Express server shows the required methods:
```javascript
const TVDB = require('node-tvdb');
const express = require('express');
const fs = require('fs');
const tvdb = new TVDB('');
const app = express();
const port = 9001;app.get('/episode', async (req, res) => {
const seasons = [5, 12, 23, 24, 22, 24, 24, 22, 24];
const season = Math.floor(Math.random() * seasons.length);
const episode = {season: Math.floor(Math.random() * seasons.length) + 1, episode:Math.floor(Math.random() * seasons[season]) + 1};
try {
const episodeResponse = await tvdb.getEpisodesBySeriesId(79169, {query: {airedSeason: episode.season, airedEpisode: episode.episode}})
const episodeInfo = {episodeName: episodeResponse[0].episodeName,
season: episode.season,
episode: episode.episode,
description: episodeResponse[0].overview,
director: episodeResponse[0].directors[0],
writers: episodeResponse[0].writers,
guestStars: episodeResponse[0].guestStars,
firstAired: episodeResponse[0].firstAired,
siteRating: episodeResponse[0].siteRating,
contentRating: episodeResponse[0].contentRating.toLowerCase(),
image: `https://thetvdb.com/banners/${episodeResponse[0].filename}`};
res.send(episodeInfo);
} catch(error) {
res.status(500);
res.send(error);
}
});app.get('/download', async (req, res) => {
res.send('');
});app.get('/cleanup', async (req, res) => {
// any action to perform after the episode has finished
});app.get('/app.js', (req, res) => {
res.send(fs.readFileSync('app.js','utf8'));
});app.listen(port);
```### Deployment
The hostname needs be changed in the `config.js` and `AppDelegate.swift` files to be externally accessible from the Apple TV, the `app.js` file also needs to be copied to a server with the new hostname.### License
[MIT License](http://opensource.org/licenses/MIT).