def get_video_by_user(self, user_id=0, req_user_id=0, begin_sec=0, begin_usec=0, batch_num=30): data = {} data['videos'] = [] data['total'] = 0 data['user_info'] = [] data['is_watch'] = False self.__base = self.__base or BaseDao() try: req_user_info = { 'req_user_id': req_user_id, 'begin_sec': begin_sec, 'begin_usec': begin_usec } res_obj = self.get_video_by_users(user_id=user_id, req_user_ids=[req_user_info], batch_num=batch_num) data['videos'] = res_obj.get('videos') data['total'] = res_obj.get('total') data['user_info'] = res_obj.get('user_info') ps = ProfileService(base=self.__base) is_watch = ps.is_watch(user_id, req_user_id) data['is_watch'] = is_watch except: logger.error(traceback.format_exc()) finally: return data
def get_user_see_history(self, user_id=0, req_user_id=0, page_num=0): self.__base = self.__base or BaseDao() video = Video(self.__base) (total, rows) = video.get_user_see_history(page_num, 30, req_user_id) arr = [] for row in rows: v = row.toDict() arr.append(v) service = ProfileService() is_watch = service.is_watch(user_id, req_user_id) service.close() data = {} data['videos'] = arr data['total'] = total data['is_watch'] = is_watch return data