Skip to content

Commit

Permalink
fixed youtube api change
Browse files Browse the repository at this point in the history
it seems youtube changed their api,
and the npm-package we use passed that along to us. great!

Made adjustments to their api and improved user feedback
when no videos were found.

Closes #231
  • Loading branch information
keydon committed Aug 17, 2019
1 parent 90eb637 commit aa8d663
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -1132,11 +1132,16 @@ exports.kodiPlayYoutube = (request, response) => { // eslint-disable-line no-unu
})).then((foundVideos) => {

let items = foundVideos
.filter((video) => video.filetype === 'file')
.filter((video) => video.filetype === 'file' || video.kind === 'youtube#video')
.map((video) => ({
file: `plugin://plugin.video.youtube/play/?video_id=${video.id}`
}));

if (items.length === 0) {
console.log(foundVideos);
return new Error(`No playable videos found!`);
}

console.log(`Playing ${items.length} youtube videos:`);

return kodi.Playlist.Clear({ // eslint-disable-line new-cap
Expand Down Expand Up @@ -1259,6 +1264,18 @@ exports.kodiTogglePartymode = (request) => {
.then((playerid) => togglePartyMode(kodi, playerid));
};

const getDirecoryContents = (kodi, path) => {
return kodi.Files.GetDirectory({ // eslint-disable-line new-cap
directory: path
})
.then((kodiResponse) => {
if (!(kodiResponse && kodiResponse.result && kodiResponse.result.files && kodiResponse.result.files.length > 0)) {
throw new Error('directory was empty');
}
return kodiResponse.result.files;
});
};

exports.kodiToggleFullscreen = (request) => { // eslint-disable-line no-unused-vars
console.log('Toggle Fullscreen request received');
let Kodi = request.kodi;
Expand Down

0 comments on commit aa8d663

Please sign in to comment.