def getNewSongList(self, lasttime): self.dogname = tsServiceTask.get_dogname() if not self.dogname: logger.debug("Falied to get dogname.") return False url = "%s/ModuleService.aspx?op=getnewsongdatabyjson&dogname=%s"\ "&storeId=%s&time=%s" % ( self.songlist, urllib.quote(tsServiceTask.get_dogname()), str(tsServiceTask.get_ktvid()),str(lasttime)) logger.debug(url) dataTypeMsg = yhttp().get_y(url) resdata = json.loads(dataTypeMsg) logger.debug("getnewsonglist: " % resdata) if resdata and int(resdata['code']) == 1: if resdata['result']: res = resdata['result'] obj_items = res['matches'] if len(obj_items) > 0: item_dict = obj_items[0] return yhttp().get_y(item_dict['TypeUrl'], 30, ct='utf-8-sig') return ""
def geto2oadcaption(self): url = '%s/ad/caption/%s' % (AppSet().O2OAPI, tsServiceTask.get_ktvid()) #url = "http://api.stage.ktvsky.com/ad/caption/1"; jsonres = request_json(url, timeout=10, method='GET') logger.debug("get o2o ad caption, url:%s result: %s" % (url, jsonres)) if "errcode" in jsonres and jsonres['errcode'] == 200: return jsonres return None
def do_run(self): self.dogname = tsServiceTask.get_dogname() self.ktvid = tsServiceTask.get_ktvid() if not self.ktvid or not self.dogname: self._lastmsg = "Falied to get ktvinfo." logger.debug(self.lastmsg) return False print("NewSong module********************") #self.do_get_new_song() self.do_get_cloud_song()
def getWallPagersNew(self): dicResult = {} url = "{0}/ad/policy/{1}".format(self.O2OAPI, tsServiceTask.get_ktvid()) logger.debug(url) res_dict = request_json(url, timeout=10, method='GET') horizon_pos = {} verticle_pos = {} if res_dict: if 'errcode' in res_dict.keys(): if int(res_dict['errcode']) == 200: hstr = [] vstr = [] if 'ad_pos' in res_dict.keys(): ad_pos = res_dict['ad_pos'] if ad_pos: if 'horizon_lock_screen' in ad_pos.keys(): horizon_pos = ad_pos['horizon_lock_screen'] if horizon_pos: hstr = horizon_pos["ad"] if 'verticle_lock_screen' in ad_pos.keys(): verticle_pos = ad_pos['verticle_lock_screen'] if verticle_pos: vstr = verticle_pos["ad"] if 'ad_info' in res_dict.keys(): array_obj = res_dict["ad_info"] for adinfo in array_obj: ad_dict = adinfo if ad_dict["type"].lower( ) == "image" and ".bmp" in ad_dict["url"]: type = 0 if len(hstr) > 0: for arrayh in hstr: if str(arrayh) == str(ad_dict["ad"]): type = 0 break if len(vstr) > 0: for arrayh in hstr: if str(arrayh) == str(ad_dict["ad"]): type = 1 break info = self.WallpaperInfo() info['paper_name'] = ad_dict["md5"] info['paper_id'] = ad_dict["ad"] info['paper_sort'] = ad_dict["ad"] info['paper_bagtype'] = type info['paper_url'] = ad_dict["url"] info['monitor_url'] = ad_dict["monitor_url"] if not type in dicResult.keys(): dicResult[type] = [] dicResult[type].append(info) return dicResult
def geto2oadinfolist(self): url = "%s/ad/policy/%s" % (self.O2OAPI1, tsServiceTask.get_ktvid()) jsonres = request_json(url, timeout=10, method='GET') logger.debug("geto2oadinfolist: url:%s \nresult:%s\n" % (url, jsonres)) ad = self.o2oad() if jsonres and 'errcode' in jsonres and jsonres['errcode'] == 200: if "ad_pos" in jsonres.keys(): ad_pos = jsonres['ad_pos'] if "start" in ad_pos.keys(): ad['start_action'] = self.parseo2oaction(ad_pos["start"]) if "mv" in ad_pos.keys(): ad['mv_action'] = self.parseo2oaction(ad_pos["mv"]) if "end" in ad_pos.keys(): ad['end_action'] = self.parseo2oaction(ad_pos["end"]) if "no_song" in ad_pos.keys(): ad['nosong_action'] = self.parseo2oaction( ad_pos["no_song"]) if "horizon_lock_screen" in ad_pos.keys(): ad['horizon_action'] = self.parseo2oaction( ad_pos["horizon_lock_screen"]) if "verticle_lock_screen" in ad_pos.keys(): ad['verticle_action'] = self.parseo2oaction( ad_pos["verticle_lock_screen"]) if "redpack" in ad_pos.keys(): ad['redpack_action'] = self.parseo2oaction( ad_pos["redpack"]) if "7000plus" in ad_pos.keys(): ad['redpack_action'] = self.parseo2oaction( ad_pos["7000plus"]) if "ad_info" in jsonres.keys(): ad_info = jsonres["ad_info"] if ad_info: for item in ad_info: mo2oad = self.o2oad_tvinfo() mo2oad['id'] = item['ad'] mo2oad['url'] = item['url'] mo2oad['url2'] = item['url2'] mo2oad['url2'] = item['url2'] if item["type"].lower() == 'video': mo2oad['type'] = 0 elif item["type"].lower() == 'gif': mo2oad['type'] = 1 else: mo2oad['type'] = 2 mo2oad['typestr'] = item["type"] mo2oad['time'] = item['time'] mo2oad['monitor_url'] = [] mo2oad['md5'] = item['md5'] for mstr in item["monitor_url"]: mo2oad['monitor_url'].append(mstr) ad['ad_dict'].append(mo2oad) return ad
def do_run(self): self.dogname = tsServiceTask.get_dogname() self.ktvid = tsServiceTask.get_ktvid() if not self.ktvid or not self.dogname: self._lastmsg = "Falied to get ktvinfo." logger.debug(self.lastmsg) return False self.get_allow_delete_list(self.lasttime) self.clean_mediafiles(self.lasttime) self.clean_tempfiles(self.lasttime) self.clean_themes(self.lasttime) self.clean_modules(self.lasttime) self.clean_modules(self.lasttime)
def getNewModule(self, m_ver, bagtype, appver): self.dogname = tsServiceTask.get_dogname() self.ktvid = tsServiceTask.get_ktvid() if not self.dogname or not self.ktvid: logger.error("Failed to get dogname or ktvinfo") return False logger.debug("getnewmodule") #获取模板信息 if self.lk == 1 or self.lk == 2: url = "%s/module_verservice.aspx?op=getmoduleverjson&version=%s&"\ "dogname=%s&bagtype=%s&storeId=%s&type=v2&appver=%s&lk=%d"\ % (self.songlist, m_ver, urllib.quote(self.dogname), bagtype, self.ktvid, appver, self.lk) else: url = "%s/module_verservice.aspx?op=getmoduleverjson&version=%s&"\ "dogname=%s&bagtype=%s&storeId=%s&type=v2&appver=%s"\ % (self.songlist, m_ver, urllib.quote(self.dogname), bagtype, self.ktvid, appver) logger.debug(url) dic_res = request_json(url, timeout=10, method='GET') arrver=[] if dic_res and str(dic_res['code']) == '1': if isinstance(dic_res['result'], dict): mresult = dic_res['result']['matches'] var = self.KtvModule_Ver() if len(mresult) > 0: for item in mresult: var['id'] = item['Id'] var['msgtime'] = item['MsgTime'] var['version'] = item['Version'] var['fileurl'] = item['FileUrl'] var['desc'] = item['Desc'] var['addtime'] = time.strftime('%Y-%m-%d %H:%M:%S', time.localtime()) var['needun'] = 0 var['revision'] = item['ReVision'] var['bagtype'] = item['BagType'] var['unpath'] = "" var['name'] = item['Name'] var['isshow'] = item['IsShow'] var['id'] = item['Id'] var['isuse'] = 1 var['vertype'] = item['VerType'] var['isdefault'] = item['IsDefault'] arrver.append(var) return arrver return arrver
def do_run(self): try: self.ktvid = tsServiceTask.get_ktvid() b_failed = False done_tasks = 0 cur_time = int(time.time()) if self.lk == 1: url = "%s/task/ktvtasklist?ktvid=%d&time=%d&lk=1" % (self.Ktv90, self.ktvid, cur_time) else: url = "%s/task/ktvtasklist?ktvid=%d&time=%d" % (self.Ktv90, self.ktvid, cur_time) logger.debug(url) dic_res = request_json(url, timeout=10, method='GET') if isinstance(dic_res, dict) and dic_res['code'] == 1: for task in dic_res['list']: task_time = 10000 if 'task_time' in task.keys(): d = datetime.datetime.strptime(task['task_time'], '%Y-%m-%d %H:%M:%S') task_time = int(time.mktime(d.timetuple())) logger.info('task_name: %s, task_time: %s, time:%s, update:%s' % ( task['task_linuxsavepath'], task['task_time'], task_time, self.last_update)) if self.last_update <= task_time: ret = self.deploy_res(task) if not ret: #only record the failed case logger.error('task_name: %s, task_time: %s, time:%s, update:%s' % ( task['task_linuxsavepath'], task['task_time'], task_time, self.last_update)) b_failed = True else: done_tasks += 1 if task['task_linuxsavepath'].endswith('SongClimax'): if not self.load_climax(): logger.error("failed to load climax info to database") if not b_failed and done_tasks >= 1: #update last_update time if all task successed update_setconfig({'climax_update': cur_time}) except Exception as e: logger.error(traceback.format_exc())