diff --git a/src/platforms/web/server.js b/src/platforms/web/server.js index 9d9a3dcf5..6f8819d84 100644 --- a/src/platforms/web/server.js +++ b/src/platforms/web/server.js @@ -1,10 +1,10 @@ const { parseURI } = require('lbry-redux'); +const { generateStreamUrl } = require('../../src/ui/util/lbrytv'); const { WEB_SERVER_PORT } = require('../../config'); const { readFileSync } = require('fs'); const express = require('express'); const path = require('path'); const app = express(); - const mysql = require('mysql'); const pool = mysql.createPool({ @@ -15,11 +15,11 @@ const pool = mysql.createPool({ database: 'chainquery', }); -const getClaim = (claimName, claimId, callback) => { +const getClaim = (claimName, claimId, channelName, channelClaimId, callback) => { let params = [claimName]; let sql = - 'SELECT channel_claim.name as channel, claim.claim_id, claim.name, claim.description, claim.language, claim.thumbnail_url, claim.title ' + + 'SELECT channel_claim.name as channel, claim.claim_id, claim.name, claim.description, claim.language, claim.thumbnail_url, claim.title, claim.source_media_type, claim.frame_width, claim.frame_height ' + 'FROM claim ' + 'LEFT JOIN claim channel_claim on claim.publisher_id = channel_claim.claim_id ' + 'WHERE claim.name = ?'; @@ -31,6 +31,17 @@ const getClaim = (claimName, claimId, callback) => { sql += ' AND claim.bid_state = "controlling"'; } + if (claimName[0] !== '@' && channelName) { + sql += ' AND channel_claim.name = ?'; + params.push('@' + channelName); + if (channelClaimId) { + sql += ' AND channel_claim.claim_id LIKE ?'; + params.push(channelClaimId + '%'); + } else { + sql += ' AND channel_claim.bid_state = "controlling"'; + } + } + sql += ' LIMIT 1'; pool.query(sql, params, callback); @@ -43,7 +54,7 @@ function truncateDescription(description) { } function insertToHead(fullHtml, htmlToInsert) { - return fullHtml.replace('%%HEAD_TOKEN%%', htmlToInsert); + return fullHtml.replace('', htmlToInsert); } const defaultHead = @@ -67,7 +78,7 @@ app.get('*', async (req, res) => { const claimName = isChannel ? '@' + channelName : streamName; const claimId = isChannel ? channelClaimId : streamClaimId; - getClaim(claimName, claimId, (err, rows) => { + getClaim(claimName, claimId, channelName, channelClaimId, (err, rows) => { if (!err && rows && rows.length > 0) { const claim = rows[0]; const title = claim.title ? claim.title : claimName; @@ -83,6 +94,7 @@ app.get('*', async (req, res) => { let head = ''; head += ''; + head += `