def get_videosInfo_req(udp_client, video_list, user_uin=0, area_id=0, game_id=1007039): try: qt = QtHelper() sess = qt.createSessInfo(pb_hero.CMD_HEROTIMESVR, pb_hero.SUBCMD_GET_VIDEOSINFO, 8031) vid_list = [] for v_info in video_list: vid_list.append(v_info.vid) req = pb_hero.GetVideosInfoReq() req.user_uin = user_uin req.area_id = area_id req.vid_list.extend(vid_list) req.game_id = game_id res = qt.buildSendPkg(sess, req) #b = res.serialize() udp_client.sendData(host=host, port=port, buf=res.serialize()) bb = udp_client.recvData() resp = qt.parseReceivePkg(bb) resp.unserialize() resp_str = str(buffer(resp.body_str)[:]) pb_resp = pb_hero.GetVideosInfoRsp() pb_resp.ParseFromString(resp_str) return pb_resp.result,pb_resp.video_info_list except: print traceback.format_exc()
def get_download_info_req(udp_client=None, vid=0, platform=10, game_id=1007039): try: qt = QtHelper() sess = qt.createSessInfo(pb_hero.CMD_HEROTIMESVR, pb_hero.SUBCMD_APPLY_DOWNLOAD_VIDEO, 8031) req = pb_hero.ApplyDownloadVideoReq() req.file_uuid = vid req.platform = platform req.game_id = game_id res = qt.buildSendPkg(sess, req) #b = res.serialize() udp_client.sendData(host=host, port=port, buf=res.serialize()) bb = udp_client.recvData() resp = qt.parseReceivePkg(bb) resp.unserialize() resp_str = str(buffer(resp.body_str)[:]) pb_resp = pb_hero.ApplyDownloadVideoRsp() pb_resp.ParseFromString(resp_str) return pb_resp except: print traceback.format_exc()
def build_multi_game_send_buf(self, game_ids=[],begin_sec=0,begin_usec=0, batch_num=10, v_type=0, uin=0, openid=''): #if not (game_ids and len(game_ids)): # logger.error('build_multi_game_send_buf args error.') # return None try: qt = QtHelper() sess = qt.createSessInfo(pb_hero.CMD_HEROTIMESVR, pb_hero.SUBCMD_GET_VIDEOTIMELINE_MULTI, 8031,uin) req = pb_hero.GetVideoTimelineMultiReq() req.type = v_type #if game_ids and len(game_ids): # req.game_id_list.extend(game_ids) req.need_tag = 1 req.begin_sec = begin_sec req.begin_usec = begin_usec req.num = batch_num if openid: req.uuid = 'LA-' + openid req.flag = openid elif uin: req.user_uin = uin req.flag = str(uin) else: fetcher.error('need uin or openid') return None res = qt.buildSendPkg(sess, req) buf = res.serialize() return buf except: fetcher.error('build_multi_game_send_buf get error:%s'%traceback.format_exc())
def get_rec_req(udp_client, game_id=1007039, area_id=0, type=1, num=10, from_num=0): try: qt = QtHelper() sess = qt.createSessInfo(pb_hero_rec.CMD_HEROTIMESVR, pb_hero_rec.SUBCMD_GET_RECOMMEND_VIDEO, 8031) req = pb_hero_rec.GetRecommendVideoReq() req.game_id = game_id req.area_id = area_id req.type = type req.num = num req.from_num = from_num res = qt.buildSendPkg(sess, req) #b = res.serialize() udp_client.sendData(host=host, port=port, buf=res.serialize()) bb = udp_client.recvData() resp = qt.parseReceivePkg(bb) resp.unserialize() resp_str = str(buffer(resp.body_str)[:]) pb_resp = pb_hero_rec.GetRecommendVideoRsp() pb_resp.ParseFromString(resp_str) return pb_resp except: print traceback.format_exc()
def get_videosInfo_req(self, vid_list=[], user_uin=0, area_id=0, game_id=0): try: qt = QtHelper() sess = qt.createSessInfo(pb_hero.CMD_HEROTIMESVR, pb_hero.SUBCMD_GET_VIDEOSINFO, 8031,user_uin) req = pb_hero.GetVideosInfoReq() req.user_uin = user_uin req.area_id = area_id req.vid_list.extend(vid_list) req.game_id = game_id req.need_tag = 1 res = qt.buildSendPkg(sess, req) #b = res.serialize() self.udp_client.sendData(buf=res.serialize()) bb = self.udp_client.recvData() resp = qt.parseReceivePkg(bb) resp.unserialize() resp_str = str(buffer(resp.body_str)[:]) pb_resp = pb_hero.GetVideosInfoRsp() pb_resp.ParseFromString(resp_str) return pb_resp.result,pb_resp.video_info_list except: fetcher.error('get error:%s'%traceback.format_exc())
def get_openid_by_uuid(uuid=0, uin=0): #need ask them l5. udp_client = UDPClient(host='10.239.196.159', port=15000) try: qt = QtHelper() sess = qt.createSessInfo(pb_openid.CMD_TICKETSVR, pb_openid.SUBCMD_PARSE_ID, 8031, uin) req = pb_openid.ParseIdReq() req.ids.extend([uuid]) res = qt.buildSendPkg(sess, req) udp_client.sendData(buf=res.serialize()) bb = udp_client.recvData() resp = qt.parseReceivePkg(bb) resp.unserialize() resp_str = str(buffer(resp.body_str)[:]) pb_resp = pb_openid.ParseIdRsp() pb_resp.ParseFromString(resp_str) return pb_resp except: logger.error('get error:%s' % traceback.format_exc()) finally: udp_client.close()
def apply_uploader_req(self, vid=0, filetype='', filesize=0, filesha='', filemd5='', addrtype=2, game_id=0, uin=289296918): try: qt = QtHelper() sess = qt.createSessInfo(pb_hero.CMD_HEROTIMESVR, pb_hero.SUBCMD_APPLY_UPLOAD_VIDEO, self.uiAppid, uin) req = pb_hero.ApplyUploadVideoReq() req.file_uuid = vid req.filetype = filetype req.filesize = filesize req.filesha = filesha req.filemd5 = filemd5 req.game_id = game_id req.addrtype = addrtype res = qt.buildSendPkg(sess, req) #b = res.serialize() self.udp_client.sendData(buf=res.serialize()) bb = self.udp_client.recvData() resp = qt.parseReceivePkg(bb) resp.unserialize() resp_str = str(buffer(resp.body_str)[:]) pb_resp = pb_hero.ApplyUploadVideoRsp() pb_resp.ParseFromString(resp_str) return pb_resp except: logger.error('get error:%s'%traceback.format_exc())
def recv_multi_game_resp(self, client=None): if not client: logger.error('recv_multi_game_resp args error.') return None try: bb = client.recvData() qt = QtHelper() resp = qt.parseReceivePkg(bb) resp.unserialize() resp_str = str(buffer(resp.body_str)[:]) pb_resp = pb_hero.GetVideoTimelineMultiRsp() pb_resp.ParseFromString(resp_str) return pb_resp except: fetcher.error('recv_multi_game_resp get error:%s'%traceback.format_exc())
def get_videoInfo_by_user(self, uin=0, game_id=0, begin_sec=0, client=None, begin_usec=0, batch_num=10, v_type=0, openid=None): try: qt = QtHelper() sess = qt.createSessInfo(pb_hero.CMD_HEROTIMESVR, pb_hero.SUBCMD_GET_VIDEOTIMELINE, 8031,uin) client = client or self.udp_client req = pb_hero.GetVideoTimelineReq() req.type = v_type req.game_id = game_id req.need_tag = 1 req.begin_sec = begin_sec req.begin_usec = begin_usec req.num = batch_num if openid: req.uuid = 'LA-' + openid elif uin: req.user_uin = uin else: fetcher.error('need uin or openid') return None res = qt.buildSendPkg(sess, req) client.sendData(buf=res.serialize()) bb = client.recvData() resp = qt.parseReceivePkg(bb) resp.unserialize() resp_str = str(buffer(resp.body_str)[:]) pb_resp = pb_hero.GetVideoTimelineRsp() pb_resp.ParseFromString(resp_str) return pb_resp except: fetcher.error('get error:%s'%traceback.format_exc())
from hero.qt_herlper import QtHelper import hero.proto.hero_time_recommend_pb2 as pb qt = QtHelper() sess = qt.createSessInfo(pb.CMD_HEROTIMESVR, pb.SUBCMD_GET_RECOMMEND_VIDEO, 0) req = pb.GetRecommendVideoReq() req.game_id = 0 req.area_id = 0 req.type = 3 req.num = 100 req.from_num = 0 res = qt.buildSendPkg(sess, req) b = res.serialize() f = open('data2', 'wb') f.write(b)
from hero.qt_herlper import QtHelper import hero.proto.hero_time_recommend_pb2 as pb qt = QtHelper() f = open('data2', 'rb') b = f.read() resp = qt.parseReceivePkg(b) resp.unserialize() print repr(resp.header.c_a) print repr(resp.header.subcmd) print repr(resp.header.cldPkgHead.command) print repr(resp.header.relayPkgHeadEx2.shExLen) print repr(resp.c_end) #resp_str = str(bytearray(resp.body_str)) resp_str = str(buffer(resp.body_str)[:]) pb_resp = pb.GetRecommendVideoReq() pb_resp.ParseFromString(resp_str) print pb_resp.game_id print pb_resp.area_id print pb_resp.type print pb_resp.num print pb_resp.from_num f.close()