Have you ever managed 100 playlists with 1000 videos each?
And have you tried to remove dead videos from the playlists?
😁
Here's a good solution: YouTube Data API
PlaylistItems: Delete
Automate your manual work with it. I will show you how to from YouTube Data API documentation into a working application.
First of all, you will do this
And have you tried to remove dead videos from the playlists?
😁
Here's a good solution: YouTube Data API
PlaylistItems: Delete
Automate your manual work with it. I will show you how to from YouTube Data API documentation into a working application.
First of all, you will do this
DELETE https://www.googleapis.com/youtube/v3/playlistItems
What is DELETE? That's one of the HTTP Verbs. It's like a commanding the internet to "make a DELETE request for the address https://www.googleapis.com/youtube/v3/playlistItems"
Let's move on. I wrote Ruby code.
Let's move on. I wrote Ruby code.
path = "/youtube/v3/playlistItems" host = "www.googleapis.com" method = "delete"
uri = URI::HTTPS.build(host: host, path: path) http_request = "Net::HTTP::#{method.capitalize}".constantize.new(uri.request_uri) # or just Net::HTTP::Delete.new(uri.request_uri) Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http| http.request http_request end
The left side of equal sign ("=") gets the value of the right side.
Next is, how you tell the internet which playlist item you are willing to remove. How about continue on the YouTube Data API documentation.
The following table lists the parameters that this query supports. All of the parameters listed are query parameters.
I will tell you what "query parameters" means in a bit. Next part you read:
The id parameter specifies the YouTube playlist item ID for the playlist item that is being deleted. In a playlistItem resource, the id property specifies the playlist item's ID.
The "query parameters" simply means you send this with the address.
"id=UEx3akRSUDVaWF9NRU9FLXpPdVRJTU9WSDBWT1lnR182OS41NkI0NEY2RDEwNTU3Q0M2"
Yes, a playlist item id is usually giant.
DELETE https://www.googleapis.com/youtube/v3/playlistItems?id=UEx3akRSUDVaWF9NRU9FLXpPdVRJTU9WSDBWT1lnR182OS41NkI0NEY2RDEwNTU3Q0M2
Look how it has a question mark between the address and a "query parameter." (In case you have another query parameter, then put "&" between parameters)
uri = URI::HTTPS.build(host: host, path: path) # not this params = "id=UEx3akRSUDVaWF9NRU9FLXpPdVRJTU9WSDBWT1lnR182OS41NkI0NEY2RDEwNTU3Q0M2" uri = URI::HTTPS.build(host: host, path: path, query: params)
Now you can delete an item from a playlist!
Next post, I will deal with how to find playlist item id, how to find dead items (Technically they are videos with privacy status as "private" or simply deleted videos).
See you next time!