コード例 #1
0
ファイル: user.py プロジェクト: k471559444/bili2.0-1
    def __init__(
            self, dict_user: dict, task_ctrl: dict, task_arrangement: dict, dict_bili: dict, force_sleep: callable):
        self.id = next(self._ids)
        self.force_sleep = force_sleep
        self.name = dict_user['username']
        self.password = dict_user['password']
        self.alias = dict_user.get('alias', self.name)
        self.task_ctrl = task_ctrl
        self.task_arrangement = task_arrangement
        self.is_log_in = True  # 登陆状态,cookie、token有效性
        self.is_in_jail = False  # 是否小黑屋

        self.bililive_session = WebSession()
        self.login_session = WebSession()
        self.other_session = WebSession()

        # 每个user里面都分享了同一个dict,必须要隔离,否则更新cookie这些的时候会互相覆盖
        self.dict_bili = copy.deepcopy(dict_bili)
        self.app_params = f'actionKey={dict_bili["actionKey"]}&' \
            f'appkey={dict_bili["appkey"]}&build={dict_bili["build"]}&' \
            f'device={dict_bili["device"]}&mobi_app={dict_bili["mobi_app"]}&' \
            f'platform={dict_bili["platform"]}'
        self.update_login_data(dict_user)
        self.list_delay = []
        self.repost_del_lock = asyncio.Lock()  # 在follow与unfollow过程中必须保证安全(repost和del整个过程加锁)
        dyn_lottery_friends = [(str(uid), name) for uid, name in task_ctrl['dyn_lottery_friends'].items()]
        self.dyn_lottery_friends = dyn_lottery_friends  # list (uid, name)
        self.storm_lock = asyncio.Semaphore(1)  # 用于控制同时进行的风暴数目(注意是单个用户的)
        self.recording_tasks = {}
コード例 #2
0
 def __init__(self, dict_user: dict, task_ctrl: dict,
              task_arrangement: dict, dict_bili: dict,
              force_sleep: Callable):
     self.id = dict_user['id']
     self.force_sleep = force_sleep
     self.name = dict_user['username']
     self.password = dict_user['password']
     self.alias = dict_user.get('alias', self.name)
     self.task_ctrl = task_ctrl
     self.task_arrangement = task_arrangement
     self.is_in_jail = False  # 是否小黑屋
     self.bililive_session = WebSession()
     self.login_session = WebSession()
     self.other_session = WebSession()
     # 每个user里面都分享了同一个dict,必须要隔离,否则更新cookie这些的时候会互相覆盖
     self.pc = PcPlatform(dict_bili['pc_headers'].copy())
     self.app = AppPlatform(dict_bili['app_headers'].copy(),
                            dict_bili['app_params'])
     self.tv = TvPlatform(dict_bili['tv_headers'].copy(),
                          dict_bili['tv_params'])
     self.dict_user = dict_user
     self.update_login_data(dict_user)
     self._waiting_login = None
     self._loop = asyncio.get_event_loop()
     self.repost_del_lock = asyncio.Lock(
     )  # 在follow与unfollow过程中必须保证安全(repost和del整个过程加锁)
     dyn_lottery_friends = [
         (str(uid), name)
         for uid, name in task_ctrl['dyn_lottery_friends'].items()
     ]
     self.dyn_lottery_friends = dyn_lottery_friends  # list (uid, name)
コード例 #3
0
    def __init__(self, dict_user: dict, task_ctrl: dict,
                 task_arrangement: dict, dict_bili: dict,
                 force_sleep: Callable):
        self.id = next(self._ids)
        self.force_sleep = force_sleep
        self.name = dict_user['username']
        self.password = dict_user['password']
        self.alias = dict_user.get('alias', self.name)
        self.manage_room = dict_user['manage_room']
        self.alerts = dict_user['alerts']
        self.gift_comb_delay = dict_user['gift_comb_delay']
        self.alert_second = dict_user['alert_second']
        self.gift_thx_format = dict_user['gift_thx_format']
        self.focus_thx_format = dict_user['focus_thx_format']
        self.danmu_length = dict_user.get('danmu_length', 30)
        self.medal_update_format = dict_user.get('medal_update_format', '')
        self.medal_update_check_delay = dict_user.get(
            'medal_update_check_delay', 30)
        self.random_list_1 = dict_user.get('random_list_1', [])
        self.random_list_2 = dict_user.get('random_list_2', [])
        self.random_list_3 = dict_user.get('random_list_3', [])
        if len(self.random_list_1) == 0:
            self.random_list_1 = [""]
        if len(self.random_list_2) == 0:
            self.random_list_2 = [""]
        if len(self.random_list_3) == 0:
            self.random_list_3 = [""]

        self.task_ctrl = task_ctrl
        self.task_arrangement = task_arrangement
        self.is_in_jail = False  # 是否小黑屋

        self.bililive_session = WebSession()
        self.login_session = WebSession()
        self.other_session = WebSession()

        # 每个user里面都分享了同一个dict,必须要隔离,否则更新cookie这些的时候会互相覆盖
        self.dict_bili = copy.deepcopy(dict_bili)
        self.app_params = {
            'actionKey': dict_bili['actionKey'],
            'appkey': dict_bili['appkey'],
            'build': dict_bili['build'],
            'device': dict_bili['device'],
            'mobi_app': dict_bili['mobi_app'],
            'platform': dict_bili['platform'],
        }
        self.update_login_data(dict_user)

        self._waiting_login = None
        self._loop = asyncio.get_event_loop()

        self.repost_del_lock = asyncio.Lock(
        )  # 在follow与unfollow过程中必须保证安全(repost和del整个过程加锁)
        dyn_lottery_friends = [
            (str(uid), name)
            for uid, name in task_ctrl['dyn_lottery_friends'].items()
        ]
        self.dyn_lottery_friends = dyn_lottery_friends  # list (uid, name)
        self.storm_lock = asyncio.Semaphore(1)  # 用于控制同时进行的风暴数目(注意是单个用户的)
