Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature playlists #35

Open
wants to merge 2 commits into
base: playlists-feature
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,16 +191,24 @@ function displayMessage(m_title, message, type) {
}
//Parse an url to send
function parseUrlPlay(url, pathname, playhost) {
var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#\&\?]*).*/;
var regExp = /^.*(youtu.be\/|v\/|u\/\w\/|embed\/|watch\?v=)([^#\&\?]*).*?((&list=)([^#\&\?]*))?.*/;
var match = url.match(regExp);
if (match && match[2].length == 11) {
sendYouTube(match[2], playhost);
if(match[5]) {
sendYouTubeList(match[5], playhost);
} else {
sendYouTubeVideo(match[2], playhost);
}
return;
}
var regExp2 = /^.*(youtube.com\/watch.*[\?\&]v=)([^#\&\?]*).*/;
var regExp2 = /^.*(youtube.com\/watch.*[\?\&]v=)([^#\&\?]*).*?((&list=)([^#\&\?]*))?.*/;
var match2 = url.match(regExp2);
if (match2 && match2[2].length == 11) {
sendYouTube(match2[2], playhost);
if(match[5]) {
sendYouTubeList(match[5], playhost);
} else {
sendYouTubeVideo(match[2], playhost);
}
return;
}
if(pathname === ''){
Expand All @@ -221,8 +229,13 @@ function parseUrlQueue(url, pathname, playhost) {
return;
}
//Send a YouTube video
function sendYouTube(ytid, playhost) {
var url = 'plugin://plugin.video.youtube/?action=play_video&videoid=' + ytid;
function sendYouTubeVideo(ytid, playhost) {
var url = 'plugin://plugin.video.youtube/play/?video_id=' + ytid;
prepareSend(url, playhost);
}
//Send a YouTube playlist
function sendYouTubeList(listid, playhost) {
var url = 'plugin://plugin.video.youtube/play/?playlist_id=' + listid + '&order=default&play=1';
prepareSend(url, playhost);
}
//Get password for server
Expand Down