Fix ustream

This commit is contained in:
Calvin Montgomery 2018-01-14 15:02:15 -08:00
parent fec1372e4e
commit d706bf63b1
6 changed files with 11 additions and 57 deletions

2
.gitignore vendored
View File

@ -16,3 +16,5 @@ integration-test-config.json
conf/*.toml
www/js/cytube-google-drive.user.js
www/js/cytube-google-drive.meta.js
www/js/player.js
tor-exit-list.json

View File

@ -2,7 +2,7 @@
"author": "Calvin Montgomery",
"name": "CyTube",
"description": "Online media synchronizer and chat",
"version": "3.52.0",
"version": "3.52.1",
"repository": {
"url": "http://github.com/calzoneman/sync"
},

View File

@ -8,5 +8,5 @@ window.UstreamPlayer = class UstreamPlayer extends EmbedPlayer
load: (data) ->
data.meta.embed =
tag: 'iframe'
src: "/ustream_bypass/embed/#{data.id}?html5ui&autoplay=1"
src: "https://www.ustream.tv/embed/#{data.id}?html5ui"
super(data)

View File

@ -1,54 +0,0 @@
import { HTTPError } from '../../errors';
import * as HTTPStatus from '../httpstatus';
import https from 'https';
import Promise from 'bluebird';
const INJECTION = `
<head>
<style type="text/css">
#PlayerOne.ui-enabled #ScreensContainer.shown {
display: none !important;
}
</style>`;
function ustreamSucks(channelId) {
const url = `https://www.ustream.tv/embed/${channelId}`;
return new Promise((resolve, reject) => {
const req = https.get(url, (res) => {
if (res.statusCode !== HTTPStatus.OK) {
res.resume();
return reject(new HTTPError(res.statusMessage, { status: res.statusCode }));
}
res.setEncoding('utf8');
let buffer = '';
res.on('data', data => buffer += data);
res.on('end', () => {
buffer = buffer.replace(/<head>/, INJECTION);
resolve(buffer);
});
});
req.on('error', error => {
reject(error);
});
});
}
export default function initialize(app) {
app.get('/ustream_bypass/embed/:channelId', (req, res) => {
if (!req.params.channelId || !/^\d+$/.test(req.params.channelId)) {
throw new HTTPError(`Invalid channel ID "${req.params.channelId}".`, {
status: HTTPStatus.BAD_REQUEST
});
}
ustreamSucks(req.params.channelId).then(buffer => {
res.type('html').send(buffer);
}).catch(HTTPError, error => {
res.status(error.status).send(error.message);
}).catch(error => {
res.status(HTTPStatus.INTERNAL_SERVER_ERROR).send('Internal Server Error');
});
});
};

View File

@ -208,7 +208,6 @@ module.exports = {
require('./acp').init(app, ioConfig);
require('../google2vtt').attach(app);
require('./routes/google_drive_userscript')(app);
require('./routes/ustream_bypass')(app);
if (process.env.UNFINISHED_FEATURE) {
const { AccountDataRoute } = require('./routes/account/data');

View File

@ -3226,6 +3226,13 @@ function startQueueSpinner(data) {
}
function stopQueueSpinner(data) {
// TODO: this is a temp hack, need to replace media ID check with
// a passthrough request ID (since media ID from API is not necessarily
// the same as the URL "ID" from the user)
if (data.type === "us") {
data = { id: data.title.match(/Ustream.tv - (.*)/)[1] };
}
var shouldRemove = (data !== null &&
typeof data === 'object' &&
$("#queueprogress").data("queue-id") === data.id);