po5 / mpv_sponsorblock

mpv script to skip sponsored segments of YouTube videos
GNU General Public License v3.0
550 stars 29 forks source link

Use XDG_DATA_HOME and XDG_CACHE_HOME if defined for UID and DB #17

Open pacien opened 4 years ago

pacien commented 4 years ago

… Falling back to standard locations then the script's shared directory otherwise.

GitHub: closes #16

robertgzr commented 1 year ago

this is also missing windows support... is that required @po5? look at the repo i linked they have https://github.com/hishamhm/datafile/blob/master/datafile/openers/windows.lua

not sure if APPDATA is the correct place to put this?

po5 commented 1 year ago

I didn't merge this PR since it's obvious it'll break on tons of systems. You should not be trying to make up paths, they should come from a source of truth. This is why the script queries mpv for the path, because it knows better than anyone where mpv scripts go.

robertgzr commented 1 year ago

agreed, but I don't think putting state into mpv's script directory is great either :stuck_out_tongue:

i don't think mpv exposes it's state/cache directories via the plugin api, so if we want to improve on the current situation the xdg paths (and their equivalent on other platforms) seem like a sane choice?

defaultxr commented 8 months ago

mpv's options support shortcuts for various paths. Maybe the directory could be an option for mpv_sponsorblock that defaults to ~~cache/mpv_sponsorblock/ or similar.

mesvam commented 7 months ago

I'm not sure why this dir is named "shared". No other users, scripts, or programs will be using this dir right? The only real requirement is that it be writable.

this is also missing windows support... is that required @po5? look at the repo i linked they have https://github.com/hishamhm/datafile/blob/master/datafile/openers/windows.lua

not sure if APPDATA is the correct place to put this?

On Windows, standard for user-specific app configs is %APPDATA%. %LOCALAPPDATA% is typically used for cache and temporary files, but can also be used for permanent storage. Both are generally writable, the main difference is %APPDATA% may be synced across multiple systems while %LOCALAPPDATA% is local to a specific machine, but this syncing feature is rarely used. Cache and temporary files are supposed to be in %TEMP%. mpv uses %APPDATA%\mpv for it's config dir by default.

If you wanted to do everything "by-the-book", I would say sponsorblock.db should go in %LOCALAPPDATA%\\mpv_sponsorblock and sponsorblock.txt should go in %APPDATA%\mpv_sponsorblock, but that is probably too much trouble for no real benefit.

I would say the best location for both files on Windows is simply the script directory, %APPDATA%\mpv\scripts\sponsorblock. You'll want to move the script itself into that dir as main.lua as well https://github.com/po5/mpv_sponsorblock/pull/66