Play Bad Apple!! (or any other video file) in Google Calendar
- Download this repo anywhere on your computer
- Install additional pip packages by running
pip install -r requirements.txt
. - Log into Google Calendar, select year in the top-right corner or press [Y] on your keyboard.
- right-click anywhere on the page and select Save Page as...
- Navigate to the path, where you downloaded this repo, and save the page as "index.html".
- A folder called "index_files" will be created along with the html-file. You can delete all of its contents, except:
- calendar_[something].png
- Every .css file
- unnamed.png
- unnamed_[something].png
- Download Bad Apple as an MP4 from The Internet Archive.
- Insert the following code at the top of
index.html
:
<script src="/badapple.js"></script>
- Run
python3 main.py --video-path [path to bad apple]
. - Open http://localhost:8000/ in a web browser.
- Open the browser's developer console and switch to the Console tab.
- Ignore all the warnings and enter
init()
. If you did everything right, all the days should light up blue. - Now type
run()
. A preview window should open and the days in the calendar should start changing to the video.
Tip
Run python3 main.py
without arguments to see all command-line options available.
The main.py script starts a Flask and a WebSocket server. The Flask server serves the index.html
file, badapple.js
and the index_files
folder.
The WebSocket server waits for a connection from the hosted webpage and then sends all the frames of the video as strings of ones and zeroes.
badapple.js
is responsible for the web browser side.
When running init()
, it organizes all of the calendar days into a list and sets their background color to blue.
And when run()
is executed, the script establishes a connection to the Python WebSocket-Server and updates every days' color to match the video's pixels.
- Add audio playback to main.py
- Compress the data sent to the browser
- Make the days RGB/Grayscale (fancy)