Skip to content

Commit b35bb64

Browse files
committed
Sync buffer time & various fixes + use piped everywhere
1 parent e5daf5c commit b35bb64

File tree

12 files changed

+181
-530
lines changed

12 files changed

+181
-530
lines changed

README.md

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,20 @@ Make a youtube playlist, collaboratively.
55

66
![dsu](https://github.com/pin3da/poolparty/blob/master/dsu.jpg)
77

8+
# Fork updates
9+
10+
This is a forked version. There are quite a few fixes and new features, including:
11+
12+
- Basic Youtube search support
13+
- Sync the playback on all clients *(experimental)*
14+
- Use piped instead of native youtube for everything - no call is ever made directly on youtube's server
15+
- Implement Shaka Player
16+
- DASH+xml conversion from streams (apparently youtube's HLS are kinda broken)
17+
- Update packages.json, remove reprecated
18+
- Dockerized
19+
20+
You can take a look at TODO.md for details about potential future features.
21+
822
## Requirements
923

1024
- [node.js](https://nodejs.org/en/)
@@ -22,7 +36,7 @@ Make a youtube playlist, collaboratively.
2236
When the server is running, everyone in the party can acces to
2337
server_ip:8080/ and add songs.
2438

25-
One person will visit server_ip:8080/play in order to reproduce the
39+
One person will visit server_ip:8080/play in order to reproduce the
2640
playlist.
2741

2842
## Authors
@@ -31,5 +45,3 @@ playlist.
3145
- [@jhonber](https://github.com/jhonber)
3246
- [@leiverandres](https://github.com/leiverandres)
3347
- [@pin3da](https://github.com/pin3da)
34-
35-

TODO.md

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
1-
- Fix deprecations :
2-
```
3-
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
4-
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
5-
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
6-
```
7-
8-
- Use Piped everywhere & configurable instance url
1+
- Use Piped configurable instance url
2+
- Search & add YT playlists
3+
- Better playlist management (remove any video)
4+
- Permissions & rooms
5+
- Better design, & mobile app (?)

app.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ var app = express();
1313
app.set('views', path.join(__dirname, 'views'));
1414
app.set('view engine', 'ejs');
1515

16-
// uncomment after placing your favicon in /public
17-
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
1816
app.use(cors());
1917
app.use(logger('dev'));
2018
app.use(bodyParser.json());

browser/main.js

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,30 @@
11
var io = require('socket.io-client');
22
var Handlebars = require('handlebars');
3-
var parseAddress = require('../views/parseAddress.js');
3+
var parseAddress = require('../lib/parseAddress.js');
4+
var youtubeInfo = require('../lib/youtubeInfo.js');
45

56
var socket = io();
67

7-
var serverTime = 0;
8+
// To have access in the templates (no better way?!)
9+
window.getParseAddress = function (address) {
10+
return parseAddress(address);
11+
}
12+
window.getYoutubeInfo = async function (youtubeId, play) {
13+
return await youtubeInfo(youtubeId, play);
14+
}
15+
816

917
function addToList(item) {
1018
list = document.getElementById('playlist');
1119
var div = document.createElement('div')
1220
div.setAttribute('id', 'item');
1321

1422
var title = document.createElement('h3');
15-
title.innerHTML = item.info.title;
23+
title.innerHTML = item.title;
1624
title.setAttribute('id', 'title');
1725

1826
var entry = document.createElement('img');
19-
var img = item.prev;
27+
var img = item.thumbnail;
2028
entry.setAttribute('src', img);
2129
entry.setAttribute('id', 'img');
2230

@@ -27,14 +35,17 @@ function addToList(item) {
2735

2836
function sendData() {
2937
document.getElementById('searchResults').style.display = "none";
30-
var songText = document.getElementById('songText');
31-
if (parseAddress(songText.value) !== "invalid") {
32-
var urlPre = 'https://pipedproxy.kavin.rocks/vi/' + parseAddress(songText.value) + '/maxresdefault.jpg?host=i.ytimg.com';
33-
var data = {url: songText.value, prev: urlPre};
34-
if (data.url !== '') {
35-
socket.emit('add song', data);
36-
songText.value = "";
37-
}
38+
var videoUrl = document.getElementById('videoUrl');
39+
var youtubeId = parseAddress(videoUrl.value);
40+
if (youtubeId) {
41+
const requestYoutubeInfo = async () => {
42+
var data = await youtubeInfo(youtubeId);
43+
if (data) {
44+
socket.emit('add video', data);
45+
videoUrl.value = "";
46+
}
47+
};
48+
requestYoutubeInfo();
3849
}
3950
}
4051

@@ -58,12 +69,10 @@ function searchData() {
5869
link.href = "https://piped.kavin.rocks"+item.url;
5970
link.title = item.title;
6071
link.onclick = function(e) {
61-
e.preventDefault;
62-
63-
var data = {url: link.href, prev: item.thumbnail};
72+
var data = {url: link.href, thumbnail: item.thumbnail, title: item.title};
6473
if (data.url !== '') {
65-
socket.emit('add song', data);
66-
songText.value = "";
74+
socket.emit('add video', data);
75+
document.getElementById('videoUrl').value = "";
6776
}
6877

6978
return false;
@@ -105,9 +114,9 @@ document.addEventListener('DOMContentLoaded', function() {
105114
});
106115

107116
var send = document.getElementById('sendButton');
108-
var songText = document.getElementById('songText');
117+
var videoUrl = document.getElementById('videoUrl');
109118
send.addEventListener('click', sendData);
110-
songText.addEventListener('keyup', function(evt) {
119+
videoUrl.addEventListener('keyup', function(evt) {
111120
if (evt.keyCode == 13)
112121
sendData();
113122
});
@@ -124,7 +133,7 @@ document.addEventListener('DOMContentLoaded', function() {
124133
addToList(data);
125134
});
126135

127-
socket.on('nextSong', function(data) {
136+
socket.on('nextVideo', function(data) {
128137
var t = document.querySelector('#playlist');
129138
if (t.children.length > 0)
130139
t.removeChild(t.children[0]);
@@ -135,33 +144,28 @@ document.addEventListener('DOMContentLoaded', function() {
135144

136145
socket.on('start', function(data) {
137146
for (var i = 0, f; f = data.playlist[i]; ++i) {
138-
if (parseAddress(f.url) !== "invalid")
139-
window.data.push(parseAddress(f.url));
147+
if (parseAddress(f.url))
148+
window.data.push(f.url);
140149
}
141150
if (window.data.length > 0) {
142-
fetchHls(window.data.shift());
151+
loadVideo(window.data.shift());
143152
}
144153
});
145154

146155
socket.on('added', function(data) {
147-
if (parseAddress(data.url) !== "invalid") {
148-
window.data.push(parseAddress(data.url));
149-
if (!document.getElementById('player-status').getAttribute('playing')) {
150-
fetchHls(window.data.shift());
156+
if (parseAddress(data.url)) {
157+
window.data.push(data.url);
158+
if (!window.playing) {
159+
loadVideo(window.data.shift());
151160
}
152161
}
153162
});
154163

155-
socket.on('updated time', function(currentTime) {
156-
if (serverTime < currentTime) {
157-
serverTime = currentTime;
158-
updatedTime(currentTime);
159-
}
160-
});
164+
socket.on('updated time', updatedTime);
161165

162-
socket.on('nextSong', function(data) {
163-
if (document.getElementById('player-status').getAttribute('current-url') != data) {
164-
fetchHls(window.data.shift());
166+
socket.on('nextVideo', function(data) {
167+
if (window.currentVideoUrl != data) {
168+
loadVideo(window.data.shift());
165169
}
166170
});
167171
}

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
version: "2.1"
22
services:
3-
radarr:
3+
poolparty:
44
image: poolparty
55
container_name: poolparty
66
environment:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ module.exports = function (address) {
1111
new_a = arr[0].split('&')[0];
1212
}
1313
} else {
14-
new_a = "invalid";
14+
new_a = null;
1515
}
1616
return new_a;
1717
}

lib/youtubeInfo.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
module.exports = async function (youtubeVideoId, play = false) {
3+
const response = await fetch(`https://pipedapi.kavin.rocks/streams/${youtubeVideoId}`)
4+
const json = await response.json();
5+
if (json) {
6+
let returnData = {url: `https://piped.kavin.rocks/watch?v=${youtubeVideoId}`, title: json['title'], thumbnail: json['thumbnailUrl']};
7+
if (play) {
8+
returnData['audioStreams'] = json['audioStreams'];
9+
returnData['videoStreams'] = json['videoStreams'];
10+
returnData['duration'] = json['duration'];
11+
}
12+
return returnData;
13+
}
14+
}

0 commit comments

Comments
 (0)