]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Fix channels import with a channel with playlists
authorChocobozzz <me@florianbigard.com>
Mon, 14 Dec 2020 08:54:38 +0000 (09:54 +0100)
committerChocobozzz <me@florianbigard.com>
Mon, 14 Dec 2020 08:55:30 +0000 (09:55 +0100)
server/tools/peertube-import-videos.ts

index 1b2c63af2628af8ffd489df5dca283811a7e80e3..5fc5a867cdbe3829c372eaa2d6718d1af9315b30 100644 (file)
@@ -74,10 +74,15 @@ async function run (url: string, user: UserInfo) {
 
   let info = await getYoutubeDLInfo(youtubeDL, program['targetUrl'], command.args)
 
-  if (info?.title === 'Uploads') {
-    console.log('Fixing URL to %s.', info.url)
+  if (!Array.isArray(info)) info = [ info ]
 
-    info = await getYoutubeDLInfo(youtubeDL, info.url, command.args)
+  // Try to fix youtube channels upload
+  const uploadsObject = info.find(i => !i.ie_key && !i.duration && i.title === 'Uploads')
+
+  if (uploadsObject) {
+    console.log('Fixing URL to %s.', uploadsObject.url)
+
+    info = await getYoutubeDLInfo(youtubeDL, uploadsObject.url, command.args)
   }
 
   let infoArray: any[]