jellyfin-plugin-tmdbboxsets icon indicating copy to clipboard operation
jellyfin-plugin-tmdbboxsets copied to clipboard

Global vs Account Level Collections

Open gfxlight55 opened this issue 4 years ago • 2 comments

I'm not sure if the plugin was meant to be this way or not. But it seems that this plugin works on a global level for all users regardless of the account type or access level. I understand that admin (root) account could create and edit collections for all users on the server. However I noticed that even a non-admin account can have full control over admin created collections. They can edit, add, remove, etc. These controls and edits not only affect their own account but EVERY account on the server on a global level. Even the root account. This doesn't seem right. A non-admin user should not be able to edit collections that affect every user as well as root. This also seems like a security risk as well. Being able to have per account collections is nice but a normal (non-admin) user should not be able to edit collections created by admins or the root user that affect every user on the server.

gfxlight55 avatar Oct 31 '20 19:10 gfxlight55

I agree with you 100% on this. Unfortunately, it seems nothing has happened in this direction for 2 1/2 years, hence I had to think of a solution or at least a workaround for myself.

I may have found a usable workaround. In fact, I started to like the idea that users can create their own collections to share with others and also that they can correct box sets that are missing newer films because the tmdb box set simply doesn't contain them. What could be an issue is when someone deletes a collection or an item in it accidentally, though.

First I thought I simply create a script that takes a zipped backup of the entire collections folder daily and maybe keep a couple of months of them. But then I came up with the idea of using a source code management software that can track all changes if only invoked often enough.

For a few days now I've been tracking changes with Fossil (https://fossil-scm.org). This is a single executable file available for many platforms. If you're on Linux there's a good chance that you can get it via the package installer.

I'm on Windows and downloaded the Windows executable. Ideally, you should place it in a folder in your path, or change your path to make it point to Fossil's executable. I haven't done this, though. The script I'm using calls Fossil directly from that path.

Open a command-line window and cd to the collections folder. On Windows, this is ...ProgramData\Jellyfin\Server\data\collections. I'm sure the folder's name is similar on Linux or a docker image. I'm assuming Fossil is in your path.

Create this repository inside your collections folder: fossil init collections.fossil

Open the repository: fossil open collections.fossil --keep Note that --keep is important to prevent Fossil from deleting your collections. If you forget it, don't worry. Fossil refuses to open it unless you use another parameter to overwrite it!

Now you can add a copy of the contents of the collections folder (you're still inside collections in a terminal or command-line window? Make sure you are.) fossil addremove fossil commit -m "Automatic commit." --no-warnings

That's it. You now got two additional files inside the collections directory: FOSSIL and collections.fossil.

Run these two lines every time when you assume a collection may have been updated, for instance from an hourly script: fossil addremove fossil commit -m "Automatic commit." --no-warnings

Or run a script infinitely that executes these lines, then sleeps for some time, then executest them again. This is probably better than a cron script.

You can use fossil ui to start a server and a browser with a tracking user interface.

I hope this is helpful.

ThomasPGH avatar Jul 08 '22 19:07 ThomasPGH

Here's my Windows command-line script. At the moment I'm calling it manually every time after a manual library scan but in the future it'll run in an infinite loop with a waiting time between invocations. Adjust the varaibles fossil and datadi to the location of fossil.exe and your collections folder.

@ECHO OFF
SETLOCAL

ECHO.
ECHO *** FossilUpdate.cmd
ECHO *** Script to update the Jellyfin collections Fossil repository
ECHO.

SET fossil=D:\Programs\Fossil\fossil.exe
SET datadi=D:\ProgramData\Jellyfin\Server\data\collections
SET fosdat=collections.fossil
SET fosfil=%datadi%\%fosdat%

REM Create and open an empty Fossil repository if it doesn't exist. This only happens
REM once.
IF NOT EXIST %fosfil% (
	ECHO Fossil repository "%fosfil%" does not exist.
	ECHO Creating repository "%fosfil%"...
	%fossil% init %fosfil%
	%fossil% open %fosfil% --keep
)
REM Add extra (new) files.
ECHO Adding or removing files to or from the Fossil repository...
%fossil% addremove

REM This only commits if something has changed. We can therefore run the script as often
REM as we like but it only commits when necessary.
ECHO Committing if changed...
%fossil% commit -m "Committed by script FossilUpdate.cmd." --no-warnings
ECHO Done.

REM Without a little delay we can't read what it says.
SLEEP 3

ENDLOCAL

ThomasPGH avatar Jul 08 '22 19:07 ThomasPGH