public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-commits] repo/proj/guru:dev commit in: mpv-plugin/mpv_sponsorblock/files/, mpv-plugin/mpv_sponsorblock/
@ 2025-05-12  5:54 Florian Albrechtskirchinger
  0 siblings, 0 replies; only message in thread
From: Florian Albrechtskirchinger @ 2025-05-12  5:54 UTC (permalink / raw
  To: gentoo-commits

commit:     27cc9c0dfa3c7e596129d22186dbe0bb99dc657b
Author:     Florian Albrechtskirchinger <falbrechtskirchinger <AT> gmail <DOT> com>
AuthorDate: Mon May 12 05:40:40 2025 +0000
Commit:     Florian Albrechtskirchinger <falbrechtskirchinger <AT> gmail <DOT> com>
CommitDate: Mon May 12 05:40:40 2025 +0000
URL:        https://gitweb.gentoo.org/repo/proj/guru.git/commit/?id=27cc9c0d

mpv-plugin/mpv_sponsorblock: add 20230130-r1

Apply GitHub PR#73 "Rely on mpv to know where to store application data
& cache" [1] to fix permission errors resulting from write attempts to
/etc.

[1] https://github.com/po5/mpv_sponsorblock/pull/73
    Commits:
    60f4c8f517445fd2e2ab11677bfad992132686df
    cce913bf3887c2b4a1bd862c6204b13640d5df96

Signed-off-by: Florian Albrechtskirchinger <falbrechtskirchinger <AT> gmail.com>

 ...sponsorblock-20230130-pr73-file-locations.patch | 72 ++++++++++++++++++++++
 .../mpv_sponsorblock-20230130-r1.ebuild            | 43 +++++++++++++
 2 files changed, 115 insertions(+)

diff --git a/mpv-plugin/mpv_sponsorblock/files/mpv_sponsorblock-20230130-pr73-file-locations.patch b/mpv-plugin/mpv_sponsorblock/files/mpv_sponsorblock-20230130-pr73-file-locations.patch
new file mode 100644
index 000000000..71a3d61f5
--- /dev/null
+++ b/mpv-plugin/mpv_sponsorblock/files/mpv_sponsorblock-20230130-pr73-file-locations.patch
@@ -0,0 +1,72 @@
+From 60f4c8f517445fd2e2ab11677bfad992132686df Mon Sep 17 00:00:00 2001
+From: nicoo <nicoo@mur.at>
+Date: Wed, 1 May 2024 13:17:52 +0000
+Subject: [PATCH 1/2] Rely on mpv to know where to store application data &
+ cache
+
+This is the most platform-independent way, and fixes things
+for users who have a global scripts directory. (see #66)
+
+Closes #17
+---
+ sponsorblock.lua | 13 +++++++++----
+ 1 file changed, 9 insertions(+), 4 deletions(-)
+
+diff --git a/sponsorblock.lua b/sponsorblock.lua
+index 96bfb24..91b2c31 100644
+--- a/sponsorblock.lua
++++ b/sponsorblock.lua
+@@ -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
+
+From cce913bf3887c2b4a1bd862c6204b13640d5df96 Mon Sep 17 00:00:00 2001
+From: nicoo <nicoo@mur.at>
+Date: Wed, 1 May 2024 13:25:09 +0000
+Subject: [PATCH 2/2] Automatically migrate files to new locations
+
+---
+ sponsorblock.lua | 12 ++++++++++++
+ 1 file changed, 12 insertions(+)
+
+diff --git a/sponsorblock.lua b/sponsorblock.lua
+index 91b2c31..4ac5f54 100644
+--- a/sponsorblock.lua
++++ b/sponsorblock.lua
+@@ -562,6 +562,18 @@ function submit_segment(category)
+     end
+ end
+ 
++-- Automatically migrate files if needed
++for new, old in pairs({
++      [uid_path]      = expand_path("~~/scripts/sponsorblock_shared/sponsorblock.txt"),
++      [database_file] = expand_path("~~/scripts/sponsorblock_shared/sponsorblock.db"),
++}) do
++   mp.msg.debug(old .. " → " .. new)
++   if file_exists(old) and not file_exists(new) and new ~= "" then
++      mg.msg.info("Migrating " .. old)
++      os.rename(old, new)
++   end
++end
++
+ mp.register_event("file-loaded", file_loaded)
+ mp.add_key_binding("g", "set_segment", set_segment)
+ mp.add_key_binding("G", "submit_segment", submit_segment)

diff --git a/mpv-plugin/mpv_sponsorblock/mpv_sponsorblock-20230130-r1.ebuild b/mpv-plugin/mpv_sponsorblock/mpv_sponsorblock-20230130-r1.ebuild
new file mode 100644
index 000000000..ad9b0ba92
--- /dev/null
+++ b/mpv-plugin/mpv_sponsorblock/mpv_sponsorblock-20230130-r1.ebuild
@@ -0,0 +1,43 @@
+# Copyright 2022 Gentoo Authors
+# Distributed under the terms of the GNU General Public License v2
+
+EAPI=8
+
+USE_MPV="rdepend"
+MPV_REQ_USE="lua"
+PYTHON_COMPAT=( python3_{11..13} )
+inherit mpv-plugin python-single-r1
+
+COMMIT="7785c1477103f2fafabfd65fdcf28ef26e6d7f0d"
+DESCRIPTION="mpv script to skip sponsored segments of YouTube videos"
+HOMEPAGE="https://github.com/po5/mpv_sponsorblock"
+SRC_URI="https://github.com/po5/${PN}/archive/${COMMIT}.tar.gz -> ${P}.tar.gz"
+S="${WORKDIR}/${PN}-${COMMIT}"
+
+LICENSE="GPL-3"
+KEYWORDS="~amd64"
+REQUIRED_USE="${PYTHON_REQUIRED_USE}"
+
+RDEPEND="
+	${PYTHON_DEPS}
+"
+
+MPV_PLUGIN_FILES=(
+	sponsorblock_shared
+	sponsorblock.lua
+)
+
+PATCHES=(
+	# https://github.com/po5/mpv_sponsorblock/pull/73
+	# fixes permission errors due to mpv_sponsorblock attempting to write to /etc
+	"${FILESDIR}/${P}-pr73-file-locations.patch"
+)
+
+src_prepare() {
+	default
+
+	# we 1) install in the system folder 2) use EPYTHON
+	sed -i sponsorblock.lua \
+		-e 's|scripts_dir =.*|scripts_dir = "/etc/mpv/scripts"|' \
+		-e "s|python3|${EPYTHON}|" || die
+}


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2025-05-12  5:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-05-12  5:54 [gentoo-commits] repo/proj/guru:dev commit in: mpv-plugin/mpv_sponsorblock/files/, mpv-plugin/mpv_sponsorblock/ Florian Albrechtskirchinger

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox