diff --git a/README.md b/README.md index db1b532..1b1bd80 100644 --- a/README.md +++ b/README.md @@ -15,3 +15,6 @@ n-dip... # Usage While you _could_ clone this repo and run the app locally (or mess with the contents of `dairy_queen/`), this app is currently being hosted at [double-dipper.herokuapp.com](https://double-dipper.herokuapp.com/). + +Also, you can always play with the [jupyter-notebook](demo.ipynb) if you want a demo on how you +can use the API programmatically. diff --git a/demo.ipynb b/demo.ipynb new file mode 100644 index 0000000..ff5ce64 --- /dev/null +++ b/demo.ipynb @@ -0,0 +1,262 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "import requests, re" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "dairy_queen_url = 'https://double-dipper.herokuapp.com/double-dips'\n", + "params = {\n", + " 'location': 'Berlin',\n", + " 'days_from_now': 0,\n", + " 'max_wait_mins': 60\n", + "}" + ] + }, + { + "cell_type": "code", + "execution_count": 9, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "r = requests.get(dairy_queen_url, params=params)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def filter_sony_center(x):\n", + " name = x.get('name')\n", + " info = x.get('info')\n", + " if re.match('CineStar', name) and re.match('.*Sony.*', info):\n", + " return True\n", + " else:\n", + " return False" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [], + "source": [ + "sony_center = next(filter(filter_sony_center, r.json()))" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "Zoomania (OV) 13:30-15:18 -> Batman v Superman: Dawn of Justice (OV) 16:00-18:32 -> Hail, Caesar! (OV) 19:30-21:16 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "My Big Fat Greek Wedding 2 (OV) 13:30-15:04 -> Batman v Superman: Dawn of Justice (OV) 16:00-18:32 -> Hail, Caesar! (OV) 19:30-21:16 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Kung Fu Panda 3 (OV) 13:30-15:06 -> Batman v Superman: Dawn of Justice (OV) 16:00-18:32 -> Hail, Caesar! (OV) 19:30-21:16 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Zoomania (OV) 13:45-15:33 -> Batman v Superman: Dawn of Justice (OV) 16:00-18:32 -> Hail, Caesar! (OV) 19:30-21:16 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Zoomania (OV) 13:45-15:33 -> Kung Fu Panda 3 (OV) 16:30-18:06\n", + "\n", + "\n", + "Die Bestimmung - Allegiant (OV) 13:45-15:45 -> Batman v Superman: Dawn of Justice (OV) 16:00-18:32 -> Hail, Caesar! (OV) 19:30-21:16 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Die Bestimmung - Allegiant (OV) 13:45-15:45 -> Kung Fu Panda 3 (OV) 16:30-18:06\n", + "\n", + "\n", + "Die Bestimmung - Allegiant (OV) 13:45-15:45 -> Zoomania (OV) 16:45-18:33 -> Hail, Caesar! (OV) 19:30-21:16 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> Kung Fu Panda 3 (OV) 16:30-18:06\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> Zoomania (OV) 16:45-18:33 -> Hail, Caesar! (OV) 19:30-21:16 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> Zoomania (OV) 17:15-19:03 -> Hail, Caesar! (OV) 19:30-21:16 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> Zoomania (OV) 17:15-19:03 -> Deadpool (OV) 19:45-21:34 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> My Big Fat Greek Wedding 2 (OV) 17:15-18:49 -> Hail, Caesar! (OV) 19:30-21:16 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> My Big Fat Greek Wedding 2 (OV) 17:15-18:49 -> Deadpool (OV) 19:45-21:34 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> Die Bestimmung - Allegiant (OV) 17:30-19:30 -> Hail, Caesar! (OV) 19:30-21:16 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> Die Bestimmung - Allegiant (OV) 17:30-19:30 -> Deadpool (OV) 19:45-21:34 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> Die Bestimmung - Allegiant (OV) 17:30-19:30 -> Zoomania (OV) 20:00-21:48 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> Die Bestimmung - Allegiant (OV) 17:30-19:30 -> Rock the Kasbah (OV) 20:15-22:02 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> Die Bestimmung - Allegiant (OV) 17:30-19:30 -> Rock the Kasbah (OV) 20:15-22:02 -> London Has Fallen (OV) 23:00-00:39\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> Die Bestimmung - Allegiant (OV) 17:30-19:30 -> Raum (OV) 20:20-22:18 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> Die Bestimmung - Allegiant (OV) 17:30-19:30 -> Raum (OV) 20:20-22:18 -> London Has Fallen (OV) 23:00-00:39\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> Die Bestimmung - Allegiant (OV) 17:30-19:30 -> Raum (OV) 20:20-22:18 -> Deadpool (OV) 23:15-01:04\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> Die Bestimmung - Allegiant (OV) 17:30-19:30 -> Raum (OV) 20:20-22:18 -> Rock the Kasbah (OV) 23:15-01:02\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> Die Bestimmung - Allegiant (OV) 17:30-19:30 -> Raum (OV) 20:20-22:18 -> The Revenant - Der Rückkehrer (OV) 23:15-01:52\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> Die Bestimmung - Allegiant (OV) 17:30-19:30 -> My Big Fat Greek Wedding 2 (OV) 20:30-22:04 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 14:00-16:32 -> Die Bestimmung - Allegiant (OV) 17:30-19:30 -> My Big Fat Greek Wedding 2 (OV) 20:30-22:04 -> London Has Fallen (OV) 23:00-00:39\n", + "\n", + "\n", + "Kung Fu Panda 3 (OV) 14:00-15:36 -> Batman v Superman: Dawn of Justice (OV) 16:00-18:32 -> Hail, Caesar! (OV) 19:30-21:16 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Raum (OV) 14:00-15:58 -> Batman v Superman: Dawn of Justice (OV) 16:00-18:32 -> Hail, Caesar! (OV) 19:30-21:16 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Raum (OV) 14:00-15:58 -> Kung Fu Panda 3 (OV) 16:30-18:06\n", + "\n", + "\n", + "Raum (OV) 14:00-15:58 -> Zoomania (OV) 16:45-18:33 -> Hail, Caesar! (OV) 19:30-21:16 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 17:00-19:32 -> Hail, Caesar! (OV) 19:30-21:16 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 17:00-19:32 -> Deadpool (OV) 19:45-21:34 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 17:00-19:32 -> Zoomania (OV) 20:00-21:48 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 17:00-19:32 -> Rock the Kasbah (OV) 20:15-22:02 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 17:00-19:32 -> Rock the Kasbah (OV) 20:15-22:02 -> London Has Fallen (OV) 23:00-00:39\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 17:00-19:32 -> Raum (OV) 20:20-22:18 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 17:00-19:32 -> Raum (OV) 20:20-22:18 -> London Has Fallen (OV) 23:00-00:39\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 17:00-19:32 -> Raum (OV) 20:20-22:18 -> Deadpool (OV) 23:15-01:04\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 17:00-19:32 -> Raum (OV) 20:20-22:18 -> Rock the Kasbah (OV) 23:15-01:02\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 17:00-19:32 -> Raum (OV) 20:20-22:18 -> The Revenant - Der Rückkehrer (OV) 23:15-01:52\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 17:00-19:32 -> My Big Fat Greek Wedding 2 (OV) 20:30-22:04 -> The Big Short (OV) 22:15-00:26\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 17:00-19:32 -> My Big Fat Greek Wedding 2 (OV) 20:30-22:04 -> London Has Fallen (OV) 23:00-00:39\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 20:00-22:32 -> London Has Fallen (OV) 23:00-00:39\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 20:00-22:32 -> Deadpool (OV) 23:15-01:04\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 20:00-22:32 -> Rock the Kasbah (OV) 23:15-01:02\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 20:00-22:32 -> The Revenant - Der Rückkehrer (OV) 23:15-01:52\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 20:45-23:17 -> Deadpool (OV) 23:15-01:04\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 20:45-23:17 -> Rock the Kasbah (OV) 23:15-01:02\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 20:45-23:17 -> The Revenant - Der Rückkehrer (OV) 23:15-01:52\n", + "\n", + "\n", + "Batman v Superman: Dawn of Justice (OV) 22:45-01:17\n", + "\n", + "\n" + ] + } + ], + "source": [ + "for double_dip in sony_center.get('doubleDips'):\n", + " # double_dip is an array of movies\n", + " print(' -> '.join([\"%s %s-%s\" % (movie.get('movie'), movie.get('startTime'), movie.get('endTime')) for movie in double_dip]))\n", + " print('\\n')" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.5.1" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +}