Exemple #1
0
 def get(self):
     try:
         user = self.current_user
         data = yield self.data.get_favoritetagname(user)
         self.finish(Respon(Baserespon, data=data))
     except Exception as e:
         self.finish(Respon(Badrespon, e))
Exemple #2
0
 def post(self):
     try:
         user = self.current_user
         json = self.get_json()
         data = yield self.data.insert_favoritetag(user, **json)
         self.finish(Respon(Baserespon, data=data))
     except Exception as e:
         self.finish(Respon(Badrespon, e))
Exemple #3
0
 def get(self, video_id):
     try:
         if not video_id:
             raise ValueError(errors.VIDEO_NOT_FOUND)
         data = yield self.data.get_videocomment(video_id)
         self.finish(Respon(Baserespon, data=data))
     except Exception as e:
         self.finish(Respon(Badrespon, message=e))
Exemple #4
0
 def get(self, uid):
     if not uid:
         self.finish(Respon(Nonerespon))
     else:
         try:
             data = yield self.data.get_user(uid)
             self.finish(Respon(Baserespon, data=data))
         except Exception as e:
             self.finish(Respon(Badrespon, e))
Exemple #5
0
 def get(self):
     try:
         user = self.current_user
         if not user:
             raise RuntimeError(errors.LOGIN_COOKIES_INVALID)
         data = yield self.data.get_user(user.uid)
         self.finish((Respon(Baserespon, data=data)))
     except Exception as e:
         self.finish(Respon(Badrespon, e))
Exemple #6
0
 def get(self, *args, **kwargs):
     user = self.current_user
     if not user:
         self.finish(Respon(Badrespon, errors.LOGIN_COOKIES_INVALID))
     else:
         data = {
             'islogin': True,
             'account': user.account,
             'nickname': user.nickname,
             'id': user.uid
         }
         self.finish(Respon(Baserespon, data=data))
Exemple #7
0
 def post(self):
     try:
         json = self.get_json()
         if not json:
             raise RuntimeError(errors.JSON_SHOULD_BE_NOT_NONE)
         message = json.get('message', '')
         reply = ''
         if message == '你好':
             reply = '你好呀~'
         elif message == '你来过这里吗?你拍的视频好有意思':
             pass
         self.finish(Respon(Baserespon, data=reply))
     except Exception as e:
         self.finish(Respon(Badrespon, message=e))
Exemple #8
0
 def get(self):
     try:
         longitude = self.get_argument('longitude', None)
         latitude = self.get_argument('latitude', None)
         level = self.get_argument('level', 8)
         page = int(self.get_argument('page', 1)) - 1  # 数据第0页开始
         if longitude and latitude and level:
             data = yield self.data.get_videoswithneighbour(
                 longitude, latitude, level, page)
             self.finish(Respon(Baserespon, data=data))
         else:
             self.finish(Respon(Nonerespon))
     except Exception as e:
         self.finish(Respon(Badrespon, e))
Exemple #9
0
 def get(self, video_id):
     try:
         if not video_id:
             page = int(self.get_argument('page', 1)) - 1  #数据第0页开始
             uid = self.get_argument('uid', None)
             if not uid:
                 data = yield self.data.get_videos(page)
             else:
                 data = yield self.data.get_videos_uid(uid, page)
         else:
             data = yield self.data.get_video(video_id)
         self.finish(Respon(Baserespon, data=data))
     except Exception as e:
         self.finish(Respon(Badrespon, message=e))
Exemple #10
0
 def delete(self, user_id):
     try:
         user = self.current_user
         yield self.data.defocus_user(user_id, user.uid)
         self.finish(Baserespon)
     except Exception as e:
         self.finish(Respon(Badrespon, message=e))
Exemple #11
0
 def put(self, commentid):
     try:
         if not commentid:
             raise ValueError(errors.COMMENT_NOT_FOUND)
         yield self.data.update_like_videocomment(commentid)
         self.finish(Baserespon)
     except Exception as e:
         self.finish(Respon(Badrespon, message=e))
