2019-11-07 20:39:22 +01:00
|
|
|
const { getHtml } = require('./html');
|
2019-12-30 20:54:53 +01:00
|
|
|
const { generateDownloadUrl } = require('../../ui/util/lbrytv');
|
|
|
|
const { LBRY_TV_API } = require('../../config');
|
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();
|
|
|
|
|
2020-01-13 18:36:26 +01:00
|
|
|
router.get(`/$/download/:claimName/:claimId`, async ctx => {
|
|
|
|
const { claimName, claimId } = ctx.params;
|
2020-01-24 17:25:31 +01:00
|
|
|
const downloadUrl = generateDownloadUrl(claimName, claimId);
|
2020-01-13 18:36:26 +01:00
|
|
|
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;
|