mirror of
https://github.com/ihmily/DouyinLiveRecorder.git
synced 2025-12-26 05:48:32 +08:00
feat: add twitcasting account login type
This commit is contained in:
parent
2df399b79c
commit
32d17e635c
@ -70,5 +70,6 @@ flextv密码 =
|
||||
popkontv账号 =
|
||||
partner_code = P-00001
|
||||
popkontv密码 =
|
||||
twitcasting账号类型 = normal
|
||||
twitcasting账号 =
|
||||
twitcasting密码 =
|
||||
6
main.py
6
main.py
@ -359,7 +359,7 @@ def get_tiktok_stream_url(json_data: dict, video_quality: str) -> Dict[str, Any]
|
||||
result['flv_url'] = flv_url_list[quality_index]['url']
|
||||
result['m3u8_url'] = m3u8_url_list[quality_index]['url']
|
||||
result['is_live'] = True
|
||||
result['record_url'] = flv_url_list[quality_index]['url']
|
||||
result['record_url'] = flv_url_list[quality_index]['url'].replace("https://", "http://")
|
||||
return result
|
||||
|
||||
|
||||
@ -1012,6 +1012,7 @@ def start_record(url_data: tuple, count_variable: int = -1):
|
||||
url=record_url,
|
||||
proxy_addr=proxy_address,
|
||||
cookies=twitcasting_cookie,
|
||||
account_type=twitcasting_account_type,
|
||||
username=twitcasting_username,
|
||||
password=twitcasting_password
|
||||
)
|
||||
@ -1756,6 +1757,7 @@ while True:
|
||||
popkontv_username = read_config_value(config, '账号密码', 'popkontv账号', '')
|
||||
popkontv_partner_code = read_config_value(config, '账号密码', 'partner_code', 'P-00001')
|
||||
popkontv_password = read_config_value(config, '账号密码', 'popkontv密码', '')
|
||||
twitcasting_account_type = read_config_value(config, '账号密码', 'twitcasting账号类型', 'normal')
|
||||
twitcasting_username = read_config_value(config, '账号密码', 'twitcasting账号', '')
|
||||
twitcasting_password = read_config_value(config, '账号密码', 'twitcasting密码', '')
|
||||
popkontv_access_token = read_config_value(config, 'Authorization', 'popkontv_token', '')
|
||||
@ -1955,4 +1957,4 @@ while True:
|
||||
|
||||
first_run = False
|
||||
|
||||
time.sleep(3)
|
||||
time.sleep(3)
|
||||
16
spider.py
16
spider.py
@ -1468,7 +1468,7 @@ def get_popkontv_stream_url(
|
||||
|
||||
@trace_error_decorator
|
||||
def login_twitcasting(
|
||||
username: str, password: str, proxy_addr: Union[str, None] = None, cookies: Union[str, None] = None
|
||||
account_type: str, username: str, password: str, proxy_addr: Union[str, None] = None, cookies: Union[str, None] = None
|
||||
) -> Union[str, None]:
|
||||
headers = {
|
||||
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
|
||||
@ -1482,7 +1482,13 @@ def login_twitcasting(
|
||||
if cookies:
|
||||
headers['Cookie'] = cookies
|
||||
|
||||
login_url = 'https://twitcasting.tv/indexcaslogin.php?redir=%2F&keep=1'
|
||||
if account_type == "normal":
|
||||
login_url = 'https://twitcasting.tv/indexcaslogin.php?redir=%2F&keep=1'
|
||||
login_api = 'https://twitcasting.tv/indexcaslogin.php?redir=/indexloginwindow.php?next=%2F&keep=1'
|
||||
else:
|
||||
login_url = 'https://twitcasting.tv/indexpasswordlogin.php'
|
||||
login_api = 'https://twitcasting.tv/indexpasswordlogin.php?redir=/indexloginwindow.php?next=%2F&keep=1'
|
||||
|
||||
html_str = get_req(login_url, proxy_addr=proxy_addr, headers=headers)
|
||||
cs_session_id = re.search('<input type="hidden" name="cs_session_id" value="(.*?)">', html_str).group(1)
|
||||
|
||||
@ -1492,9 +1498,6 @@ def login_twitcasting(
|
||||
'action': 'login',
|
||||
'cs_session_id': cs_session_id,
|
||||
}
|
||||
|
||||
login_api = 'https://twitcasting.tv/indexcaslogin.php?redir=/indexloginwindow.php?next=%2F&keep=1'
|
||||
|
||||
try:
|
||||
if proxy_addr:
|
||||
proxies = {
|
||||
@ -1524,6 +1527,7 @@ def get_twitcasting_stream_url(
|
||||
url: str,
|
||||
proxy_addr: Union[str, None] = None,
|
||||
cookies: Union[str, None] = None,
|
||||
account_type: Union[str, None] = None,
|
||||
username: Union[str, None] = None,
|
||||
password: Union[str, None] = None,
|
||||
) -> Dict[str, Any]:
|
||||
@ -1552,7 +1556,7 @@ def get_twitcasting_stream_url(
|
||||
anchor_name, live_status = get_data(headers)
|
||||
except AttributeError:
|
||||
print('获取TwitCasting数据失败,正在尝试登录...')
|
||||
new_cookie = login_twitcasting(username=username, password=password, proxy_addr=proxy_addr, cookies=cookies)
|
||||
new_cookie = login_twitcasting(account_type=account_type, username=username, password=password, proxy_addr=proxy_addr, cookies=cookies)
|
||||
if not new_cookie:
|
||||
raise RuntimeError('TwitCasting登录失败,请检查配置文件中的账号密码是否正确')
|
||||
print('TwitCasting 登录成功!开始获取数据...')
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user