Create Smart Collection based on file location

Server Version#: Linux 1.24.5.5173
Player Version#: NA

Is there a way to create a ‘Smart Collection’ based on file location?

I use Plex to host shows off my TiVo. Shows I record go into a folder /media/tivo/recordings. Tivo suggestions (shows tivo records to ensure there is always something to watch based on my watching habits… Essentially re-runs of old favorites) get saved to /media/tivo/suggestions. Until this point, these have been 2 separate libraries. I would like to combine these into a single library and use the smart collections feature. This way, if I want to find a family friendly show for the kids, I can search by genre and not necessarily care if it’s a recording or suggestion. However, if I want to look at my list of recordings/suggestions, I can filter by collection… Without having to update tags manually… For every recording.

Is this possible? Or is there a better way to do this?

Anybody? Where can I request a feature? I’d like to create a ‘Smart Collection’ based on file location.

I have my TV shows broken down into 3 logical folders on my hard drive. I’d like to combine them into a single Plex library so if the kids want to watch say ‘Sesame Street’, they don’t care if it’s a new episode or a re-run. However, if I want to watch something, I may only care about ‘new’ episodes in the Recordings folder (hence Smart Collection).

There’s currently no such option.
There is an open feature suggestion asking for an option to filter items by their path (or segments of their path). Though it’s a bit older and hasn’t gotten a lot of attention / interest from the community.

there are tools you can use for flagging/tagging that uses plex’s own API if you are programing mindset.

Linky? I was not aware of any such tools. I have no problem creating a bash script to tag each file based on path. That would actually be very helpful.

I use python and the PlexAPI · PyPI package. Little more complex than a simple bash script

Python works too. Thanks @dbirch !

Im using an older version of that package, but Ill post a couple useful snipits.

    video.addLabel('TAG')

    account = MyPlexAccount('<username>', '<password>')
    plex = account.resource('<servername>').connect()

    places = ['<show library name>']
    for place in places:
      tv_shows = plex.library.section(place)
      for show in tv_shows.all():

    episodes = None
    error_count = 0
    while not episodes:
      try:
        episodes = show.episodes()
      except:
        error_count +=1
        pass
      if error_count > 10:
        episodes = show.episodes()
      time.sleep(2)
    for video in episodes:
      for part in video.iterParts():
        filename = part.file
      if not re.search(ur'<path fragment>',filename,flags=re.I):

So I found a way to iterate through all my shows, but it looks like there is a limitation I’m hitting with Plex. I can add a Genre or Label to a show, but not an episode… I may have a show that I actively record show up in the ‘Recordings’ bucket, but re-runs get tossed in the ‘Suggestions’ bucket. Same show, but I’d like each episode to have a respective ‘filter’ I can apply…

Any ideas on a filter I can apply at the episode level?

def main():
    plex = PlexServer(baseurl, token)

    alltvshows = plex.library.section('02 - All TV Shows')
    for tvshow in alltvshows.all():
        for episode in tvshow.episodes():
            for locstring in episode.locations:
                if "Tivo/Recordings" in locstring:
                    print("Recording")
                    episode.addLabel("Recording") # addLabel doesn't exist for show....
                elif "Tivo/Suggestions" in locstring:
                    print("Suggestion")
                    episode.addLabel("Suggestion") # addLabel doesn't exist for show....
                elif "Chromecast/TV Shows" in locstring:
                    print("Archive")
                    episode.addLabel("Archive") # addLabel doesn't exist for show....

Ended up just tagging each show instead of each episode. Some shows/episodes will show up in multiple buckets, but I think I can work with that.

if you wanna do it kinda hacky use addCollection(“re-run”) instead of addLabel

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.