Retrieving videos from a custom playlist -YouTube API

Is there a way to get a list of videos from a specific user playlist? I tried the next call, but it doesnโ€™t seem to give me a list of videos in this playlist

Power: //gdata.youtube.com/feeds/users/USERNAME/playlists/PLAYLIST_ID

Thanks in advance,

Scott

+8
youtube-api
source share
2 answers

http://gdata.youtube.com/feeds/api/playlists/PLAYLIST_ID

Update

Just to add to this answer. This url above ... works, however, like @crunkchitis mentioned below.

This will not work for me because I used the wrong playlist id. My playlists looked like โ€œPL123456789โ€, but make sure โ€œPLโ€ and use โ€œ123456789โ€ as the identifier for the playlist! - @crunkchitis

If you need a way to extract this information ... using PHP ...

<?php $cont = json_decode(file_get_contents('http://gdata.youtube.com/feeds/api/playlists/[PLAYLIST_ID]/?v=2&alt=json&feature=plcp')); ?> <?php $feed = $cont->feed->entry; ?> <?php if(count($feed)): foreach($feed as $item): // youtube start ?> <?php echo $item->title->{'$t'} ?> <br /> <?php echo $item->{'media$group'}->{'media$description'}->{'$t'} ?> <?php endforeach; endif; // youtube end ?> 

user print_r($item) if you need other information such as thumbnail, identifier, etc.

Hope this helps

+19
source share

I really struggle with this myself. I found him. but its not quite easy to get to. I am using json. Therefore, if you use xml, you need to add "& alt = json" and then the end of your URL.

I found under an array of records. in the media ad $ group-> media $ content-> media $ thumbnail they have a list of thumbnails for the video. Each of them contains a video identifier in its path. Not the best solution, but it should work fine.

 "media$group": { "media$content": [ { "url": "http://www.youtube.com/p/PLE7C605988F1AFDAA", "type": "application/x-shockwave-flash", "yt$format": 5 } ], "media$thumbnail": [ { "url": "https://i.ytimg.com/vi/[VIDEO_ID]/default.jpg", "height": 90, "width": 120, "yt$name": "default" }, { "url": "https://i.ytimg.com/vi/[VIDEO_ID]/mqdefault.jpg", "height": 180, "width": 320, "yt$name": "mqdefault" }, { "url": "https://i.ytimg.com/vi/[VIDEO_ID]/hqdefault.jpg", "height": 360, "width": 480, "yt$name": "hqdefault" } ], "media$title": { "$t": "[VIDEO_NAME]", "type": "plain" } }, 
+1
source share

Source: https://habr.com/ru/post/650721/


All Articles