def movie_recommend(): bb_cli = BigbroCache() res_type = 'movie' lang = request.args.get('lang', 'zh') mid = bb_cli.get_recommend_movie(lang) if not mid: return '{}' mc = bb_cli.get_resource(res_type=res_type, res_id=mid) if not mc or mc['online'] == 'off': return '{}' return json.dumps({ 'title': mc['content']['title'], 'director': mc['content']['director'], 'writer': mc['content']['writer'], 'poster': mc['content']['pmajor'], 'release_date': mc['content']['release_date'], 'release_vision': mc['content']['release_vision'], 'stars': mc['content']['stars'], 'lang': mc['content']['lang'], 'duration': mc['content']['duration'], 'country': mc['content']['country'], 'genre': mc['content']['genre'], 'producer': mc['content']['producer'], 'movie_id': mc['res_id'] })
def movie_recommend(): bb_cli = BigbroCache() rtp = 'movie' pg = int(request.args.get('pg', 1)) movie_total = 0 total_pg = 0 m_id = bb_cli.get_recommend_movie() m_id_en = bb_cli.get_recommend_movie(lang='en') rst = [] for mid in [m_id, m_id_en]: if not mid: continue movie_total += 1 total_pg = 1 mc = bb_cli.get_resource(res_type=rtp, res_id=mid) if mc and mc['online'] == 'on': slz = {} slz['res_id'] = mc['res_id'] slz['bb'] = mc['bb'] slz['created'] = timestamp_to_strftime(mc['created']) slz['online'] = mc['online'] for k in movie_keys: slz[k] = mc['content'].get(k, '') slz['videos'] = mc['content']['videos'] rst.append(slz) return render_template('movie_recommend.html', movies=rst, movie_total=movie_total, total_pg=total_pg, pg=pg)