async def send_gift(): if ConfigLoader().dic_user['task_control']['clean-expiring-gift']: argvs = await utils.fetch_bag_list(show=False) printer.warn(argvs) roomID = ConfigLoader( ).dic_user['task_control']['clean-expiring-gift2room'] time_set = ConfigLoader().dic_user['task_control']['set-expiring-time'] list_gift = [] for i in argvs: left_time = i[3] if left_time is not None and 0 < int( left_time) < time_set: # 剩余时间少于半天时自动送礼 list_gift.append(i[:3]) if list_gift: print('发现即将过期的礼物') if ConfigLoader( ).dic_user['task_control']['clean_expiring_gift2all_medal']: print('正在投递其他勋章') list_medal = await utils.fetch_medal(show=False) list_gift = await full_intimate(list_gift, list_medal) print('正在清理过期礼物到指定房间') for i in list_gift: giftID = i[0] giftNum = i[1] bagID = i[2] await utils.send_gift_web(roomID, giftNum, bagID, giftID) else: print('未发现即将过期的礼物') BiliTimer.call_after(send_gift, 21600)
async def auto_send_gift(): # await utils.WearingMedalInfo() # return list_medal = [] if ConfigLoader().dic_user['task_control']['send2wearing-medal']: list_medal = await utils.WearingMedalInfo() if not list_medal: print('暂未佩戴任何勋章') # BiliTimer.call_after(auto_send_gift, 21600) if ConfigLoader().dic_user['task_control']['send2medal']: list_medal += await utils.fetch_medal( False, ConfigLoader().dic_user['task_control']['send2medal']) # print(list_medal) print('正在投递勋章') temp = await utils.fetch_bag_list(show=False) # print(temp) list_gift = [] for i in temp: gift_id = int(i[0]) left_time = i[3] if (gift_id not in [4, 3, 9, 10]) and left_time is not None: list_gift.append(i[:3]) await full_intimate(list_gift, list_medal) # printer.info(["# 自动送礼共送出亲密度为%s的礼物" % int(calculate)]) BiliTimer.call_after(auto_send_gift, 21600)
async def run(self): self.roomid = ConfigLoader().dic_user['other_control']['gift_monitor_roomid'] if not self.roomid: print('没写gift房间') return self.danmuji = GiftMonitorHandler(self.roomid, self.areaid) while True: print('# 正在启动直播监控弹幕姬') time_start = int(utils.CurrentTime()) connect_results = await self.danmuji.connectServer() # print(connect_results) if not connect_results: continue task_main = asyncio.ensure_future(self.danmuji.ReceiveMessageLoop()) task_heartbeat = asyncio.ensure_future(self.danmuji.HeartbeatLoop()) finished, pending = await asyncio.wait([task_main, task_heartbeat], return_when=asyncio.FIRST_COMPLETED) print('主弹幕姬异常或主动断开,正在处理剩余信息') time_end = int(utils.CurrentTime()) if not task_heartbeat.done(): task_heartbeat.cancel() task_terminate = asyncio.ensure_future(self.danmuji.close_connection()) await asyncio.wait(pending) await asyncio.wait([task_terminate]) printer.info(['主弹幕姬退出,剩余任务处理完毕'], True) if time_end - time_start < 5: dsn = ConfigLoader().dic_user['other_control']['sentry_dsn'] client = Client(dsn) try: raise Exception('网络不稳定,重试中') except: client.captureException() print('# 当前网络不稳定,为避免频繁不必要尝试,将自动在5秒后重试') await asyncio.sleep(5)
async def draw_lottery(): for i in range(74, 90): json_response = await bilibili.get_lotterylist(i) blacklist = ConfigLoader( ).dic_user['other_control']['additional_blacklist'].append( ['test', 'TEST', '测试', '加密']) # -400 不存在 if not json_response['code']: temp = json_response['data']['title'] if any(word in temp for word in blacklist): print("检测到疑似钓鱼类测试抽奖,默认不参与,请自行判断抽奖可参与性") if (ConfigLoader().dic_user['other_control']['debug_mode']): print(temp) else: check = json_response['data']['typeB'] for g, value in enumerate(check): join_end_time = value['join_end_time'] join_start_time = value['join_start_time'] ts = CurrentTime() if int(join_end_time) > int(ts) > int(join_start_time): json_response1 = await bilibili.get_gift_of_lottery( i, g) print( "当前时间:", time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(time.time()))) print("参与实物抽奖回显:", json_response1) else: pass else: break
def init(formatter): try: action_loader.load_actions() except LoadError as e: print_error_list(formatter, "action import: ", e) try: template.load_customtests() except LoadError as e: print_error_list(formatter, "customtests import: ", e) try: template.load_customfilters() except LoadError as e: print_error_list(formatter, "customfilters import: ", e) if option.config_file: formatter.debug("config file: " + option.config_file) config_loader = ConfigLoader(option.config_file) config_loader.setup_klass(action_loader.get_all_action_map()) env = {"formatter": formatter} env.update(action_loader.get_all_action_map()) return env
def RefreshToken(): # return response = bilibili.request_refresh_token() json_response = response.json() # print(json_response) if not json_response['code'] and 'mid' in json_response['data'][ 'token_info']: print('token刷新成功') data = json_response['data'] access_key = data['token_info']['access_token'] refresh_token = data['token_info']['refresh_token'] cookie = data['cookie_info']['cookies'] generator_cookie = (f'{i["name"]}={i["value"]}' for i in cookie) cookie_format = ';'.join(generator_cookie) dic_saved_session = { 'csrf': cookie[0]['value'], 'access_key': access_key, 'refresh_token': refresh_token, 'cookie': cookie_format } bilibili.load_session(dic_saved_session) if ConfigLoader().dic_user['other_control']['keep-login']: ConfigLoader().write2bilibili(dic_saved_session) # 更新token信息 return True print('联系作者(token刷新失败,cookie过期)', json_response) return False
def control_printer(self, danmu_control=None, debug_control=None): if danmu_control is not None: self.danmu_control = danmu_control ConfigLoader().dic_user['print_control']['danmu'] = danmu_control if debug_control is not None: ConfigLoader().dic_user['print_control']['debug'] = debug_control self.debug_control = debug_control
def __new__(cls, *args, **kw): if not cls.instance: cls.instance = super(bilibili, cls).__new__(cls, *args, **kw) cls.instance.dic_bilibili = ConfigLoader().dic_bilibili dic_bilibili = ConfigLoader().dic_bilibili cls.instance.bili_session = None cls.instance.app_params = f'actionKey={dic_bilibili["actionKey"]}&appkey={dic_bilibili["appkey"]}&build={dic_bilibili["build"]}&device={dic_bilibili["device"]}&mobi_app={dic_bilibili["mobi_app"]}&platform={dic_bilibili["platform"]}' return cls.instance
def __new__(cls, *args, **kw): if not cls.instance: cls.instance = super(Printer, cls).__new__(cls, *args, **kw) cls.instance.dic_color = ConfigLoader().dic_color cls.instance.dic_user = ConfigLoader().dic_user if (cls.instance.dic_user['platform']['platform'] == 'ios_pythonista'): cls.instance.danmu_print = cls.instance.concole_print else: cls.instance.danmu_print = cls.instance.normal_print return cls.instance
def init(formatter): action_loader.load_actions() for error in action_loader.load_error_list: formatter.debug("action import: " + unicode(error)) if option.config_file: formatter.debug("config file: " + option.config_file) config_loader = ConfigLoader(option.config_file) config_loader.apply_config_to_klass(action_loader.get_all_action_map()) env = {"formatter": formatter} env.update(action_loader.get_all_action_map()) return env
async def sliver2coin(): if ConfigLoader().dic_user['task_control']['silver2coin']: # 403 done json_response1 = await bilibili.silver2coin_app() # -403 done json_response = await bilibili.silver2coin_web() printer.info([f'# {json_response["msg"]}']) printer.info([f'# {json_response1["msg"]}']) if json_response['code'] == -403 and '只' in json_response['msg']: finish_web = True else: finish_web = False if json_response1['code'] == 403 and '最多' in json_response1['msg']: finish_app = True else: finish_app = False if finish_app and finish_web: sleeptime = (utils.seconds_until_tomorrow() + 300) BiliTimer.call_after(sliver2coin, sleeptime) return else: BiliTimer.call_after(sliver2coin, 350) return BiliTimer.call_after(sliver2coin, 21600)
async def send_medal_gift(): list_medal = [] task_control = ConfigLoader().dic_user['task_control'] if task_control['send2wearing-medal']: list_medal = await utils.WearingMedalInfo() if not list_medal: print('暂未佩戴任何勋章') if task_control['send2medal']: all_medals = await utils.fetch_medal(True) wanted_medals = task_control['send2medal'] if wanted_medals != None: for roomid in wanted_medals: for m in all_medals: if m[0] == roomid: list_medal.append(m[:3]) print('正在投递勋章') temp = await utils.fetch_bag_list(show=False) list_gift = [] for i in temp: gift_id = int(i[0]) left_time = i[3] if (gift_id not in [4, 3, 9, 10]) and left_time is not None: list_gift.append(i[:3]) await full_intimate(list_gift, list_medal)
async def sliver2coin(): if ConfigLoader().dic_user['task_control']['silver2coin']: # 403 done json_response1 = await bilibili.silver2coin_app() # -403 done json_response = await bilibili.silver2coin_web() Printer().printlist_append( ['join_lottery', '', 'user', "# ", json_response['msg']]) Printer().printlist_append( ['join_lottery', '', 'user', "# ", json_response1['msg']]) if json_response['code'] == -403 and '只' in json_response['msg']: finish_web = True else: finish_web = False if json_response1['code'] == 403 and '最多' in json_response1['msg']: finish_app = True else: finish_app = False if finish_app and finish_web: sleeptime = (utils.seconds_until_tomorrow() + 300) await BiliTimer.append2list_jobs(sliver2coin, sleeptime) return else: await BiliTimer.append2list_jobs(sliver2coin, 350) return await BiliTimer.append2list_jobs(sliver2coin, 21600)
async def BiliMainTask(): login, watch_av, num, share_av = await utils.GetRewardInfo() if ConfigLoader().dic_user['task_control']['fetchrule'] == 'bilitop': list_topvideo = await utils.GetTopVideoList() else: list_topvideo = await utils.fetch_uper_video(ConfigLoader().dic_user['task_control']['mid']) if (not login) or not watch_av: await GetVideoExp(list_topvideo) coin_sent = (num) / 10 coin_set = min((ConfigLoader().dic_user['task_control']['givecoin']), 5) coin_remain = coin_set - coin_sent await GiveCoinTask(coin_remain, list_topvideo) if not share_av: await GetVideoShareExp(list_topvideo) # b站傻逼有记录延迟,3点左右成功率高一点 await BiliTimer.append2list_jobs(BiliMainTask, utils.seconds_until_tomorrow() + 10800)
def do_14(self, line): if ConfigLoader().dic_user['platform']['platform'] == 'ios_pythonista': roomid = input('请输入roomid') real_roomid = fetch_real_roomid(roomid) self.append2list_console([[real_roomid], utils.watch_living_video]) return print('仅支持ios')
async def SendJoinChannel(self, channelId): uid = (int)(100000000000000.0 + 200000000000000.0 * random.random()) body = '{"roomid":%s,"uid":%s}' % (channelId, uid) await self.SendSocketData( 0, 16, ConfigLoader().dic_bilibili['_protocolversion'], 7, 1, body) return True
def fetch_real_roomid(roomid): if roomid: real_roomid = [[roomid], utils.check_room] else: real_roomid = ConfigLoader( ).dic_user['other_control']['default_monitor_roomid'] return real_roomid
def process_watch_living_video(): if ConfigLoader().dic_user['platform']['platform'] == 'ios_pythonista': roomid = input('请输入roomid') real_roomid = fetch_real_roomid(roomid) Biliconsole.append2list_console([[real_roomid], utils.watch_living_video]) return print('仅支持ios')
async def run(): global thx_queue food = ['迪迪', '晨晨', '蓝BUFF', '蓝BUFF', '蓝BUFF', '蓝BUFF', '蓝BUFF', '蓝BUFF', '红BUFF', '红BUFF', '红BUFF', '红BUFF', '红BUFF', '河蟹', '野猪', '猎豹', '小鸟', '暴君', '黑暗暴君', '暗影主宰', '刚出生的蜥蜴弟弟', '雄猎豹的女票', '两只魔种小熊', '妲己', '自己的老婆貂蝉QwQ', '叶子', '自己', '小兵'] eat = [random.choice(['还想吃一个', '偷偷咬了一口', '一口吞下了', '吃掉了峡谷里最后的'])+i for i in food] g = ['亿圆', '喵娘', '蓝白胖次', '爱心便当', '闪耀之星', '游戏机', '海带缠潜艇', '盛夏么么茶', '真香', '狂欢之椅', '咸鱼', '给大佬递茶', '炮车', '锄头', '460', '三级头', '鸡小萌', '情书', '辣条', '比心', '小花花', '干杯', '凉了', '冰阔落', 'flag', '金币', '???', '吃瓜', 'B坷垃', '喵娘', '打榜', '小金人', '中国队加油', '氪金键盘', '变欧喷雾', '节奏风暴', '666', '233', '友谊的小船', '冰淇淋', '给代打的礼物', '门把手', '你别哭啊', '小光头', '灯塔', '疯狂打call', '粉丝卡', '小电视飞船', '月色真美', '月饼', '南瓜车', '摩天大楼', '礼花'] want_gift = ['还想吃许多'+i for i in g] while(True): length = thx_queue.qsize() temp_list = [] filter_list = [] for i in range(length): temp_list.append(thx_queue.get()) for j in temp_list: if len(filter_list) == 0: filter_list.append(j) continue added = False for k in range(len(filter_list)): # 添加重复 ans = filter_list[k] if j.get('uname') == ans.get('uname') and j.get('giftName') == ans.get('giftName') and j.get('roomid') == ans.get('roomid') and j.get('coin_type') == ans.get('coin_type'): filter_list[k].update({ 't': time.time(), 'num': ans.get('num') + j.get('num'), }) added = True break if not added: filter_list.append(j) for _ in range(len(filter_list)): thx_dic = filter_list[_] if time.time() - thx_dic['t'] > 5: try: if 'lc4t' in thx_dic['uname']: msg = '感谢[吨吨]赠送的%d个%s mua~' % (thx_dic['num'], thx_dic['giftName']) else: msg = '感谢[%s]赠送的%d个%s~' % (thx_dic['uname'], thx_dic['num'], thx_dic['giftName']) if thx_dic['giftName'] == 'B坷垃': msg = '恭喜[%s]喜提叶叶勋章~' % (thx_dic['uname']) if thx_dic['coin_type'] == 'gold': end = random.choice(['说了句还想吃', '说了句没吃饱', '说了句不够吃', '说了句还是饿'] + eat + want_gift) msg = '叶叶吃掉了%s的%d个%s并且' % (thx_dic['uname'], thx_dic['num'], thx_dic['giftName']) msg += '.' * (30-len(msg)) msg += end except: traceback.print_exc() dsn = ConfigLoader().dic_user['other_control']['sentry_dsn'] client = Client(dsn) client.captureException() await thx_danmu(msg, thx_dic['roomid']) else: thx_queue.put(thx_dic) await asyncio.sleep(1)
async def run(self): self.room_id = ConfigLoader( ).dic_user['other_control']['default_monitor_roomid'] self.danmuji = danmu.DanmuPrinter(self.room_id, self.area_id) time_now = 0 while True: if int(utils.CurrentTime()) - time_now <= 3: printer.info(['当前网络不稳定,弹幕监控将自动延迟3秒后重启'], True) await asyncio.sleep(3) printer.info(['正在启动直播监控弹幕姬'], True) time_now = int(utils.CurrentTime()) connect_results = await self.danmuji.open() if not connect_results: continue task_main = asyncio.ensure_future(self.danmuji.read_datas()) task_heartbeat = asyncio.ensure_future(self.danmuji.heart_beat()) tasks = [task_main, task_heartbeat] finished, pending = await asyncio.wait( tasks, return_when=asyncio.FIRST_COMPLETED) printer.info(['主弹幕姬异常或主动断开,正在处理剩余信息'], True) if not task_heartbeat.done(): task_heartbeat.cancel() await self.danmuji.close() await asyncio.wait(pending) printer.info(['主弹幕姬退出,剩余任务处理完毕'], True)
def __init__(self, roomid=None, area_id=None): self.client = aiohttp.ClientSession() self.loop_func = self.DanMuraffle self.roomid = roomid self.area_id = area_id self.target = ConfigLoader( ).dic_user['other_control']['default_monitor_roomid']
async def reconnect(roomid): ConfigLoader( ).dic_user['other_control']['default_monitor_roomid'] = roomid print('已经切换roomid') if connect.instance.danmuji is not None: connect.instance.danmuji.roomid = roomid await connect.instance.danmuji.terminate()
async def run(self): self.roomid = ConfigLoader( ).dic_user['other_control']['raffle_minitor_roomid'] if not self.roomid: return self.danmuji = danmu.YjMonitorHandler(self.roomid, self.areaid) while True: printer.info(['正在启动Yj监控弹幕姬'], True) time_start = int(utils.CurrentTime()) connect_results = await self.danmuji.start() if not connect_results: continue task_main = asyncio.ensure_future(self.danmuji.handle_msg()) task_heartbeat = asyncio.ensure_future(self.danmuji.heart_beat()) tasks = [task_main, task_heartbeat] finished, pending = await asyncio.wait( tasks, return_when=asyncio.FIRST_COMPLETED) printer.info(['Yj弹幕姬异常或主动断开,正在处理剩余信息'], True) time_end = int(utils.CurrentTime()) if not task_heartbeat.done(): task_heartbeat.cancel() task_terminate = asyncio.ensure_future(self.danmuji.terminate()) await asyncio.wait(pending) await asyncio.wait([task_terminate]) printer.info(['Yj弹幕姬退出,剩余任务处理完毕'], True) if time_end - time_start < 5: printer.info(['当前网络不稳定,为避免频繁不必要尝试,将自动在5秒后重试'], True) await asyncio.sleep(5)
async def doublegain_coin2silver(): if ConfigLoader().dic_user['task_control']['doublegain_coin2silver']: json_response0 = await OnlineNet().req('request_doublegain_coin2silver' ) json_response1 = await OnlineNet().req('request_doublegain_coin2silver' ) print(json_response0['msg'], json_response1['msg']) BiliTimer.call_after(doublegain_coin2silver, 21600)
async def connectServer(self): try: reader, writer = await asyncio.open_connection( ConfigLoader().dic_bilibili['_ChatHost'], ConfigLoader().dic_bilibili['_ChatPort']) except: print("# 连接无法建立,请检查本地网络状况") return False self._reader = reader self._writer = writer if (await self.SendJoinChannel(ConfigLoader().dic_user['other_control'] ['default_monitor_roomid'])): self.connected = True Printer().printlist_append( ['join_lottery', '', 'user', '连接弹幕服务器成功'], True) # await self.ReceiveMessageLoop() return True
async def req_fetch_case(self): url = 'http://api.bilibili.com/x/credit/jury/caseObtain' payload = { "jsonp": "jsonp", "csrf": ConfigLoader().dic_bilibili['csrf'] } json_rsp = await self.other_session_post(url, headers=self.dic_bilibili['pcheaders'], data=payload) return json_rsp
def __init__(self, roomid=None, area_id=None): self.client = aiohttp.ClientSession() if roomid is None: self.roomid = ConfigLoader( ).dic_user['other_control']['default_monitor_roomid'] self.area_id = 0 else: self.roomid = roomid self.area_id = area_id
def RefreshToken(): # return response = bilibili.request_refresh_token() json_response = response.json() # print(json_response) if not json_response['code'] and json_response['data'].get('mid', ''): print('token刷新成功') dic_saved_session = { 'access_key': json_response['data']['access_token'], 'refresh_token': json_response['data']['refresh_token'] } bilibili.load_session(dic_saved_session) if ConfigLoader().dic_user['other_control']['keep-login']: ConfigLoader().write2bilibili(dic_saved_session) # 更新token信息 return True print('联系作者(token刷新失败,cookie过期)', json_response) return False
async def getRecommend(): async def fetch_room(url): roomidlist = [] should_stop = False for x in range(1, 250): if not (x % 10): print(f'截止第{x}页,获取了{len(roomidlist)}个房间(可能重复)') json_data = await bilibili().get_roomids(url, x) if not json_data['data']: break for room in json_data['data']: if room['online'] <= 100: pass should_stop = True print(room) break roomidlist.append(room['roomid']) if should_stop: print(f'截止第{x}页,获取了{len(roomidlist)}个房间(可能重复)') break print('去重之前', len(roomidlist)) unique_list = [] for id in roomidlist: if id not in unique_list: unique_list.append(id) return unique_list urls = [ 'http://api.live.bilibili.com/area/liveList?area=all&order=online&page=', 'http://api.live.bilibili.com/room/v1/room/get_user_recommend?page=', ] roomlist0 = await fetch_room(urls[0]) roomlist1 = await fetch_room(urls[1]) len_0 = len(roomlist0) len_1 = len(roomlist1) print('两种获取热度房间的方法获得房间数目', len_0, len_1) unique_list = [] for i, j in zip_longest(roomlist0, roomlist1): if i is not None and i not in unique_list: unique_list.append(i) if j is not None and j not in unique_list: unique_list.append(j) print(f'总获取房间{len(unique_list)}') roomid_conf = ConfigLoader().list_roomid for i in roomid_conf: if i not in unique_list: unique_list.append(i) if len(unique_list) == 6000: break print(f'总获取房间{len(unique_list)}') return unique_list + [0] * (6000 - len(unique_list))
async def HeartbeatLoop(self): Printer().printlist_append([ 'join_lottery', '', 'user', '弹幕模块开始心跳(由于弹幕心跳间隔为30s,所以后续正常心跳不再提示)' ], True) while self.connected: await self.SendSocketData( 0, 16, ConfigLoader().dic_bilibili['_protocolversion'], 2, 1, "") await asyncio.sleep(30)
def init_config(self): configs = ConfigLoader() self.dic_color = configs.dic_color self.dic_user = configs.dic_user self.dic_title = configs.dic_title if (sys.platform == 'ios'): self.danmu_print = self.concole_print else: self.danmu_print = self.normal_print self.danmu_control = self.dic_user['print_control']['danmu']
async def thx_danmu(msg, roomid=None): loop = asyncio.get_event_loop() if roomid is None: roomid = ConfigLoader().dic_user['other_control']['gift_monitor_roomid'] if len(str(roomid)) < 6: real_roomid = await check_room(roomid) else: real_roomid = roomid asyncio.run_coroutine_threadsafe(bilibili.request_send_danmu_msg_web(msg, real_roomid), loop)
def main(): action_loader.load_actions() global_env = {} global_env.update(action_loader.get_all_action_map()) if option.config_file: print("using config file: " + option.config_file) config_loader = ConfigLoader(option.config_file) config_loader.apply_config_to_klass(action_loader.get_all_action_map()) for target in option.targets: try: print "" print "[running]", target scenario = scenario_loader.load_file(target) scenario.run(global_env) except ActionException as e: print "--------------------------" print(e.stack_trace) print(e.original) print "--------------------------"
Autor: PABLO PIZARRO @ github.com/ppizarror Fecha: OCTUBRE 2015 - 2016 Licencia: GPLv2 """ __author__ = "ppizarror" # Importación de librerías iniciales from binpath import DIR_BIN, sys from configloader import ConfigLoader from _version import __version__ import binpath import errors # Configuración de entorno # noinspection PyProtectedMember __binconfig = ConfigLoader(binpath._DIR_CONFIG, "bin.ini") # noinspection PyUnresolvedReferences sys.setdefaultencoding(__binconfig.get_value("SET_DEFAULT_ENCODING")) # @UndefinedVariable # noinspection SpellCheckingInspection if __binconfig.is_true("DONT_WRITE_BYTECODE"): reload(sys) sys.dont_write_bytecode = True # Module test if __name__ == '__main__': try: import mechanize except: errors.throw(errors.ERROR_IMPORTERRORMECHANIZE) try: from hashdir import md5file, path_checksum
Licencia: GPLv2 """ __author__ = "ppizarror" # Importación de librerías y obtención de directorios from binpath import _LANG_DIRCONFIG, _LANG_DIRLANGS, _DIR_CONFIG from configloader import ConfigLoader from utils import google_translate import errors import math # noinspection PyProtectedMember # Se cargan las configuraciones langselfconfig = ConfigLoader(_DIR_CONFIG, "Langs.ini") # noinspection SpellCheckingInspection langconfig = ConfigLoader(_LANG_DIRCONFIG, "const.ini") langavaiable = ConfigLoader(_LANG_DIRCONFIG, "Langs.txt") # noinspection SpellCheckingInspection langtranslateconfig = ConfigLoader(_DIR_CONFIG, "langstransl.ini") # Constantes del programa _SPACE = "|" _SPLITTER = str(langconfig.get_value(1)).replace("*", " ") LANG_LOADED = "El archivo de idiomas '{0}' ha sido cargado correctamente" LANG_PRINT_ELEMENT = "\t{0}{1}=> {2}" LANG_PRINT_TITLE = "Entradas:\n\tID STRING" NULL_IDENTIFIER = "NULL_LANG_ID<" NULL_LANG = NULL_IDENTIFIER + "{0}>" # Definición de funciones
(r, g, b) = map(lambda f: int(255.0 * f), colorsys.hsv_to_rgb(h, 1.0, 1.0)) pygame.draw.circle(ts, (r, g, b), (x, y), 1, 0) n += 1 tlx, tly = fixture.position angle = float(fixture.angle) scale = float(fixture.scale) positions[fixture.id] = [tlx, tly, angle, scale] render_surfaces[fixture.id] = ts colorshift += 0.0075 if __name__ == '__main__': loader = ConfigLoader('test_surface.json') config = loader.load() if config is None: print "Exiting..." sys.exit(1) (width, height) = config.surfaces[0].dimensions pygame.init() size = width, height screen = pygame.display.set_mode(size) pygame.event.set_allowed([QUIT, KEYDOWN, USEREVENT])