Auto create playlist youtube

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: # //www.youtube.com/watch?v=aBcDeFGH iLink = iLine.split['v='][1] inputData.append[iLink] if ['be/'] in iLine: # //youtu.be/aBcDeFGH iLink = iLine.split['be/'][1] inputData.append[iLink] return inputData videoLinks = ReadMultipleDataFrom[inputFileName, "https"] # print videoLinks listOfVideos = "//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 = "//www.youtube.com/playlist?list="+playListLink+"&disable_polymer=true" webbrowser.open[playListURL]

Video liên quan

Chủ Đề