my code: https://editor.p5js.org/miniverse/sketches/uhuv5GAOY
***EDIT***
my process:
I wanted to make an API based clock where I took the time and searched for a spotify song with related words or numbers in the title. However, because the clock won’t have internet connection when displayed, Golan suggested scraping texts and getting excerpts which mention the time. Those could be stored statically as small files along with the code. Therefore I wouldn’t need the internet.
To do this, one needs some knowledge of python and mountains of plain text to look at. I had python expertise, and Golan pointed me to a repo with all of Project Gutenberg (database of text out of copywrite) saved as a plain text 8 GB zip file.
The picture below is part of the preprocessing python script I used to parse Gutenberg for a couple hours. I listed calendar key words and looked for them linearly by looping through all the files. I stored the line the keyword was in to a JSON.
This was the first iteration of the clock when I didn’t scrape the text properly and and didn’t read the documentation for p5.js:
changes to the display code from the photos above:
- I removed the font. The text has german, Russian, Spanish and other characters that “Vogue.tff” from free fonts.com doesn’t support. Now I use Times New Roman.
- I rescraped all the texts and screened for profanity. The way I scraped before had bugs and was on a computer with not enough processing power.
- Here are the scripts for scraping and filtering profanity: https://github.com/himalinig/gutenberg_clock
- I include the minutes and seconds. For each text excerpt I also include the title of the text it came from. I restructured the code and read through the p5.js documentation which opened allowed me to fix the irregular highlighting.
Here’s the gifs of the new and improved project:
during the minute:
when the minute changes:
Another one:
Things I learned:
- Don’t do this the night before. I couple of hours when I wasn’t exhausted was more productive than the all nighter I pulled.
- Process is important. It was hard to isolate bugs when too many variables could be responsible. Make small changes, test, and then add complexity.
- Make changes in order of importance. Small changes that are hard to figure out can be done later.