mirror of
https://github.com/gentoo-mirror/guru.git
synced 2026-04-07 03:10:15 -04:00
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@gmail.com>
This commit is contained in:
@@ -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)
|
||||
@@ -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
|
||||
}
|
||||
Reference in New Issue
Block a user