• 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 Off Topic General Discussion Help with playlist script windows

     
    • 0 Vote(s) - 0 Average

    Help with playlist script windows

    Trying to build a script to update playlists
    robyn
    Offline

    Junior Member

    Posts: 2
    Threads: 1
    Joined: 2024 Apr
    Reputation: 0
    Country:Canada
    #1
    2024-04-25, 08:53 PM
    So far I have been able to get as far as generating an updated XML file in the playlists folder here

    C:\ProgramData\Jellyfin\Server\data\playlists\<name of playlist>\playlist.xml

    I can replace the file but nothing seems to update in jellyfin itself. If I update the playlist from within jellyfin it will overwrite the content of the file but I can't seem to update the other way around.
    I have tried restarting the jellyfin service, and refreshing the metadata but nothing changes when I look at the playlist from the web interface.

    Anyone have any suggestions on what to look at next to get jellyfin to reingest the file?
    TheDreadPirate
    Offline

    Community Moderator

    Posts: 15,374
    Threads: 10
    Joined: 2023 Jun
    Reputation: 460
    Country:United States
    #2
    2024-04-25, 09:13 PM (This post was last modified: 2024-04-25, 09:13 PM by TheDreadPirate.)
    I can't answer your specific question other than stating that when I copied my main music playlist from my stable Jellyfin to unstable for testing, it didn't immediately show up with no explanation as for why. Then a couple days later I noticed that my playlist was there....again, no explanation.
    Jellyfin 10.10.7 (Docker)
    Ubuntu 24.04.2 LTS w/HWE
    Intel i3 12100
    Intel Arc A380
    OS drive - SK Hynix P41 1TB
    Storage
        4x WD Red Pro 6TB CMR in RAIDZ1
    [Image: GitHub%20Sponsors-grey?logo=github]
    robyn
    Offline

    Junior Member

    Posts: 2
    Threads: 1
    Joined: 2024 Apr
    Reputation: 0
    Country:Canada
    #3
    2024-04-27, 12:07 AM
    ended up abandoning updating the xml files it just wouldn't read the updates in. Decided to go a different route and wrote a script to make PLS files instead. Along the way I noticed these will break if you have any weird characters in your file names. I cleaned mine with advanced renamer. It will also break if you have non playable files (like album art) and have code to account for that.

    save the text below as a file with the extension of .ps1 and run on the machine hosting your files. update the paths and playlist names. I now have this running as a daily scheduled task.

    Code:
    # Function to filter audio files
    function Is-AudioFile {
        param ([string]$filePath)
        $audioExtensions = @(".mp3", ".wav", ".ogg", ".flac")  # Add more audio file extensions if needed
        $extension = [System.IO.Path]::GetExtension($filePath).ToLower()
        return $audioExtensions -contains $extension
    }

    # Define array of paths, playlist names, and destination folders
    $pathsAndPlaylists = @(
        @{ Path = "D:\DATA\Music\Music\folder1"; PlaylistName = "folder1 "; Destination = "D:\DATA\Music\Music\Playlists" },
        @{ Path = "D:\DATA\Music\Music\folder2 "; PlaylistName = "folder2"; Destination = "D:\DATA\Music\Music\Playlists" },
        @{ Path = "D:\DATA\Music\Music\ folder3"; PlaylistName = "folder3"; Destination = "D:\DATA\Music\Music\Playlists" },
        @{ Path = "D:\DATA\Music\Music\ folder4"; PlaylistName = "folder4"; Destination = "D:\DATA\Music\Music\Playlists" },
        @{ Path = "D:\DATA\Music\Music\ folder5"; PlaylistName = "folder5"; Destination = "D:\DATA\Music\Music\Playlists" }

    )


    # Loop through each path, playlist name, and destination
    foreach ($item in $pathsAndPlaylists) {
        $folderPath = $item.Path
        $playlistName = $item.PlaylistName
        $destinationFolder = $item.Destination

        # Check if the folder exists
        if (-not (Test-Path $folderPath -PathType Container)) {
            Write-Host "Folder '$folderPath' doesn't exist. Skipping."
            continue
        }

        # Get all audio files in the folder and its subfolders
        $filePaths = Get-ChildItem -Path $folderPath -File -Recurse | Where-Object { Is-AudioFile $_.FullName } | Select-Object -ExpandProperty FullName

        # Check if there are any audio files
        if ($filePaths.Count -eq 0) {
            Write-Host "No audio files found in folder '$folderPath'. Skipping."
            continue
        }

        # Create PLS playlist content
        $playlistContent = "[playlist]`n"
        foreach ($filePath in $filePaths) {
            $entry = "File" + ($filePaths.IndexOf($filePath) + 1) + "=" + $filePath
            $playlistContent += $entry + "`n"
        }
        $playlistContent += "NumberOfEntries=" + $filePaths.Count + "`nVersion=2"

        # Determine the playlist file path
        $playlistFilePath = Join-Path -Path $destinationFolder -ChildPath ($playlistName + ".pls")

        # Save playlist to file
        Set-Content -Path $playlistFilePath -Value $playlistContent -Encoding UTF8

        Write-Host "Playlist '$playlistName' has been created at $playlistFilePath"
    }
    « Next Oldest | Next Newest »

    Users browsing this thread: 1 Guest(s)


    • 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