## [[工具]] ## [[配置]] ## 配置 { #### ~/.config/helix/config.toml <pre><code>`# theme = "tokyonight" theme = "tokyonight_day" [editor] cursor-shape.insert = "bar" # lsp.enable = false [keys.insert] "C-a" = "goto_line_start" "C-e" = "goto_line_end" "C-s" = ":w" [keys.normal] # "C-a" = "goto_line_start" "C-e" = "goto_line_end" "C-s" = ":w"`</code></pre> #### ~/.config/mpv/mpv.conf <pre><code>`# profile=high-quality profile=fast # ytdl-raw-options=cookies-from-browser=firefox,format-sort="vcodec:avc1" ytdl-raw-options=cookies-from-browser=firefox:exlk4k0r.bilivip,format-sort="vcodec:avc1,res:1080" # http-proxy=http://127.0.0.1:7890 hwdec=auto gpu-api=vulkan geometry=100% cache-secs=30 slang=zh,en,ja # keep-open=yes # cscale=catmull_rom # deband=yes # video-sync=display-resample # interpolation=yes # tscale=oversample`</code></pre> #### ~/.config/mpv/scripts/bdanmaku.lua <pre><code>`-- Author: UlyssesZhan <ulysseszhan@gmail.com> -- License: MIT -- Homepage: https://github.com/UlyssesZh/bdanmaku table.unpack = table.unpack or unpack -- 5.1 compatibility local CURL = mp.get_opt('curl_executable') or 'curl' local BILIASS = mp.get_opt('biliass_executable') or 'biliass' local TMPDIR = mp.get_opt('tmpdir') or '/tmp/danmaku' local BILIASS_OPTS = {} for token in (mp.get_opt('biliass_options') or '--fontsize 48 --alpha 0.5 --duration-marquee 10'):gmatch('[^%s]+') do BILIASS_OPTS[#BILIASS_OPTS + 1] = token end local utils = require 'mp.utils' local danmaku_track_id = nil local xml_filename = nil local has_unloaded = false function execute(command) if _ENV then -- Lua 5.2 local success, status, code = os.execute(command) return success and status == "exit" and code == 0 else return os.execute(command) == 0 end end function download_xml() local url = nil for track_i = 0, mp.get_property('track-list/count') - 1 do url = mp.get_property('track-list/'..track_i..'/external-filename') if url then url = url:match '%w+://comment.bilibili.com/.*%.xml$' if url then danmaku_track_id = track_i break end end end if not danmaku_track_id then mp.msg.debug('no XML danmaku found') return end if not execute('mkdir -p '..TMPDIR) then execute('powershell mkdir '..TMPDIR) end xml_filename = TMPDIR..'/'..mp.get_property('pid')..'.xml' local curl_args = { CURL, url, '--silent', '--output', xml_filename, '--compressed' } mp.msg.debug('curl_command: '..table.concat(curl_args, ' ')) local curl_result = utils.subprocess({args = curl_args}) if curl_result.status == 0 then mp.msg.debug('danmaku downloaded, will convert to ASS') else xml_filename = nil mp.msg.warn('downloading XML danmaku from '..url..' failed: '..curl_result.error) end end function replace_sub() local width, height, par = mp.get_osd_size() if width == 0 or height == 0 or not xml_filename or has_unloaded then return end local resolution = width..'x'..height local ass_filename = TMPDIR..'/'..mp.get_property('pid')..'.ass' local biliass_args = { BILIASS, xml_filename, '--size', resolution, '--output', ass_filename, table.unpack(BILIASS_OPTS) } mp.msg.debug('biliass_command: '..table.concat(biliass_args, ' ')) local biliass_result = utils.subprocess({args = biliass_args}) if biliass_result.status == 0 then local sid = mp.get_property('track-list/'..danmaku_track_id..'/id') mp.msg.debug('deleting original subtitle sid='..sid) mp.commandv('sub-remove', sid) mp.msg.debug('adding new subtitle') mp.commandv('sub-add', ass_filename, 'select', 'danmaku', 'danmaku') for track_i = 0, mp.get_property('track-list/count') - 1 do if mp.get_property('track-list/'..track_i..'/external-filename') == ass_filename then danmaku_track_id = track_i break end end else mp.msg.warn('converting XML danmaku from '..xml_filename..' to '..ass_filename..' failed: '..biliass_result.error) end end function unload_handler() mp.msg.debug('unload handler start') has_unloaded = true; os.remove(TMPDIR..'/'..mp.get_property('pid')..'.xml') os.remove(TMPDIR..'/'..mp.get_property('pid')..'.ass') end mp.register_event('file-loaded', download_xml) mp.observe_property('osd-width', nil, replace_sub) mp.observe_property('osd-height', nil, replace_sub) mp.add_hook('on_unload', 50, unload_handler)`</code></pre> }## 工具 <a href="https://sp.anqi.fun" target="_blank">sp.anqi.fun↗</a> <a href="https://sbl.anqi.fun" target="_blank">sbl.anqi.fun↗</a>