My friends I were joking last night about how we liked to mainline entire seasons of TV via Netflix -- especially while in bed. The thing is, eventually you want snacks, (gummi bears, a fancy soda, maybe a pint of Cherry Garcia). But, you don't want to put on pants, switch apps, go outside, or order the same thing from Seamless again.
Honestly, it's a big missed opportunity for Netflix. They could enable in-app purchasing & drive up revenue a bajillion percent. And in New York, Amazon Prize Now is a pretty great option for delivery. I bet Postmates would work really well too.
So I thought to myself, why not regularly monitor my online viewing activity to determine if I'm marathoning and trigger some helpful alerts / calls-to-action? Imagine getting this text:
Note: my broheim Devin Mancuso and I have been trading browser automation hacks using Python / Selenium and Node/ phantomJS for the past couple weeks, and it's been super fun. If you haven't tried it, you're missing out.
- Logging into Netflix account using Selenium & PhantomJS
- Parsing activity history with BeautifulSoup
- Checking if last 3 shows watched are from same series (marathon) and updating local tinyDB to avoid repeat triggers on same day.
- Sending SMS / MMS via Twilio - when marathon conditions are met - with prompt & link to Amazon Prime Now for SNACK DELIVERY, (which is great for Manhattan / NYC)
- Light Twitter shaming
- Deployed to Digital Ocean & running every 10 minutes via cron.
Console output case 1: new marathon detected (with MMS alert) and case 2: 'old' marathon detected / no alert sent
- Add front end for user registration & hide sensitive user data.
- Deep links / API integrations for other apps & APIs 'marathon supplies' (Postmates / Seamless / Delivery.com / Amazon Prime now)
Installation & usage
- First, install the dependencies (and yes, you should really install homebrew)
pip install selenium tinydb twilio beautifulsoup4 python-twitter brew install phantomjs
Then, put your Netflix + Twilio login details & API keys into the
keys_ex.py& rename it
keys.py(Yeah, I know, I should use env variables, but it was also a really long night.)
And finally, run the script
If you want to run the script regularly, you'll need to write your own cron job - and if you do - I recommend adding some logging.