コード例 #4
0
ファイル: client.py プロジェクト: xx0746/geetest_test
    def __init__(self):
        dict_user = utils.get_1st_user('client_core/conf/user.toml')
        dict_bili = utils.get_dict_bili('client_core/conf/bili.toml')
        self.user = utils.new_user(dict_user, dict_bili)

        self.name = self.user.name
        self.password = self.user.password
        self.__web_session = WebSession()
コード例 #5
0
    def __init__(self, executable_path=None, no_selenium=False):
        if no_selenium:
            self.driver = None
        else:
            options = webdriver.ChromeOptions()
            options.add_argument("--log-level=3")
            options.add_argument("--window-size=350,560")

            self.driver = webdriver.Chrome(executable_path, options=options)
        self.session = WebSession()
コード例 #6
0
ファイル: user.py プロジェクト: vcfee/bili2.0
    def __init__(self, dict_user: dict, task_ctrl: dict,
                 task_arrangement: dict, dict_bili: dict, dict_bilitv: dict,
                 force_sleep: Callable):
        self.id = next(self._ids)
        self.force_sleep = force_sleep
        self.name = dict_user['username']
        self.password = dict_user['password']
        self.alias = dict_user.get('alias', self.name)
        self.task_ctrl = task_ctrl
        self.task_arrangement = task_arrangement
        self.is_in_jail = False  # 是否小黑屋

        self.bililive_session = WebSession()
        self.login_session = WebSession()
        self.other_session = WebSession()

        # 每个user里面都分享了同一个dict,必须要隔离,否则更新cookie这些的时候会互相覆盖
        self.dict_bili = copy.deepcopy(dict_bili)
        self.dict_bilitv = copy.deepcopy(dict_bilitv)
        self.app_params = {
            'actionKey': dict_bili['actionKey'],
            'appkey': dict_bili['appkey'],
            'build': dict_bili['build'],
            'device': dict_bili['device'],
            'mobi_app': dict_bili['mobi_app'],
            'platform': dict_bili['platform'],
        }
        self.update_login_data(dict_user)

        self._waiting_login = None
        self._loop = asyncio.get_event_loop()

        self.repost_del_lock = asyncio.Lock(
        )  # 在follow与unfollow过程中必须保证安全(repost和del整个过程加锁)
        dyn_lottery_friends = [
            (str(uid), name)
            for uid, name in task_ctrl['dyn_lottery_friends'].items()
        ]
        self.dyn_lottery_friends = dyn_lottery_friends  # list (uid, name)
コード例 #7
0
    def __init__(self, dict_user: dict, dict_bili: dict):
        self.id = next(self._ids)
        self.name = dict_user['username']
        self.password = dict_user['password']
        self.alias = dict_user.get('alias', self.name)

        self.bililive_session = WebSession()
        self.login_session = WebSession()
        self.other_session = WebSession()

        # 每个user里面都分享了同一个dict,必须要隔离,否则更新cookie这些的时候会互相覆盖
        self.dict_bili = copy.deepcopy(dict_bili)
        self.app_params = [
            f'actionKey={dict_bili["actionKey"]}',
            f'appkey={dict_bili["appkey"]}',
            f'build={dict_bili["build"]}',
            f'device={dict_bili["device"]}',
            f'mobi_app={dict_bili["mobi_app"]}',
            f'platform={dict_bili["platform"]}',
        ]
        self.update_login_data(dict_user)

        self._waiting_login = None
        self._loop = asyncio.get_event_loop()
