is there any chance to get video information with or without youtube APIs? right now I'm getting the thumbnail of videos using their video_id but I want information like title, description, views, YouTuber profile picture, and YouTuber name. I looked at youtube docs but just simple things like using players for playing videos.
this is the way I get thumbnails.
"https://img.youtube.com/vi/${videoID}/0.jpg"
also, I'm using youtube API for playing videos in my app with this code.
val intent = YouTubeStandalonePlayer.createVideoIntent(requireActivity(), "AIzaSyChnBzNGITQM2gUc52RnRfG3eDYmYRAhQ8", video_id)
startActivity(intent)
You can use these API to get video data
https://www.googleapis.com/youtube/v3/videos?id=VIDEO_ID&key=YOUR_API_KEY&part=snippet,statistics&fields=items(id,snippet,statistics)
Note: just add your API key in place of YOUR_API_KEY and pass videoId in place of VIDEO_ID.
API Response
{
"videos": [
{
"id": "7lCDEYXw3mM",
"snippet": {
"publishedAt": "2012-06-20T22:45:24.000Z",
"channelId": "UC_x5XG1OV2P6uZZ5FSM9Ttw",
"title": "Google I/O 101: Q&A On Using Google APIs",
"description": "Antonio Fuentes speaks to us and takes questions on working with Google APIs and OAuth 2.0.",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/7lCDEYXw3mM/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/7lCDEYXw3mM/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/7lCDEYXw3mM/hqdefault.jpg"
}
},
"categoryId": "28"
},
"statistics": {
"viewCount": "3057",
"likeCount": "25",
"dislikeCount": "0",
"favoriteCount": "17",
"commentCount": "12"
}
}
]
}
Related
Can anybody tell me how can i play the live streaming cam video from this response of API world-cam..
I am getting problem to preview the video from this link directly :
{
"live": {
"available": true,
"embed": "https://api.lookr.com/embed/player/1485691420/live"
},
"day": {
"available": true,
"link": "https://www.lookr.com/lookout/1485691420#action-play-day",
"embed": "https://api.lookr.com/embed/player/1485691420/day"
},
"month": {
"available": true,
"link": "https://www.lookr.com/lookout/1485691420#action-play-month",
"embed": "https://api.lookr.com/embed/player/1485691420/month"
},
}
If you wish stream and play Video in Android App , you can use this library : Vitamio Library
I have recently implemented Google Custom search. I am getting a result but it every link in it whether it is for website or image or thumbnail, it is from maps.
example result -
{
"kind": "customsearch#result",
"title": "Saga Tree",
"htmlTitle": "Saga \u003cb\u003eTree\u003c/b\u003e",
"link": "https://***www.google.com/mymaps***/viewer?mid=1yF1gMCZhBaeEouT9GB-7bQqXmuw&hl=en",
"formattedUrl": "***https://www.google.com/mymaps***/viewer?mid...7bQqXmuw&hl...",
"pagemap": {
"cse_thumbnail": [
{
"width": "221",
"height": "228",
"src": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2SZoZ2AF7PUVw5wGucLb5Hd4k1Bwkt3x6__ed8E_01Mlq5Fwd7nKpKI2b"
}
],
"website": [
{
"name": "Saga Tree",
"description": "Saga Tree",
"url": "***https://www.google.com/maps/d/viewer***?mid=1yF1gMCZhBaeEouT9GB-7bQqXmuw&hl=en",
"image": "***https://www.google.com/maps***/d/thumbnail?mid=1yF1gMCZhBaeEouT9GB-7bQqXmuw&hl=en"
}
],
"metatags": [
{
"viewport": "initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0,width=device-width",
"og:type": "website",
"og:title": "Saga Tree",
"og:description": "Saga Tree",
"og:url": "***https://www.google.com/maps***/d/viewer?mid=1yF1gMCZhBaeEouT9GB-7bQqXmuw&hl=en",
"og:image": "***https://www.google.com/maps***/d/thumbnail?mid=1yF1gMCZhBaeEouT9GB-7bQqXmuw&hl=en",
"twitter:card": "summary_large_image",
"twitter:title": "Saga Tree",
"twitter:description": "Saga Tree",
"twitter:image:src": "https://www.google.com/maps/d/thumbnail?mid=1yF1gMCZhBaeEouT9GB-7bQqXmuw&hl=en"
}
],
"cse_image": [
{
"src": "https://www.google.com/maps/d/thumbnail?mid=1yF1gMCZhBaeEouT9GB-7bQqXmuw&hl=en"
}
]
}
}
This is with every result. I want results as if I have searched it in the browser.
This usually happens when the Custom Search API performs search only with the default included site ( www.google.com ). This is the default. To change it go to Basics -> Sites to Search under your Custom Search engine and choose "Search the entire web but emphasise included sites" instead of the default "Search only included sites".
Also ensure Image Search is enabled under Basics.
Here is my json file i use thumbnail on listview but there no such tag that fetch videos . Define it which tag i use ?
That perfectly add thumbnail or other things
Below is my preview of Listview items
{
"kind": "youtube#playlistItemListResponse",
"etag": "\"GM4ZnRh2gk1X1BLWgHklTm-3cgQ/uvcwjZ_9_NYCLF7JAzfY5FiuzuQ\"",
"nextPageToken": "CAUQAA",
"pageInfo": {
"totalResults": 1998,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#playlistItem",
"etag": "\"GM4ZnRh2gk1X1BLWgHklTm-3cgQ/dCBViPWfe-MGrqHIcuMZ55HcLJ0\"",
"id": "VVVHaENWR1owWlNwZTVoSkhXeWlMd0hBLlZHRHFaakFMSF9N",
"snippet": {
"publishedAt": "2017-01-26T08:58:26.000Z",
"channelId": "UCGhCVGZ0ZSpe5hJHWyiLwHA",
"title": "Top 10 - Scariest scenes in Resident evil 7",
"description": "Resident Evil 7 brings the series back to its roots while mak Epidemic Sound.\nhttp://www.epidemicsound.com/youtube-creator-subscription/",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/VGDqZjALH_M/default.jpg",
"width": 120,
"height": 90
},
},
"channelTitle": "ZoominGames",
"playlistId": "UUGhCVGZ0ZSpe5hJHWyiLwHA",
"position": 0,
"resourceId": {
"kind": "youtube#video",
"videoId": "VGDqZjALH_M"
}
}
},
Well, it is true that you cannot find any url in the json output. The only thing that you can get from here is the videoId.
You can use this videoId as part of this https://www.youtube.com/watch?v="insert_videoId" to get a video link.
So in your case, this is the link https://www.youtube.com/watch?v=VGDqZjALH_M
I am newer in youtube api,I need help for implementing youtube api in android. I have find one youtube api for getting all channel list on associated username https://www.googleapis.com/youtube/v3/channels?part=snippet&forUsername={USERNAME}&key={YOUR_API_KEY}. I have created 3 channels in my youtube account but above api is not getting response.
This is response for above api with valid username and api key
{
"kind": "youtube#channelListResponse",
"etag": "\"I_8xdZu766_FSaexEaDXTIfEWc0/ewwRz0VbTYpp2EGbOkvZ5M_1mbo\"",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
},
"items": []
}
Use it like this:
https://www.googleapis.com/youtube/v3/channels?part=statistics&id=channel_id&key=your_key
You can try your API request here: https://developers.google.com/youtube/v3/docs/channels/list#try-it
Request:
HTTP GET: GET https://www.googleapis.com/youtube/v3/channels?part=statistics&id={CHANNEL_ID}&key={YOUR_API_KEY}
Response (with id=UCt7iVnJwjBsof8IPLJHCTgQ):
{
"kind": "youtube#channelListResponse",
"etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/WNxXCvycTyqTjTn9sLJ5toVjBRY\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#channel",
"etag": "\"dhbhlDw5j8dK10GxeV_UG6RSReM/jijTuA_iWn2Kv9aRnqeAWNAcQ6I\"",
"id": "UCt7iVnJwjBsof8IPLJHCTgQ",
"statistics": {
"viewCount": "796662",
"commentCount": "20",
"subscriberCount": "257",
"hiddenSubscriberCount": false,
"videoCount": "126"
}
}
]
}
You can pass in a comma-separated list of Channel IDs for the id parameter. Because I only passed in one id, the first object of the items array will have the values you need. Get the object for the subscriberCount and videoCount values in the statistics dictionary for the data you want.
I'm building an app for Android to read twitter feed I got an issue to play video from a tweet. Currently my tweet feed is showing the thumb image and when I click on it, if it's an image I show the image and in case of a video I expect to be able to play it.
To load the image, I'm doing:
ImageLoader mImageLoader = new ImageLoader(mActivity);
mImageLoader.DisplayImage(mPicToShowUrl, tweet_pic) ;
mPicToShowUrl is coming from :
mediaEntity.getMediaURL().toString();
mediaEntity is coming from the Twitter4j Status.getExpandedURL
tweet_pic is just an ImageView
The URL get look like : example.com/xxx/status/89284924/video/1 which is mainly unusable on any player as it do not contain something like xxx.com/1.avi
This kind of URL and ImageLoader allow to load an image. I'm looking for the same method for a video
I think the twitter video is more a streaming video
Any idea how to play a video from twitter in an ImageView or any other View ?
Thanks
You need to look in the extended_entities of the response. You'll see something like
"extended_entities": {
"media": [
{
"id": 567972074346807300,
"id_str": "567972074346807296",
"indices": [
46,
68
],
"media_url": "http://pbs.twimg.com/ext_tw_video_thumb/567972074346807296/pu/img/uz53Ap4wEah7cV50.jpg",
"media_url_https": "https://pbs.twimg.com/ext_tw_video_thumb/567972074346807296/pu/img/uz53Ap4wEah7cV50.jpg",
"url": "http://t.co/cGazAn7H3E",
"display_url": "pic.twitter.com/cGazAn7H3E",
"expanded_url": "http://twitter.com/katiemoffat/status/567972190639022080/video/1",
"type": "video",
"sizes": {
"small": {
"w": 340,
"h": 340,
"resize": "fit"
},
"thumb": {
"w": 150,
"h": 150,
"resize": "crop"
},
"medium": {
"w": 600,
"h": 600,
"resize": "fit"
},
"large": {
"w": 720,
"h": 720,
"resize": "fit"
}
},
"video_info": {
"aspect_ratio": [
1,
1
],
"duration_millis": 6605,
"variants": [
{
"bitrate": 832000,
"content_type": "video/mp4",
"url": "https://video.twimg.com/ext_tw_video/567972074346807296/pu/vid/480x480/eU1s1ig_skHgeRjB.mp4"
},
{
"content_type": "application/x-mpegURL",
"url": "https://video.twimg.com/ext_tw_video/567972074346807296/pu/pl/tr7sF7aHBPOCuL8H.m3u8"
},
{
"bitrate": 832000,
"content_type": "video/webm",
"url": "https://video.twimg.com/ext_tw_video/567972074346807296/pu/vid/480x480/eU1s1ig_skHgeRjB.webm"
},
{
"bitrate": 1280000,
"content_type": "video/mp4",
"url": "https://video.twimg.com/ext_tw_video/567972074346807296/pu/vid/720x720/njkDGgpJBpsTjQD3.mp4"
},
{
"bitrate": 320000,
"content_type": "video/mp4",
"url": "https://video.twimg.com/ext_tw_video/567972074346807296/pu/vid/240x240/Gye4gcWtlJq8zXhF.mp4"
}
]
}
}
]
},
So, you need to access extended_entities->media->video_info->variants to see all the different sizes and formats of video available.
You can choose between different sizes of MP4, a WEBM, and a stream - depending on what is suitable for the device you're playing back on.
(Taken from https://shkspr.mobi/blog/2015/02/working-with-the-twitter-videos-api/ )