Jellyfin Forum
Is it possible to have separate library based on language? - Printable Version

+- Jellyfin Forum (https://forum.jellyfin.org)
+-- Forum: Support (https://forum.jellyfin.org/f-support)
+--- Forum: General Questions (https://forum.jellyfin.org/f-general-questions)
+--- Thread: Is it possible to have separate library based on language? (/t-is-it-possible-to-have-separate-library-based-on-language)

Pages: 1 2


Is it possible to have separate library based on language? - fedonr - 2024-06-21

Okay, so I am using [Censored by TDP] for my media libraries, where I have separate movies and TV show folders which works great. But is there a way that I can separate the libraries in Jellyfin based on their language? So I prefer to watch movies in X and Y both languages, while the other members only prefers X language, so is there a way I can have a separate library for X language? This would be really helpful for my parents to navigate their media.


RE: Is it possible to have separate library based on language? - TheDreadPirate - 2024-06-21

Are you asking about the metadata for the library or what audio track is played by default?. Showing library metadata in a particular language requires creating a separate library and changing the language in the library settings to your language of choice. Settings > Dashboard > Library > Add new library > Set "Preferred download language" to your language of choice, configure rest of library settings as you normally would. You can go one step farther and create a separate account for your family and only give them access to the libraries in their language.

If you only care about the audio track played by default, you don't need a separate library. You have to change the client settings to prefer your language's audio track. Settings > Playback > Audio settings > Preferred audio language.


RE: Is it possible to have separate library based on language? - fedonr - 2024-06-21

Im mainly referring to the audio language of the movies.

For example, I have 5 movies in X language and 5 movies in Y Language. Now I want my library to show up all 10 movies, while for my parent's library I want only 5 movies to show up which are in X language.

Or if both X and Y can have separate library I can manage with that, as my parents won't need to go thru a huge library as they only watch movies in X language (audio)


RE: Is it possible to have separate library based on language? - TheDreadPirate - 2024-06-21

AFAIK, you cannot filter based on the audio language. So you'd need to go the separate library route. You can use symlinks to the movie folders so you don't have to duplicate data.


RE: Is it possible to have separate library based on language? - fedonr - 2024-06-21

I'm not sure how to do it automatically.

I tried this and ran it as cronjob with every reboot

Code:
#!/bin/bash

# Define directories and language code
SOURCE_DIR="/drive1t/media/movies"
TARGET_DIR="/drive1t/media/himovies"
LANGUAGE="hin"

# Check ffprobe path (modify if necessary)
FFPROBE_PATH="/usr/bin/ffprobe"  # Update this if ffprobe is in a different location

# Create the target directory if it doesn't exist
mkdir -p "$TARGET_DIR"

while true; do
  # Loop through video files (mp4, mkv)
  find "$SOURCE_DIR" -type f \( -name "*.mp4" -o -name "*.mkv" \) | while read -r FILE; do
    echo "Processing file: $FILE"

    # Extract language using ffprobe (error handling added)
    LANG=$("$FFPROBE_PATH" -v error -select_streams a:0 -show_entries stream=codec_type:stream_tags=language:stream=codec_name -of default=noprint_wrappers=1:nokey=1 "$FILE" 2>&1 | grep -oP '(?<=language=)[^,]+' | head -n 1)

    # Check for ffprobe errors (optional)
    if [[ $? -ne 0 ]]; then
      echo "Error extracting language for: $FILE (ffprobe might have failed)"
      continue  # Skip to the next file if ffprobe has errors
    fi

    echo "Detected language: $LANG"

    # Check if language matches and create symlink if needed
    if [ "$LANG" == "$LANGUAGE" ]; then
      if [ ! -L "$TARGET_DIR/$(basename "$FILE")" ]; then
        ln -s "$FILE" "$TARGET_DIR/$(basename "$FILE")"
        echo "Created symlink for: $FILE"
      else
        echo "Symlink already exists for: $FILE"
      fi
    fi
  done

  # Sleep for 10 minutes (600 seconds)
  sleep 600
done

....doesn't work tho


RE: Is it possible to have separate library based on language? - TheDreadPirate - 2024-06-21

In your ffprobe you are specifying "default=noprint_wrappers=1:nokey=1", but then grepping on the key "language". When nokey is set to 1 the output is

Code:
chris@rat-trap:~$ /usr/bin/ffprobe -v error -select_streams a:0 -show_entries stream=codec_type:stream_tags=language:stream=codec_name -of default=noprint_wrappers=1:nokey=1 "/media/storage2/testMovies/Mad Max Fury Road/Mad Max Fury Road.mkv"
truehd
audio
eng

As a result, the grep doesn't retrieve anything and LANG is always null. But when it is set to 0.

Code:
chris@rat-trap:~$ /usr/bin/ffprobe -v error -select_streams a:0 -show_entries stream=codec_type:stream_tags=language:stream=codec_name -of default=noprint_wrappers=1:nokey=0 "/media/storage2/testMovies/Mad Max Fury Road/Mad Max Fury Road.mkv"
codec_name=truehd
codec_type=audio
TAG:language=eng

And debug output confirms that LANG is populated now.

Code:
+ grep -oP (?<=language=)[^,]+
+ + echohead /media/storage2/testMovies/Batman -n Begins/Batman 1 Begins.mkv
+ /usr/bin/ffprobe -v error -i /media/storage2/testMovies/Batman Begins/Batman Begins.mkv -select_streams a:0 -show_entries stream=codec_type:stream_tags=language:stream=codec_name -of default=noprint_wrappers=1:nokey=0
+ LANG=eng



RE: Is it possible to have separate library based on language? - TheDreadPirate - 2024-06-21

Oh. And instead of making symlinks for the file you need to make a symlink for the folder that the movie is in. In my code blocks in the above post I would make a symlink for "/media/storage2/testMovies/Batman Begins" instead of the mkv in it.

Jellyfin will follow symlinks for folders but will ignore symlinks for files.


RE: Is it possible to have separate library based on language? - fedonr - 2024-06-21

(2024-06-21, 07:19 PM)TheDreadPirate Wrote: Oh.  And instead of making symlinks for the file you need to make a symlink for the folder that the movie is in.  In my code blocks in the above post I would make a symlink for "/media/storage2/testMovies/Batman Begins" instead of the mkv in it.

Jellyfin will follow symlinks for folders but will ignore symlinks for files.

THanks that worked, but now I am able to play it from the Network Storage File Manager, but Jellyfin would not add it in library, I get errors like

Code:
[02:14:50] [ERR] [24] Emby.Server.Implementations.IO.ManagedFileSystem: Reading the file size of the symlink at /data/regmov/movies/Khufiya (2023) WEBRip-1080p.mkv failed. Marking the file as not existing.
System.IO.FileNotFoundException: Could not find file '/data/regmov/movies/Khufiya (2023) WEBRip-1080p.mkv'.
File name: '/data/regmov/movies/Khufiya (2023) WEBRip-1080p.mkv'
  at Interop.ThrowExceptionForIoErrno(ErrorInfo errorInfo, String path, Boolean isDirError)
  at Microsoft.Win32.SafeHandles.SafeFileHandle.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize, UnixFileMode openPermissions, Int64& fileLength, UnixFileMode& filePermissions, Boolean failForSymlink, Boolean& wasSymlink, Func`4 createOpenException)
  at System.IO.File.OpenHandle(String path, FileMode mode, FileAccess access, FileShare share, FileOptions options, Int64 preallocationSize)
  at Emby.Server.Implementations.IO.ManagedFileSystem.GetFileSystemMetadata(FileSystemInfo info)
[02:14:54] [INF] [15] Emby.Server.Implementations.ScheduledTasks.TaskManager: Scan Media Library Completed after 0 minute(s) and 4 seconds
[02:14:54] [INF] [20] Emby.Server.Implementations.IO.LibraryMonitor: Watching directory /data/regmov



RE: Is it possible to have separate library based on language? - TheDreadPirate - 2024-06-21

In your source folder each movie needs to be in its own folder, which is what our documentation states is the recommended folder and file structure anyway.

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

Once you put each movie in its own folder, modify your script to symlink the folder instead of the file.

As I stated, Jellyfin will follow symlinks for folders and will ignore symlinks for files.


RE: Is it possible to have separate library based on language? - fedonr - 2024-06-21

Ah! I thought so that would be an issue, and I am truly so much thankful to you. It works now.

I can't thank you enough it, would make navigation for my parents so much easy.

And me being a noob I didn't even write that scripts I just asked multiple AI tools to do it and did trial and error.