Skip to content

Add Path variable and infer Library accordingly#313

Open
qaz741wsd856 wants to merge 3 commits intojellyfin:masterfrom
qaz741wsd856:master
Open

Add Path variable and infer Library accordingly#313
qaz741wsd856 wants to merge 3 commits intojellyfin:masterfrom
qaz741wsd856:master

Conversation

@qaz741wsd856
Copy link
Copy Markdown

Added Path variable
Infer the associated library based on storage path matching. Request #303 #114
Added 4 variables:

  • LibraryIdByMaxPath, LibraryNameByMaxPath: Returns the library with the longest matching path prefix.
  • LibraryIdByMinPath, LibraryIdByMinPath: Returns the library with the shortest matching path prefix.

Example:
Consider two libraries:

  • Library "Media" with path /media
  • Library "SubMedia" with path /media/sub

For a media file located at /media/sub/xxxx/xxx.mkv:

  • LibraryNameByMaxPath will always return "SubMedia"
  • LibraryNameByMinPath will always return "Media"

This is regardless of whether the media file is actually included in either library.

While this simple identification method should handle most use cases, I personally don't recommend using such nested library structures.

Comment on lines +464 to +465
if (dataObject.TryGetValue("Path", out var pathObject) &&
pathObject is string path)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should just get the path from the item instead of casting from the data object

Comment on lines +468 to +471
string maxMatchLibraryId = string.Empty;
string maxMatchLibraryName = string.Empty;
string minMatchLibraryId = string.Empty;
string minMatchLibraryName = string.Empty;
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jellyfin doesn't support nested libraries so this can be simplified to just a singular match

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought so before, but the movies library does support such nested libraries.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And some users might add their top folder to Mixed Movies and Shows library and add particular sub folders to more specific libraries. So I prefer to infer the library by the longest path prefix matching if you think just one group of LibraryName and LibraryId is enough.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Jellyfin has never supported nested libraries, and anyone doing this is relying on undefined behavior.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants