I have some older movies that do not have the movie titles in their file names. Instead, I have organized the movies into folders, whose names reflect the movie titles. Is there a way to have an agent query on the parent folder name instead of the file name? I see in the script:
title = media.name
Can I change this to something like
title = media.parentfoldername
?
You could try and extract the movie title from the media.filename (available in the search method of Metadata Agents). This gives you the complete path to the file, for example: /Users/sander/Movies/The Bourne Ultimatum (2007)/The Bourne Ultimatum (2007).mkv
Thanks for the quick reply! I tried logging the media.filename as str(media.filename), but I didn’t get a result. Is there another function I should use to return the media.filename as a string?
media.filename is only available inside the search method of the primary metadata agent. Where did you try to log it? Which agent?
** def search(self, results, media, lang):
Log("media.name = " + media.name)
Log("media.filename = " + str(media.filename))**
In the media agent log, I see:
INFO (logkit:16) - media.name = S8E9 Majestic Pine
INFO (logkit:16) - media.filename = None
To my knowledge the filename is only available in the part subobject which for Movie is:
filenameWithPath = media.items[0].parts[0].file
See here: http://dev.plexapp.com/docs/agents/search.html
This is available only in the primary agent's search method but both in primary and contributing agent's update method.
Yeah, that works, thanks! I’m not sure if it’s easier to do (I have no Python experience), but I found the parent directory by using:
os.path.basename(os.path.normpath(os.path.join(media.items[0].parts[0].file, ‘…’)))
You get the parent directory with full path:
os.path.dirname(filenameWithPath)
And if you want traverse the path further towards the root or get the parent folder without path information:
(path, parentFolder) = os.path.split(os.path.dirname(filenameWithPath))
I have found the official python reference documentation quite nice:
http://docs.python.org/2/library/os.path.html
Did you ever get this figured out?
I have the same issue. My folder names are the proper movie names (and year), but the filenames are scene release names. I can't rename thousands of files, not because it would be a pain, but I am also using xbmc for local viewing (plex for remote) and I'd rather not rescrape the entire database.
I have used the xbmc nfo agents (scraper) that use nfo and local files to import into plex, but they don't play nice with other addons like trakt.tv
I wish plex had the simple option of using folder names for lookup like it used to back in the day.
Did you ever get this figured out?
I have the same issue. My folder names are the proper movie names (and year), but the filenames are scene release names. I can't rename thousands of files, not because it would be a pain, but I am also using xbmc for local viewing (plex for remote) and I'd rather not rescrape the entire database.
I have used the xbmc nfo agents (scraper) that use nfo and local files to import into plex, but they don't play nice with other addons like trakt.tv
I wish plex had the simple option of using folder names for lookup like it used to back in the day.
I'm in the same situation.
I'm in the same situation.
Let me know if you still need an agent to name media after folders. I implemented the above for movies and could upload it to git if someone wants it.
I may get around to parsing scene names as well some day :)
I would be interested, Jason Mehring. Trying to figure out a way to make Plex display localized titles. Amazingly this doesn't seem to possible in vanilla Plex ;(
Could you post your solution?
@Jason Mehring said:
cros13 wrote on April 1 2013, 12:53 AM: »Let me know if you still need an agent to name media after folders. I implemented the above for movies and could upload it to git if someone wants it.
I may get around to parsing scene names as well some day
I’m also interested.
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.