TextExpander is an application that can automate routine typings on your Mac, and I think it is one of those must have apps for your Mac. Beyond the conventional text expanding capabilities, TextExpander supports AppleScript and Shell Script.
Inspired by David Sparks’ media review snippets, I decided to create my version that can automatically import some key metadata from IMDB.
- I open the IMDB title page for the movie that I want to review (i.e. http://www.imdb.com/title/tt1375666/)
- start a new entry in Day One (Day One is a great journal app)
- expand the snippet (my abbreviation is “xmov”)
Without manually copying-and-pasting, you instantly get the following: link to the IMDB title page specific to the movie, IMDB rating, director(s), writer(s), actors, and a quick summary. I don’t have to type or copy-and-paste any of these. With a brief keyword(;mov), I get all the metadata that I want to include in my review in a pre-formatted Markdown. Actor/writer/director names are links, which allows me to further read about a particular individual if I am interested in him/her.
- Despite my messy script and set-up, everything should work within a second.
- IMDB does not have an official API, so I parsed the actual title page (html). There are some third-party APIs available, but parsing the HTML source works fine.
- In this particular solution, AppleScript captures the URL of the IMDB page from Safari and passes it to the Python script that actually does the job. This whole thing can be duplicated only using AppleScript. Despite the inconvenience and additional complexities of having two scripts system, I wrote the main script in Python since I am much more comfortable with Python than AppleScript.
- unfortunately, Day One does not fully support AppleScript. There is a CLI (command-line interface) for the app, but it is relatively limited (no tagging support).
- Python 3 (some modifications are needed for Python 2)
- BeautifulSoup (a Python package used here to parse strings). Check out You can do “pip install beautifulsoup4” on Terminal (depending on your set-up, you may need “sudo”) or Google it to find out how to install the latest version.