Refresh Metadata by Folder?

All understood Otto. If you read my thread, this library seldom changes. It’s big (at least from my very slow computer’s viewpoint), really a waste of processing time to constantly run jobs when nothing changes 99% of the time. So, as I wrote, when we get excited over finding some .srt file we didn’t have before, we are eager to watch. I can either refresh metadata one at a time, or issue the job and wait (quite some time, for me) for the entire library.

So again, I posted inquiring about a happy medium - in my case, that would be a folder-level metadata refresh or a script I could drag/drop multiple files onto or a plex web where I could select more than one item at a time on the webpage and issue refresh against multiple items. Any of those would be faster and easier than one at a time. No harm in asking (or so I thought).

And again, huh? You’ve never ever had a media you added but didn’t find .srt file for it until sometime later? You are luckier than me, my friend :grin:

I haven’t “made my PMS into something I like” - it inherited access to an existing library meant for something else and I found it really nice that I could just point Plex at it and be able to play the media through Roku Plex app. I’ve changed nothing for or against PMS.

I will get back to all the details you’ve given, for sure, to see what can work for me. I’m just swamped at the moment, give me a week or so. I do appreciate the time you’ve taken to test and detail your approaches.

Kind regards.

@Sheepy_Desktop

You can scan a section using the following URL in your browser..

Use the following command:

http://[PMS_IP_Address]:32400/library/sections/[sectionID]/refresh?X-Plex-Token=YourTokenGoesHere

To Identify the Section ID: You can list all library sections to find the ID of the section you want to scan. Use the following command:

http://[PMS_IP_Address]:32400/library/sections?X-Plex-Token=YourTokenGoesHere

Thanks, I will add this to my list of things to examine - but first, what is X-Plex-Token?

An X-Plex-Token is the key to your PMS kingdom. Never post it online.

I find that opening a Plex Player as the PMS admin user allows me to get an admin level X-Plex-Token easily as explained in that document under the The device token section, which is about ¼ the way down the page.

After I click 3-dots on a poster, choose Get Info, then click the View XML button and look at the web page it opens, I find my admin level token at the end of the URL.

On that same webpage, in the top line of the body, you can see the librarySectionID for your library. Because you have only one library you said, your librarySectionID is likely 1.

ViewXML.librarySectionID

You will need both your Token and librarySectionID to issue the following API command, described by drzoiberg33 and nydave69 and tested by me but not posted yet.

  • if your server was at 192.168.1.20
  • and your librarySectionID was 1
  • and your token was 1234567890ABCDEFGHIJ
  • and your movie is in its own folder with the external SRT
  • then you would paste this in a browser on your LAN and hit Return to do a Partial Refresh Metadata where only the items that have changed are scanned (what has changed is the contents of that one movie folder). All unchanged items are skipped. It’s very fast.
http://192.168.1.20:32400/library/sections/1/refresh/?X-Plex-Token=1234567890ABCDEFGHIJ

I was hoping to see your library structure because I wanted to make a test library with your settings and prove to myself what works and what doesn’t before posting.

You could bookmark that type of link, but beware of leaving your token for someone to see.

fwiw I used the folder layout that the OP prefers in Plex for Mac and did not visit the pre-play page. I did no Scan and no Refresh. The external SRT was automatically picked up and enabled when I hit play like this… I clicked into the folder below:

Then I hit this play button on the poster

Maybe the user runs another client that behaves differently than Plex for Mac?
Maybe it’s his directory structure or his Agent + Scanner or his Audio & Subtitle Settings that stops the subtitle file from automatically being enabled like you said?

Always appreciate your help.
nibs

There are measures in place which normally should prevent the re-processing of old media.
In Windows, these rely on the “Changed at” timestamp of the media folder (and each of its subfolders). On Linux (and derivates) it is often connected to the inotify mechanism in the kernel.

Yes, there are constellations where this is not working. For instance if you have some tool running that is constantly modifying files in your media storage, even if the media themselves are not changing, then this will cause an expensive library scan (instead of a short one, where all unchanged folders are skipped).

The same can happen if you use rsync or other methods of mounting media storage which don’t properly support the above mentioned “changed” flags.

Or if the media storage device doesn’t have reliable/accurate clock and date, the time stamps on the files and folders will be all over the place and can cause unnecessary re-scans. There are plenty of NAS devices (commercial or self-built) out there which either have no CMOS battery, or where the battery ran flat.

Thanks, fortunately none of those things are in play by all measures. It is just a very very old computer with a barely perceptible I/O rate :laughing:

Thanks for info on the X Plex Token. For your Mac test, did you ensure the .SRT was never known by Plex before you put it there? If it was previously known it will re-associate it. I have already stated I am using Roku Plex app, not Plex web or any other web app. I do not know what runs “underneath” the Roku Plex app.

Will try out the various ideas here in a week or so and get back. Thanks to all of you for the ongoing ideas to try.

ETA: My directory structure is nothing special, typical folders you’d find on any disk for any purpose.

(at root of drive)

