use custom endpoint for lbry.tv embeds
This commit is contained in:
parent
30c9a3bc1c
commit
50bea913ec
3 changed files with 14 additions and 8 deletions
|
@ -6,10 +6,11 @@ const send = require('koa-send');
|
||||||
|
|
||||||
const router = new Router();
|
const router = new Router();
|
||||||
|
|
||||||
// TODO
|
router.get(`/embed/:claimName/:claimId`, async ctx => {
|
||||||
// router.get(`/embed/:claimName/:claimId`, async ctx => {
|
const { claimName, claimId } = ctx.params;
|
||||||
// Proxy request through lbrytv
|
const streamUrl = generateStreamUrl(claimName, claimId, LBRY_TV_API);
|
||||||
// });
|
ctx.redirect(streamUrl);
|
||||||
|
});
|
||||||
|
|
||||||
router.get('*', async ctx => {
|
router.get('*', async ctx => {
|
||||||
const html = await getHtml(ctx);
|
const html = await getHtml(ctx);
|
||||||
|
|
|
@ -3,8 +3,7 @@ import * as ICONS from 'constants/icons';
|
||||||
import { FormField } from 'component/common/form';
|
import { FormField } from 'component/common/form';
|
||||||
import Button from 'component/button';
|
import Button from 'component/button';
|
||||||
import React, { useRef } from 'react';
|
import React, { useRef } from 'react';
|
||||||
import { generateStreamUrl } from 'util/lbrytv';
|
import { generateEmbedUrl } from 'util/lbrytv';
|
||||||
import { LBRY_TV_API } from 'config';
|
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
copyable: string,
|
copyable: string,
|
||||||
|
@ -19,7 +18,7 @@ export default function EmbedArea(props: Props) {
|
||||||
const { claim_id: claimId, name } = claim;
|
const { claim_id: claimId, name } = claim;
|
||||||
const input = useRef();
|
const input = useRef();
|
||||||
|
|
||||||
const streamUrl = generateStreamUrl(name, claimId, LBRY_TV_API);
|
const streamUrl = generateEmbedUrl(name, claimId);
|
||||||
let embedText = `<iframe width="560" height="315" src="${streamUrl}" allowfullscreen></iframe>`;
|
let embedText = `<iframe width="560" height="315" src="${streamUrl}" allowfullscreen></iframe>`;
|
||||||
|
|
||||||
function copyToClipboard() {
|
function copyToClipboard() {
|
||||||
|
|
|
@ -1,7 +1,13 @@
|
||||||
|
const { URL } = require('../../config');
|
||||||
|
|
||||||
function generateStreamUrl(claimName, claimId, apiUrl) {
|
function generateStreamUrl(claimName, claimId, apiUrl) {
|
||||||
const prefix = process.env.SDK_API_URL || apiUrl;
|
const prefix = process.env.SDK_API_URL || apiUrl;
|
||||||
return `${prefix}/content/claims/${claimName}/${claimId}/stream`;
|
return `${prefix}/content/claims/${claimName}/${claimId}/stream`;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function generateEmbedUrl(claimName, claimId) {
|
||||||
|
return `${URL}/embed/${claimName}/${claimId}`;
|
||||||
|
}
|
||||||
|
|
||||||
// module.exports needed since the web server imports this function
|
// module.exports needed since the web server imports this function
|
||||||
module.exports = { generateStreamUrl };
|
module.exports = { generateStreamUrl, generateEmbedUrl };
|
||||||
|
|
Loading…
Reference in a new issue