Skip to content

Commit

Permalink
Rely on mpv to know where to store application data & cache
Browse files Browse the repository at this point in the history
This is the most platform-independent way, and fixes things
for users who have a global scripts directory. (see po5#66)

Closes po5#17
  • Loading branch information
nbraud committed May 1, 2024
1 parent 7785c14 commit 60f4c8f
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions sponsorblock.lua
Original file line number Diff line number Diff line change
Expand Up @@ -92,11 +92,16 @@ end
options.local_database = false

local utils = require "mp.utils"
scripts_dir = mp.find_config_file("scripts")
local function expand_path(path)
return mp.command_native({"expand-path", path})
end

local sponsorblock = mp.find_config_file("scripts/sponsorblock_shared/sponsorblock.py")
local uid_path = expand_path("~~state/sponsorblock.txt")
local database_file = options.local_database and expand_path("~~cache/sponsorblock.db") or ""
mp.msg.debug("uid_path: " .. uid_path)
mp.msg.debug("database_file: " .. database_file)

local sponsorblock = utils.join_path(scripts_dir, "sponsorblock_shared/sponsorblock.py")
local uid_path = utils.join_path(scripts_dir, "sponsorblock_shared/sponsorblock.txt")
local database_file = options.local_database and utils.join_path(scripts_dir, "sponsorblock_shared/sponsorblock.db") or ""
local youtube_id = nil
local ranges = {}
local init = false
Expand Down

0 comments on commit 60f4c8f

Please sign in to comment.