Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file added .jules/bolt.md
Empty file.
199 changes: 74 additions & 125 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@
error_window_size = 10
error_threshold = 5
monitoring = 0
running_list = []
running_list = set()
url_tuples_list = []
url_comments = []
url_comments = set()
text_no_repeat_url = []
create_var = locals()
first_start = True
Expand All @@ -71,6 +71,44 @@
backup_dir = f'{script_path}/backup_config'
text_encoding = 'utf-8-sig'
rstr = r"[\/\\\:\*\??\"\<\>\|&#.。,, ~!· ]"
rstr_re = re.compile(rstr)
url_pattern = re.compile(r"(https?://)?(www\.)?[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+(:\d+)?(/.*)?")

platform_host = [
'live.douyin.com', 'v.douyin.com', 'www.douyin.com', 'live.kuaishou.com',
'www.huya.com', 'www.douyu.com', 'www.yy.com', 'live.bilibili.com',
'www.redelight.cn', 'www.xiaohongshu.com', 'xhslink.com', 'www.bigo.tv',
'slink.bigovideo.tv', 'app.blued.cn', 'cc.163.com', 'qiandurebo.com',
'fm.missevan.com', 'look.163.com', 'twitcasting.tv', 'live.baidu.com',
'weibo.com', 'fanxing.kugou.com', 'fanxing2.kugou.com', 'mfanxing.kugou.com',
'www.huajiao.com', 'www.7u66.com', 'wap.7u66.com', 'live.acfun.cn',
'm.acfun.cn', 'live.tlclw.com', 'wap.tlclw.com', 'live.ybw1666.com',
'wap.ybw1666.com', 'www.inke.cn', 'www.zhihu.com', 'www.haixiutv.com',
"h5webcdnp.vvxqiu.com", "17.live", 'www.lang.live', "m.pp.weimipopo.com",
"v.6.cn", "m.6.cn", 'www.lehaitv.com', 'h.catshow168.com', 'e.tb.cn',
'huodong.m.taobao.com', '3.cn', 'eco.m.jd.com', 'www.miguvideo.com',
'm.miguvideo.com', 'show.lailianjie.com', 'www.imkktv.com', 'www.picarto.tv'
]
overseas_platform_host = [
'www.tiktok.com', 'play.sooplive.co.kr', 'm.sooplive.co.kr',
'www.sooplive.com', 'm.sooplive.com', 'www.pandalive.co.kr',
'www.winktv.co.kr', 'www.flextv.co.kr', 'www.ttinglive.com',
'www.popkontv.com', 'www.twitch.tv', 'www.liveme.com',
'www.showroom-live.com', 'chzzk.naver.com', 'm.chzzk.naver.com',
'live.shopee.', '.shp.ee', 'www.youtube.com', 'youtu.be', 'www.faceit.com'
]
all_platform_hosts = set(platform_host + overseas_platform_host)
clean_url_host_list = {
"live.douyin.com", "live.bilibili.com", "www.huajiao.com", "www.zhihu.com",
"www.huya.com", "chzzk.naver.com", "www.liveme.com", "www.haixiutv.com",
"v.6.cn", "m.6.cn", 'www.lehaitv.com'
}


def contains_url(string: str) -> bool:
return url_pattern.search(string) is not None


default_path = f'{script_path}/downloads'
os.makedirs(default_path, exist_ok=True)
file_update_lock = threading.Lock()
Expand Down Expand Up @@ -377,8 +415,8 @@ def clear_record_info(record_name: str, record_url: str) -> None:
global monitoring
recording.discard(record_name)
if record_url in url_comments and record_url in running_list:
running_list.remove(record_url)
monitoring -= 1
running_list.discard(record_url)
monitoring = len(running_list)
color_obj.print_colored(f"[{record_name}]已经从录制列表中移除\n", color_obj.YELLOW)


