|
|
@ -95,14 +95,26 @@ def movie_list(lang='en'): |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@app.route('/movie/<mid>/', methods=['GET']) |
|
|
|
@app.route('/movie/<mid>/', methods=['GET']) |
|
|
|
|
|
|
|
@app.route('/movie/<mid>/<lang>/', methods=['GET']) |
|
|
|
@crossdomain(origin='*') |
|
|
|
@crossdomain(origin='*') |
|
|
|
def movie_item(mid): |
|
|
|
def movie_item(mid, lang='en'): |
|
|
|
|
|
|
|
lang = lang if lang in ('en', 'th') else 'en' |
|
|
|
try: |
|
|
|
try: |
|
|
|
movie = db.movies.find_one({'tmdb_id': int(mid)}) |
|
|
|
movie = db.movies.find_one({'tmdb_id': int(mid)}) |
|
|
|
except ValueError: |
|
|
|
except ValueError: |
|
|
|
movie = db.movies.find_one({'_id': bson.objectid.ObjectId(mid)}) |
|
|
|
movie = db.movies.find_one({'_id': bson.objectid.ObjectId(mid)}) |
|
|
|
if not movie: |
|
|
|
if not movie: |
|
|
|
movie = {} |
|
|
|
movie = {} |
|
|
|
|
|
|
|
for k in ('title', 'tagline', 'director', 'cast', 'storyline'): |
|
|
|
|
|
|
|
if movie[k][lang]: |
|
|
|
|
|
|
|
movie[k] = movie[k][lang] |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
movie[k] = movie[k]['th' if lang == 'en' else lang] |
|
|
|
|
|
|
|
try: |
|
|
|
|
|
|
|
del movie['indexes'] |
|
|
|
|
|
|
|
except KeyError: |
|
|
|
|
|
|
|
pass |
|
|
|
|
|
|
|
|
|
|
|
r = make_response(dumps(movie, default=miscObjHandler)) |
|
|
|
r = make_response(dumps(movie, default=miscObjHandler)) |
|
|
|
r.mimetype = 'application/json' |
|
|
|
r.mimetype = 'application/json' |
|
|
|
return r |
|
|
|
return r |
|
|
|