我试图使用YouTube数据API v3从其YouTube id获得单个视频。我正在使用谷歌API python客户端。当我尝试执行以下代码时:
search_response = youtube.search().list(
id="QkhBcLk_8f0",
part="snippet",
).execute()
我总是得到这个错误:
Traceback (most recent call last):
File "search.py", line 55, in <module>
youtube_search(args)
File "search.py", line 24, in youtube_search
part="snippet",
File "/usr/local/lib/python2.7/dist-packages/googleapiclient/discovery.py",
line 669, in method
raise TypeError('Got an unexpected keyword argument "%s"' % name)
TypeError: Got an unexpected keyword argument "id"
但是我知道API中有一个id
参数,因为它在参考中列出。
您应该使用youtube.videos()
方法。
youtube.videos().list(id="QkhBcLk_8f0",part="snippet").execute()
{u'etag': u'"YxyobdYztCvdjXOUqpUttvF39GM/nr0_6QcUDyGR0D_Gxz762lsqqfU"',
u'items': [{u'etag': u'"YxyobdYztCvdjXOUqpUttvF39GM/n7wasYBTHMM3SB4Jtsxu6JeDFPA"',
u'id': u'QkhBcLk_8f0',
u'kind': u'youtube#video',
u'snippet': {u'categoryId': u'27',
u'channelId': u'UCzu2OUGZlNtXPom3KNPGFzg',
u'channelTitle': u'FFreeThinker',
u'description': u'http://facebook.com/ScienceReason ... Great Minds, Great Words: Richard Feynman - The Uncertainty of Knowledge ... The Nature and Purpose of the Universe.nnPlaylist "Great Minds, Great Words":nu2022 http://www.youtube.com/user/FFreeThinker#grid/user/CC4F721030F8D4D1nn---nPlease SUBSCRIBE to Science & Reason:nu2022 http://www.youtube.com/FFreeThinkernu2022 http://www.youtube.com/ScienceTVnu2022 http://www.youtube.com/Best0fSciencenu2022 http://www.youtube.com/RationalHumanismn---nnRichard Feynman (1918-1988) was an American physicist known for his work in the path integral formulation of quantum mechanics, the theory of quantum electrodynamics and the physics of the superfluidity of supercooled liquid helium, as well as in particle physics (he proposed the parton model).nnFor his contributions to the development of quantum electrodynamics, Feynman, jointly with Julian Schwinger and Sin-Itiro Tomonaga, received the Nobel Prize in Physics in 1965. He developed a widely used pictorial representation scheme for the mathematical expressions governing the behavior of subatomic particles, which later became known as Feynman diagrams. During his lifetime, Feynman became one of the best-known scientists in the world.nnHe assisted in the development of the atomic bomb and was a member of the panel that investigated the Space Shuttle Challenger disaster. In addition to his work in theoretical physics, Feynman has been credited with pioneering the field of quantum computing, and introducing the concept of nanotechnology (creation of devices at the molecular scale). He held the Richard Chace Tolman professorship in theoretical physics at the California Institute of Technology.nnFeynman was a keen popularizer of physics through both books and lectures, notably a 1959 talk on top-down nanotechnology called "There's Plenty of Room at the Bottom" and "The Feynman Lectures on Physics". Feynman also became known through his semi-autobiographical books ("Surely You're Joking, Mr. Feynman!" and "What Do You Care What Other People Think?") and books written about him, such as "Tuva or Bust!"nnHe was regarded as an eccentric and free spirit. He was a prankster, juggler, safecracker, proud amateur painter, and bongo player. He liked to pursue a variety of seemingly unrelated interests, such as art, percussion, Maya hieroglyphs, and lock picking.nnFeynman also had a deep interest in biology, and was a friend of the geneticist and microbiologist Esther Lederberg, who developed replica plating and discovered bacteriophage lambda. They had several mutual physicist friends who, after beginning their careers in nuclear research, moved for moral reasons into genetics, among them Lexf3 Szilxe1rd, Guido Pontecorvo, and Aaron Novick.nnu2022 http://en.wikipedia.org/wiki/Richard_Feynmann.',
u'liveBroadcastContent': u'none',
u'localized': {u'description': u'http://facebook.com/ScienceReason ... Great Minds, Great Words: Richard Feynman - The Uncertainty of Knowledge ... The Nature and Purpose of the Universe.nnPlaylist "Great Minds, Great Words":nu2022 http://www.youtube.com/user/FFreeThinker#grid/user/CC4F721030F8D4D1nn---nPlease SUBSCRIBE to Science & Reason:nu2022 http://www.youtube.com/FFreeThinkernu2022 http://www.youtube.com/ScienceTVnu2022 http://www.youtube.com/Best0fSciencenu2022 http://www.youtube.com/RationalHumanismn---nnRichard Feynman (1918-1988) was an American physicist known for his work in the path integral formulation of quantum mechanics, the theory of quantum electrodynamics and the physics of the superfluidity of supercooled liquid helium, as well as in particle physics (he proposed the parton model).nnFor his contributions to the development of quantum electrodynamics, Feynman, jointly with Julian Schwinger and Sin-Itiro Tomonaga, received the Nobel Prize in Physics in 1965. He developed a widely used pictorial representation scheme for the mathematical expressions governing the behavior of subatomic particles, which later became known as Feynman diagrams. During his lifetime, Feynman became one of the best-known scientists in the world.nnHe assisted in the development of the atomic bomb and was a member of the panel that investigated the Space Shuttle Challenger disaster. In addition to his work in theoretical physics, Feynman has been credited with pioneering the field of quantum computing, and introducing the concept of nanotechnology (creation of devices at the molecular scale). He held the Richard Chace Tolman professorship in theoretical physics at the California Institute of Technology.nnFeynman was a keen popularizer of physics through both books and lectures, notably a 1959 talk on top-down nanotechnology called "There's Plenty of Room at the Bottom" and "The Feynman Lectures on Physics". Feynman also became known through his semi-autobiographical books ("Surely You're Joking, Mr. Feynman!" and "What Do You Care What Other People Think?") and books written about him, such as "Tuva or Bust!"nnHe was regarded as an eccentric and free spirit. He was a prankster, juggler, safecracker, proud amateur painter, and bongo player. He liked to pursue a variety of seemingly unrelated interests, such as art, percussion, Maya hieroglyphs, and lock picking.nnFeynman also had a deep interest in biology, and was a friend of the geneticist and microbiologist Esther Lederberg, who developed replica plating and discovered bacteriophage lambda. They had several mutual physicist friends who, after beginning their careers in nuclear research, moved for moral reasons into genetics, among them Lexf3 Szilxe1rd, Guido Pontecorvo, and Aaron Novick.nnu2022 http://en.wikipedia.org/wiki/Richard_Feynmann.',
u'title': u'Great Minds: Richard Feynman - The Uncertainty Of Knowledge'},
u'publishedAt': u'2010-03-04T15:12:56.000Z',
u'tags': [u'great',
u'minds',
u'words',
u'richard',
u'feynman',
u'uncertainty',
u'knowledge',
u'nature',
u'purpose',
u'universe',
u'god',
u'religion',
u'atheists',
u'atheism',
u'science',
u'physicists',
u'quantum',
u'mechanics',
u'electrodynamics',
u'superfluidity',
u'nobel',
u'prize',
u'theoretical',
u'physics',
u'atomic',
u'bomb',
u'space',
u'nano',
u'technology'],
u'thumbnails': {u'default': {u'height': 90,
u'url': u'https://i.ytimg.com/vi/QkhBcLk_8f0/default.jpg',
u'width': 120},
u'high': {u'height': 360,
u'url': u'https://i.ytimg.com/vi/QkhBcLk_8f0/hqdefault.jpg',
u'width': 480},
u'maxres': {u'height': 720,
u'url': u'https://i.ytimg.com/vi/QkhBcLk_8f0/maxresdefault.jpg',
u'width': 1280},
u'medium': {u'height': 180,
u'url': u'https://i.ytimg.com/vi/QkhBcLk_8f0/mqdefault.jpg',
u'width': 320},
u'standard': {u'height': 480,
u'url': u'https://i.ytimg.com/vi/QkhBcLk_8f0/sddefault.jpg',
u'width': 640}},
u'title': u'Great Minds: Richard Feynman - The Uncertainty Of Knowledge'}}],
u'kind': u'youtube#videoListResponse',
u'pageInfo': {u'resultsPerPage': 1, u'totalResults': 1}}