How to parse event.payload to get filename without the path?

If you have a question or need help, this is the place to be.
z3us
Posts: 43
Joined: Fri Jul 29, 2011 2:35 am

Re: How to parse event.payload to get filename without the path?

Post by z3us » Mon Jan 18, 2021 2:13 pm

Flook wrote:
Tue Apr 13, 2010 7:30 pm
Maybe I need set a global variable in the python script based on the result and then access that variable in the expression. I'll try that out and see what happens.

edit: Hell yea! It worked.

Code: Select all

from os import path
fp = eg.event.payload[0]
head, tail = path.split(fp)
name, ext = path.splitext(tail)
eg.result  = "New Episode of %s" % name
eg.globals.testVar = eg.result
Then put {eg.globals.testVar} in my subject line of the email plugin configuration and then BAM! Worked like a charm. Perfect adition to my fully automated HTPC virtual machine. It now automatically:
1. downloads tv shows, emails me what show I just got, copies, renames, moves, downloads library data, seeds for two days then deletes original files.
2. un packs movies, renames, moves, downloads library data, seeds for 2 days then deletes original files.

A more detailed look at the setup here. http://forum.xbmc.org/showthread.php?t=70530

Thanks a lot for your help Pako
Really useful. Thanks for the script (you and Pako)

Post Reply