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 Bard to write some of them.
- Setup
- New
- Random experiments
- Dice games
- Wikipedia & news
- Google & YouTube APIs
- YouTube downloaders
- YouTube and Geolocation Requirements
youtubedl/dlvideo.py
options- More
For initial setup, create a virtual environment & run it:
$ python -m venv venv
$ . venv/bin/activate
Then install requirements:
$ pip install -r requirements.txt
Thereafter, just run the second venv line to activate the virtual environment.
To run experiments, type python
and the file name. For example, try this one:
$ python ytdl_updated.py
business_assumptions.py
- calculate breakeven cost and amount of drivers needed for a hypothetical future business idea.moviesearch.py
- prints number of movies released in a range of years.- Squid game sims -
squid_game.py
&squid_game01.py
- red light green light sim. write_key.py
- asks for a key and value and adds it to a dictionary. If the dictionary doesn't exist, creates it.- new YouTube downloaders.
wordplay/word_or_phrase.py
- Asks if you want to generate a random phrase or define a word.
wordplay/random_sentence.py
- Creates random nonsense words and sentences.wordplay/gensen_worddict.py
- Expandedwordplay/random_sentence.py
. Pulls random words from thehttps://random-word-api.herokuapp.com/word
API endpoint and strings them together to create a sentence, then verifies the sentence against thelanguage_tool_python
API.wordplay/random_sentence_save.py
- Same aswordplay/random_sentence.py
except saves to file.
wordplay/gen_pass.py
- Generate passphrase. Uses thehttps://random-word-api.herokuapp.com/word
API endpoint to generate a passphrase.entername.py
- Enter your name and get greeted with the current time.givename.py
- Runsentername.py
and passes in a hardcoded name.
dice_roles.py
- Rolls 2 6-sided dice.dice_roll_anysided
- Roll a die with the number of sides specified by the user.
die_roll_games3.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.
wiki_articles.py
- Display the 10 most recently-updated articles.gnews_scraper.py
- Scrape the latest 5 Google News headlines based onh4
top stories.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.
youtubedl/your_youtube.py
- Display the 10 most recently-added YouTube videos.youtubedl/youtube_search_loc.py
- Display the 10 most recently-added YouTube videos in a specific location.youtubedl/yt_loc2.py
- User-friendly YouTube search by location.lat_long.py
- Display the latitude and longitude for an address. Uses the Google Maps API.
Most of these use the yt_dlp
YoutubeDL
Python class or embedded CLI to download videos.
How to download a video from X/Twitter using the yt-dlp
CLI
- open in Firefox, log in, pass the following:
yt-dlp replaceWithURL --cookies-from-browser firefox::none
- Reference: https://www.reddit.com/r/youtubedl/comments/15wn3mb/ytdlp_cant_download_from_twitter/
Run this to get everything.
youtubedl/ytdl_updated.py
- Updated downloader to download video and description, and download and convert transcript, comments, and live chat.
youtubedl/ytdl_comments.py
- just downloads comments.youtubedl/ytdl_livechat.py
- just downloads live chat.youtubedl/ytdltranscript.py
- just downloads transcripts.
These are older and no longer maintained.
youtubedl/dlvideo.py
- (not just YouTube) Download YouTube, TikTok, and other videos from URL usingyt_dlp
.youtubedl/ytdlchatvidthreads.py
- Download YouTube Live video and chat.youtubedl/commentdl.py
- Download comments from YouTube video. Saves output as a JSON and CSV file. Depends onyoutubedl/youtube_functions.py
.youtubedl/ytlivechatcommentdl.py
- Download YouTube live stream video, live chat, and comments. Extracts comments and live chat to CSV.- Consolidates
youtubedl/ytdlchatvidthreads.py
,youtubedl/main_extraction.py
andyoutubedl/commentdl.py
. - Uses
youtubedl/youtube_functions.py
andyoutubedl/youtube_functions2.py
.
- Consolidates
youtubedl/ytlive-chatextract.py
- Extract YouTube live chat from JSON to CSV.youtubedl/ytdltranscript.py
- Download YouTube transcript and save cleaned version without timecodes to text file. Usesyoutubedl/youtube_functions.py
youtubedl/youtube_functions.py
- Functions used inyoutubedl/ytlivechatcommentdt.py
,youtubedl/commentdl.py
, andyoutubedl/ytdltranscript.py
.youtubedl/youtube_functions2.py
- Used inyoutubedl/ytlivechatcommentdt.py
andyoutubedl/ytlive-chatextract.py
.- Uses
youtubedl/extract_functions.py
.
- Uses
Required for Google & YouTube API apps
- Sign up to develop with the Google Cloud Platform, create a project, and activate the YouTube Data API v3 and the Geocoding API.
- Create an
.env
file withYOUTUBE_API_KEY=yourapikey
andMAPS_API_KEY=yourmapsapikey
.
Suggested for YouTube downloaders
- Programs using
yt_dlp
, such asrandtube
&rectube
- you should installffmpeg
. Easiest way on macOS is through homebrew:brew install ffmpeg
See for more: https://trac.ffmpeg.org/wiki/CompilationGuide/macOS.
# 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
}
See Programming notes.