Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use separate bookmark table for each file option #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions bookmarker-menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ local confirmDelete = false
local rate = 1.5
-- The filename for the bookmarks file
local bookmarkerName = "bookmarker.json"
-- Use separate bookmark table for each file
local separateTable = false

-- All the "global" variables and utilities; don't touch these
local utils = require 'mp.utils'
Expand Down Expand Up @@ -426,7 +428,11 @@ end
-- Also checks for bookmarks made by "mpv-bookmarker" and converts them
-- Also removes anything it doesn't recognize as a bookmark
function loadBookmarks()
bookmarks = loadTable(getFilepath(bookmarkerName))
if separateTable then
bookmarks = loadTable(getFilepath(mp.get_property("filename") .. "-" .. bookmarkerName))
else
bookmarks = loadTable(getFilepath(bookmarkerName))
end
if bookmarks == nil then bookmarks = {} end

local doSave = false
Expand Down Expand Up @@ -476,7 +482,11 @@ end

-- Save the globally loaded bookmarks to the JSON file
function saveBookmarks()
saveTable(bookmarks, getFilepath(bookmarkerName))
if separateTable then
saveTable(bookmarks, getFilepath(mp.get_property("filename") .. "-" .. bookmarkerName))
else
saveTable(bookmarks, getFilepath(bookmarkerName))
end
end

-- Make a bookmark of the current media file, position and name
Expand Down