Named after the Library of Babel website. This started as an experiment in randomness but now hosts a bunch of experimental programs. I got help from chatGPT, Claude AI, and Gemini, and Github CoPilot to write them.
- Quick start
- Setup
- Run
- encodeDecodeImage
- Games
- Other
- Radius
- Wordplay
- YouTube downloaders
- Additional documentation
The most updated files are the two main YouTube downloaders:
- Modern downloader CLI –
youtube-downloader-app/src/main.py - Live chat–focused CLI –
ytdownload/livechat.py
These both wrap yt-dlp under the hood to download videos and/or live chats.
Requirements:
- Python virtualenv activated and dependencies installed (see Setup).
yt-dlpinstalled (already inrequirements.txt).
Run:
cd youtube-downloader-app
python src/main.pyThen:
- Paste a YouTube URL when prompted.
- Choose whether to use cookies, download comments, transcripts, etc.
- Let the script download the video and any selected extras into the output folder.
See youtube-downloader-app README for more details and advanced options.
This script is optimized for grabbing live chat (and optionally video) for live streams.
Requirements:
- Python virtualenv activated and dependencies installed.
yt-dlpinstalled.- (Optional but recommended)
ffmpeginstalled for robust video merging:brew install ffmpeg
Run:
cd ytdownload
python livechat.pyThen:
- Enter the YouTube
VIDEO_ID(the part afterv=in the URL). - Follow the prompts to start fetching live chat and/or video.
- Monitor progress in the terminal; output files (CSV, video) will be written into the current folder.
If you hit authentication or region errors, see Using yt-dlp cookies and the YouTube downloaders section below for cookie and browser-based login examples.
For initial setup, create a virtual environment & run it:
python -m venv venv
. venv/bin/activateThen install requirements:
pip install -r requirements.txtAfter the initial setup & requirements, you only have to run the second venv line to activate the virtual environment when running in the future.
If necessary you may need to upgrade yt-dlp. For example, if you see "The following content is not available on this app" or similar errors when running yt-dlp --live-from-start -- video_id
Check version.
yt-dlp --versionInstall upgrade.
pip install yt-dlp --upgradeOr
pip install -U yt-dlpTo run experiments, type python and the file name. For example, try this one:
cd ytdownload
python youtube_downloader.pyCode that encodes text into an image using simple least-significant-bit (LSB) steganography, and decodes it back.
create_image.py– Creates an image of a blue cirle with a white background. Defines circle parameters, draws the circle, and saves the image. Useful for generating a clean base image to encode into.encode_image.py– Converts text to binary and encodes the bits into the RGB pixel values of an image, saving the result asencoded_image.png.decode_image.py– Reads pixel data fromencoded_image.png, reconstructs the hidden binary data, converts it back to text, and prints the decoded message (or reports that no hidden message was found).encode_decode_image.md– Walkthrough and explanation of how the encoding/decoding works using PIL (Pillow) and LSB manipulation; serves as conceptual documentation for this mini‑project.original_image.png– Example unencoded source image used as the input to the encoding script.encoded_image.png– Example output image containing hidden text data produced by the encoding script.
dice_game.py- experimental treasure hunt game.dice_roll_anysided- Roll a die with the number of sides specified by the user.dice_rolls.py- Rolls 2 6-sided dice.die_roll_games.py- 3 games- Choose the number of sides for the die and roll it.
- Add to game 1 & see how many rolls it takes to roll the number again.
- Play game 2 a number of times.
die_roll_probability.py- guess how many rolls it will take for game 2 (work in progress)die-roll-histogram- roll a die and generate a histogram of the values.squid_game.py- red light green light sim.
business_assumptions.py- calculate breakeven cost and amount of drivers needed for a hypothetical future business idea.gnews_scraper.py- Scrape the latest 5 Google News headlines based onh4top stories.lat_long.py- find latitude & longitude.life.html- Interactive artificial-life “soup” simulation (Tierra‑Lite v2) running entirely in the browser.lifetime-metrics.html- Lifetime metrics calculator; lets you explore how many hours you’ve spent on sleep, work, commuting, etc. given your habits.moviesearch.py- prints number of movies released in a range of years.news_scraper.py- BBC and NY Times headline scraper. Adapted Indently's BBC News Headline scraper to scrape BBC news and New York Times headlines.random_tarot.py- Draw a random Major Arcana tarot card and show its meaning.repeated_multiplication.py- repeatedly multiply numbers.retirement_calc.py- calculate retirement.savings_calc.py- Calculate and export a 12‑month interest table for a savings account (principal, APY, monthly interest, and running balance).timeline.py- Generate a horizontal timeline PNG for a date range, with start/end labels, equidistant tick marks, and today highlighted if it falls inside the range.wiki_articles.py- Display the 10 most recently-updated articles.word_count.py- Count how many times a target word appears in a text file.write_key.py- asks for a key and value and adds it to a dictionary. If the dictionary doesn't exist, creates it.
radius_notes.md- Notes and step‑by‑step instructions for building a “draw a radius on a map” tool using Google Maps APIs andfolium, including setup, code samples, and troubleshooting (e.g.,REQUEST_DENIED/ billing).radius.py- Python script that geocodes a hardcoded address (Empire State Building) with Google Maps, then usesfoliumto generate an HTML map (map_with_radius.html) showing a 1 km radius circle around the location.
count_letters.py- Count letters in a word.define_word.py- Define a word.entername.py- Enter your name and get greeted with the current time.gen_pass.py- Generate passphrase. Uses thehttps://random-word-api.herokuapp.com/wordAPI endpoint to generate a passphrase.gensen_worddict.py- Expandedrandom_sentence.py. Pulls random words from thehttps://random-word-api.herokuapp.com/wordAPI endpoint and strings them together to create a sentence, then verifies the sentence against thelanguage_tool_pythonAPI.givename.py- Runsentername.pyand passes in a hardcoded name.random_phrase.py- (Buggy) Generate random phrase.random_sentence_save.py- Same asrandom_sentence.pyexcept saves to file.word_or_phrase.py- Asks if you want to generate a random phrase or define a word.
youtube-downloader-app is the more modern downloader to download videos and past livestreams including transcripts, comments, and live chat. ytdownload is the older version that is still useful for downloading livestreams. See python livechat.py for details.
These use the yt_dlp YoutubeDL Python class or embedded CLI to download videos. You may want to install ffmpeg to handle some video conversion. Easiest way on macOS is through homebrew: brew install ffmpeg.
Usage:
-
Run the application:
python src/main.py
-
Follow the prompts to enter the YouTube URL and choose your options regarding cookies and comments.
See youtube-downloader-app README for more details.
ytdownload/analyze_chat.py- Analyze a youtube live chat CSV output byyoutube_downloader.py.ytdownload/extract_functions.py- Extract functions used byyoutube_downloader.py.ytdownload/youtube_downloader.py- Updated downloader using classes to download video, description, transcript, comments, and live chat and convert comments & live chat to CSV.
To save live video and chat:
-
Copy the VIDEO_ID, which is the final segment in a YouTube URL, for example,
ABC123inhttps://www.youtube.com/watch?v=ABC123. -
Run the following to download the live chat:
python youtube-live-chat-fetcher.py
-
Enter the VIDEO_ID in the input field.
-
Copy the code to download the live video from the start and run it in a new terminal:
yt-dlp --live-from-start -- VIDEO_ID
If you get the error:
ERROR: [youtube] URL: Sign in to confirm you’re not a bot. Use --cookies-from-browser or --cookies for the authentication. See https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp for how to manually pass cookies. Also see https://github.com/yt-dlp/yt-dlp/wiki/Extractors#exporting-youtube-cookies for tips on effectively exporting YouTube cookiesSign in with firefox then try:
yt-dlp --cookies-from-browser firefox --live-from-start -- URLhttps://superuser.com/questions/1409426/how-to-pass-input-to-a-script-from-terminal
The following will start the program and begin downloading the VIDEO_ID provided in the link.
printf '%s\n' "https://www.youtube.com/watch?v=VIDEO_ID" | python youtube_downloader.py
To download using a guest token, use yt-dlp X_URL.
If you get the error "file name too long", use the following:
yt-dlp -o "%(id)s.%(ext)s" X_URLSee more here, here, and here.
See Using yt-dlp cookies if you need to log in to download
Use yt-dlp --cookies-from-browser firefox URL.
See yt-dlp/yt-dlp#8290 (comment).
Simple option:
yt-dlp <kick_replay_url>Previous option (if the above doesn't work, this is the old way):
how-to-download-your-kick-replays
- Open your browser and press F12
- Click the "Network" tab
- Load the replay in your browser
- In the network tab, search for m3u8
- Right Click the file master.m3u8 and select Copy URL
- Open your command line / terminal
- If on Windows, go to the directory where the yt-dlp file has been installed
- Run the following Command:
yt-dlp <kick_replay_url>
Merge downloaded fragments with ffmpeg’s concat demuxer.
- Create a file named filelist.txt with the files listed in order.
file 'filename.f137.mp4.part'
file 'filename.f140.mp4.part'- Run the ffmpeg command to merge them:
ffmpeg -f concat -safe 0 -i filelist.txt -c copy output.mp4This will merge the fragments into output.mp4.
# other options
ydl_opts = {
'listformats': True, # list available formats
}
ydl_opts = {
'format' : '00' # enter format ID
'merge_output_format': 'mp4', # Ensure the final output is in mp4 format
}
ydl_opts = {
'format': 'bestvideo[height<=720]+bestaudio/best[height<=720]', # download up to 720p video
'merge_output_format': 'mp4', # Ensure the final output is in mp4 format
}List formats
yt-dlp -F "https://www.youtube.com/watch?v=VIDEO_ID"Download best video and audio at the highest resolution
yt-dlp -f "bestvideo+bestaudio/best" "https://www.youtube.com/watch?v=VIDEO_ID"ytdownload/youtube-live-chat-fetcher.py- Fetch live chat during a live stream. Requires API key.- Sign up to develop with the Google Cloud Platform, create a project, and activate the YouTube Data API v3.
- Create an
.envfile withYOUTUBE_API_KEY=yourapikeyandMAPS_API_KEY=yourmapsapikey.