PHP Youtube API: Search videos where a URL is within the description - youtube-api

I'm working on a site where they have recently changed their domain. I'm trying to get a list of all the videos that contain that domain and change to the new domain using the Youtube API.
I am using the developers PHP example on search list, changing the 'q' value to be equal the old website domain and also adding a channelId parameter so that it'll only search inside their channel.
The problem is that some of the results do not contain the old URL in the description. Am I doing something wrong?
Thanks!

AFAIK there isn't any official YouTube Data API v3 endpoint to directly do what you are trying to.
If I were you I would list the YouTube channel's videos and then use Videos: list with part=snippet to retrieve their descriptions and then I would locally filter the retrieved descriptions.

Related

Is there a way to access the comments I make on YouTube through the API?

I'm trying to retrieve the comments I've made on YouTube to turn them into Markdown files, but I can't find a way to do it filtering by user in the API documentation.
I thought it would be possible since the Google account has a link for it but when using the parameter "channelID" in the API to list comments as it says in the documentation, it gives back a 400 error.
You are looking for the comments your channel posted, however when using CommentThreads: list with channelId=YOUR_CHANNEL_ID you are listing comments people wrote on your channel, as described the documentation:
channelId
string
The channelId parameter instructs the API to return comment threads containing comments about the specified channel. (The response will not include comments left on videos that the channel uploaded.)
One more time YouTube Data API v3 AFAIK doesn't provide this basic feature.
You have two possibilities:
Use Google TakeOut (make sure to export Comments in YouTube and YouTube Music)
Web-scrap the webpage you provided

YouTube Content ID API - Views and earnings per asset

Assuming that I'm quite new to the YouTube Content ID API (and in general to YouTube Content ID), i'm looking for a method for get quickly the views and the earnings of a single asset.
Analyzing the YouTube Analytics API, I have not found anything making reference to the assets,
then I tried to base myself on the claims to obtain the data which I need. It's work, but, having to walk multiple pages, this takes many requests to the YouTube API server and it responds really slowly.
I would like, in practice, achieve a similar result:
I'm using PHP for this, but I do mostly GET requests directly basing on the documentation of YouTube Content ID API
I've found the solution:
Using the Youtube Analytics API:
ids=contentOwner==MY_CONTENT_OWNER_ID
start-date=my_start_date
end-date=my_end_date
metrics=estimatedMinutesWatched,averageViewDuration,averageViewPercentage, views,subscribersGained
dimensions=video
filters=claimedStatus==claimed
max-results=10
sort=-views
I can obtain the top 10 videos claimed sorted by views.
With the video ids, I can get the views, the earnings and the asset id using the ClaimSearch reference in YouTube Content ID API I can find the rest of the informations that I need.
EDIT:
There is a dimension missed on the official documentation: asset.
I've updated the query of Analytics API:
ids=contentOwner==MY_CONTENT_OWNER_ID
start-date=my_start_date
end-date=my_end_date
metrics=estimatedMinutesWatched,averageViewDuration,averageViewPercentage, views,subscribersGained
dimensions=asset
filters=claimedStatus==claimed
max-results=10
sort=-views
and it show directly the assets.

YouTube API Search by Tags

I'm trying to add videos to an existing ASP.NET MVC site, and I'd like to show videos from our YouTube channel.
I have added a tag to each video to indicate what page it should appear on. I had thought that I could search our channel by tag on each page to render the relevant video on that page.
I'm trying to exclusively use the API v3, but it seems I can't do this.
I can't use developer tags, because videos are uploaded by multiple users using the standard YouTube front end. This seems like basic functionality, so I'm assuming it's my inexperience with this API.
As an example, our YouTube channel is ChillinWithCharlie. During development, one video is tagged 20141213Cheneys.
I can get all videos in our channel, but is there a way to query the v3 API to retrieve just this video?
I've seen one suggestion here that I retrieve all videos, and filter in code. This feels inefficient, so I'd rather not do this, but I can't even see where the tag is returned with all channel videos, that I could interrogate in code.
It's not just you. There seems to be no specific query parameter to search by tag with API v3.
I would recommend doing a search with your tag in the 'q' (search) parameter, then checking the results to see if the tag exists in the returned snippet->tags property to verify the exact video.
Note YouTube tags are only visible to the video's uploader.
https://developers.google.com/youtube/v3/docs/videos#snippet.tags[]

channelId, username and tags functionality in API v3

I am new in youtube API v3 and I would like to ask some theoretical questions that confuse me a litle.
The first question is about the username, chanelID and channelTitle. So far I have understand that in API v3 channelID is the one we should use in order to distinquish users and not usernames. Is that true? If yes this means that each user has a unique channelID by default we he creates an Youtube account? Does the ChannelTitle follows the same logic?
The second question I would like to ask is about tags/keyworks that an uploaders optionally attach into their uploads. In the API documentation says that tags are available
only for uploaders. This means that we can not retrieve tags for the queried videos through API v3? Until now I could't notice any tag variable into the snippet obtained
from video->list for some videos I tested. Is authorization matter? In my account YouTube Analytics API, YouTube Data API v3 are enabled.
PS: I am working Youtube API v3 in Python.
Thank you in advance.
Only channelID is unique, user may not have username and channelTitle is not unique.
Tags should be available for response. Example here shows how to update tags. https://code.google.com/p/youtube-api-samples/source/browse/samples/python/update_video.py
Mind that you can only retrieve tags (aka keywords) of your own videos.
More information in the blog post.

PHP Youtube API v3 Missing Description in Playlist Items

I'm not getting the description form my uploaded videos when i query them via Youtube Data API v3 using OAuth 2.0 and the sample code provided here https://developers.google.com/youtube/v3/docs/playlistItems/list.
Could this be a bug? None of my videos are private and the only thing that is missing from the response is the video's description!
I'm using the PHP library and the "part" parameter is snippet (don't know if this helps).
Thanks in advance.
I believe this is intended, since video descriptions are not displayed when viewing playlists on YouTube.
If you wish to include the description of your uploaded videos, consider using YouTube API v3 Search: list instead. An ellipsis-truncated description will be provided for your videos under snippet/description. Again, this behaviour is similar to searching on YouTube, where descriptions are cut off.
If a full description is required, you'll need to use Videos: list.
Alternatively, use version 2 of the API: https://gdata.youtube.com/feeds/api/users/youtube_username/uploads?max-results=50&start-index=1.

Resources