update style, add title extractor
Signed-off-by: Christian Richter <crichter@owncloud.com>
This commit is contained in:
@@ -2,8 +2,49 @@
|
||||
<head>
|
||||
<script type='text/javascript' src='http://www.youtube.com/player_api'></script>
|
||||
<title>Weirdradio</title></head>
|
||||
<style>
|
||||
div.body {
|
||||
width: 1024px;
|
||||
height: 768px;
|
||||
border: solid 1px;
|
||||
padding: 1pc;
|
||||
}
|
||||
div.leftcolumn {
|
||||
width: 30%;
|
||||
float: left;
|
||||
}
|
||||
div.title {
|
||||
height: 20%;
|
||||
}
|
||||
div.playlist {
|
||||
height: 80%;
|
||||
}
|
||||
div.rightcolumn {
|
||||
width: 60%;
|
||||
float: left;
|
||||
}
|
||||
#playerframe {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
background-color: purple;
|
||||
}
|
||||
</style>
|
||||
<body onload="connectSocket()">
|
||||
<div class="body">
|
||||
<div class="leftcolumn">
|
||||
<div class="title">
|
||||
<h1>Weirdradio</h1>
|
||||
</div>
|
||||
<div class="playlist">
|
||||
{playlist}
|
||||
</div>
|
||||
</div>
|
||||
<div class="rightcolumn">
|
||||
<div class="playerframe">
|
||||
<div id="player"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
<script>
|
||||
// 2. This code loads the IFrame Player API code asynchronously.
|
||||
|
||||
@@ -82,16 +82,24 @@ client.on("room.message", (roomId, event) => {
|
||||
var r = new RegExp(/https?:\/\/[^\ ]*youtube.com\/watch\?v=([^\ ]*)/g);
|
||||
link_matches = r.exec(body);
|
||||
if (link_matches && link_matches.length > 1) {
|
||||
// get title
|
||||
request(link_matches[0], function (err, _res, body) {
|
||||
if (err) return console.error(err);
|
||||
title = "unset";
|
||||
let $ = cheerio.load(body);
|
||||
tmpTitle = $("title").text();
|
||||
if (tmpTitle != "") {
|
||||
title = tmpTitle.replace(" - YouTube", "");
|
||||
}
|
||||
// pass to server
|
||||
var obj = {
|
||||
link: link_matches[0],
|
||||
embedLink:
|
||||
"https://www.youtube.com/embed/" + link_matches[1] + "?autoplay=1",
|
||||
videoId: link_matches[1],
|
||||
|
||||
title: title,
|
||||
};
|
||||
console.log("Relaying: " + obj.link);
|
||||
sockets.forEach((s) => s.send(JSON.stringify(obj)));
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user