Rob Colbert
3 months ago
15 changed files with 100 additions and 175 deletions
@ -1,67 +0,0 @@ |
|||
// gab-tv.js
|
|||
// Copyright (C) 2021 Digital Telepresence, LLC
|
|||
// License: Apache-2.0
|
|||
|
|||
'use strict'; |
|||
|
|||
const fetch = require('node-fetch'); // jshint ignore:line
|
|||
|
|||
const CACHE_DURATION = 60 * 5; |
|||
|
|||
const { SiteService } = require('../../lib/site-lib'); |
|||
|
|||
class GabTVService extends SiteService { |
|||
|
|||
constructor (dtp) { |
|||
super(dtp, module.exports); |
|||
} |
|||
|
|||
channelMiddleware ( ) { |
|||
return async (req, res, next) => { |
|||
try { |
|||
if (!res.locals.site || !res.locals.site.gabtvUrl) { |
|||
return next(); |
|||
} |
|||
this.log.debug('GabTV URL', { url: res.locals.site.gabtvUrl }); |
|||
const urlParts = res.locals.site.gabtvUrl.split('/'); |
|||
const channelSlug = urlParts[urlParts.length - 1]; |
|||
res.locals.gabTvChannel = await this.getChannelEpisodes(channelSlug, { allowCache: true }); |
|||
return next(); |
|||
} catch (error) { |
|||
this.log.error('failed to populdate Gab TV channel', { error }); |
|||
return next(); |
|||
} |
|||
}; |
|||
} |
|||
|
|||
async getChannelEpisodes (channelSlug, options) { |
|||
const { cache: cacheService } = this.dtp.services; |
|||
const cacheKey = `gabtv:ch:${channelSlug}`; |
|||
|
|||
options = Object.assign({ |
|||
allowCache: true, |
|||
}, options); |
|||
|
|||
let json; |
|||
if (options.allowCache) { |
|||
json = await cacheService.getObject(cacheKey); |
|||
if (json) { |
|||
return json; |
|||
} |
|||
} |
|||
|
|||
const response = await fetch(`https://tv.gab.com/channel/${channelSlug}/feed/json`); |
|||
json = await response.json(); |
|||
|
|||
await cacheService.setObjectEx(cacheKey, CACHE_DURATION, json); |
|||
|
|||
return json; |
|||
} |
|||
} |
|||
|
|||
module.exports = { |
|||
logId: 'svc:gab-tv', |
|||
index: 'gabTV', |
|||
className: 'GabTVService', |
|||
create: (dtp) => { return new GabTVService(dtp); }, |
|||
}; |
After Width: | Height: | Size: 5.2 KiB |
@ -1,29 +0,0 @@ |
|||
<!DOCTYPE html> |
|||
<html lang="en"> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|||
<title>Shing.tv | Offline</title> |
|||
|
|||
<style type="text/css"> |
|||
html, body { |
|||
margin: 0; |
|||
padding: 0; |
|||
} |
|||
</style> |
|||
</style> |
|||
</head> |
|||
|
|||
<body> |
|||
<div class="container"> |
|||
<section> |
|||
<img src="/static/img/header.png" class="responsive" alt="Digital Telepresence Platform"/> |
|||
<p>Shing.tv as you know it has been closed for at least two weeks. Meeting less than 50% of the funding goal means this site won't be here for at least 50% of a month. Because we're taking advantage of this time to make some pretty radical changes to the site and the services provided.</p> |
|||
|
|||
<p>This <a href="https://twitter.com/dtp_llc/status/1741661171294323022">thread on X</a> describes what's happening, and this is a fine time to follow us on X to keep up with the progress as we go.</p> |
|||
|
|||
</section> |
|||
</div> |
|||
</body> |
|||
|
|||
</html> |
Loading…
Reference in new issue