Python检索视频url youtube api v3

2024-04-18 16:55:36 发布

您现在位置:Python中文网/ 问答频道 /正文

所以,我有一个连接聊天室的python应用程序和一个检索youtube视频的命令。我根本不懂检索视频的v3api系统。我在java中找到了一个,但这对我没有任何帮助,因为我对它不是很在行。你知道吗

有人知道我怎样才能让v3api与下面的脚本一起工作吗?我有开发人员密钥,所以这不是问题。谢谢

elif used_prefix and cmd=="youtube" and len(args) > 0:
            try:
                yword=args.replace(" ","_")
                ydata= urlreq.urlopen("https://www.googleapis.com/youtube/v3/search?part=snippet&MaxResults=1&q="+yword+"key=")
                yread= str(ydata.read())
                if "<openSearch:totalResults>0</openSearch:totalResults>" in yread:
                    room.message("No results found for "+args)
                else:
                    trash , yclean=yread.split("<media:player url='http://www.youtube.com/watch?v=",1)
                    yclean , trash=yclean.split("&amp;",1)
                    room.message("http://http://www.youtube.com/watch?v="+yclean,True)
            except:
                room.message("Error.")

我已经尝试了好几种选择,但都没有成功。你知道吗

任何与此相关的帮助都将不胜感激,因为我已经厌倦了v3api。你知道吗


Tags: andcomhttpmessage视频youtubewwwargs