我有多个视频 ID(200 多个),我想使用所有视频 ID 创建一个 YouTube 播放列表。我从这里尝试了解决方案: https://webapps.stackexchange.com/questions/120451/how-to-create-a-playlist-form-a-list-of-links-not-from-bookmarks
这些解决方案都不起作用,而且大多数都有 50 个视频的限制。给出的Python代码中只有第一个视频,没有其他视频。第一种方法也行不通,Excel表格复制后对我来说完全崩溃了。
有什么方法可以让我将这些视频添加到播放列表(非手动)吗?例如。使用播放列表创建器或程序/API?谢谢。
来源/鸣谢:使用此 URL 技巧在没有帐户的情况下创建 YouTube 播放列表
按照这个结构,您可以创建一个无标题的播放列表:
http://www.youtube.com/watch_videos?video_ids=ID1,ID2,ID3,ID4
这是我创建的示例:
http://www.youtube.com/watch_videos?video_ids=nWyetldx4PU,gvubjVKOMuc,M3emJNkMmnA,QL2ohdMRck0,irTjCnHmU-E
将之前的网址粘贴到浏览器中后,网址变为:
https://www.youtube.com/watch?v=nWyetldx4PU&list=TLGGyc5oTGfqXdswNjEwMjAyMA
如果您有视频的 URL,请使用正则表达式获取视频的 id。
然后,在@Mauricio Arias Olave 的答案的帮助下创建一个播放列表。 或者你也可以关注我的视频https://youtu.be/_gaVUYfWb6g
然后使用下面的 Js 代码,您可以将播放列表转换为 YouTube 帐户中的永久播放列表。它只是将这些视频添加到第一个可用的播放列表中。
els2[1].click();
您可以更改此行中的数字来选择不同的播放列表。
您必须在浏览器控制台中运行此代码。
这将一直有效,直到 YouTube 更改其 HTML 哈哈。
(function myLoop(i) {
setTimeout(function() {
console.log(i);
letters[i].click();
var els = document.querySelectorAll(".style-scope.ytd-menu-service-item-renderer");
console.log(els);
if(els.length){
els[6].click();
var els2 = document.querySelectorAll(".checkbox-height.style-scope.ytd-playlist-add-to-option-renderer");
if(els2.length){
els2[1].click();
console.log("saved in playlist");
}
}
document.getElementsByTagName("body")[0].click();
if (--i) myLoop(i); // decrement i and call myLoop again if i > 0
}, 3000)
})(letters.length-1);
更新了@arif-khan 脚本的工作版本(2024)
在播放列表页面,假设您要复制到的播放列表是最新的播放列表
var three_dots_menus = Array.from(document.querySelectorAll(".dropdown-trigger.style-scope.ytd-menu-renderer")).slice(1);
undefined
for (let index = 0; index < three_dots_menus.length; index++) {
console.log(index)
var menu = three_dots_menus[index];
menu.click();
await new Promise(r => setTimeout(r, 500));
var sub_menu = document.querySelectorAll(".style-scope.ytd-menu-service-item-renderer");
sub_menu[8].click();
await new Promise(r => setTimeout(r, 500));
document.querySelectorAll(".checkbox-height.style-scope.ytd-playlist-add-to-option-renderer")[1].click();
await new Promise(r => setTimeout(r, 500));
document.getElementsByTagName("body")[0].click();
await new Promise(r => setTimeout(r, 500));
}
你可能需要使用超时
也许有人仍然需要解决方案,我有一个网络应用程序,您可以从歌曲标题列表或链接列表创建 YouTube 播放列表,并将其保存到您的 YouTube 帐户中:https://myplaylistcreator。 com