Exemple #12
0
 def get(self, *args, **kwargs):
     try:
         type = self.get_argument('type', 'send')
         page = int(self.get_argument('page', 1)) - 1  # 数据第0页开始
         user = self.current_user
         if not user:
             raise RuntimeError(errors.LOGIN_COOKIES_INVALID)
         if type == 'send':
             data = yield self.data.get_send_message(user.uid, page)
         elif type == 'recive':
             data = yield self.data.get_recive_message(user.uid, page)
         elif type == 'unreadnum':
             data = yield self.data.unread_messagenum(user.uid)
         else:
             data = None
         self.finish(Respon(Baserespon, data=data))
     except Exception as e:
         self.finish(Respon(Badrespon, message=e))
Exemple #13
0
 def get(self):
     try:
         # user = self.current_user
         # if user:
         #     vids = yield self.recommend_video('-5104583026337327941')
         # else:
         #     vids = yield self.recommend_video('-5104583026337327941')
         vids = ['6584690495409097991', '6584398245387046147', '6570100343449849092',\
                 '6584573083351256327', '6580138391453568264', '6502363396086697229',\
                 '6569537911270673677', '6585385921045073159', '6584251747315748109',\
                 '6584626231122070798']
         if vids:
             data = yield self.data.get_videoswithvids(vids)
         else:
             data = yield self.data.get_videos(page=0)
         self.finish(Respon(Baserespon, data=data))
     except Exception as e:
         self.finish(Respon(Badrespon, message=e))
Exemple #14
0
 def get(self, user_id):
     try:
         type = self.get_argument('type', 'fan')
         page = int(self.get_argument('page', 1)) - 1  #数据第0页开始
         user = self.current_user
         if not user:
             raise RuntimeError(errors.LOGIN_COOKIES_INVALID)
         if type == 'fan':
             data = yield self.data.get_fanuser(user.uid, page)
         elif type == 'master':
             data = yield self.data.get_masteruser(user.uid, page)
         elif type == 'isfollow':
             data = yield self.data.isfollow(user_id, user.uid)
         else:
             data = None
         self.finish(Respon(Baserespon, data=data))
     except Exception as e:
         self.finish(Respon(Badrespon, message=e))
Exemple #15
0
 def post(self, *args, **kwargs):
     try:
         json = self.get_json()
         uid, nickname, account = yield self.data.create_user(**json)
         self.set_secure_cookie('uid', str(uid))
         self.set_secure_cookie('nickname', nickname)
         self.set_secure_cookie('account', account)
         self.finish(Baserespon)
     except Exception as e:
         self.finish(Respon(Badrespon, e))
Exemple #16
0
 def post(self, *args, **kwargs):
     try:
         user = self.current_user
         json = self.get_json()
         if not user:
             raise RuntimeError(errors.LOGIN_COOKIES_INVALID)
         yield self.data.insert_message(user.uid, **json)
         self.finish(Baserespon)
     except Exception as e:
         self.finish(Respon(Badrespon, message=e))
Exemple #17
0
 def post(self, video_id):
     try:
         user = self.current_user
         json = self.get_json()
         if user is None:
             raise RuntimeError(errors.LOGIN_COOKIES_INVALID)
         if not video_id:
             raise ValueError(errors.VIDEO_NOT_FOUND)
         yield self.data.insert_videocomment(video_id, user.uid, **json)
         self.finish(Baserespon)
     except Exception as e:
         self.finish(Respon(Badrespon, message=e))
Exemple #18
0
 def get(self):
     data = yield self.data.get_videotag()
     self.finish(Respon(Baserespon, data=data))
Exemple #19
0
 def delete(self, messageid):
     try:
         yield self.data.delete_message(messageid)
         self.finish(Baserespon)
     except Exception as e:
         self.finish(Respon(Badrespon, message=e))
Exemple #20
0
 def put(self, video_id):
     try:
         yield self.data.like_video(video_id)
         self.finish(Baserespon)
     except Exception as e:
         self.finish(Respon(Badrespon, message=e))
Exemple #21
0
 def put(self, messageid):
     try:
         yield self.data.read_message(messageid)
         self.finish(Baserespon)
     except Exception as e:
         self.finish(Respon(Badrespon, message=e))