Batch deleting videos using YouTube API and HTTpWe

2019-08-03 00:48发布

I've spent almost 10 hours on this, and still no luck, only errors.

I am trying to delete 2 videos in batch, using the YouTube API and HttpWebRequest in c# .net (I am not using the default api dll)

I am sending the request (with POST) to: http://gdata.youtube.com/feeds/api/users/default/uploads/batch?v=2

Here is the xml request I am sending:

<feed xmlns='http://www.w3.org/2005/Atom' 
 xmlns:media='http://search.yahoo.com/mrss/' 
 xmlns:batch='http://schemas.google.com/gdata/batch' 
 xmlns:yt='http://gdata.youtube.com/schemas/2007'>
<entry>
<batch:operation type="delete"/>
<id>http://gdata.youtube.com/feeds/api/users/default/uploads/Fe-Wzz4thKk</id>
</entry>
</feed>

I am getting the error: Invalid entry Id/Uri

I also tried to send only the ID of the video but still no luck, only errors. What can I do about this ? It's really frustrating because I can't find any examples of deleting videos (not playlists).

Hope somebody can help.

Thank you! Vlad

EDIT:

I also tried to send the POST data to:

http://gdata.youtube.com/feeds/api/videos/batch?v=2

And data:

 <feed xmlns='http://www.w3.org/2005/Atom' 
 xmlns:media='http://search.yahoo.com/mrss/' 
 xmlns:batch='http://schemas.google.com/gdata/batch' 
 xmlns:yt='http://gdata.youtube.com/schemas/2007'>
<entry>
<batch:operation type="delete"/>
<id>http://gdata.youtube.com/feeds/api/videos/Fe-Wzz4thKk</id>
</entry>
</feed>

The error with this was: This feed is read-only

I am logged it with the good user (I tested uploading videos and other stuff and it works).

1条回答
看我几分像从前
2楼-- · 2019-08-03 01:28

I want to let you guys now I cracked this. The answer is pretty simple.

First off, the request is made to:

http://gdata.youtube.com/feeds/api/users/ACCOUNT_CHANNEL_NAME/uploads/batch?v=2

AND NOT to:

http://gdata.youtube.com/feeds/api/users/default/uploads/batch?v=2

So you cannot use the "default" keyword. I think it's the only place where it does not work.

Also, the .. of every element should look like this:

<id>http://gdata.youtube.com/feeds/api/users/ACCOUNT_CHANNEL_NAME/uploads/VIDEO_ID</id>

Good luck!

查看更多
登录 后发表回答