Is it possible to search multiple channels with one query? - javascript

I want to search multiple channels via the Channels.id parameter for videos with one query.
For example:
My request URL is: https://youtube.googleapis.com/youtube/v3/search?part=snippet&channelId=UCSzAsgKDpNkch1eRA9w5nww%20%2B%20UCyCBf6asf89aQJaSXuAuTsg&q=Bitcoin&type=video&key=[YOUR_API_KEY]
The answer is:
{
"kind": "youtube#searchListResponse",
"etag": "DCv8u79rz_Z5yPVlSxf2awnPWTQ",
"regionCode": "DE",
"pageInfo": {.
"totalResults": 0,
"resultsPerPage": 0
},
}, "items": []
}
Is it not possible with YouTube Search API V3 in 2022 to search multiple Channel.id's for a topic with one request?
I have already tried several combining operators.
Am i doing something wrong?

No, it's not possible in the way you're trying - when using multiple channels (or multiple values in a field/parameter for that matter), values are comma-separated, but, even with this fix to the request, the API does not bring any results.
See demo
Instead, you should make one request per channel.
Search with channelId UCSzAsgKDpNkch1eRA9w5nww - see demo # 1
Search with channelId UCyCBf6asf89aQJaSXuAuTsg - see demo # 2
If instead, you want to search channels that matches your criteria (Bitcoin in region DE), then see this sample
Results (summarized):
{
"kind": "youtube#searchListResponse",
"etag": "MF1reS3I3oQvjOtYP2oZ8FI9sJ8",
"nextPageToken": "CAUQAA",
"regionCode": "DE",
"pageInfo": {
"totalResults": 19344,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "pBsNFEU4k7Fc5rWvL9z8woS_0ew",
"id": {
"kind": "youtube#channel",
"channelId": "UCwdYYyyX9V3u_b6URNpBh_w"
},
"snippet": {
"publishedAt": "2020-05-24T15:48:35Z",
"channelId": "UCwdYYyyX9V3u_b6URNpBh_w",
"title": "Bitcoin verstehen",
"description": "Was ist Bitcoin und wieso benötigen wir ihn? In diesem Podcast bringen wir neugierigen Einsteigern und auch Fortgeschrittenen ...",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/nz1XMTZCai2Op7clT386e3l9vFBb2eYKOexx8udRqDbmwDqkR10els3i-RYeH7ukSSoGWtSDp8A=s88-c-k-c0xffffffff-no-rj-mo"
},
"medium": {
"url": "https://yt3.ggpht.com/nz1XMTZCai2Op7clT386e3l9vFBb2eYKOexx8udRqDbmwDqkR10els3i-RYeH7ukSSoGWtSDp8A=s240-c-k-c0xffffffff-no-rj-mo"
},
"high": {
"url": "https://yt3.ggpht.com/nz1XMTZCai2Op7clT386e3l9vFBb2eYKOexx8udRqDbmwDqkR10els3i-RYeH7ukSSoGWtSDp8A=s800-c-k-c0xffffffff-no-rj-mo"
}
},
"channelTitle": "Bitcoin verstehen",
"liveBroadcastContent": "none",
"publishTime": "2020-05-24T15:48:35Z"
}
},
{
"kind": "youtube#searchResult",
"etag": "j2amjttw_gCECoVnlJEB4Y5g41E",
"id": {
"kind": "youtube#channel",
"channelId": "UC61jC9ggxeGu8HJ9Q_TxOGg"
},
"snippet": {
"publishedAt": "2013-09-06T02:12:33Z",
"channelId": "UC61jC9ggxeGu8HJ9Q_TxOGg",
"title": "BITCOIN",
"description": "YouTube.com/c/BITC0IN https://Odysee.com/#BITCOIN:d77 https://Twitter.com/BITC0INALLCAPS https://zbd.gg/BITC0IN - Tip ...",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/WG8_95AszbGpSw8w2Qx1VWq_1Ko6-VIvfezMG_YRi330HpZMWQaroK1wMf--zBXKddg4TW2Wvg=s88-c-k-c0xffffffff-no-rj-mo"
},
"medium": {
"url": "https://yt3.ggpht.com/WG8_95AszbGpSw8w2Qx1VWq_1Ko6-VIvfezMG_YRi330HpZMWQaroK1wMf--zBXKddg4TW2Wvg=s240-c-k-c0xffffffff-no-rj-mo"
},
"high": {
"url": "https://yt3.ggpht.com/WG8_95AszbGpSw8w2Qx1VWq_1Ko6-VIvfezMG_YRi330HpZMWQaroK1wMf--zBXKddg4TW2Wvg=s800-c-k-c0xffffffff-no-rj-mo"
}
},
"channelTitle": "BITCOIN",
"liveBroadcastContent": "upcoming",
"publishTime": "2013-09-06T02:12:33Z"
}
},
[...]
]
}

