kktuax / youtupi

YouTube (mobile) web frontend for your Raspberry Pi
https://maxtuni.es/2013/02/16/Introducing-YouTuPi.html
20 stars 6 forks source link

Youtube Playlist Support #23

Closed ixs0792 closed 8 years ago

ixs0792 commented 8 years ago

These changes adds the ability to search for existing YouTube playlists. Searching for a playlist list=id (e.i "list=PLFs4vir_WsTwEd-nJgVJCZPNL3HALHHpF") returns the playlist songs.

Updated youtupi.youtube.js: function getYoutubeQueryUrl(){ var url; var query = $("#search-basic").val().trim(); if(query != ''){ if(query.indexOf("list=") > -1){ var lid = query.split("="); url = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId='+lid[1]+'&type=video&maxResults='+$('#slider').val()+'&key=AIzaSyAdAR3PofKiUSGFsfQ03FBEpVkVa1WA0J4'; } else { url = 'https://www.googleapis.com/youtube/v3/search?order=relevance&part=snippet&q='+query+'&type=video&maxResults='+$('#slider').val()+'&key=AIzaSyAdAR3PofKiUSGFsfQ03FBEpVkVa1WA0J4'; } } return url; }

function getYoutubeResponseVideos(response){ var videos = []; var entries = response.items || []; for (var i = 0; i < entries.length; i++) { var entry = entries[i]; if(typeof entry.video != 'undefined'){ entry = entry.video; } var video = {} if(typeof entry.id.videoId != 'undefined'){ video.id = entry.id.videoId; } else { video.id = entry.snippet.resourceId.videoId; }
video.description = entry.snippet.description; video.title = entry.snippet.title; video.duration = entry.duration; if(typeof entry.snippet.thumbnails != 'undefined'){ if(typeof entry.snippet.thumbnails.high != 'undefined'){ video.thumbnail = entry.snippet.thumbnails.high.url; }else if(typeof entry.snippet.thumbnails.medium != 'undefined'){ video.thumbnail = entry.snippet.thumbnails.medium.url; }else{ video.thumbnail = entry.snippet.thumbnails.default.url; } } video.type = "youtube"; video.operations = [ {'name': 'download', 'text': 'Download', 'successMessage': 'Video downloaded'} ]; videos.push(video); } return videos; }

kktuax commented 8 years ago

Thanks for your changes! I have incorported then, but with the prefix: list: instead of list=

pantallazo

You can also now use lists: for searching for youtube playlists. pantallazo-1

ixs0792 commented 8 years ago

I used the "=" because of the easy cut and paste from the youtube URL, but the ":" works just as well.

Now, is there an elegant way to modify the search return limit to be >50. So far I've been modifying around line 290 in youtupi.js to capture the nextPageToken in the response and call the search again, but I haven't figured out a clean solution "n" results just yet.

kktuax commented 8 years ago

I have added a next page button, please try updating after commit 7d7d0cdb1e0ebefcc5da10f479128cd570b62824

ixs0792 commented 8 years ago

Absolutely Perfect! I like the "lists:" search. Thank you for the great work.