Mike Smith Mike Smith - 1 month ago 6
Python Question

Please help me with a simple config option for a python application \[(?P<id>.{11})\]

I need some quick help. I'm using a plugin for plex. This plugin has one configuration option in the interface and it is to tell it how to find an ID for a video. The default pattern included expects the ID to be in [ ] but I have hundreds of files that just have the ID as the last ~11 characters in the file name, before the extension.

Here is the "Default" pattern that looks for an ID between [ ]

\[(?P<id>.{11})\]


I would like to know how to change this so that it will look for the ID in the last 11 characters of the file name, ignoring all characters before (which varies). There aren't any other configuration options, it's literally a box in the plex interface you insert a pattern, and click save.

I do, however, have a link to the very short python script that drives everything, if that help.

https://github.com/sander1/YouTube-Agent.bundle/blob/master/Contents/Code/__init__.py

Any help is appreciated. Thank you

This is the string that worked for me:

(?P<id>.{11})....$

Answer

Try (?P<id>.{11}$)

This takes any eleven non-newline characters at the end of the string. though perhaps you may need (?P<id>.{11})....$ to account for file extension...

Comments