Related

How to get a youtube channelid from the channels link programmatically

I need to get the channelid of a youtube channel (to use the youtube data api) with the link of the channel.
The problem is that there are a few types of links for a youtube channel.
The first one is where the channel id is in the link:
https://www.youtube.com/channel/UC-lHJZR3Gqxm24_Vd_AJ5Yw
This is ok because i can just extract the channelid from the link.
The problem comes with the second one:
https://www.youtube.com/#PewDiePie
This is the link you normally get for a youtube channel and it has a # instead of the channelid.
When i use the youtube api to get the channel id of a not so popular channel i get the wrong results:
https://www.googleapis.com/youtube/v3/search?part=snippet&q=#pewdiepie6&type=channel&key=[API_KEY]
I would like to get the channel info and channelid for the channel with the #pewdiepie6 handle.
But i get the more popular channel with the #pewdiepie6802 handle.
Also, i get more than 1 channel as a result.
{
"kind": "youtube#searchListResponse",
"etag": "ecshCA97Jd0CuntIj9NzN3UF37U",
"nextPageToken": "CAUQAA",
"regionCode": "CH",
"pageInfo": {
"totalResults": 51,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "x4yStPuXhfUUIaev-BCMiq1JQ4E",
"id": {
"kind": "youtube#channel",
"channelId": "UCnJABWFF_vWuPgPjGjVJF8A"
},
"snippet": {
"publishedAt": "2018-03-02T14:07:51Z",
"channelId": "UCnJABWFF_vWuPgPjGjVJF8A",
"title": "PewDiePie",
"description": "",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu84CCwyUjzgQkuvN7ms2JUCU0EgofxrTdhZLZKs=s88-c-k-c0xffffffff-no-rj-mo"
},
"medium": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu84CCwyUjzgQkuvN7ms2JUCU0EgofxrTdhZLZKs=s240-c-k-c0xffffffff-no-rj-mo"
},
"high": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu84CCwyUjzgQkuvN7ms2JUCU0EgofxrTdhZLZKs=s800-c-k-c0xffffffff-no-rj-mo"
}
},
"channelTitle": "PewDiePie",
"liveBroadcastContent": "none",
"publishTime": "2018-03-02T14:07:51Z"
}
},
{
"kind": "youtube#searchResult",
"etag": "2et4mkoeeilV2DhJRH7M5xlgnuQ",
"id": {
"kind": "youtube#channel",
"channelId": "UCSn7KcaNdOrVf4aH-6OdFMg"
},
"snippet": {
"publishedAt": "2017-04-23T06:06:06Z",
"channelId": "UCSn7KcaNdOrVf4aH-6OdFMg",
"title": "PewDiePie 6",
"description": "",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu8OB0Z-JNTYnB2Q0KLoV6LjvpUYpYfN0sfAMgfT=s88-c-k-c0xffffffff-no-rj-mo"
},
"medium": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu8OB0Z-JNTYnB2Q0KLoV6LjvpUYpYfN0sfAMgfT=s240-c-k-c0xffffffff-no-rj-mo"
},
"high": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu8OB0Z-JNTYnB2Q0KLoV6LjvpUYpYfN0sfAMgfT=s800-c-k-c0xffffffff-no-rj-mo"
}
},
"channelTitle": "PewDiePie 6",
"liveBroadcastContent": "none",
"publishTime": "2017-04-23T06:06:06Z"
}
},
{
"kind": "youtube#searchResult",
"etag": "88l8OAYbY0S8XY9NbWcqW2QtJJ4",
"id": {
"kind": "youtube#channel",
"channelId": "UCpqNuOLjibXIO43tJbZ-s3w"
},
"snippet": {
"publishedAt": "2017-06-17T21:56:28Z",
"channelId": "UCpqNuOLjibXIO43tJbZ-s3w",
"title": "PewDiePie",
"description": "",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu-GIq-DWy8zPGzPmQnb5LHvR_MlnlK3t-G5-45i=s88-c-k-c0xffffffff-no-rj-mo"
},
"medium": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu-GIq-DWy8zPGzPmQnb5LHvR_MlnlK3t-G5-45i=s240-c-k-c0xffffffff-no-rj-mo"
},
"high": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu-GIq-DWy8zPGzPmQnb5LHvR_MlnlK3t-G5-45i=s800-c-k-c0xffffffff-no-rj-mo"
}
},
"channelTitle": "PewDiePie",
"liveBroadcastContent": "none",
"publishTime": "2017-06-17T21:56:28Z"
}
},
{
"kind": "youtube#searchResult",
"etag": "MItPbLglqDfEkQ-fXSbQef7js2c",
"id": {
"kind": "youtube#channel",
"channelId": "UCQXfsdNRgLL0Cz67stMFNVQ"
},
"snippet": {
"publishedAt": "2018-03-31T09:27:20Z",
"channelId": "UCQXfsdNRgLL0Cz67stMFNVQ",
"title": "Marian Pewdiepie 6",
"description": "Nu voi mai posta mai mult de 1 an căci nu prea am vhef Dar totuși dați subscribe.",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu9G8MRCxqrk5dCx9T6lxjWpaAL62QuD54LGpgV6=s88-c-k-c0xffffffff-no-rj-mo"
},
"medium": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu9G8MRCxqrk5dCx9T6lxjWpaAL62QuD54LGpgV6=s240-c-k-c0xffffffff-no-rj-mo"
},
"high": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu9G8MRCxqrk5dCx9T6lxjWpaAL62QuD54LGpgV6=s800-c-k-c0xffffffff-no-rj-mo"
}
},
"channelTitle": "Marian Pewdiepie 6",
"liveBroadcastContent": "upcoming",
"publishTime": "2018-03-31T09:27:20Z"
}
},
{
"kind": "youtube#searchResult",
"etag": "_yNYVPOhK2ZEn0yq580TFty6AHU",
"id": {
"kind": "youtube#channel",
"channelId": "UCR8SFIzFOxf50N0lYER8_-w"
},
"snippet": {
"publishedAt": "2019-03-09T20:56:38Z",
"channelId": "UCR8SFIzFOxf50N0lYER8_-w",
"title": "Go sub to Pewdiepie 6",
"description": "",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu_3fwpv9uhEyzb_bUgNuzETQHpdgvKv-xDSYQ=s88-c-k-c0xffffffff-no-rj-mo"
},
"medium": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu_3fwpv9uhEyzb_bUgNuzETQHpdgvKv-xDSYQ=s240-c-k-c0xffffffff-no-rj-mo"
},
"high": {
"url": "https://yt3.ggpht.com/ytc/AMLnZu_3fwpv9uhEyzb_bUgNuzETQHpdgvKv-xDSYQ=s800-c-k-c0xffffffff-no-rj-mo"
}
},
"channelTitle": "Go sub to Pewdiepie 6",
"liveBroadcastContent": "none",
"publishTime": "2019-03-09T20:56:38Z"
}
}
]
}
I also tried to extract the channelid out of the javascript of the page but using Beautiful Soup.
But i could not get it to return the right javascript.
There is also a second api link with the forUsername parameter.
But with this link it tries to look for a user which uploads on a channel which is not what i want.
At the end of the day i want a safe method to get the channel id with the channels link.
https://www.youtube.com/#pewdiepie6
=> UCl-0ct6u2AAfsqGGgVh5dEw
(I got this manually out of the #pewdiepie6 javascript file from the page at externalid)

trouble while parsing json

I am trying to react displayName in req
when I write
console.log(req.session.passport.user._raw)
the output is:
{
"kind": "plus#person",
"etag": "\"ucaTEV-ZanNH5M3SCxYRM0QRw2Y/XiR7kPThRbzcIw-YLiARoF22TMY\"",
"emails": [
{
"value": "rajanlagah#gmail.com",
"type": "account"
}
],
"objectType": "person",
"id": "100428644453494579140",
"displayName": "Rajan Lagah",
"name": {
"familyName": "Lagah",
"givenName": "Rajan"
},
"url": "https://plus.google.com/100428644453494579140",
"image": {
"url": "https://lh3.googleusercontent.com/-XdUIqdMkCWA/AAAAAAAAAAI/AAAAAAAAAAA/4252rscbv5M/photo.jpg?sz=50",
"isDefault": true
},
"isPlusUser": true,
"language": "en",
"circledByCount": 0,
"verified": false
}
Now the from this object I am trying to get kind (say)
console.log(req.session.passport.user._raw.kind)
then the output is undefined
Can any one tell my mistake?
Is req.session.passport.user._raw a string? You may need to parse it first, eg:
var data = JSON.parse(req.session.passport.user._raw);
console.log(data.kind);

Get Youtube Video URL using Youtube V3 API & JavaScript

I have searched alot on this topic but i was only able to find resources related to V2 of Youtube API which is nor depricated.
What i want to do is get Youtube video title, thumbnail and link from the JSON response of the Youtube V3 API URL using Javascript.
I run the code below but get an error message Uncaught TypeError: Cannot read property 'items' of undefined
<input id="searchquery" />
<div id="results"></div>
<!-- Include the latest jQuery library -->
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function ($) {
$('#searchquery').keyup(function () {
// the search term
var q = $('#searchquery').val().trim();
// container to display search results
var $results = $('#results');
// YouTube Data API base URL (JSON response)
var url = "https://www.googleapis.com/youtube/v3/search?part=snippet&order=date&key=AIzaSyC3TJRI1C0EVEdl7b19InH1gv9yrAOX2YU"
url = url + '&max-results=50';
$.getJSON(url + "&q=" + q, function (json) {
var count = 0;
if (json.data.items) {
var items = json.data.items;
var html = "";
items.forEach(function (item) {
// Check the duration of the video,
// full-length movies are generally longer than 1 hour
var duration = Math.round((item.duration) / (60 * 60));
// Filter out videos that aren't in the Film or Movies category
if ((duration > 1) && (item.category == "Movies" || item.category == "Film")) {
// Include the YouTube Watch URL youtu.be
html += '<p><a href="http://youtu.be/' + item.id + '">';
// Add the default video thumbnail (default quality)
html += '<img src="http://i.ytimg.com/vi/' + item.id + '/default.jpg">';
// Add the video title and the duration
html += '<h2>' + item.title + ' ' + item.duration + '</h2></a></p>';
count++;
}
});
}
// Did YouTube return any search results?
if (count === 0) {
$results.html("No videos found");
} else {
// Display the YouTube search results
$results.html(html);
}
});
});
});
</script>
My url is
https://www.googleapis.com/youtube/v3/search?part=snippet&order=date&key=AIzaSyC3TJRI1C0EVEdl7b19InH1gv9yrAOX2YU&q=opencourseware
this returns
{
"kind": "youtube#searchListResponse",
"etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/anQeVHiFN6CH_dx-tP89Q8heOos\"",
"nextPageToken": "CAUQAA",
"pageInfo": {
"totalResults": 24815,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/4DMiUQkDt0Bic4cV0lZbi7KZ1tk\"",
"id": {
"kind": "youtube#playlist",
"playlistId": "PL-4XVpiAbrw8bRUhUHfm-omUYAyBepYiB"
},
"snippet": {
"publishedAt": "2015-09-01T06:23:39.000Z",
"channelId": "UCOY4GuDhH3KHVcpZqD5S87w",
"title": "Popular Videos - Bioinformatics & OpenCourseWare",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/R-PjAS8d1_0/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/R-PjAS8d1_0/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/R-PjAS8d1_0/hqdefault.jpg"
}
},
"channelTitle": "",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/-D3XCQyB-podnhbL-keBQoIZMb8\"",
"id": {
"kind": "youtube#video",
"videoId": "vOpp8nOp9uA"
},
"snippet": {
"publishedAt": "2015-08-10T09:27:38.000Z",
"channelId": "UCBL-6EKd9b1DW73ZcY-PNcw",
"title": "Audio OpenCourseWare",
"description": "OpenCourseWare dilaksanakan pada tanggal 10 Juli 2015 di Ruang Video Conference, Gedung D, Lantai 2 Direktorat Sistem Informasi, Telkom University ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/vOpp8nOp9uA/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/vOpp8nOp9uA/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/vOpp8nOp9uA/hqdefault.jpg"
}
},
"channelTitle": "",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/hwBjyzzUi0M3qf0QKR6EvAD6RTs\"",
"id": {
"kind": "youtube#playlist",
"playlistId": "PL2Co6UkQCJCrvFuM-KEY6Pfccm2PKNhGe"
},
"snippet": {
"publishedAt": "2015-08-03T21:28:26.000Z",
"channelId": "UCqHlUWMIi07M5U6kVSJT7RA",
"title": "Popular Videos - OpenCourseWare & Teacher",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/SQI2I48QUBQ/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/SQI2I48QUBQ/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/SQI2I48QUBQ/hqdefault.jpg"
}
},
"channelTitle": "",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/igp-ZANLFmAQxfuTsPHpNeJwdwg\"",
"id": {
"kind": "youtube#playlist",
"playlistId": "PLfu3FYNDydnC8bAZrkXpFXXxbCE8O9ZYS"
},
"snippet": {
"publishedAt": "2015-07-07T15:38:00.000Z",
"channelId": "UCqL4K9FRJ90uHEvRsSXi5cA",
"title": "Popular Videos - MIT OpenCourseWare & Field",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/PgE9oBDIgdc/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/PgE9oBDIgdc/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/PgE9oBDIgdc/hqdefault.jpg"
}
},
"channelTitle": "",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"sGDdEsjSJ_SnACpEvVQ6MtTzkrI/9G1cGWzCiMxuc7L_KpgWTyJFjzk\"",
"id": {
"kind": "youtube#playlist",
"playlistId": "PL2Co6UkQCJCp_IpNmpim5CPhKC0gE95jv"
},
"snippet": {
"publishedAt": "2015-06-19T21:28:19.000Z",
"channelId": "UCqHlUWMIi07M5U6kVSJT7RA",
"title": "Popular Videos - OpenCourseWare & Educational Technology",
"description": "",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/ad4oFCHBSRQ/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/ad4oFCHBSRQ/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/ad4oFCHBSRQ/hqdefault.jpg"
}
},
"channelTitle": "",
"liveBroadcastContent": "none"
}
}
]
}
Change json.data.items to json.items

