9

This question already has an answer here:

I have very long lists of YouTube links/bookmarks. I want to create playlists for my YouTube channel with them. Is there any way to do it automatically without having to add each individual URL to a playlist?

marked as duplicate by user0, serenesat, Vidar S. Ramdal, jonsca Mar 20 at 23:44

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
  • @user0 The current question and answer below have dates far earlier than the link you have provided? How is this question a duplicate of the link you have provided if this question has a prior date? shouldn't it be the other way around? – jaggi Jun 1 at 7:48
  • @jaggi new question with an accepted answer has higher priority than an older unaccepted question (said mods). also, double posting the answer here has no meaning due to the lost interest of OP (OP does not have an account) – user0 Jun 1 at 9:07
  • @user0 Don't mods have the power to accept an answer for a question? This question and the provided answer have more upvotes & more activity than the other link. Did you genuinely try to point the OP of your link to this question, before you wrote the answer there which is more or less same as the answer written here? – jaggi Jun 1 at 9:39
  • @jaggi sure they can I guess but they never do so. as for the rest - I wasn't aware of this post when answering over there back in Sep 2018 and as you can notice this was linked as duplicate just recently (Mar 2019). apologies for my non-awareness. – user0 Jun 1 at 10:00
14
  1. Go to bookmarks manager and select all the YouTube links and copy and paste them in a text file, say you.list, and RUN following on your terminal (assuming you use a linux system):

    grep -o 'v=.*' you.list | cut -f2 -d"="| tr '\n' ','

    You'll get comma separated list video ids something like: J6PBD-wNEDs,afwPe_OqPX0,OGcG4jSKOVA,hegL0V4ckco,LajAWn51HmE.

  2. Copy these ids and append it to http://www.youtube.com/watch_videos? video_ids=

    You'll get a link similar to this http://www.youtube.com/watch_videos?video_ids=J6PBD- wNEDs,afwPe_OqPX0,OGcG4jSKOVA,hegL0V4ckco,LajAWn51HmE

  3. Open this link in the browser and it'll create an 'untitled playlist', for the above links it would be https://www.youtube.com/watch?v=J6PBD-wNEDs&list=TLGGDO-k0WVJQ_8yNDA1MjAxNw

  4. Go to the playlist URL for the generated playlist in this format:
    https://www.youtube.com/playlist?list=[PLAYLIST ID]&disable_polymer=true, which for the above example would be https://www.youtube.com/playlist?list=TLGGDO-k0WVJQ_8yNDA1MjAxNw&disable_polymer=true. Press the three dots to the right of the playlist title, and then select "Add all to..." to add the videos to your own playlist. As @jet-blue says, you may need to use the &disable_polymer=true URL parameter to see the "Add all to..." drop-down option.

I guess the proper way of doing what the question is asking for is through YouTube developer api. https://developers.google.com/youtube/v3/docs/playlists/insert#examples

Reference:http://cects.com/youtube-playlist/

  • I created the playlists I wanted long ago, but opened your link out of curiosity. It does generate a temporary playlist, but its title ("Untitled list") is not clickable, so there's no way to access the page that would let me save it to my account. – user14334 May 24 '17 at 14:57
  • 2
    Your answer is nearly complete. Once you have the untitled playlist open in youtube there is an option to "Copy All into" (dots in the right hand corner gives you this option) whereby you can create a new playlist which will have all those videos in it. – CashCow Jul 1 '17 at 23:09
  • 2
    @CashCow Can you edit the answer to include this info? – Stevoisiak Aug 12 '17 at 21:56
  • 2
    Append &disable_polymer=true to the playlist url in order to get access to the Add all to... feature. – Jet Blue Nov 21 '17 at 17:57
  • 1
    @jaggi just some minor details to mention: - Video ids must be clean from other utms (eg. use Xkj931k not Xkj931k?t=10, which would be a video at specific time) - Also don't include more than 50 video ids in one url. At this moment, 50 video ids is the maximum that youtube will display in the new untitled playlist. As a turn around you have to create new playlists for every 50 songs you want to add – gpelelis Mar 18 at 0:15
1

A small python script

  • to extract all the youtube links from the text file you.list.
  • open the browser (in background) with all the videos - urllib2.urlopen(listOfVideos).
  • gets the new playlist link - response.geturl().
  • opens the web browser again to allow the user to edit the playlist properties webbrowser.open(playListURL).

*tested on Google Chrome

import os, io
import webbrowser
import urllib2

inputFileName = 'you.list'

def ReadMultipleDataFrom(thisTextFile, thisPattern):
    inputData = []
    file = open(thisTextFile, "r")
    for iLine in file:
        if iLine.startswith(thisPattern):
            iLine = iLine.rstrip()
            # print iLine
        if ('v=') in iLine: # https://www.youtube.com/watch?v=aBcDeFGH
            iLink = iLine.split('v=')[1]
            inputData.append(iLink) 
        if ('be/') in iLine: # https://youtu.be/aBcDeFGH
            iLink =  iLine.split('be/')[1]
            inputData.append(iLink)
    return inputData

videoLinks =  ReadMultipleDataFrom(inputFileName, "https")              
# print videoLinks

listOfVideos = "http://www.youtube.com/watch_videos?video_ids=" + ','.join(videoLinks)
# print listOfVideos

response = urllib2.urlopen(listOfVideos)
playListLink = response.geturl()
# print playListLink

playListLink = playListLink.split('list=')[1]
# print playListLink

playListURL = "https://www.youtube.com/playlist?list="+playListLink+"&disable_polymer=true"
webbrowser.open(playListURL)