Expand Down Expand Up @@ -492,7 +530,7 @@ def check_subprocess(record_name: str, record_url: str, ffmpeg_command: list, sa


def clean_name(input_text):
cleaned_name = re.sub(rstr, "_", input_text.strip()).strip('_')
cleaned_name = rstr_re.sub("_", input_text.strip()).strip('_')
cleaned_name = cleaned_name.replace("(", "(").replace(")", ")")
if clean_emoji:
cleaned_name = utils.remove_emojis(cleaned_name, '_').strip('_')
Expand Down Expand Up @@ -1939,34 +1977,32 @@ def read_config_value(config_parser: configparser.RawConfigParser, section: str,
sys.exit(-1)


def contains_url(string: str) -> bool:
pattern = r"(https?://)?(www\.)?[a-zA-Z0-9-]+(\.[a-zA-Z0-9-]+)+(:\d+)?(/.*)?"
return re.search(pattern, string) is not None


try:
url_comments, line_list, url_line_list = [[] for _ in range(3)]
url_comments.clear()
line_list, url_line_list = [], set()
line_set = set()
file_changed = False
with (open(url_config_file, "r", encoding=text_encoding, errors='ignore') as file):
for origin_line in file:
if origin_line in line_list:
delete_line(url_config_file, origin_line)
if origin_line in line_set:
file_changed = True
continue
line_list.append(origin_line)
line_set.add(origin_line)
line = origin_line.strip()
if len(line) < 18:
continue

line_spilt = line.split('主播: ')
if len(line_spilt) > 2:
line = update_file(url_config_file, line, f'{line_spilt[0]}主播: {line_spilt[-1]}')
line = f'{line_spilt[0]}主播: {line_spilt[-1]}'
file_changed = True

is_comment_line = line.startswith("#")
if is_comment_line:
line = line.lstrip('#')

if re.search('[,,]', line):
split_line = re.split('[,,]', line)
else:
split_line = [line, '']
split_line = re.split('[,,]', line) if re.search('[,,]', line) else [line, '']

if len(split_line) == 1:
url = split_line[0]
Expand All @@ -1984,130 +2020,44 @@ def contains_url(string: str) -> bool:
if quality not in ("原画", "蓝光", "超清", "高清", "标清", "流畅"):
quality = '原画'

if url not in url_line_list:
url_line_list.append(url)
else:
delete_line(url_config_file, origin_line)
if url in url_line_list:
file_changed = True
continue
url_line_list.add(url)

url = 'https://' + url if '://' not in url else url
url_host = url.split('/')[2]

platform_host = [
'live.douyin.com',
'v.douyin.com',
'www.douyin.com',
'live.kuaishou.com',
'www.huya.com',
'www.douyu.com',
'www.yy.com',
'live.bilibili.com',
'www.redelight.cn',
'www.xiaohongshu.com',
'xhslink.com',
'www.bigo.tv',
'slink.bigovideo.tv',
'app.blued.cn',
'cc.163.com',
'qiandurebo.com',
'fm.missevan.com',
'look.163.com',
'twitcasting.tv',
'live.baidu.com',
'weibo.com',
'fanxing.kugou.com',
'fanxing2.kugou.com',
'mfanxing.kugou.com',
'www.huajiao.com',
'www.7u66.com',
'wap.7u66.com',
'live.acfun.cn',
'm.acfun.cn',
'live.tlclw.com',
'wap.tlclw.com',
'live.ybw1666.com',
'wap.ybw1666.com',
'www.inke.cn',
'www.zhihu.com',
'www.haixiutv.com',
"h5webcdnp.vvxqiu.com",
"17.live",
'www.lang.live',
"m.pp.weimipopo.com",
"v.6.cn",
"m.6.cn",
'www.lehaitv.com',
'h.catshow168.com',
'e.tb.cn',
'huodong.m.taobao.com',
'3.cn',
'eco.m.jd.com',
'www.miguvideo.com',
'm.miguvideo.com',
'show.lailianjie.com',
'www.imkktv.com',
'www.picarto.tv'
]
overseas_platform_host = [
'www.tiktok.com',
'play.sooplive.co.kr',
'm.sooplive.co.kr',
'www.sooplive.com',
'm.sooplive.com',
'www.pandalive.co.kr',
'www.winktv.co.kr',
'www.flextv.co.kr',
'www.ttinglive.com',
'www.popkontv.com',
'www.twitch.tv',
'www.liveme.com',
'www.showroom-live.com',
'chzzk.naver.com',
'm.chzzk.naver.com',
'live.shopee.',
'.shp.ee',
'www.youtube.com',
'youtu.be',
'www.faceit.com'
]

platform_host.extend(overseas_platform_host)
clean_url_host_list = (
"live.douyin.com",
"live.bilibili.com",
"www.huajiao.com",
"www.zhihu.com",
"www.huya.com",
"chzzk.naver.com",
"www.liveme.com",
"www.haixiutv.com",
"v.6.cn",
"m.6.cn",
'www.lehaitv.com'
)

if 'live.shopee.' in url_host or '.shp.ee' in url_host:
url_host = 'live.shopee.' if 'live.shopee.' in url_host else '.shp.ee'

if url_host in platform_host or any(ext in url for ext in (".flv", ".m3u8")):
if url_host in all_platform_hosts or any(ext in url for ext in (".flv", ".m3u8")):
new_url = url
if url_host in clean_url_host_list:
url = update_file(url_config_file, old_str=url, new_str=url.split('?')[0])
new_url = url.split('?')[0]

if 'xiaohongshu' in url:
host_id = re.search('&host_id=(.*?)(?=&|$)', url)
if host_id:
new_url = url.split('?')[0] + f'?host_id={host_id.group(1)}'
url = update_file(url_config_file, old_str=url, new_str=new_url)

url_comments = [i for i in url_comments if url not in i]
if new_url != url:
url = new_url
file_changed = True

if is_comment_line:
url_comments.append(url)
url_comments.add(url)
else:
new_line = (quality, url, name)
url_tuples_list.append(new_line)
else:
if not origin_line.startswith('#'):
color_obj.print_colored(f"\r{origin_line.strip()} 本行包含未知链接.此条跳过", color_obj.YELLOW)
update_file(url_config_file, old_str=origin_line, new_str=origin_line, start_str='#')
file_changed = True

if file_changed:
with open(url_config_file, "w", encoding=text_encoding) as f:
f.write(''.join(line_list))

while len(need_update_line_list):
a = need_update_line_list.pop()
Expand All @@ -2125,19 +2075,18 @@ def contains_url(string: str) -> bool:

if len(text_no_repeat_url) > 0:
for url_tuple in text_no_repeat_url:
monitoring = len(running_list)

if url_tuple[1] in not_record_list:
continue

if url_tuple[1] not in running_list:
monitoring = len(running_list) + 1
print(f"\r{'新增' if not first_start else '传入'}地址: {url_tuple[1]}")
monitoring += 1
args = [url_tuple, monitoring]
create_var[f'thread_{monitoring}'] = threading.Thread(target=start_record, args=args)
create_var[f'thread_{monitoring}'].daemon = True
create_var[f'thread_{monitoring}'].start()
running_list.append(url_tuple[1])
running_list.add(url_tuple[1])
monitoring = len(running_list)
time.sleep(local_delay_default)
url_tuples_list = []
first_start = False
Expand Down
29 changes: 15 additions & 14 deletions src/ab_sign.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,21 +209,22 @@ def sum(self, data=None, output_format=None):
return result


def result_encrypt(long_str: str, num: str | None = None) -> str:
# 魔改base64编码表
encoding_tables = {
"s0": "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
"s1": "Dkdpgh4ZKsQB80/Mfvw36XI1R25+WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=",
"s2": "Dkdpgh4ZKsQB80/Mfvw36XI1R25-WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=",
"s3": "ckdp1h4ZKsUB80/Mfvw36XIgR25+WQAlEi7NLboqYTOPuzmFjJnryx9HVGDaStCe",
"s4": "Dkdpgh2ZmsQB80/MfvV36XI1R45-WUAlEixNLwoqYTOPuzKFjJnry79HbGcaStCe"
}
# 魔改base64编码表
ENCODING_TABLES = {
"s0": "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",
"s1": "Dkdpgh4ZKsQB80/Mfvw36XI1R25+WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=",
"s2": "Dkdpgh4ZKsQB80/Mfvw36XI1R25-WUAlEi7NLboqYTOPuzmFjJnryx9HVGcaStCe=",
"s3": "ckdp1h4ZKsUB80/Mfvw36XIgR25+WQAlEi7NLboqYTOPuzmFjJnryx9HVGDaStCe",
"s4": "Dkdpgh2ZmsQB80/MfvV36XI1R45-WUAlEixNLwoqYTOPuzKFjJnry79HbGcaStCe"
}

# 位移常量
masks = [16515072, 258048, 4032, 63] # 对应 0, 1, 2 的掩码,添加63作为第四个掩码
shifts = [18, 12, 6, 0] # 对应的位移量
# 位移常量
MASKS = [16515072, 258048, 4032, 63] # 对应 0, 1, 2 的掩码,添加63作为第四个掩码
SHIFTS = [18, 12, 6, 0] # 对应的位移量

encoding_table = encoding_tables[num]

def result_encrypt(long_str: str, num: str | None = None) -> str:
encoding_table = ENCODING_TABLES[num]

result = ""
round_num = 0
Expand All @@ -241,7 +242,7 @@ def result_encrypt(long_str: str, num: str | None = None) -> str:
index = i % 4

# 使用掩码和位移提取6位值
char_index = (long_int & masks[index]) >> shifts[index]
char_index = (long_int & MASKS[index]) >> SHIFTS[index]

result += encoding_table[char_index]

Expand Down
40 changes: 21 additions & 19 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@
OptionalStr = str | None
OptionalDict = dict | None

EMOJI_PATTERN = re.compile(
"["
"\U0001F1E0-\U0001F1FF" # flags (iOS)
"\U0001F300-\U0001F5FF" # symbols & pictographs
"\U0001F600-\U0001F64F" # emoticons
"\U0001F680-\U0001F6FF" # transport & map symbols
"\U0001F700-\U0001F77F" # alchemical symbols
"\U0001F780-\U0001F7FF" # Geometric Shapes Extended
"\U0001F800-\U0001F8FF" # Supplemental Arrows-C
"\U0001F900-\U0001F9FF" # Supplemental Symbols and Pictographs
"\U0001FA00-\U0001FA6F" # Chess Symbols
"\U0001FA70-\U0001FAFF" # Symbols and Pictographs Extended-A
"\U00002702-\U000027B0" # Dingbats
"]+",
flags=re.UNICODE
)

JSONP_PATTERN = re.compile(r'(\w+)\((.*)\);?$')


class Color:
RED = "\033[31m"
Expand Down Expand Up @@ -116,23 +135,7 @@ def get_file_paths(directory: str) -> list:


def remove_emojis(text: str, replace_text: str = '') -> str:
emoji_pattern = re.compile(
"["
"\U0001F1E0-\U0001F1FF" # flags (iOS)
"\U0001F300-\U0001F5FF" # symbols & pictographs
"\U0001F600-\U0001F64F" # emoticons
"\U0001F680-\U0001F6FF" # transport & map symbols
"\U0001F700-\U0001F77F" # alchemical symbols
"\U0001F780-\U0001F7FF" # Geometric Shapes Extended
"\U0001F800-\U0001F8FF" # Supplemental Arrows-C
"\U0001F900-\U0001F9FF" # Supplemental Symbols and Pictographs
"\U0001FA00-\U0001FA6F" # Chess Symbols
"\U0001FA70-\U0001FAFF" # Symbols and Pictographs Extended-A
"\U00002702-\U000027B0" # Dingbats
"]+",
flags=re.UNICODE
)
return emoji_pattern.sub(replace_text, text)
return EMOJI_PATTERN.sub(replace_text, text)


def remove_duplicate_lines(file_path: str | Path) -> None:
Expand Down Expand Up @@ -175,8 +178,7 @@ def generate_random_string(length: int) -> str:


def jsonp_to_json(jsonp_str: str) -> OptionalDict:
pattern = r'(\w+)\((.*)\);?$'
match = re.search(pattern, jsonp_str)
match = JSONP_PATTERN.search(jsonp_str)

if match:
_, json_str = match.groups()
Expand Down