How to show thumbnails of YouTube videos

my site allows users to download youtube video codes. I'm trying to make a playlist by showing thumbnails of downloaded videos and playing the corresponding video after clicking on the thumbnail.

I would like to know how to get the title and thumbnails of those videos that were downloaded using the youtube built-in code?

Edit:

To make the question clearer, my users download the code as shown below:

<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/-L8DFfSJbqU&hl=en_US&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/-L8DFfSJbqU&hl=en_US&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>

so from this code, how can I first find the vedio id and then the second snapshot?

+3
source share
6 answers

YouTube, URL- -

:

http://img.youtube.com/vi/<youtube-video-id>/default.jpg

(HQ):

http://img.youtube.com/vi/<youtube-video-id>/hqdefault.jpg

:

http://img.youtube.com/vi/<youtube-video-id>/mqdefault.jpg

:

http://img.youtube.com/vi/<youtube-video-id>/maxresdefault.jpg

,

YouTube link - http://www.youtube.com/watch?v=4EvNxWhskf8
YouTube video id - 4EvNxWhskf8

, -

<img src="http://img.youtube.com/vi/4EvNxWhskf8/hqdefault.jpg" title="YouTube Video" alt="YouTube Video" />
+5

API YouTube:

   /* Some stuff goes before here to initialize API connection */

   /* Then get started: */
   $yt = new Zend_Gdata_YouTube()
   $videoEntry = $yt->getVideoEntry('the0KZLEacs'); //Video-ID
   $videoThumbnails = $videoEntry->getVideoThumbnails()

   echo 'Video: ' . $videoEntry->getVideoTitle() . "\n";
   echo 'Video ID: ' . $videoEntry->getVideoId() . "\n";
   echo 'Updated: ' . $videoEntry->getUpdated() . "\n";
   echo 'Description: ' . $videoEntry->getVideoDescription() . "\n";
   echo 'Category: ' . $videoEntry->getVideoCategory() . "\n";
   echo 'Tags: ' . implode(", ", $videoEntry->getVideoTags()) . "\n";
   echo 'Watch page: ' . $videoEntry->getVideoWatchPageUrl() . "\n";
   echo 'Flash Player Url: ' . $videoEntry->getFlashPlayerUrl() . "\n";
   echo 'Duration: ' . $videoEntry->getVideoDuration() . "\n";
   echo 'View count: ' . $videoEntry->getVideoViewCount() . "\n";
   echo 'Rating: ' . $videoEntry->getVideoRatingInfo() . "\n";
   echo 'Geo Location: ' . $videoEntry->getVideoGeoLocation() . "\n";
   echo 'Recorded on: ' . $videoEntry->getVideoRecorded() . "\n";

:

+3

, ,

http://shofnee.com/metal_shofnee/apps/youtube_app/youtube_app.php

, , php

 <?php
                //getting and validating the embed code
                $cde = $_POST['txt_embd'];
                if(!empty($cde))
                {
                $part_one_cde = explode("/",$cde);

                $part_2_cde = explode("?",$part_one_cde[4]);

                $img_1 = "http://img.youtube.com/vi/$part_2_cde[0]/0.jpg";
                $img_2 = "http://img.youtube.com/vi/$part_2_cde[0]/1.jpg";
                $img_3 = "http://img.youtube.com/vi/$part_2_cde[0]/2.jpg";

                echo "Img 1";
                echo "<br />";
                echo "<img src=\"$img_3\" width=\"100\" height=\"100\" />";
                echo"<br /><br />";
                echo "Img 2";
                echo "<br />";
                echo "<img src=\"$img_2\" width=\"150\" height=\"150\" />";
                echo"<br /><br />";
                echo "Img 3";
                echo "<br />";
                echo "<img src=\"$img_1\" width=\"200\" height=\"200\" />";

                }
                else
                {
                echo "Please put any embed code to get it pics ...";  

                }
                ?>
+2

, ,

:

http://img.youtube.com/vi/VIDEO_ID/default.jpg

, :

<object width="640" height="385"><param name="movie" value="http://www.youtube.com/v/-L8DFfSJbqU&hl=en_US&fs=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/-L8DFfSJbqU&hl=en_US&fs=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="640" height="385"></embed></object>

-:

http://www.youtube.com/v/-L8DFfSJbqU&hl=en_US&fs=1

:

-L8DFfSJbqU

:

http://img.youtube.com/vi/-L8DFfSJbqU/default.jpg
+1

API GData youtube , , ..

, :

http://code.google.com/apis/youtube/2.0/reference.html#youtube_data_api_tag_media:thumbnail

Do not re-encode URLs, because Google can change them when it wants. Use the API.

+1
source

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


All Articles