• Login
  • Register
  • Login Register
    Login
    Username/Email:
    Password:
    Or login with a social network below
  • Forum
  • Website
  • GitHub
  • Status
  • Translation
  • Features
  • Team
  • Rules
  • Help
  • Feeds
User Links
  • Login
  • Register
  • Login Register
    Login
    Username/Email:
    Password:
    Or login with a social network below

    Useful Links Forum Website GitHub Status Translation Features Team Rules Help Feeds
    Jellyfin Forum Support General Questions Is it possible to have separate library based on language?

     
    • 0 Vote(s) - 0 Average

    Is it possible to have separate library based on language?

    fedonr
    Offline

    Junior Member

    Posts: 21
    Threads: 3
    Joined: 2024 Jun
    Reputation: 0
    #5
    2024-06-21, 06:37 PM (This post was last modified: 2024-06-21, 06:38 PM by fedonr. Edited 1 time in total.)
    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
    « Next Oldest | Next Newest »

    Users browsing this thread: 1 Guest(s)


    Messages In This Thread
    Is it possible to have separate library based on language? - by fedonr - 2024-06-21, 03:05 PM
    RE: Is it possible to have separate library based on language? - by TheDreadPirate - 2024-06-21, 03:23 PM
    RE: Is it possible to have separate library based on language? - by fedonr - 2024-06-21, 03:32 PM
    RE: Is it possible to have separate library based on language? - by TheXaman - 2025-02-26, 10:57 AM
    RE: Is it possible to have separate library based on language? - by TheDreadPirate - 2024-06-21, 03:39 PM
    RE: Is it possible to have separate library based on language? - by fedonr - 2024-06-21, 06:37 PM
    RE: Is it possible to have separate library based on language? - by TheDreadPirate - 2024-06-21, 07:02 PM
    RE: Is it possible to have separate library based on language? - by TheDreadPirate - 2024-06-21, 07:19 PM
    RE: Is it possible to have separate library based on language? - by fedonr - 2024-06-21, 08:52 PM
    RE: Is it possible to have separate library based on language? - by TheDreadPirate - 2024-06-21, 08:57 PM
    RE: Is it possible to have separate library based on language? - by fedonr - 2024-06-22, 04:49 PM
    RE: Is it possible to have separate library based on language? - by fedonr - 2024-06-22, 05:19 PM
    RE: Is it possible to have separate library based on language? - by fedonr - 2024-06-21, 09:33 PM
    RE: Is it possible to have separate library based on language? - by TheDreadPirate - 2024-06-22, 05:27 PM
    RE: Is it possible to have separate library based on language? - by fedonr - 2024-06-22, 05:30 PM

    • View a Printable Version
    • Subscribe to this thread
    Forum Jump:

    Home · Team · Help · Contact
    © Designed by D&D - Powered by MyBB
    L


    Jellyfin

    The Free Software Media System

    Linear Mode
    Threaded Mode