trying to bind a JSON object to a dropdownlist

Good afternoon SO,
I have a dropdownbox called: "#dropDownDest" I'm trying to bind
a JSON object to this dropdown "dropdowndest" but have been unable to do so.
Would you please direct me on what exactly am I doing wrong?
$('#dropDownDest').html('<pre>' + JSON.stringify(JSONOBJECT) + '</pre>');
This is a sample of the return JSON element:
{
"kind": "youtube#searchListResponse",
"etag": "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/x2_4Du3jO25OnFY9_O_B3xXrQC0\"",
"nextPageToken": "CAUQAA",
"pageInfo": {
"totalResults": 1000000,
"resultsPerPage": 5
},
"items": [
{
"kind": "youtube#searchResult",
"etag": "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/M-VYdHEsqyE1SqT3g91C7VdEHj0\"",
"id": {
"kind": "youtube#video",
"videoId": "Vi8VKaOi2nc"
},
"snippet": {
"publishedAt": "2014-05-09T16:12:09.000Z",
"channelId": "UClsy9JcwIVaq29WhPFI0eBg",
"title": "BEST FUNNY DOGS COMPILATION LONG (2013 - 2014)",
"description": "BEST FUNNY DOGS COMPILATION (2013 - 2014) Funny Animals includes cats, dogs, elephants, goats, otters, seals, birds, monkeys, Funny Cats, Funny, Dogs, ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/Vi8VKaOi2nc/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/Vi8VKaOi2nc/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/Vi8VKaOi2nc/hqdefault.jpg"
}
},
"channelTitle": "onehourcompilations",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/YEKnjRQqLp8j1qKJDy8sxNW3wKY\"",
"id": {
"kind": "youtube#video",
"videoId": "D_eo7PZy4Dc"
},
"snippet": {
"publishedAt": "2015-05-12T17:00:01.000Z",
"channelId": "UC5GSO2hiHevgZUhSQIJNd2A",
"title": "SLEEPING DOGS - RENDIAMOCI UTILI",
"description": "A 5€ qui: http://bit.ly/ScontiGiochi Sitorna a menare le mani su Sleeping Dogs, dopo GTA 5 mi è tornata voglia di andare in Cina a picchiare un po' di sgherri.",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/D_eo7PZy4Dc/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/D_eo7PZy4Dc/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/D_eo7PZy4Dc/hqdefault.jpg"
}
},
"channelTitle": "QueiDueSulServer2",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/5M32hctZeuP9PvX7ZBoiAx5oVeM\"",
"id": {
"kind": "youtube#video",
"videoId": "CpbYBZKdi3s"
},
"snippet": {
"publishedAt": "2014-05-10T21:37:35.000Z",
"channelId": "UCKy3MG7_If9KlVuvw3rPMfw",
"title": "Cute dogs waking up owners - Funny dog compilation",
"description": "Awesome Halloween costumes for babies, children and adults: For babies: Puppy costume: ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/CpbYBZKdi3s/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/CpbYBZKdi3s/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/CpbYBZKdi3s/hqdefault.jpg"
}
},
"channelTitle": "wloltigerlolw2",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/0SjgjtKwO10wRaYuKHIJ15B6i1s\"",
"id": {
"kind": "youtube#video",
"videoId": "fk9iJougDFE"
},
"snippet": {
"publishedAt": "2014-07-23T19:09:29.000Z",
"channelId": "UCsKQLakuQKvr4LG4VLOpWDQ",
"title": "10 MINUTES OF FUNNY DOGS",
"description": "SUBSCRIBE & BECOME A FOLLOWER OF FUNNY: http://www.youtube.com/subscription_center?add_user=tuneintoaccess NEW VIDEOS MONDAY, ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/fk9iJougDFE/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/fk9iJougDFE/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/fk9iJougDFE/hqdefault.jpg"
}
},
"channelTitle": "tuneintoaccess",
"liveBroadcastContent": "none"
}
},
{
"kind": "youtube#searchResult",
"etag": "\"tbWC5XrSXxe1WOAx6MK9z4hHSU8/o0Zb5d1-RECh4OCIVJgkLnvP9BA\"",
"id": {
"kind": "youtube#video",
"videoId": "RKBcs9tNWg8"
},
"snippet": {
"publishedAt": "2013-08-16T03:09:51.000Z",
"channelId": "UCVUdHi-tdW5AKdzMiTPG97Q",
"title": "Dogs Welcoming Soldiers Home Compilation 2012 [HD]",
"description": "Soldiers coming home to their lovable pups Dogs Welcome Home Soldiers 2014 - https://www.youtube.com/watch?v=5BnxV9H_ExA Puppies & Babies & Kitties ...",
"thumbnails": {
"default": {
"url": "https://i.ytimg.com/vi/RKBcs9tNWg8/default.jpg"
},
"medium": {
"url": "https://i.ytimg.com/vi/RKBcs9tNWg8/mqdefault.jpg"
},
"high": {
"url": "https://i.ytimg.com/vi/RKBcs9tNWg8/hqdefault.jpg"
}
},
"channelTitle": "funnyplox",
"liveBroadcastContent": "none"
}
}
]
}
See http://jsfiddle.net/qxn7sry3/1/
You need to select some value for the option value and the text. You can iterate through the array in the object and append them to the select as <option ...
for (var i = 0; i < JSONOBJECT.items.length; i++) {
var item = JSONOBJECT.items[i];
$("#dropDownDest").append('<option value=' + item.id.videoId + '>' + item.snippet.title + '</option>');
}

