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;








1















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?










share|improve this question
























  • 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

















1















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?










share|improve this question
























  • 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













1












1








1








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?










share|improve this question














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






share|improve this question













share|improve this question











share|improve this question




share|improve this question










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

















  • 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












1 Answer
1






active

oldest

votes


















2














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).






share|improve this answer



























  • Thank you, it worked

    – Tor Jakobsen
    Mar 27 at 20:19










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
);



);













draft saved

draft discarded


















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









2














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).






share|improve this answer



























  • Thank you, it worked

    – Tor Jakobsen
    Mar 27 at 20:19















2














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).






share|improve this answer



























  • Thank you, it worked

    – Tor Jakobsen
    Mar 27 at 20:19













2












2








2







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).






share|improve this answer















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).







share|improve this answer














share|improve this answer



share|improve this answer








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

















  • 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








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.



















draft saved

draft discarded
















































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.




draft saved


draft discarded














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





















































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







Popular posts from this blog

Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현