This Program is able to copy all video titles of all your Youtube playlists. This is important because sometimes Youtube deletes videos or a user sets a video as private and so you can not see which video exactly is missing in your playlist.
This short script saves all video titles and Youtube channel uploader name from all your playlists into a directory and creates another with the current date.
If a video from your playlist gets deleted you can use the created files to lookup which one it was and then search for the same video from a different uploader and add it again to your playlist.
First you'll need a Google Account and then go to https://console.developers.google.com/project and create a new project. Then go to login details and create a oauth authentication. Download your credentials json and safe it as client_secret.json All of this is of course free.
Then start the index.py and follow the instructions in the browser where you should allow the connection.
This Software needs Python3 to run.
If a video is deleted in your playlist, it will be shown as "Index Number - Deleted Video".
If you have a public playlist for example from Youtube directly or for example from a friend you first have to save the playlist into your own account or else you can't download it.
It would quit the script saying:
404 Playlist was not found
I would recommend to run this script once a week. Why not more often? In my case I use about 5 playlists with at least ~ 1000 videos in all playlists together in it. This script also downloads the thumbnail of each video so that it helps you recognize the videos content. I download those thumbnails in high resolution which is about ~ 100kb per video. If you run this every day you waste a lot of space on your hard disk. On my system 7 runs of the script are around ~ 150 MByte on the hard disk.
On macOS you can create a launchctl service which will run this script automatically. Cron wouldn't work because when your computer sleeps or is shut down the cron job misses the job and does NOT run the next time you start the computer.
I use homebrew to install newest python3 and pipenv:
Homebrew Website
brew install python3 pipenvThen change into the scripts folder and run the following commands:
pipenv install
pipenv run index.pyThen the script should be running without any errors. If this step is successfull you can go on further.
Next is an example code for launchctl service I created for myself: Create a file with the following name in this directory with
nano ~/Library/LaunchAgents/com.youtubetitlegetter.plistand insert the following but don't forget to edit {userName} into your current username and also {pathToScriptLocation} to the location where the script is stored.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.youtubetitlegetter</string>
<key>ProgramArguments</key>
<array>
<string>/opt/homebrew/bin/pipenv</string>
<string>run</string>
<string>python3</string>
<string>/Users/{userName}/{pathToScriptLocation}/YoutubePlaylistVideoTitle/index.py</string>
</array>
<key>StartCalendarInterval</key>
<dict>
<key>Hour</key>
<integer>0</integer>
<key>Minute</key>
<integer>0</integer>
<key>Weekday</key>
<integer>1</integer>
</dict>
<key>WorkingDirectory</key>
<string>/Users/{userName}/{pathToScriptLocation}/YoutubePlaylistVideoTitle/</string>
<key>StandardOutPath</key>
<string>/tmp/youtube-out.log</string>
<key>StandardErrorPath</key>
<string>/tmp/youtube-error.log</string>
</dict>
</plist>To start and register the service you'll have to run the following commands:
id -uThis command id -u gives you a specific number directly linked to the current user account.
Use this number for the next 2 commands to work properly.
Insert this number in my case 501 into the following {number} => 501
launchctl bootstrap gui/{number} com.youtubetitlegetter.plist
launchctl kickstart -k gui/{number}/com.youtubetitlegetterWith the last command you kickstart the service. This means you trigger it to run once to check if everything is fine. Let it run and look into the script directory under the playlist folder if there is a folder with current date and video titles in it. If there is the script runs successfully. If there isn't you can go to /tmp/youtube-error.log to check what specific error the script has thrown.
On Linux you can use anacron or a similar command.
For questions or comments you can create an issue or reach me here:
https://github.com/DanielOberlechner/YoutubePlaylistVideoTitle/issues
https://twitter.com/danielthehok
Greets by Daniel Oberlechner! :)