/mainfolder
  bunch of media
  /folder1
    bunch of media
    /folder1subfolder1
      bunch of media
    /folder1subfolder2
      bunch of media
  /folder2
    bunch of media
  /folder3
     /folder3subfolder1
       bunch of media
     /folder3subfolder2 
       bunch of media

and so on.

Yes I carefully tested against several foreign audio films I’ve had for years which never had english subs nor external SRTs.

However, I vaguely recalled you mentioning Roku and have been concerned I wasn’t testing against your configuration to prove what worked. Thanks for clarifying. As I don’t own a Roku, my testing against Plex for Mac, the hosted web app, and my AppleTV isn’t enough. Sorry about that.

A few other things you or some future person might benefit from.

  • One of the simplest ways to get a librarySectionID isn’t the API which returns gory XML. It’s the Plex Media Scanner:
I type pscan -l, e.g.

nibbles$ pscan -l
  3: Movies
  7: TV Shows
  8: MusicTest
nibbles$ 
  • Also the pscan -r action for doing a refresh is deprecated, and it doesn’t seem to work for partial scans of only items that changed. It always seems to want to do a full scan on the few instances of PMS I’ve tried, but that’s anecdotal. I’m not a pro.
  • I don’t find the API useful for trying to limit a refresh by folder name like you requested. When it comes to the API call that drzoidberg33 posted about, which includes an optional query parameter for PATH, it doesn’t work for just any random directory path. The only paths it will accept are the ones you added to your Library preferences. The following image shows the only paths I could add to the API command for my Movies library.

  • While I find it easy to get my Token using the GUI as shown a few posts back, there are a couple of CLI methods also:
On Mac PMS from any directory:

$ defaults read com.plexapp.plexmediaserver PlexOnlineToken
1234567890ABCDEFGHIJ
$ 


On a Linux PMS I cd down to Preferences.xml then grep the token
using code I found on StackExchange or SuperUser I forget where:

$ grep -Po ' PlexOnlineToken="\K[^"]+' Preferences.xml
4567890123ABCDEFGHIJ
$ 
curl -X GET https://plex.tv/api/v2/server/access_tokens?auth_token={X-Plex-Token}

Thanks again for your topic and your patience. :slight_smile:

Thank you for all the time you’ve spent. I got a little time today but didn’t have any luck with either the command line scanner nor the API URL, as you’ve also found. Looks like I am stuck.

Wish I could have the ‘three dots’ menu next to the folder name in Plex Web, and find ‘refresh metadata’ in there :slight_smile: would be exactly perfect.

Kind regards.

Bottom right on poster, hover mouse pointer to show it.

What poster? If it’s what was already discussed, I only have individual. Want to do an entire disk directory.

Put the pointer on the menu item, 3 dots show

There are no three dots by my folders. That’s what I’m wanting.

Can you post a picture of the folders your talking about.

Sorry, the folders are people’s names so I had to sanitize it - that pretty much removes everything on Plex web you can see. It’s just folders. Can you post a screenshot of how you bring up the three dots on folder names?

Trying to understand the use case here… are you making folders to segregate the movies by the user/viewer?

I’ve already described all that to others, if you could go back to the top and try to understand, that will save me pages of copy/paste. As best we can tell, not available, except with perhaps one caveat (juice not worth the squeeze). nibbles has put a lot of time into experimenting and described all of that above as well.

Only suggestion I have at this point would be for you to go to the support docs and see how Plex is to be setup. Understand how the media is to be structured so that it works with Plex.

1 Like

I did actually read this thread back when it first started, and it gave vibes of “I didn’t set up my Plex server properly – why is it not working the way I want?”

I can appreciate that you want to enjoy foreign-language media, but the fact you are needing to go look for subtitles and add them at the time you want to watch doesn’t make sense. Why add media to your server without the subs already there if you need them? The idea of a media server is the content is “ready to watch”.

Personally I would only obtain media with the subs included so I don’t have to monkey with editing or timing, even though I know how to do those. But if I had to revert to a “raw” file I’d go look for the get subs before adding it.

You should just use the normal item-level refresh from the normal (not-folder) view, like nibbles said.

I’m sure if you used the Subtitle Search feature built into Plex it would add the subs immediately to the content.

The problem is Folder View itself is antithesis to Plex as a concept, which is to divorce the media files and how they are organized on disk with how the content is presented and organized to the viewer to consume. The file structure is for Plex to understand what the files are, not for browsing really.

I’ve reviewed the thread again and I didn’t see where you explained why the directories are named after users. If you’re trying to segregate the files into collections tailored to each user there are three ways to do that, but if you have the files themselves already separated like this the BEST way is simply to make separate Libraries for each user. Use the directory with their name as the root directory for the library. If you have films you all enjoy then make a separate folder called “shared” or “all” or something, and add it as a second root directory to every library. People sometimes forget a library can be multiple folders, and a folder can be in multiple libraries simultaneously.

Bonus: With separate libraries everyone can set their own favorite poster/background art for the shared movies when viewed in their library.

Now you can just refresh the metadata on the one person’s library that changed, and only that small subset of your media will be checked instead of all the files.

Each user would have their own Plex account or a Managed User profile, and you can assign their personal library to their profile so they wont have to see the other Libraries.