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