Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the date a video was uploaded through the Youtube API?

I'm confused as to where I can find the date a youtube video was uploaded. I've been using the following two functions:

$videoEntry->getUpdated()->getText();
$videoEntry->getVideoRecorded()

The first is when the video was last updated, and I'm not so sure that is the same as when it was uploaded. The "video recorded" is not always present. I assume its taken from camera metadata.

I need the date it was uploaded to the youtube website. Thanks.

like image 399
J3nnings Avatar asked Nov 09 '09 04:11

J3nnings


People also ask

What data can you get from YouTube API?

The API provides the ability to retrieve feeds related to videos, users, and playlists. It also provides the ability to manipulate these feeds, such as creating new playlists, adding videos as favorites, and sending messsages.

Can you find out the exact time an old YouTube video was uploaded?

By clicking on the description you can find the exact date of a youtube video. To know which date the video was uploaded and in which year, go to the description of that video, then you will see the date of publishing the video at the top.


4 Answers

From the YouTube API Reference Guide.

"The <yt:uploaded> tag specifies the time that a playlist entry was originally uploaded to YouTube."

If you just browse the feed file for a particular video, such as http://gdata.youtube.com/feeds/api/videos/bTL5bErRk-g, you can see the uploaded date in the "published" tag, near the top:

<entry>
    <id>http://gdata.youtube.com/feeds/api/videos/bTL5bErRk-g</id>
    <published>2009-08-02T13:59:54.000Z</published>
    <updated>2009-10-29T11:20:11.000Z</updated>
...

Whatever 'published' technically means to YouTube, that's my video, and I can confirm that that's when I uploaded it.

like image 200
Ralph Lavelle Avatar answered Sep 27 '22 20:09

Ralph Lavelle


I was actually hoping for an answer through the PHP API specifically. None of the functions in the documentation were working, though I was able to get the date uploaded from PHP like so:

$videoEntry->mediaGroup->uploaded->text
like image 41
J3nnings Avatar answered Sep 27 '22 22:09

J3nnings


Latest Youtube API supports date.

https://developers.google.com/youtube/v3/docs/search/list#examples

like image 25
freakk69 Avatar answered Sep 27 '22 21:09

freakk69


For Youtube V3, it's something like this:

https://www.googleapis.com/youtube/v3/videos?part=snippet&id=(youtube_video_id)&key=(your_oauth_key)

"publishedAt" seems to have the date and time of publication in UTC timezone

like image 28
georgiecasey Avatar answered Sep 27 '22 20:09

georgiecasey