Making a compilation of Netflix movies you watched past year
It’s that time of year again when all kind of compilation videos are popping up on YouTube. From best memes of 2020 (https://www.youtube.com/watch?v=FGgtwEQ-BTk), most important news (https://www.youtube.com/watch?v=vGQQbulRUjY) to best movies (https://www.youtube.com/watch?v=JjOTEOLY6-0). What if you could do your own compilation of movies and series you watched?
- coding skills (or copy-paste skills :-)
- command-line skills (gotta feel like a hacker!)
- youtube-dl (https://youtube-dl.org/)
- python 3.8 (optional)
(1) Simply go to https://www.netflix.com/viewingactivity to see all records of your viewing activity.
(2) For each movie, search for movie name + trailer on youtube, to get a trailer. For example “Enola Holmes trailer” yields relevant first result https://www.youtube.com/watch?v=1d0Zf9sXlHk
(3) Create a new playlist on YouTube (I’ve called mine Watching 2020) and save the trailer to the playlist. Make sure that the playlist is set to “unlisted” or “public” so that
youtube-dl can read it. Do this for each movie (or automate it with a script). You can go ahead and mix in trailers for games you finished, or other streaming services such as Disney+ (If you haven’t watched The Mandalorian yet you should fix it this year!).
(4) Download the whole playlist with youtube-dl (use command line as youtube-dl is a command-line only tool). Since we are downloading trailers and only for our own usage, we should be clear of any pirate waters.
youtube-dl -i PLwJ2VKmefmxpUJEGB1ff6yUZ5Zd7Gegn2
Where the long string is the id of your playlist.
Make sure you have up-to-date youtube-dl with the command:
youtube-dl — version
If you struggling to get the latest version on Linux, just use:
sudo wget https://yt-dl.org/latest/youtube-dl -O /usr/local/bin/youtube-dl
sudo chmod a+x /usr/local/bin/youtube-dl
(5) Now that you have a folder full of trailers, you can play them in a playlist using VLC (https://www.videolan.org/). However, if you watched a lot of movies, you can get have a long playlist amounting to hours of footage! What we want is a short compilation.
Creating a short compilation
I have decided the rule of thumb that the middle 10 seconds of the trailer are the most relevant (since the beginning is set up and the ending is just the release date).
(6) Getting the duration of a movie clip is actually easy:
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 input.mp4
If you are missing ffprobe command, you want to install ffmpeg package (https://ffmpeg.org/).
(7) Now we want to divide duration by two and add 10 seconds to it (not perfect middle but close enough) and cut video to the given duration. Here is where python comes to play:
Now in folder
short_trailers you have 10-second long trailer snippets. Not all are nicely cut, some of the snippets will be awkward, but hey, we didn’t spend ages creating our own compilation! Now go ahead and play all your videos as VLC Playlist.
Merging it all in one video
Yes, it would have been nice to have it in one video, but I’ve tried and failed to do that. I’ve tried the command:
ffmpeg -f concat -i short/list.txt out.mp4
Where list.txt is a generated list of files in python:
file 1922__Official_Trailer_[HD]__Netflix-3E_fT0aTsjI.mp4file Better_Call_Saul_Season_5_Trailer__Rotten_Tomatoes_TV-quC2GkURViU.mp4
But the result was always very choppy between the trailers and I was pretty ok with a VLC playlist. One thing someone could try is to dump all trailers to jpeg sequence, dump all audio files, merge audio files into one audio track and then merge jpeg sequence into a new video file with corresponding audio.
Making it all automatic
I think that youtube-dl has a search feature that allows youtube to be searched. With that, all we would have to do is to copy the whole website https://www.netflix.com/viewingactivity, parse it say with https://www.crummy.com/software/BeautifulSoup/bs4/doc/ and run youtube-dl for each row. Maybe I’ll try that next year :).