Jellyfin Forum
Manually create library with a script? - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Development (https://forum.jellyfin.org/f-development)
+--- Forum: Plugin Development (https://forum.jellyfin.org/f-plugin-development)
+--- Thread: Manually create library with a script? (/t-manually-create-library-with-a-script)

Pages: 1 2


Manually create library with a script? - z33d - 2024-07-05

tl'dr
I want to manually (by script or plugin) create a library, completely bypassing built-in worker.

I have a quite large collection of movies, spanning multiple drives, with nested structures, etc.
When using the built-in worker it does identifies most of the movies, but creates a lot of mess by including extras, misinterpreting nested structures, and so on.
Luckily I've been following a naming structure, that allowed me to parse disks content, identify 99,9% of the movies, and even grab the data from imdb [1].
I've used it to create a small web application to help select the next movie to watch.

So I have a small database where I have all the movies, including paths, imdb ids, genres, ratings, everything.
I want to use it to manually build a library.

I can try to create a custom plugin or write a script that will inject data straight into database?
If you could point me into the right direction. Smiling-face


RE: Manually create library with a script? - Efficient_Good_5784 - 2024-07-05

(2024-07-05, 03:52 PM)z33d Wrote: When using the built-in worker it does identifies most of the movies, but creates a lot of mess by including extras, misinterpreting nested structures, and so on.
Are your media files correctly organized how Jellyfin expects them to be? You're not supposed to nest folders beyond what Jellyfin expects.

Take a look at the documentation:

https://jellyfin.org/docs/general/server/media/movies

https://jellyfin.org/docs/general/server/media/shows


RE: Manually create library with a script? - z33d - 2024-07-05

No, they are not.
But I have them catalogued already, and I'd rather write a script or plugin to import them manually than rename all of them.


RE: Manually create library with a script? - Efficient_Good_5784 - 2024-07-05

(2024-07-05, 09:03 PM)z33d Wrote: No, they are not.
But I have them catalogued already, and I'd rather write a script or plugin to import them manually than rename all of them.
Are you never going to rescan the library you're putting them into ever again? Because a rescan will most likely break things again.


RE: Manually create library with a script? - z33d - 2024-07-06

If I'll be able to build the library manually I see no reason to.
Like I've said, I have my own script, that can catalogue all of my collection, and fetch corresponding imdb info on its own.

All I want is to use that script (or data) to manually build jellyfins library myself.


RE: Manually create library with a script? - Efficient_Good_5784 - 2024-07-06

It's possible to do what you want, but it will be quite a lot of work. You'll basically be replacing Jellyfin's own scanner and replacing it with your own. As long as you insert your data into the database correctly, they should appear in the server without any scan. But do note that any scan of that library at all will break things.

From speaking with a team member, different types of media each have a class that can be saved into the database. You should look at those class files to figure out how to make your external metadata into a new instance and insert it into the database. The team member also points out that "most of them inherit the 'LibraryItem' Class".

I myself am not much help here, so you'll have to wait for others knowledgeable enough in this subject to help you.


RE: Manually create library with a script? - z33d - 2024-07-06

Cool!
I'm only interested in using Jellyfin for movies.

For someone who's not familiar with the codebase at all, nor fluent in c# (although I've been programming for 20y and I'm familiar with OOP languages), what would be the recommended path - creating my own scanner based on the existing one (this would act as a plugin, right?) or writing an external script that would inject data directly into database?

In either case, would you be so kind and point me to the code responsible for the default movie scanner?


RE: Manually create library with a script? - mcarlton00 - 2024-07-06

The recommended path is "seriously, do not do this". This is such a massive project that it's going to be a lot of pain before you get any sort of realistic functionality out of it. If you insist, then the only real guidance we can give you is to run the server, import your stuff, and then go digging through it to figure out what goes where. It's not going to be fun. It's also going to be very fragile, as anytime there's an update to the scanning code and the database format shifts slightly you're going to have to update your script to match it.

Good luck.


RE: Manually create library with a script? - I-G-1-1 - 2024-07-20

Why don't you create a script to ln (hardlinks) all the folders/files with the structure that jellyfin library scanner expects in some folder called jellyfin_library?


RE: Manually create library with a script? - z33d - 2024-07-22

Hey, that's quite brilliant, I really like the idea.
If I'll be hosting JF on linux this will probably be the solution.