Code Monkey home page Code Monkey logo

Comments (4)

JimPancakes avatar JimPancakes commented on June 26, 2024 2

I made changes so that the script would automatically work for both mpv in portable mode on windows and for mpv-android since this is what I wanted to use it for. I don't know if it works on linux or the normal mpv mode on windows.

The changes I made are as follows:

thumbs_dir = ON_WINDOWS and "%APPDATA%\\mpv\\gallery-thumbs-dir" or "~/.cache/thumbnails/mpv-gallery/",

to

thumbs_dir = mp.command_native({ "expand-path", "~~/thumbnails" }),

and

if ON_WINDOWS then
	thumbs_dir = string.gsub(opts.thumbs_dir, "^%%APPDATA%%", os.getenv("APPDATA") or "%APPDATA%")
else
	thumbs_dir = string.gsub(opts.thumbs_dir, "^~", os.getenv("HOME") or "~")
end
local res = utils.file_info(thumbs_dir)
if not res or not res.is_dir then
	if opts.mkdir_thumbs then
		local args = ON_WINDOWS and { "mkdir", thumbs_dir } or { "mkdir", "-p", thumbs_dir }
		utils.subprocess({ args = args, playback_only = false })
	else
		msg.error(string.format("Thumbnail directory \"%s\" does not exist", thumbs_dir))
	end
end

to

thumbs_dir = opts.thumbs_dir
local res = utils.file_info(thumbs_dir)
if not res or not res.is_dir then
	if opts.mkdir_thumbs then
		if ON_WINDOWS then
			os.execute("mkdir " .. thumbs_dir:gsub("/", "\\"))
		else
			local args = { "mkdir", "-p", thumbs_dir }
			utils.subprocess({ args = args, playback_only = false })
		end
	else
		msg.error(string.format("Thumbnail directory \"%s\" does not exist", thumbs_dir))
	end
end

The use of expand-path was the key.

from mpv-gallery-view.

occivink avatar occivink commented on June 26, 2024 1

I don't know if it's possible currently, but we might be able to use expand-path on the configured thumbs dir, such that it can be defined relative to the mpv config location.
I won't be able to check it in the near future though, so either PRs welcome or ping me again in ~2 weeks

from mpv-gallery-view.

JimPancakes avatar JimPancakes commented on June 26, 2024

Managed to solve it on my own. Thanks for the hint!

from mpv-gallery-view.

occivink avatar occivink commented on June 26, 2024

Could you share your solution?

from mpv-gallery-view.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.