mirror of
https://github.com/ihmily/DouyinLiveRecorder.git
synced 2026-03-22 07:28:24 +08:00
style: fix lint issues
This commit is contained in:
@@ -122,7 +122,7 @@ def install_ffmpeg_linux():
|
|||||||
logger.debug("Trying to install the stable version of ffmpeg")
|
logger.debug("Trying to install the stable version of ffmpeg")
|
||||||
result = subprocess.run(['yum', '-y', 'update'], capture_output=True)
|
result = subprocess.run(['yum', '-y', 'update'], capture_output=True)
|
||||||
if result.returncode != 0:
|
if result.returncode != 0:
|
||||||
logger.error(f"Failed to update package lists using yum.")
|
logger.error("Failed to update package lists using yum.")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
result = subprocess.run(['yum', 'install', '-y', 'ffmpeg'], capture_output=True)
|
result = subprocess.run(['yum', 'install', '-y', 'ffmpeg'], capture_output=True)
|
||||||
|
|||||||
16
main.py
16
main.py
@@ -4,7 +4,7 @@
|
|||||||
Author: Hmily
|
Author: Hmily
|
||||||
GitHub: https://github.com/ihmily
|
GitHub: https://github.com/ihmily
|
||||||
Date: 2023-07-17 23:52:05
|
Date: 2023-07-17 23:52:05
|
||||||
Update: 2025-02-08 19:19:00
|
Update: 2025-06-14 12:19:00
|
||||||
Copyright (c) 2023-2025 by Hmily, All Rights Reserved.
|
Copyright (c) 2023-2025 by Hmily, All Rights Reserved.
|
||||||
Function: Record live stream video.
|
Function: Record live stream video.
|
||||||
"""
|
"""
|
||||||
@@ -102,9 +102,9 @@ def display_info() -> None:
|
|||||||
if split_video_by_time:
|
if split_video_by_time:
|
||||||
print(f"录制分段开启: {split_time}秒", end=" | ")
|
print(f"录制分段开启: {split_time}秒", end=" | ")
|
||||||
else:
|
else:
|
||||||
print(f"录制分段开启: 否", end=" | ")
|
print("录制分段开启: 否", end=" | ")
|
||||||
if create_time_file:
|
if create_time_file:
|
||||||
print(f"是否生成时间文件: 是", end=" | ")
|
print("是否生成时间文件: 是", end=" | ")
|
||||||
print(f"录制视频质量为: {video_record_quality}", end=" | ")
|
print(f"录制视频质量为: {video_record_quality}", end=" | ")
|
||||||
print(f"录制视频格式为: {video_save_type}", end=" | ")
|
print(f"录制视频格式为: {video_save_type}", end=" | ")
|
||||||
print(f"目前瞬时错误数为: {error_count}", end=" | ")
|
print(f"目前瞬时错误数为: {error_count}", end=" | ")
|
||||||
@@ -220,7 +220,7 @@ def converts_mp4(converts_file_path: str, is_original_delete: bool = True) -> No
|
|||||||
try:
|
try:
|
||||||
if os.path.exists(converts_file_path) and os.path.getsize(converts_file_path) > 0:
|
if os.path.exists(converts_file_path) and os.path.getsize(converts_file_path) > 0:
|
||||||
if converts_to_h264:
|
if converts_to_h264:
|
||||||
color_obj.print_colored(f"正在转码为MP4格式并重新编码为h264\n", color_obj.YELLOW)
|
color_obj.print_colored("正在转码为MP4格式并重新编码为h264\n", color_obj.YELLOW)
|
||||||
ffmpeg_command = [
|
ffmpeg_command = [
|
||||||
"ffmpeg", "-i", converts_file_path,
|
"ffmpeg", "-i", converts_file_path,
|
||||||
"-c:v", "libx264",
|
"-c:v", "libx264",
|
||||||
@@ -231,7 +231,7 @@ def converts_mp4(converts_file_path: str, is_original_delete: bool = True) -> No
|
|||||||
"-f", "mp4", converts_file_path.rsplit('.', maxsplit=1)[0] + ".mp4",
|
"-f", "mp4", converts_file_path.rsplit('.', maxsplit=1)[0] + ".mp4",
|
||||||
]
|
]
|
||||||
else:
|
else:
|
||||||
color_obj.print_colored(f"正在转码为MP4格式\n", color_obj.YELLOW)
|
color_obj.print_colored("正在转码为MP4格式\n", color_obj.YELLOW)
|
||||||
ffmpeg_command = [
|
ffmpeg_command = [
|
||||||
"ffmpeg", "-i", converts_file_path,
|
"ffmpeg", "-i", converts_file_path,
|
||||||
"-c:v", "copy",
|
"-c:v", "copy",
|
||||||
@@ -366,7 +366,7 @@ def run_script(command: str) -> None:
|
|||||||
print(stderr_decoded)
|
print(stderr_decoded)
|
||||||
except PermissionError as e:
|
except PermissionError as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
logger.error(f'脚本无执行权限!, 若是Linux环境, 请先执行:chmod +x your_script.sh 授予脚本可执行权限')
|
logger.error('脚本无执行权限!, 若是Linux环境, 请先执行:chmod +x your_script.sh 授予脚本可执行权限')
|
||||||
except OSError as e:
|
except OSError as e:
|
||||||
logger.error(e)
|
logger.error(e)
|
||||||
logger.error('Please add `#!/bin/bash` at the beginning of your bash script file.')
|
logger.error('Please add `#!/bin/bash` at the beginning of your bash script file.')
|
||||||
@@ -1621,8 +1621,8 @@ try:
|
|||||||
print("System Proxy: http://{}:{}".format(proxy_info.ip, proxy_info.port))
|
print("System Proxy: http://{}:{}".format(proxy_info.ip, proxy_info.port))
|
||||||
except HTTPError as err:
|
except HTTPError as err:
|
||||||
print(f"HTTP error occurred: {err.code} - {err.reason}")
|
print(f"HTTP error occurred: {err.code} - {err.reason}")
|
||||||
except URLError as err:
|
except URLError:
|
||||||
color_obj.print_colored(f"INFO:未检测到全局/规则网络代理,请检查代理配置(若无需录制海外直播请忽略此条提示)",
|
color_obj.print_colored("INFO:未检测到全局/规则网络代理,请检查代理配置(若无需录制海外直播请忽略此条提示)",
|
||||||
color_obj.YELLOW)
|
color_obj.YELLOW)
|
||||||
except Exception as err:
|
except Exception as err:
|
||||||
print("An unexpected error occurred:", err)
|
print("An unexpected error occurred:", err)
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
import gzip
|
import gzip
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import urllib.error
|
import urllib.error
|
||||||
from urllib.request import Request
|
|
||||||
import requests
|
import requests
|
||||||
import ssl
|
import ssl
|
||||||
import json
|
import json
|
||||||
|
|||||||
@@ -2,10 +2,19 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
from loguru import logger
|
||||||
|
|
||||||
|
logger.remove()
|
||||||
|
|
||||||
custom_format = "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | <level>{level: <8}</level> - <level>{message}</level>"
|
custom_format = "<green>{time:YYYY-MM-DD HH:mm:ss.SSS}</green> | <level>{level: <8}</level> - <level>{message}</level>"
|
||||||
os.environ["LOGURU_FORMAT"] = custom_format
|
|
||||||
from loguru import logger
|
logger.add(
|
||||||
|
sink=sys.stderr,
|
||||||
|
format=custom_format,
|
||||||
|
level="DEBUG",
|
||||||
|
colorize=True,
|
||||||
|
enqueue=True
|
||||||
|
)
|
||||||
|
|
||||||
script_path = os.path.split(os.path.realpath(sys.argv[0]))[0]
|
script_path = os.path.split(os.path.realpath(sys.argv[0]))[0]
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
Author: Hmily
|
Author: Hmily
|
||||||
GitHub: https://github.com/ihmily
|
GitHub: https://github.com/ihmily
|
||||||
Date: 2023-07-15 23:15:00
|
Date: 2023-07-15 23:15:00
|
||||||
Update: 2025-02-08 17:59:16
|
Update: 2025-06-14 12:19:00
|
||||||
Copyright (c) 2023-2025 by Hmily, All Rights Reserved.
|
Copyright (c) 2023-2025 by Hmily, All Rights Reserved.
|
||||||
Function: Get live stream data.
|
Function: Get live stream data.
|
||||||
"""
|
"""
|
||||||
@@ -26,7 +26,7 @@ from . import JS_SCRIPT_PATH, utils
|
|||||||
from .utils import trace_error_decorator
|
from .utils import trace_error_decorator
|
||||||
from .logger import script_path
|
from .logger import script_path
|
||||||
from .room import get_sec_user_id, get_unique_id, UnsupportedUrlError
|
from .room import get_sec_user_id, get_unique_id, UnsupportedUrlError
|
||||||
from .http_clients.async_http import async_req, get_response_status
|
from .http_clients.async_http import async_req
|
||||||
|
|
||||||
|
|
||||||
ssl_context = ssl.create_default_context()
|
ssl_context = ssl.create_default_context()
|
||||||
@@ -1011,8 +1011,8 @@ async def get_sooplive_stream_data(
|
|||||||
else:
|
else:
|
||||||
raise RuntimeError("sooplive login failed, please check if the account and password are correct")
|
raise RuntimeError("sooplive login failed, please check if the account and password are correct")
|
||||||
elif json_data['data']['code'] == -6001:
|
elif json_data['data']['code'] == -6001:
|
||||||
print(f"error message:Please check if the input sooplive live room address "
|
print("error message:Please check if the input sooplive live room address "
|
||||||
f"is correct.")
|
"is correct.")
|
||||||
return result
|
return result
|
||||||
if json_data['result'] == 1 and anchor_name:
|
if json_data['result'] == 1 and anchor_name:
|
||||||
broad_no = json_data['data']['broad_no']
|
broad_no = json_data['data']['broad_no']
|
||||||
@@ -2998,7 +2998,7 @@ async def get_faceit_stream_data(url: str, proxy_addr: OptionalStr = None, cooki
|
|||||||
|
|
||||||
if cookies:
|
if cookies:
|
||||||
headers['Cookie'] = cookies
|
headers['Cookie'] = cookies
|
||||||
nickname = re.findall(f'/players/(.*?)/stream', url)[0]
|
nickname = re.findall('/players/(.*?)/stream', url)[0]
|
||||||
api = f'https://www.faceit.com/api/users/v1/nicknames/{nickname}'
|
api = f'https://www.faceit.com/api/users/v1/nicknames/{nickname}'
|
||||||
json_str = await async_req(api, proxy_addr=proxy_addr, headers=headers)
|
json_str = await async_req(api, proxy_addr=proxy_addr, headers=headers)
|
||||||
json_data = json.loads(json_str)
|
json_data = json.loads(json_str)
|
||||||
|
|||||||
Reference in New Issue
Block a user