Retrieve Youtube Tags using Jquery

I'm trying to figure out how to retrieve Youtube Tags and use them in my code behind, but I can't even seem to retrieve any information whatsoever. What would be the best way to retrieve tags with a delimiter like a , or a ; ?
var video_id='VA770wpLX-Q';
$.getJSON('http://gdata.youtube.com/feeds/api/videos/'+video_id+'?v=2&alt=jsonc',function(data,status,xhr){
alert(data.data.tags);
});
This is what the Json object looks like:
{
"apiVersion": "2.1",
"data": {
"id": "VA770wpLX-Q",
"uploaded": "2011-02-24T22:31:02.000Z",
"updated": "2012-04-08T21:37:06.000Z",
"uploader": "drdrevevo",
"category": "Music",
"title": "Dr. Dre - I Need A Doctor (Explicit) ft. Eminem, Skylar Grey",
"description": "Music video by Dr. Dre performing I Need A Doctor featuring Eminem and Skylar Grey (Explicit). © 2011 Aftermath Records",
"tags": ["Dr", "Dre", "Eminem", "New", "Song", "Skylar", "Grey", "GRAMMYs", "Dr.", "Need", "Doctor", "video", "Eazy", "N.W.A.", "NWA", "easy", "drdre", "and", "em"],
"thumbnail": {
"sqDefault": "http://i.ytimg.com/vi/VA770wpLX-Q/default.jpg",
"hqDefault": "http://i.ytimg.com/vi/VA770wpLX-Q/hqdefault.jpg"
},
"player": {
"default": "http://www.youtube.com/watch?v=VA770wpLX-Q&feature=youtube_gdata_player"
},
"content": {
"5": "http://www.youtube.com/v/VA770wpLX-Q?version=3&f=videos&app=youtube_gdata"
},
"duration": 457,
"aspectRatio": "widescreen",
"rating": 4.902695,
"likeCount": "430519",
"ratingCount": 441253,
"viewCount": 88270796,
"favoriteCount": 306556,
"commentCount": 270597,
"status": {
"value": "restricted",
"reason": "requesterRegion"
},
"restrictions": [{
"type": "country",
"relationship": "deny",
"countries": "DE"
}],
"accessControl": {
"comment": "allowed",
"commentVote": "allowed",
"videoRespond": "allowed",
"rate": "allowed",
"embed": "allowed",
"list": "allowed",
"autoPlay": "denied",
"syndicate": "allowed"
}
}
}
Youtube no longer supports "tag" functionality with it's API.

Categories

Resources