|
|
|
@ -1,10 +1,10 @@
|
|
|
|
|
from flask import Flask, make_response, request, current_app |
|
|
|
|
from simplejson import dumps |
|
|
|
|
from pymongo import MongoClient |
|
|
|
|
from pymongo import MongoClient, DESCENDING # ASCENDING |
|
|
|
|
import datetime |
|
|
|
|
import dateutil.parser |
|
|
|
|
import bson |
|
|
|
|
|
|
|
|
|
from settings import mongo_config |
|
|
|
|
from datetime import timedelta |
|
|
|
|
from functools import update_wrapper |
|
|
|
|
|
|
|
|
@ -52,7 +52,7 @@ def crossdomain(origin=None, methods=None, headers=None,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app = Flask(__name__) |
|
|
|
|
client = MongoClient(**{'host': '10.10.10.51', 'port': 27017}) |
|
|
|
|
client = MongoClient(mongo_config) |
|
|
|
|
db = client.showtimes |
|
|
|
|
|
|
|
|
|
miscObjHandler = lambda obj: ( |
|
|
|
@ -71,7 +71,7 @@ def hello_world():
|
|
|
|
|
@app.route('/movies/<lang>/', methods=['GET']) |
|
|
|
|
@crossdomain(origin='*') |
|
|
|
|
def movie_list(lang='en'): |
|
|
|
|
result = db.movies.find() |
|
|
|
|
result = db.movies.find().sort('release_date', DESCENDING) |
|
|
|
|
movies = [] |
|
|
|
|
for i in result: |
|
|
|
|
if 'original' in i['title']: |
|
|
|
@ -97,7 +97,10 @@ def movie_list(lang='en'):
|
|
|
|
|
@app.route('/movie/<mid>/', methods=['GET']) |
|
|
|
|
@crossdomain(origin='*') |
|
|
|
|
def movie_item(mid): |
|
|
|
|
movie = db.movies.find_one({'id': int(mid)}) |
|
|
|
|
try: |
|
|
|
|
movie = db.movies.find_one({'tmdb_id': int(mid)}) |
|
|
|
|
except ValueError: |
|
|
|
|
movie = db.movies.find_one({'_id': bson.objectid.ObjectId(mid)}) |
|
|
|
|
if not movie: |
|
|
|
|
movie = {} |
|
|
|
|
r = make_response(dumps(movie, default=miscObjHandler)) |
|
|
|
@ -153,8 +156,8 @@ def list_showtimes(group=None, code=None):
|
|
|
|
|
if code: |
|
|
|
|
q['theater'] = code |
|
|
|
|
|
|
|
|
|
result = db.showtimes.find(q) |
|
|
|
|
items = [i for i in result] |
|
|
|
|
result = db.showtimes.find(q).sort('date', DESCENDING) |
|
|
|
|
items = [i for i in result[:300]] |
|
|
|
|
json_dict = { |
|
|
|
|
'meta': { |
|
|
|
|
'total_count': len(items) |
|
|
|
|