Python error trying to get data from youtube apiHow to get the current time in PythonGetting the last element of a listHow do I get the number of elements in a list?How do I get a YouTube video thumbnail from the YouTube API?Why can't Python parse this JSON data?Why is reading lines from stdin much slower in C++ than Python?How to remove a key from a Python dictionary?Get View Count in YouTube V3 API for javaYouTube V3 API Playlistitems resourceIdRequiredYouTube PlayListitemInsert code not working API
What force enables us to walk? Friction or normal reaction?
Why are we moving in circles with a tandem kayak?
Is it safe if the neutral lead is exposed and disconnected?
How long does it take for electricity to be considered OFF by general appliances?
Semen retention is a important thing in Martial arts?
Is The Venice Syndrome documentary cover photo real?
8086 stack segment and avoiding overflow in interrupts
To find islands of 1 and 0 in matrix
Can this party play the Lost Mine of Phandelver adventure without too much trouble?
Blank spaces in a font
Can Papyrus be folded?
Can a US President, after impeachment and removal, be re-elected or re-appointed?
Why does Canada require bilingualism in a lot of federal government posts?
Surviving a planet collision?
If you inherit a Roth 401(k), is it taxed?
Who said "one can be a powerful king with a very small sceptre"?
Why did some Apollo missions carry a grenade launcher?
Why is it considered acid rain with pH <5.6?
Why put copper in between battery contacts and clamps?
How do I find the FamilyGUID of an exsting database
Why is softmax function used to calculate probabilities although we can divide each value by the sum of the vector?
What clothes would flying-people wear?
Did Vladimir Lenin have a cat?
Why did House of Representatives need to condemn Trumps Tweets?
Python error trying to get data from youtube api
How to get the current time in PythonGetting the last element of a listHow do I get the number of elements in a list?How do I get a YouTube video thumbnail from the YouTube API?Why can't Python parse this JSON data?Why is reading lines from stdin much slower in C++ than Python?How to remove a key from a Python dictionary?Get View Count in YouTube V3 API for javaYouTube V3 API Playlistitems resourceIdRequiredYouTube PlayListitemInsert code not working API
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have an issue, i am trying to make Python search for videos through the Youtube API, a part of the code doesn't work. When i try to get the tags of the video, it gives me an error.
So far i have used the example from Google "search_by_keyword".
It has worked well. I have however changed it a little.
What i want is Python to give me video IDs with the tags in that video.
I tried debugging, by making it print the whole "snippet" part of the table, it appears that "tags" are not found at all in "snippet"
only a bit of the code have been added, the rest is working find.
for search_result in search_response.get("items", []):
if search_result["id"]["kind"] == "youtube#video":
videos.append("%s (%s)" % (search_result["snippet"]["tags"],
search_result["id"]["videoId"]))
print ("Videos:n", "n".join(videos), "n")
At
videos.append("%s (%s)" % (search_result["snippet"]["tags"]
i expect it here to give me the tags of the video, but it only comes up with a traceback error "keyerror: tags".
Trying to make it print the whole "snippet" part, gives me everything but "tags" AND "categoryid"
I think the question comes down to:
Where do i find the "tags" element in the data table?
python api youtube youtube-api youtube-data-api
add a comment |
I have an issue, i am trying to make Python search for videos through the Youtube API, a part of the code doesn't work. When i try to get the tags of the video, it gives me an error.
So far i have used the example from Google "search_by_keyword".
It has worked well. I have however changed it a little.
What i want is Python to give me video IDs with the tags in that video.
I tried debugging, by making it print the whole "snippet" part of the table, it appears that "tags" are not found at all in "snippet"
only a bit of the code have been added, the rest is working find.
for search_result in search_response.get("items", []):
if search_result["id"]["kind"] == "youtube#video":
videos.append("%s (%s)" % (search_result["snippet"]["tags"],
search_result["id"]["videoId"]))
print ("Videos:n", "n".join(videos), "n")
At
videos.append("%s (%s)" % (search_result["snippet"]["tags"]
i expect it here to give me the tags of the video, but it only comes up with a traceback error "keyerror: tags".
Trying to make it print the whole "snippet" part, gives me everything but "tags" AND "categoryid"
I think the question comes down to:
Where do i find the "tags" element in the data table?
python api youtube youtube-api youtube-data-api
Can you share what error you have encountered when you are trying to run your code?
– MαπμQμαπkγVπ.0
Mar 27 at 8:03
add a comment |
I have an issue, i am trying to make Python search for videos through the Youtube API, a part of the code doesn't work. When i try to get the tags of the video, it gives me an error.
So far i have used the example from Google "search_by_keyword".
It has worked well. I have however changed it a little.
What i want is Python to give me video IDs with the tags in that video.
I tried debugging, by making it print the whole "snippet" part of the table, it appears that "tags" are not found at all in "snippet"
only a bit of the code have been added, the rest is working find.
for search_result in search_response.get("items", []):
if search_result["id"]["kind"] == "youtube#video":
videos.append("%s (%s)" % (search_result["snippet"]["tags"],
search_result["id"]["videoId"]))
print ("Videos:n", "n".join(videos), "n")
At
videos.append("%s (%s)" % (search_result["snippet"]["tags"]
i expect it here to give me the tags of the video, but it only comes up with a traceback error "keyerror: tags".
Trying to make it print the whole "snippet" part, gives me everything but "tags" AND "categoryid"
I think the question comes down to:
Where do i find the "tags" element in the data table?
python api youtube youtube-api youtube-data-api
I have an issue, i am trying to make Python search for videos through the Youtube API, a part of the code doesn't work. When i try to get the tags of the video, it gives me an error.
So far i have used the example from Google "search_by_keyword".
It has worked well. I have however changed it a little.
What i want is Python to give me video IDs with the tags in that video.
I tried debugging, by making it print the whole "snippet" part of the table, it appears that "tags" are not found at all in "snippet"
only a bit of the code have been added, the rest is working find.
for search_result in search_response.get("items", []):
if search_result["id"]["kind"] == "youtube#video":
videos.append("%s (%s)" % (search_result["snippet"]["tags"],
search_result["id"]["videoId"]))
print ("Videos:n", "n".join(videos), "n")
At
videos.append("%s (%s)" % (search_result["snippet"]["tags"]
i expect it here to give me the tags of the video, but it only comes up with a traceback error "keyerror: tags".
Trying to make it print the whole "snippet" part, gives me everything but "tags" AND "categoryid"
I think the question comes down to:
Where do i find the "tags" element in the data table?
python api youtube youtube-api youtube-data-api
python api youtube youtube-api youtube-data-api
asked Mar 26 at 20:33
Tor JakobsenTor Jakobsen
134 bronze badges
134 bronze badges
Can you share what error you have encountered when you are trying to run your code?
– MαπμQμαπkγVπ.0
Mar 27 at 8:03
add a comment |
Can you share what error you have encountered when you are trying to run your code?
– MαπμQμαπkγVπ.0
Mar 27 at 8:03
Can you share what error you have encountered when you are trying to run your code?
– MαπμQμαπkγVπ.0
Mar 27 at 8:03
Can you share what error you have encountered when you are trying to run your code?
– MαπμQμαπkγVπ.0
Mar 27 at 8:03
add a comment |
1 Answer
1
active
oldest
votes
As per Google's docs (https://developers.google.com/youtube/v3/docs/search#resource) the JSON object snippet obtained from Search endpoint has no tags member. Therefore, your code getting a KeyError exception exhibits correct behavior.
For reaching the tags property of a video resource (https://developers.google.com/youtube/v3/docs/videos#snippet.tags[]) you have to make a separate API call for each video you're interested in on Videos endpoint (https://developers.google.com/youtube/v3/docs/videos/list).
Addendum: you may alleviate calling the API several times on Videos endpoint for the videos you're interested in by specifying those videos -- in one API call only -- to the parameter id as a comma-separated list of video ids (https://developers.google.com/youtube/v3/docs/videos/list#id).
Thank you, it worked
– Tor Jakobsen
Mar 27 at 20:19
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55365769%2fpython-error-trying-to-get-data-from-youtube-api%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
As per Google's docs (https://developers.google.com/youtube/v3/docs/search#resource) the JSON object snippet obtained from Search endpoint has no tags member. Therefore, your code getting a KeyError exception exhibits correct behavior.
For reaching the tags property of a video resource (https://developers.google.com/youtube/v3/docs/videos#snippet.tags[]) you have to make a separate API call for each video you're interested in on Videos endpoint (https://developers.google.com/youtube/v3/docs/videos/list).
Addendum: you may alleviate calling the API several times on Videos endpoint for the videos you're interested in by specifying those videos -- in one API call only -- to the parameter id as a comma-separated list of video ids (https://developers.google.com/youtube/v3/docs/videos/list#id).
Thank you, it worked
– Tor Jakobsen
Mar 27 at 20:19
add a comment |
As per Google's docs (https://developers.google.com/youtube/v3/docs/search#resource) the JSON object snippet obtained from Search endpoint has no tags member. Therefore, your code getting a KeyError exception exhibits correct behavior.
For reaching the tags property of a video resource (https://developers.google.com/youtube/v3/docs/videos#snippet.tags[]) you have to make a separate API call for each video you're interested in on Videos endpoint (https://developers.google.com/youtube/v3/docs/videos/list).
Addendum: you may alleviate calling the API several times on Videos endpoint for the videos you're interested in by specifying those videos -- in one API call only -- to the parameter id as a comma-separated list of video ids (https://developers.google.com/youtube/v3/docs/videos/list#id).
Thank you, it worked
– Tor Jakobsen
Mar 27 at 20:19
add a comment |
As per Google's docs (https://developers.google.com/youtube/v3/docs/search#resource) the JSON object snippet obtained from Search endpoint has no tags member. Therefore, your code getting a KeyError exception exhibits correct behavior.
For reaching the tags property of a video resource (https://developers.google.com/youtube/v3/docs/videos#snippet.tags[]) you have to make a separate API call for each video you're interested in on Videos endpoint (https://developers.google.com/youtube/v3/docs/videos/list).
Addendum: you may alleviate calling the API several times on Videos endpoint for the videos you're interested in by specifying those videos -- in one API call only -- to the parameter id as a comma-separated list of video ids (https://developers.google.com/youtube/v3/docs/videos/list#id).
As per Google's docs (https://developers.google.com/youtube/v3/docs/search#resource) the JSON object snippet obtained from Search endpoint has no tags member. Therefore, your code getting a KeyError exception exhibits correct behavior.
For reaching the tags property of a video resource (https://developers.google.com/youtube/v3/docs/videos#snippet.tags[]) you have to make a separate API call for each video you're interested in on Videos endpoint (https://developers.google.com/youtube/v3/docs/videos/list).
Addendum: you may alleviate calling the API several times on Videos endpoint for the videos you're interested in by specifying those videos -- in one API call only -- to the parameter id as a comma-separated list of video ids (https://developers.google.com/youtube/v3/docs/videos/list#id).
edited Mar 27 at 11:41
answered Mar 27 at 7:01
stvarstvar
5391 gold badge3 silver badges7 bronze badges
5391 gold badge3 silver badges7 bronze badges
Thank you, it worked
– Tor Jakobsen
Mar 27 at 20:19
add a comment |
Thank you, it worked
– Tor Jakobsen
Mar 27 at 20:19
Thank you, it worked
– Tor Jakobsen
Mar 27 at 20:19
Thank you, it worked
– Tor Jakobsen
Mar 27 at 20:19
add a comment |
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55365769%2fpython-error-trying-to-get-data-from-youtube-api%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you share what error you have encountered when you are trying to run your code?
– MαπμQμαπkγVπ.0
Mar 27 at 8:03