AutoHotkey: Create YouTube Playlist by Copying Video Links to Clipboard

Print Page

YouTube video links follow a particular format, such as https://www.youtube.com/watch?v=1FJD7jZqZEk. Each video has their own unique ID. We can concatenate different IDs and create a new playlist like this: http://www.youtube.com/watch_videos?video_ids=ID1,ID2,.. You can play, share, and embed this playlist just like any other playlist on YouTube. In this post, we have an AutoHotkey script that would allow you to quickly and easily create a YouTube playlist by simply copying video links to the clipboard.

YouTube-Playlist

Create YouTube Playlist by Copying Video Links to Clipboard

Copy and paste below code to an AHK file and run it:

clipboard =  

playlist = http://www.youtube.com/watch_videos?video_ids=

#Persistent
OnClipboardChange("ClipChanged")
return

ClipChanged(Type) {
if clipboard contains youtube.com/watch,youtube.com/embed/,youtu.be
	{
	StringRight, clipboard, clipboard, 11  
	gosub, doit
	return
	} 
	return   
} 

doit:
	count++
	playlist = %playlist%%clipboard%,
	TrayTip, Current Playlist:, %playlist% `nNumber of Videos: %count%`nUse Ctrl + Alt + Y to use playlist
	Sleep 4000
	TrayTip  ; Turn off tray tip
	return

; Ctrl + Alt + Y : Activate script
^!y:: 
StringTrimRight, playlist2, playlist, 1
clipboard = %playlist2%
OnClipboardChange("ClipChanged", 0)
MsgBox, 0, YouTube Playlist, Number of videos in playlist: %count% `nCurrent link: %playlist2% `n`n`nPlaylist copied to clipboard. Press Ctrl + Alt + Z to exit app.
OnClipboardChange("ClipChanged", 1)
return

; Ctrl + Alt + C : Clear clipboard
^!c:: 
MsgBox, 0, YouTube Playlist - Clipboard cleared, Number of videos in playlist: %count% `n`n`nClipboard cleared.
clipboard = 
playlist = http://www.youtube.com/watch_videos?video_ids=
count = 
return

; Ctrl + Alt + Z : Exit app
^!z:: 
ExitApp

Now just press Ctrl+Alt+Y keyboard combination to start monitoring the clipboard. Then go to YouTube.com and copy URLs for the videos which you’d like to add to the playlist. Script works with these links: youtube.com/watch, youtube.com/embed/ or youtu.be. You’ll get a tray notification each time a URL is added to the playlist. To turn this notification off, just comment out or remove TrayTip from the script.

YouTube Playlist Notification
And when you are done, once again press Ctrl+Alt+Y to get the final playlist link for all the videos. You can paste this playlist URL into your browser to start playing or share it with anyone.

  • https://www.youtube.com/watch?v=-qnWM2HWpCU
  • https://www.youtube.com/watch?v=1FJD7jZqZEk

You will get a concatenated URL like this in the end: http://www.youtube.com/watch_videos?video_ids=-qnWM2HWpCU,1FJD7jZqZEk

If you make a mistake while copying, use Ctrl+Alt+C to start over. To exit the script, use Ctrl+Alt+Z. You can modify the script to use a different set of keyboard keys for any of the actions.

This handy script was originally created by Computing Tidbits here. I’ve changed it a bit to add notification title and functionality to clear clipboard.