• 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 Troubleshooting Media Scanning & Identification Can I mass remove a specific bit of metadata from ALL movies?

     
    • 0 Vote(s) - 0 Average

    Can I mass remove a specific bit of metadata from ALL movies?

    kandykarter
    Offline

    Member

    Posts: 153
    Threads: 21
    Joined: 2023 Jun
    Reputation: 3
    #1
    2024-11-05, 10:59 PM
    Silly, odd question, but if for example I wanted to remove the credited Casting Director from the metadata of every movie in my collection, is there a way to do that beyond manual editing?
    Specifics:
    Jellyfin 10.10.7 (docker) on Debian 12.6 // N100 16GB
    Storage: Synology DS220+ CIFS mounts
    Clients: Jellyfin4Kodi (Addon Mode), Android, Android TV, Roku, Symfonium

    TheDreadPirate
    Offline

    Community Moderator

    Posts: 15,374
    Threads: 10
    Joined: 2023 Jun
    Reputation: 460
    Country:United States
    #2
    2024-11-05, 11:34 PM
    Not that I am aware of.
    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]
    qwerty12
    Offline

    Junior Member

    Posts: 30
    Threads: 0
    Joined: 2023 Jun
    Reputation: 3
    #3
    2024-11-06, 02:26 AM
    You can use your browser's console to invoke the Jellyfin API directly. I knocked out a quick Go program recently to mass remove TvDb IDs from shows; this is more a less a quick and dirty conversion of that. I'll also mention I'm not particularly adept with JavaScript at all, I got ChatGPT to look over my work...

    Good advice in general, but especially so when running code that performs an action in mass: Shutdown your Jellyfin server first and backup its data folder! I've intentionally made it so that this stops working after attempting to manipulate the first match - remove the last-most break if/once you've confirmed this hasn't blown up your collections' metadata. This attempts to remove all the people listed as "Casting Director" (case-sensitive, changable via the targetField variable) as per the following view, and then locks the item: [Image: nPgL8fO.png]

    In your browser, go to the Jellyfin web interface, make sure you're logged in as an administrator (or a user that has permissions to edit items) and then bring up the browser console (on Windows/*NIX, press the F12 key). Paste the following in, press Enter, and cross your fingers:

    PHP Code:
    await (async () => {
        const 
    targetField = "Line Producer";
        const 
    allMovies = await (await fetch(`${ApiClient._serverAddress}/Items?enableImages=false&enableTotalRecordCount=false&fields=People&includeItemTypes=Movie&recursive=true`, {
            
    "headers": {
                
    "Accept": "application/json",
                
    "Authorization": `MediaBrowser Client="${ApiClient._appName}", Device="${ApiClient._deviceName}", DeviceId="${ApiClient._deviceId}", Version="${ApiClient._serverVersion}", Token="${ApiClient.accessToken()}"`,
            },
            
    "method": "GET"
        
    })).json();
        
        const 
    ids = allMovies.Items.flatMap(movie =>
            
    movie.People.some(person => person.Role === targetField) ? [movie.Id] : []
        );

        for (const 
    id of ids) {
            const 
    itemReq = await fetch(`${ApiClient._serverAddress}/Items/${id}?userId=${ApiClient._currentUser.Id}`, {
                
    "headers": {
                    
    "Accept": "application/json",
                    
    "Authorization": `MediaBrowser Client="${ApiClient._appName}", Device="${ApiClient._deviceName}", DeviceId="${ApiClient._deviceId}", Version="${ApiClient._serverVersion}", Token="${ApiClient.accessToken()}"`,
                },
                
    "method": "GET"
            
    });

            if (!
    itemReq.ok)
                break;

            const 
    movie = await itemReq.json();
            
    console.log(movie.Name);

            
    movie.People = movie.People.filter(person => person.Role !== targetField);
            
    movie.LockData = true;

            try {
                
    await fetch(`${ApiClient._serverAddress}/Items/${id}`, {
                    
    "headers": {
                        
    "Authorization": `MediaBrowser Client="${ApiClient._appName}", Device="${ApiClient._deviceName}", DeviceId="${ApiClient._deviceId}", Version="${ApiClient._serverVersion}", Token="${ApiClient.accessToken()}"`,
                        
    "Content-Type": "application/json",
                    },
                    
    "body": JSON.stringify(movie),
                    
    "method": "POST"
                
    });
            } catch (
    err) {
                
    console.error(err.message);
                break;
            }

            break;
        }
    })(); 

    The name of the first matching movie will be printed, go and see its metadata and see if it worked. I'm not particularly knowledgeable with the Jellyfin API, there might be more efficient ways to do this. Still better than direct database manipulation, however, I reckon.

    The first part retrieves every movie on your server. The IDs of movies where there's a person with a "Line Producer" role are stored. Then, the complete information for each matching movie is pulled down, a new array of people where the existing entries are added except for the people we don't want, a metadata lock is requested on the movie and then the modified information is sent back to the Jellyfin server to update.
    « 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