コード例 #8
0
ファイル: user.py プロジェクト: zsnmwy/bili2.0
 def other_session(self):
     if self._other_session is None:
         self._other_session = WebSession()
     return self._other_session
コード例 #9
0
ファイル: user.py プロジェクト: zsnmwy/bili2.0
 def login_session(self):
     if self._login_session is None:
         self._login_session = WebSession()
         # print('测试session')
     return self._login_session
コード例 #10
0
ファイル: user.py プロジェクト: zsnmwy/bili2.0
 def bililive_session(self):
     if self._bililive_session is None:
         self._bililive_session = WebSession()
     return self._bililive_session
コード例 #11
0
ファイル: client.py プロジェクト: xx0746/geetest_test
 def __init__(self, url):
     self.__web_session = WebSession()
     self.__url = url
コード例 #12
0
ファイル: user.py プロジェクト: lc4t/Bili-Live-Bot
    def __init__(self, dict_user: dict, task_ctrl: dict,
                 task_arrangement: dict, dict_bili: dict,
                 force_sleep: Callable):
        self.id = next(self._ids)
        self.force_sleep = force_sleep
        self.name = dict_user['username']
        self.password = dict_user['password']
        self.alias = dict_user.get('alias', self.name)
        self.task_ctrl = task_ctrl
        self.task_arrangement = task_arrangement
        self.is_in_jail = False  # 是否小黑屋
        ##
        self.manage_room = dict_user['manage_room']
        self.alerts = dict_user.get('alerts', [])
        self.gift_comb_delay = dict_user['gift_comb_delay']
        self.alert_second = dict_user['alert_second']
        self.gift_thx_format = dict_user.get(
            'gift_thx_format', '感谢{username}投喂的{giftname}x{num}')
        self.silver_gift_thx_format = dict_user.get('silver_gift_thx_format',
                                                    self.gift_thx_format)
        self.gold_gift_thx_format = dict_user.get('gold_gift_thx_format',
                                                  self.gift_thx_format)
        self.focus_thx_format = dict_user['focus_thx_format']
        self.guard_thx_format = dict_user.get('guard_thx_format',
                                              self.gift_thx_format)
        self.danmu_length = dict_user.get('danmu_length', 30)
        self.medal_update_format = dict_user.get('medal_update_format', '')
        self.medal_update_check_delay = dict_user.get(
            'medal_update_check_delay', 30)
        self.only_live_thx = dict_user.get('only_live_thx', False)
        self.only_live_alert = dict_user.get('only_live_alert', True)
        self.anchor_alert_format = dict_user.get('anchor_alert_format', '')
        self.reply = dict_user.get('reply', [])
        self.ban = dict_user.get('ban', [])
        self.height = dict_user.get('height', 0)
        self.weight = dict_user.get('weight', 0)
        self.disable_gift_thx = dict_user.get('disable_gift_thx', False)

        if dict_user.get('const_json'):
            self.const_json = json.load(open(dict_user.get('const_json'), 'r'))
        else:
            self.const_json = {}

        self.fans_check_delay = dict_user.get('fans_check_delay', 20)

        self.random_list_1 = dict_user.get('random_list_1', [])
        self.random_list_2 = dict_user.get('random_list_2', [])
        self.random_list_3 = dict_user.get('random_list_3', [])
        if len(self.random_list_1) == 0:
            self.random_list_1 = [""]
        if len(self.random_list_2) == 0:
            self.random_list_2 = [""]
        if len(self.random_list_3) == 0:
            self.random_list_3 = [""]
        ##
        self.bililive_session = WebSession()
        self.login_session = WebSession()
        self.other_session = WebSession()

        # 每个user里面都分享了同一个dict,必须要隔离,否则更新cookie这些的时候会互相覆盖
        self.pc = PcPlatform(dict_bili['pc_headers'].copy())
        self.app = AppPlatform(dict_bili['app_headers'].copy(),
                               dict_bili['app_params'])
        self.tv = TvPlatform(dict_bili['tv_headers'].copy(),
                             dict_bili['tv_params'])

        self.dict_user = dict_user

        self.update_login_data(dict_user)

        self._waiting_login = None
        self._loop = asyncio.get_event_loop()

        self.repost_del_lock = asyncio.Lock(
        )  # 在follow与unfollow过程中必须保证安全(repost和del整个过程加锁)
        dyn_lottery_friends = [
            (str(uid), name)
            for uid, name in task_ctrl['dyn_lottery_friends'].items()
        ]
        self.dyn_lottery_friends = dyn_lottery_friends  # list (uid, name)