Skip to content

Commit 2e40cf4

Browse files
committed
fix: repeat initialization
1 parent 48a954c commit 2e40cf4

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

api.lua

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,14 @@ function get_danmaku_with_hash(file_name, file_path)
11041104
end
11051105

11061106
-- 从用户添加过的弹幕源添加弹幕
1107-
function addon_danmaku(from_menu)
1107+
function addon_danmaku(from_menu, dir)
1108+
if dir then
1109+
local history_json = read_file(history_path)
1110+
local history = utils.parse_json(history_json) or {}
1111+
if history[dir] and history[dir].extra ~= nil then
1112+
return
1113+
end
1114+
end
11081115
for url, source in pairs(danmaku.sources) do
11091116
if source.from ~= "api_server" then
11101117
add_danmaku_source(url, from_menu)
@@ -1393,7 +1400,7 @@ function load_danmaku_for_url(path)
13931400
dir = title
13941401
end
13951402
auto_load_danmaku(path, dir, filename, episod_number)
1396-
addon_danmaku()
1403+
addon_danmaku(false, dir)
13971404
return
13981405
end
13991406
get_danmaku_with_hash(filename, path)
@@ -1476,7 +1483,7 @@ function init(path)
14761483
add_danmaku_source_local(danmaku_xml, true)
14771484
else
14781485
auto_load_danmaku(path, dir, filename)
1479-
addon_danmaku(true)
1486+
addon_danmaku(true, dir)
14801487
end
14811488
end
14821489
end
@@ -1549,7 +1556,7 @@ mp.register_event("file-loaded", function()
15491556
if options.auto_load then
15501557
enabled = true
15511558
auto_load_danmaku(path, dir, filename)
1552-
addon_danmaku()
1559+
addon_danmaku(false, dir)
15531560
return
15541561
end
15551562

0 commit comments

Comments
 (0)