lbry-desktop/lbrytv/src/routes.js

25 lines
901 B
JavaScript
Raw Normal View History

2019-11-07 20:39:22 +01:00
const { getHtml } = require('./html');
2020-03-25 22:49:14 +01:00
const { generateStreamUrl, CONTINENT_COOKIE } = require('../../ui/util/lbrytv');
2019-11-07 20:39:22 +01:00
const Router = require('@koa/router');
2019-11-11 19:19:31 +01:00
2019-11-07 20:39:22 +01:00
const router = new Router();
router.get(`/$/download/:claimName/:claimId`, async ctx => {
const { claimName, claimId } = ctx.params;
2020-03-25 22:49:14 +01:00
// hack to get around how we managing the continent cookie
// defaulting to "NA" becasue saved-passwords.js assumes it's in the browser and won't work properly
// changes need to be made to that to better work with the server
const streamingContinentCookie = ctx.cookies.get(CONTINENT_COOKIE) || 'NA';
const streamUrl = generateStreamUrl(claimName, claimId, undefined, streamingContinentCookie);
const downloadUrl = `${streamUrl}?download=1`;
ctx.redirect(downloadUrl);
});
2019-11-07 20:39:22 +01:00
router.get('*', async ctx => {
const html = await getHtml(ctx);
ctx.body = html;
});
module.exports = router;