How to get youtube video description with video id? - javascript

I am currently using the Javascript API by youtube to display a video on my web page however now I want to also retrieve the youtube description from the video id? How would I go about doing this?
I only want description and title:
ex:
"kind": "youtube#video",
"etag": etag,
"id": string,
"snippet": {
"publishedAt": datetime,
"channelId": string,
"title": string,
"description": string,
"thumbnails": {
(key): {
"url": string,
"width": unsigned integer,
"height": unsigned integer
}
https://developers.google.com/youtube/v3/docs/videos
If anyone could post a link or either show me an example of code on how I can accomplish this?

The developer documentation you linked to has some excellent code examples -- that'll be the best place to start. Use the "list" reference menu for videos.
If you're saying that you just want the title and description without the other fields, you can use the fields parameter in your request ... something like this:
https://www.googleapis.com/youtube/v3/videos?part=snippet&id={VIDEO_ID}&fields=items/snippet/title,items/snippet/description&key={YOUR_API_KEY}

Related

What paramater am I missing for YouTube Data API Insert method

I'm using Google's Apps Script for this project. I'm using the YouTube data API V3 and of that API I am using the PlaylistItems class. I'm trying to insert a video into a playlist and I've pieced together what I can from the documentation that they have given.
YouTube.PlaylistItems.insert({
"part": [
"snippet"
],
"resource": {
"snippet": {
"playlistId": "PL5t3YGq3D2WnrLyuYL9WCgprQ2RUcwl8a",
"position": 0,
"resourceId": {
"kind": "youtube#video",
"videoId": testVidId
// testVidId is the ID of the video I'm trying to insert
}
}
}
});
When I run this though, I get an error of
Exception: Invalid number of arguments provided. Expected 2-3 only
My question is: what argument am I missing?
I believe your goal as follows.
You want to insert an item to the play list using Google Apps Script.
Modification point:
When YouTube.PlaylistItems.insert(resource, part) is used, the arguments are resource, part which are an object and an array of string, respectively.
When your script is modified, it becomes as follows.
Modified script:
YouTube.PlaylistItems.insert(
{
"snippet": {
"playlistId": "PL5t3YGq3D2WnrLyuYL9WCgprQ2RUcwl8a",
"position": 0,
"resourceId": {
"kind": "youtube#video",
"videoId": testVidId
}
}
},
["snippet"]
);
Note:
Before you use this, please confirm whether YouTube Data API v3 is enabled at Advanced Google services, again.
Reference:
PlaylistItems: insert

Use the YouTube API to check if a video is embeddable

I'm trying to figure out if a YouTube video is embeddable using the YouTube Data API v3, from answers to similar questions I noticed the status.embeddable property of videos, for a request like this:
https://www.googleapis.com/youtube/v3/videos?id=63flkf3S1bE&part=contentDetails,status&key={MY_API_KEY}
The response is the following
{
"kind": "youtube#videoListResponse",
"etag": "\"ksCrgYQhtFrXgbHAhi9Fo5t0C2I/ctZQYtBcOuMdnQXh8-Fv1EbS_VA\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"ksCrgYQhtFrXgbHAhi9Fo5t0C2I/Cd8aGZD09NPuGYNumIEozZs2S90\"",
"id": "63flkf3S1bE",
"contentDetails": {
"duration": "PT8M23S",
"dimension": "2d",
"definition": "hd",
"caption": "false",
"licensedContent": false,
"projection": "rectangular"
},
"status": {
"uploadStatus": "processed",
"privacyStatus": "public",
"license": "youtube",
"embeddable": true,
"publicStatsViewable": true,
"madeForKids": false
}
}
]
}
The embeddable parameter under status is returned as true, HOWEVER this video is not actually embeddable, as can be seen here.
When actually embedding the video using the iframe API, there is a more detailed error message as well:
Video unavailable
This video contains content from International Olympic Committee, who has blocked it from display on this website or application.
Watch on YouTube
I don't see how it is possible to detect this case from the YouTube Data API - can anyone help out?
Other option is used in this answer:
Here, you can use the following URL:
https://www.youtube.com/get_video_info?video_id=<VIDEO_ID>
Where VIDEO_ID is the YouTube video_id you want retrieve the information.
In this case, once you get the response, you'll see a property called "playabilityStatus.status".
Here is a extract of the response:
"playabilityStatus": {
"status": "UNPLAYABLE",
"reason": "The video is not available",
"errorScreen": {
"playerErrorMessageRenderer": {
"reason": {
"simpleText": "The video is not available"
},
Additional to johnh10's answer, some of the results saw in the YouTube webpage is not always shown/available in the APIs.
I have the answer. The file that outputs from the https://www.youtube.com/get_video_info?video_id=
is nothing more than a standard text file that is URLENCODED.
To see it properly you first have to DECODE it using a URLDECODER and then you have to separate the json part from the URL querystring part. To take a look at the JSON part you can use a json formatted and to look at the URL part you can use PrettyPrint URL.
Once you do this you will notice that the tag you are looking for to validate weather the video is playable or not is the one mentioned by the other user here. It sits on the URL parameter named "player_response", after you DECODE the file you will find it easily. This parameter holds a longer JSON file that has the playability status under playabilityStatus.Status.
To manipulate it on Javascript simply parse this part of the file as a JSON file and access your node of choice, or parse it as a text and search for the playabilityStatus node that must be unencoded if you dont care to decode it (nothing to fear, only some %2D and %7B instead of spaces and curly brackets).
Good luck!
Unfortunately, this 'copyright check' happens directly from the player. This data is not available through the API.

Facebook Graph API - get page feed + full event info?

Is it possible to, in 1 request, get the feed of a page but with the full event info?
As it is now, if a shared event is posted, you only get back the link to that event, no picture or title:
{
"id": "xxx",
"from": {
"category": "Community",
"name": "xxx",
"id": "xxx"
},
"story": "xxx shared xxx's event.",
"link": "https://www.facebook.com/events/xxx/",
"actions": [
{
"name": "Comment",
"link": "https://www.facebook.com/xxx/posts/xxx"
},
{
"name": "Like",
"link": "https://www.facebook.com/xxx/posts/xxx"
}
],
"privacy": {
"value": ""
},
"type": "link",
"status_type": "shared_story",
"application": {
"name": "Links",
"id": "xxx"
},
"created_time": "2013-06-19T10:05:50+0000",
"updated_time": "2013-06-19T10:05:50+0000",
"likes": {
"data": [
{
"name": "xxx",
"id": "xxx"
}
],
"count": 1
}
}
If I understand correctly, you need to retrieve the events but you want to do it all at once with the feed because you want to retrieve the information on the feed anyway.
Before doing that, you must know that the feed doesn't contain all the events.... Once created, a link to the event is automatically shared on the page feed. It is only a reference, which can then be hidden. The event won't be displayed on the feed anymore even if it still exists.
Requesting two different objects at the same time
So, the feed doesn't have the events information and the events and posts (feed) are stored on 2 different tables. Therefore, you need to get the events independently from the feed:
The feed /PAGE_ID/feed
The events /PAGE_ID/events
And, as you wanted, Graph API allows you to do this in only one request:
/PAGE_ID?fields=feed,events
Additional fields
Note that either feed or events accept the limit and fields parameters. For example, events can be specified by:
events.limit(100).fields(location,name,owner,description,updated_time,venue)
Possible fields are given in the doc.
There is no way to get the "full info" at once. You will have to specify each field in the request. So, don't get the "full info", but just the information you really need.
There is a post from Facebook addressing this scenario using multi-queries and FQL (Facebook Query Language). This will allow you to make multiple FQL calls in one request.
https://developers.facebook.com/docs/technical-guides/fql/#multi

How to generate a dynamic search form for Django?

I wrote a REST API based on Django's ORM. Here's some examples of my REST API
curl "http://example.com/api/pcserver?last_update__lt=2012-06-01 00:00:00&hostname__startswith=xen"
On server side, I uses a queryset.filter() function to process all the GET parameters, and convert the result queryset into a json, then return to user.
Now I'm having trouble convert this API into web based search form.
What I want to have about this magic search form:
dynamic add/delete query parameters using javascript, join them using AND (I don't need OR between these parameters)
provide drop down menu to select the field to be searched based on the model
support for selecting operators e.g. __lt, __gt, __regex
Are there any wheels out there so I don't have to re-invent it? Thank you:-)
#yegle
I'd suggest to use this media type: http://code.ge/media-types/collection-next-json/ it's an extension of the: http://amundsen.com/media-types/collection/format/ media type and you can achieve your goal without problems.
Look at this document:
{"collection": {
"version": 1.0,
"queries": [
{
"href": "http://service.com/my-resource",
"rel": "search",
"prompt": "Enter search string",
"data" : [
{
"name": "query",
"prompt": "Search query",
"required": true
}, {
"name": "gender",
"prompt": "Gender",
"list": {
"default": "female",
"options": [
{"value": "female", "prompt": "Female"},
{"value": "male", "prompt": "Male"}
]
}
}
]
}
]
}}
with "queries" array you can describe several search templates which easily can be transformed to the HTML form. In each query object you can define:
Search URI
Title of the "form"(i.e. prompt); and
Any number of query parameters with different requirements.
As you see from example above there are two query parameters - "query" and "gender", of which "query" parameter can be converted to HTML.input and "gender" parameter to HTML.select.
I hope I correctly understood your question and goal.
I am not sure about django tools.However,you can use MYSQL's full text boolean search to achieve most of the above requirements.Refer the below link and revert back with your comments!
http://dev.mysql.com/doc/refman//5.5/en/fulltext-boolean.html
Have a look at django-filter
Or, in some hacking way, use Django Admin. You could customize a ModelAdmin for the target model and use ChangeList to deal w/ querystring. Take built-in User for example:
from django.contrib.admin.options.IncorrectLookupParameters
from django.contrib.admin.views.main import ChangeList
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
self = UserAdmin(User, None) # or taken from admin.site._registry if the model admin is registered
cl = ChangeList(request, User, self.list_display,
self.list_display_links, self.list_filter, self.date_hierarchy,
self.search_fields, self.list_select_related,
self.list_per_page, self.list_max_show_all, self.list_editable,
self)
# then cl.get_query_set would process querystring and generate the queryset
try:
cl.get_query_set(request)
except IncorrectLookupParameters:
'encounter an invalid lookup'

facebook graph api picture

How can I retrieve friends picture using graph api.
I have manage to get my friends profile picture using this
https://graph.facebook.com/{user_id}
But, I want to get the photos my friend has posted.
I am able to get this data
"link": "http://www.facebook.com/photo.php?fbid=121312&set=a.23342344855.11344514&type=1",
"name": "~KAALAM moments :)",
"caption": "51 new photos",
"icon": "http://static.ak.fbcdn.net/rsrc.php/v1/yz/r/StEh3RhPvjk.gif",
"actions": [
{
"name": "Comment",
"link": "http://www.facebook.com/1140004514/posts/12234"
},
{
"name": "Like",
"link": "http://www.facebook.com/1140004514/posts/12234"
}
],
"type": "photo",
"object_id": "2554798026153",
To get your friend's pictures you will need
Valid access token with friends_photos
HTTP GET \{friendId}\photos to get photo's the friend is tagged in
or
Valid access token with friends_photos
HTTP GET \{friendId}\albums to get a friend's albums listing, loop thru it to get the photos in each album by \{albumId}\photos
Try it out here: https://developers.facebook.com/tools/explorer

Categories

Resources