我需要获取当前直播的频道 ID 列表。经过大量研究后,看起来唯一的解决方案是使用搜索端点,指定channelId。该解决方案不起作用,因为单位成本非常高(列表中每个通道 100 个单位)。此外,我会每隔 5 分钟左右轮询一次该频道列表的直播。这对于工作来说成本太高了。
潜在的解决方案:
1) 推送通知 API https://developers.google.com/youtube/v3/guides/push_notifications
如果这个 API 还可以在频道开始直播时发送通知,这将完全解决我的问题
2) 活动端点 https://developers.google.com/youtube/v3/docs/activities/list
如果此端点还包括直播活动,我可以使用它,因为每个频道的成本仅为 1 个单位,这是可行的。
3)搜索端点 https://developers.google.com/youtube/v3/docs/search/list
如果此端点可以接受多个channelId,我可以使用一些搜索调用来获取所有通道,这也可能有效。
还有其他方法可以解决这个问题吗?对于 Youtube API 来说,这似乎是一个非常有效的用例,它能够获取频道的实时流,而无需为每个频道付出高昂的成本。
我是一个名为 youtube-dl 的工具,它是用于下载 youtube 视频/音频的命令行工具。当运行下面的命令时
youtube-dl https://youtube.com/watch?v=$1 \
--quiet --extract-audio --audio-format wav \
--output "$outname.%(ext)s
我遇到错误 429,请求太多。任何解决这个问题的方法。
我正在尝试从音频集数据集中下载音频。
我试图弄清楚 YouTube 视频是否可以使用 YouTube Data API v3 嵌入,从类似问题的答案中我注意到视频的 status.embeddable 属性,对于这样的请求:
https://www.googleapis.com/youtube/v3/videos?id=63flkf3S1bE&part=contentDetails,status&key={MY_API_KEY}
Run Code Online (Sandbox Code Playgroud)
响应如下
{
"kind": "youtube#videoListResponse",
"etag": "\"ksCrgYQhtFrXgbHAhi9Fo5t0C2I/ctZQYtBcOuMdnQXh8-Fv1EbS_VA\"",
"pageInfo": {
"totalResults": 1,
"resultsPerPage": 1
},
"items": [
{
"kind": "youtube#video",
"etag": "\"ksCrgYQhtFrXgbHAhi9Fo5t0C2I/Cd8aGZD09NPuGYNumIEozZs2S90\"",
"id": "63flkf3S1bE",
"contentDetails": {
"duration": "PT8M23S",
"dimension": "2d",
"definition": "hd",
"caption": "false",
"licensedContent": false,
"projection": "rectangular"
},
"status": {
"uploadStatus": "processed",
"privacyStatus": "public",
"license": "youtube",
"embeddable": true,
"publicStatsViewable": true,
"madeForKids": false
}
}
]
}
Run Code Online (Sandbox Code Playgroud)
embeddable下面的参数返回status为 true,但是该视频实际上不可嵌入,如此处所示。
当实际使用 iframe API 嵌入视频时,还有更详细的错误消息:
视频不可用 该视频包含来自国际奥委会的内容,该委员会已阻止其在本网站或应用程序上显示。在 YouTube …
我遇到了 YouTube API 的问题,我正在使用 ("google/apiclient": "2.7")
我已经创建了广播并将其绑定到流,然后将 RTMP URL 作为端点添加到我的直播中但我找不到在 YouTube 上启动直播的方法(在原始直播开始后)
$access_token = $data['yt-access-token'];
$title = $data['title'];
$description = $data['description'];
//=======================================//
$client = new Google_Client();
$client->setClientId(env('GOOGLE_APP_ID'));
$client->setClientSecret(env('GOOGLE_SECRET'));
$client->setScopes('https://www.googleapis.com/auth/youtube');
$client->setAccessToken($access_token);
// Define an object that will be used to make all API requests.
$youtube = new Google_Service_YouTube($client);
//=======================================//
try {
// Create an object for the liveBroadcast resource's snippet. Specify values
// for the snippet's title, scheduled start time, and scheduled end time.
$broadcastSnippet = new Google_Service_YouTube_LiveBroadcastSnippet();
$broadcastSnippet->setTitle($title);
$broadcastSnippet->setDescription($description);
$broadcastSnippet->setScheduledStartTime('2020-08-20T00:00:00.000Z'); …Run Code Online (Sandbox Code Playgroud) 我编写了一个脚本,用于将 .mp4 文件可恢复上传到 YouTube 等。负责处理此问题的代码大部分是从https://learndataanalysis.org/how-to-upload-a-video-to-youtube-using-youtube-data-api-in-python/和https://developers重用的.google.com/youtube/v3/guides/uploading_a_video,尽管我对过时的语法和库做了一些小的修改。
这是我的代码:
def create_service(client_secret_file, api_name, api_version, *scopes):
CLIENT_SECRET_FILE = client_secret_file
API_SERVICE_NAME = api_name
API_VERSION = api_version
SCOPES = [scope for scope in scopes[0]]
cred = None
pickle_file = f'token_{API_SERVICE_NAME}_{API_VERSION}.pickle'
if os.path.exists(pickle_file):
with open(pickle_file, 'rb') as token:
cred = pickle.load(token)
if not cred or not cred.valid:
if cred and cred.expired and cred.refresh_token:
cred.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(CLIENT_SECRET_FILE, SCOPES)
cred = flow.run_local_server()
with open(pickle_file, 'wb') as token:
pickle.dump(cred, token)
try:
service = build(API_SERVICE_NAME, API_VERSION, …Run Code Online (Sandbox Code Playgroud) 使用 YouTube API 时,我的代码中出现此错误。该代码以前有效,并且我的代码没有任何变化。我收到此错误:
Failed to load resource: the server responded with a status of 404 ()
https://content-youtube.googleapis.com/static/proxy.html?usegapi=1&jsh=m%3B%2F_%2Fscs%2Fapps-static%2F_%2Fjs%2Fk%3Doz.gapi.en.myOGgYJo9ys.O%2Fam%3DwQE%2Fd%3D1%2Fct%3Dzgms%2Frs%3DAGLTcCMR2Cg_3Iqxcgmos-E9G6cjWQG_Kw%2Fm%3D__features__#parent=https%3A%2F%2Fcreatorinventory.com&rpctoken=657579414
Run Code Online (Sandbox Code Playgroud)
成功登录 oauth2 并调用 api 后出现此错误。这是我的一些代码:
function handleClientLoad(){
gapi.load('client:auth2', initClient);
}
function initClient(){
gapi.client.init({
discoveryDocs: DISCOVERY_DOCS,
clientId: CLIENT_ID,
scope: SCOPES
}).then(() => {
// Listen for sign state changes
gapi.auth2.getAuthInstance().isSignedIn.listen(updateSigninStatus);
// Handle initial sign in state
updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());
authorizeButton.onclick = handleAuthClick;
signoutButton.onclick = handleSignouClick;
});
}
function updateSigninStatus(isSignedIn)
{
if(isSignedIn){
//Update UI
signinCont.style.display = 'none';
signoutButton.style.display = 'block';
loading.style.display = 'block';
//get Channel
gapi.client.youtube.channels.list({ …Run Code Online (Sandbox Code Playgroud) 我想从 Youtube Music 中提取播放列表数据,以及与所述播放列表中的歌曲相关的元数据。这可以通过 Youtube Data V3 API 或 YouTube Analytics API 实现吗?
如果是这样,我在哪里可以找到有关调用和可用元数据的文档;我在 YouTube 数据 API 页面上找不到我需要的内容。我目前在参考文档中引用 PlaylistItems 和 Playlists,但似乎适用于视频。这是特意设计的吗?因为您可以在 YouTube Music 中在视频和音频之间切换?
如果可能的话有官方的 Rust Crate 吗?
预先感谢您的帮助。
youtube-api youtube-analytics youtube-data-api youtube-analytics-api
YouTube 数据 API 是否支持通过 @handle 查询频道?这似乎不被支持。
例如:https: //www.youtube.com/@lionsgatemovies
forUsername参数
GET https://www.googleapis.com/youtube/v3/channels?part=id,snippet&forUsername=@lionsgatemovies
{
"kind": "youtube#channelListResponse",
"etag": "RuuXzTIr0OoDqI4S0RU6n4FqKEM",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
}
}
Run Code Online (Sandbox Code Playgroud)
id参数
GET https://www.googleapis.com/youtube/v3/channels?part=id,snippet&id=@lionsgatemovies
{
"kind": "youtube#channelListResponse",
"etag": "RuuXzTIr0OoDqI4S0RU6n4FqKEM",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
}
}
Run Code Online (Sandbox Code Playgroud)
支持的过滤器参数似乎都不合适:
GET https://www.googleapis.com/youtube/v3/channels?part=id,snippet&forUsername=@lionsgatemovies
{
"kind": "youtube#channelListResponse",
"etag": "RuuXzTIr0OoDqI4S0RU6n4FqKEM",
"pageInfo": {
"totalResults": 0,
"resultsPerPage": 5
}
}
Run Code Online (Sandbox Code Playgroud) @username我正在尝试编写一个简单的 Python 脚本,通过或搜索返回有关频道的一些信息UCrandomID123。
我知道您可以使用以下端点来访问频道数据:https://www.googleapis.com/youtube/v3/channels
然而,我遇到了一些可能的限制和问题。某些频道的频道 URL 中可能没有自定义“名称”:
与
我查了一下问题并发现了多个解决该问题的帖子:
但这两种解决方案都相当陈旧,我想知道现在是否有更好的解决方案来解决这个问题?
我有以下代码:
async def get_channel_id(self, channel_input):
api_url = f"https://www.googleapis.com/youtube/v3/channels"
params = {
'part': 'snippet',
'key': DEVELOPER_KEY,
'maxResults': 1
}
# Determine if the input is a channel ID or username
if channel_input.startswith('UC'):
# Channel ID provided
params['id'] = channel_input
else:
# Assume it's a custom username
params['forUsername'] = channel_input
response = await self.make_api_request(api_url, params) # Just a function to make …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用youtube data api将本地视频文件上传到我的YouTube帐户.
示例:https://github.com/youtube/api-samples/blob/master/ruby/upload_video.rb
呼叫:
$ ruby upload_video.rb --file video.mp4
Run Code Online (Sandbox Code Playgroud)
我收到一条错误消息:
/Users/user/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/openssl/buffering.rb:326:in `syswrite': Broken pipe (Errno::EPIPE)
from /Users/user/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/openssl/buffering.rb:326:in `do_write'
from /Users/user/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/openssl/buffering.rb:344:in `write'
from /Users/user/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http/generic_request.rb:202:in `copy_stream'
from /Users/user/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http/generic_request.rb:202:in `send_request_with_body_stream'
from /Users/user/.rvm/rubies/ruby-2.1.1/lib/ruby/2.1.0/net/http/generic_request.rb:132:in `exec'
...
from upload_video.rb:73:in `main'
from upload_video.rb:91:in `<main>'
Run Code Online (Sandbox Code Playgroud)
upload_video.rb(第73行):
videos_insert_response = client.execute!(
:api_method => youtube.videos.insert,
:body_object => body,
:media => Google::APIClient::UploadIO.new(opts[:file], 'video/*'),
:parameters => {
:uploadType => 'resumable',
:part => body.keys.join(',')
}
)
Run Code Online (Sandbox Code Playgroud) youtube-data-api ×10
youtube-api ×7
youtube ×3
javascript ×2
python ×2
audio ×1
google-api ×1
php ×1
ruby ×1
streaming ×1
youtube-dl ×1