首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >频道上传播放列表id返回playlistNotFound

频道上传播放列表id返回playlistNotFound
EN

Stack Overflow用户
提问于 2022-11-05 20:49:07
回答 1查看 31关注 0票数 0

我正在做一个项目,使用forUsername参数和youtube-data-api,通过传统用户名获取频道上传播放列表的id。在这里,它搜索上传播放列表字符串。从那里,它得到了他们的频道上的视频和我需要的信息。

当我尝试一些频道时,它工作得很好,并且完全符合我的预期。然而,对于其他人,它给了我一个playlistNotFound错误,尽管我打印了我要接收的playlistId,以确保它是正确的。

错误(来自通道ManchesterUnited的播放列表id UUNbg-_aV3kK4MEb2vgdBtsw ):

代码语言:javascript
复制
googleapiclient.errors.HttpError: <HttpError 404 when requesting https://youtube.googleapis.com/youtube/v3/playlistItems?part=snippet&playlistId=UUNbg-_aV3kK4MEb2vgdBtsw&maxResults=50&key=AIzaSy...&alt=json returned "The playlist identified with the request's <code>playlistId</code> parameter cannot be found.". Details: "[{'message': "The playlist identified with the request's <code>playlistId</code> parameter cannot be found.", 'domain': 'youtube.playlistItem', 'reason': 'playlistNotFound', 'location': 'playlistId', 'locationType': 'parameter'}]">

我的代码:

代码语言:javascript
复制
from scraper_api import ScraperAPIClient
import requests
import googleapiclient.discovery
import html
import gspread
from oauth2client.service_account import ServiceAccountCredentials
import json
username=input("what is the channel username? (go to page and then you will see in the url) ")
ytapi = requests.get("https://www.googleapis.com/youtube/v3/channels?part=contentDetails&forUsername="+username+"&key=AIzaSy...")
print(ytapi.text)
at=ytapi.text.split(' ')
c=1
b=0
viewnumbers = []
titles = []
vtypes = []
urls = []
for i in at:
    c+=1
    if 'uploads' in i:
        for it in at[c-3:]:
            if 'U' in it:
                print(it)
                idd=it[1:len(it)-2]
                print(idd)
                break

playlist_id = idd

youtube = googleapiclient.discovery.build("youtube", "v3", developerKey = "AIzaSy...")

request = youtube.playlistItems().list(
    part = "snippet",
    playlistId = playlist_id,
    maxResults = 50
)
response = request.execute()
EN

回答 1

Stack Overflow用户

发布于 2022-11-06 10:40:16

如果我错了,纠正我,但是你提供的播放列表是无效的,不管怎么样?它根本不存在。您提供的播放列表ID为24个字符,与我在进入您所描述的曼彻斯特联队频道时发现的32个字符播放列表ID不同。

例如,https://www.youtube.com/playlist?list=PL5-QUghxmluKZGNgKiJPctZl2hgar88Hq

票数 -1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/74331394

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档