mirror of
https://github.com/xhlove/GetDanMu.git
synced 2025-12-17 08:35:57 +08:00
完善说明,爱奇艺支持series命令,增加弹幕区间设定
This commit is contained in:
27
basic/ass.py
27
basic/ass.py
@@ -3,15 +3,14 @@
|
||||
'''
|
||||
# 作者: weimo
|
||||
# 创建日期: 2020-01-04 19:14:46
|
||||
# 上次编辑时间 : 2020-01-11 17:20:21
|
||||
# 上次编辑时间 : 2020-02-07 18:33:14
|
||||
# 一个人的命运啊,当然要靠自我奋斗,但是...
|
||||
'''
|
||||
|
||||
import os
|
||||
|
||||
import json
|
||||
from basic.vars import fonts
|
||||
|
||||
|
||||
ass_script = """[Script Info]
|
||||
; Script generated by N
|
||||
ScriptType: v4.00+
|
||||
@@ -30,15 +29,29 @@ ass_events_head = """[Events]\nFormat: Layer, Start, End, Style, Name, MarginL,
|
||||
# 基于当前时间范围,在0~1000ms之间停留在(676.571,506.629)处,在1000~3000ms内从位置1300,600移动到360,600(原点在左上)
|
||||
# ass_baseline = """Dialogue: 0,0:20:08.00,0:20:28.00,Default,,0,0,0,,{\t(1000,3000,\move(1300,600,360,600))\pos(676.571,506.629)}这是字幕内容示意"""
|
||||
|
||||
def get_fonts_info():
|
||||
fonts_path = r"C:\Windows\Fonts"
|
||||
if os.path.exists("config.json"):
|
||||
with open("config.json", "r", encoding="utf-8") as f:
|
||||
fr = f.read()
|
||||
try:
|
||||
config = json.loads(fr)
|
||||
except Exception as e:
|
||||
print("get_fonts_info error info ->", e)
|
||||
else:
|
||||
fonts_path = config["fonts_base_folder"]
|
||||
fonts = config["fonts"]
|
||||
return fonts_path, fonts
|
||||
|
||||
def get_ass_head(font_style_name, font_size):
|
||||
ass_head = ass_script + "\n\n" + ass_style_head + "\n" + ass_style_base.format(font=font_style_name, font_size=font_size) + "\n\n" + ass_events_head
|
||||
return ass_head
|
||||
|
||||
def check_font(font):
|
||||
win_font_path = r"C:\Windows\Fonts"
|
||||
maybe_font_path = os.path.join(win_font_path, font)
|
||||
fonts_path, fonts = get_fonts_info()
|
||||
maybe_font_path = os.path.join(fonts_path, font)
|
||||
font_style_name = "微软雅黑"
|
||||
font_path = os.path.join(win_font_path, fonts[font_style_name]) # 默认
|
||||
font_path = os.path.join(fonts_path, fonts[font_style_name]) # 默认
|
||||
if os.path.exists(font):
|
||||
# 字体就在当前文件夹 或 完整路径
|
||||
if os.path.isfile(font):
|
||||
@@ -58,7 +71,7 @@ def check_font(font):
|
||||
pass
|
||||
elif fonts.get(font):
|
||||
# 别名映射
|
||||
font_path = os.path.join(win_font_path, fonts.get(font))
|
||||
font_path = os.path.join(fonts_path, fonts.get(font))
|
||||
font_style_name = font
|
||||
else:
|
||||
pass
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
'''
|
||||
# 作者: weimo
|
||||
# 创建日期: 2020-01-04 19:14:35
|
||||
# 上次编辑时间 : 2020-01-28 17:43:44
|
||||
# 上次编辑时间 : 2020-02-07 17:57:05
|
||||
# 一个人的命运啊,当然要靠自我奋斗,但是...
|
||||
'''
|
||||
|
||||
|
||||
Reference in New Issue
Block a user