[Script] Email yourself missing and upcoming episodes

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
G_G inks
Power User
Posts: 8
Joined: 04 Mar 2013, 10:34

[Script] Email yourself missing and upcoming episodes

Post by G_G inks »

Description:
  1. Searchs your TV Show folder for TV Show names
  2. Creates a file containing those names (User can edit later to ignore shows/seasons)
  3. Scrape online DB using that file
  4. Sends an email with list of shows you don't have. It's grouped by those
    • Already Aired
    • Coming in the next 7 days (user can edit)
    • The next episode for each show (easy to see when new season starts)
    • Missing Air Date
  5. (The best bit) Simply click an episode in the email to search your favourite torrent site for it.
I've only tested this on my XBMCbuntu HTPC. By adding the following to crontab, I've got it to send me an email every Tuesday at 2PM ;)

Code: Select all

00 14 * * 2 filebot -script /home/user/Filebot/MissingEpisodes.groovy /data/TV\ Shows/ "/home/user/Filebot/MyTVShowsReal.csv" --def gmail=user:passwords --def [email protected]
This was a learning exercise so any feedback would be appreciated. I pretty much had amc.groovy open the whole time I was hacking this together.

**Edit**
Updated script now uses Filebot functions for reading Series Names, Seasons Numbers and Episode Numbers for robust matching of different naming formats
Last edited by G_G inks on 14 Apr 2013, 10:52, edited 1 time in total.
c.murphy360
Donor
Posts: 8
Joined: 16 Mar 2013, 09:59

Re: [Script] Email yourself missing and upcoming episodes

Post by c.murphy360 »

Tried using this in Windows...

Got this error. Any Thoughts?


IndexOutOfBoundsException: index is out of range 0..-1 (index = 0)
java.lang.IndexOutOfBoundsException: index is out of range 0..-1 (index = 0)
at Script3$_run_closure6_closure18.doCall(Script3.groovy:115)
at Script3$_run_closure6.doCall(Script3.groovy:113)
at Script3.run(Script3.groovy:111)
at net.sourceforge.filebot.cli.ScriptShell.evaluate(Unknown Source)
at net.sourceforge.filebot.cli.ScriptShell.runScript(Unknown Source)
at net.sourceforge.filebot.cli.ArgumentProcessor.process(Unknown Source)

at net.sourceforge.filebot.Main.main(Unknown Source)
Failure (░_░)
G_G inks
Power User
Posts: 8
Joined: 04 Mar 2013, 10:34

Re: [Script] Email yourself missing and upcoming episodes

Post by G_G inks »

c.murphy360 wrote:
IndexOutOfBoundsException: index is out of range 0..-1 (index = 0)
java.lang.IndexOutOfBoundsException: index is out of range 0..-1 (index = 0)
at Script3$_run_closure6_closure18.doCall(Script3.groovy:115)
at Script3$_run_closure6.doCall(Script3.groovy:113)
at Script3.run(Script3.groovy:111)
Here's how I work through this.
If you're "out of bounds" when trying to access index 0 of an array, that array don't exist.
Going to line 115 we see it's trying to read an array that was supposed to be created at line 114.
Line 114 uses regex to match the file name, so the most likely error is the file name doesn't match.

The file name has to be like this:
Blah Blah Blah - S00E00
00 could be a single digit and still match.
S and E have to be capital
Has to be a "space dash space" in front of it though

What format are you using? I'll suggest a regex expression to replace the one there.

Otherwise, you could insert "println it" between line 113 and 114 and it will print to console the file name it is processing. That way you'll get a better picture of what it's doing.

Obviously, I'm happy to help.

Thanks for trying out my script!
c.murphy360
Donor
Posts: 8
Joined: 16 Mar 2013, 09:59

Re: [Script] Email yourself missing and upcoming episodes

Post by c.murphy360 »

Ok so i inserted print it like you said. Looks like i'm getting an error when it runs into a file called .SyncID (From bittorrent syncapp) Removed that file and it ran through fine on $#*t My Dad Says which is in the format you suggested (testing Purposes only) It errors out on the next show due to improper formatting. I prefer the following format -> Series Name.S00E00.Episode Title.mkv

Thanks for the quick reply, still trying to wrap my head around this stuff.
G_G inks
Power User
Posts: 8
Joined: 04 Mar 2013, 10:34

Re: [Script] Email yourself missing and upcoming episodes

Post by G_G inks »

Regex is a pain to begin with but well worth the effort. Check out Wikipedia for what the stuff between the forward slashes means.

Replace line 114 and 115 with the following:

Code: Select all

def splitName = it.getNameWithoutExtension() =~ /.+\.S(\d+)E(\d+)\.(.+)/
myEpisodes.addEpisode( splitName[0][3], null, splitName[0][1].toInteger(), splitName[0][2].toInteger(), null)
I changed the regex to match your file name format. I also had to change the indices on the next line because of the episode name will now me the last item in the array.

Give it a whirl and let me know how you go.
c.murphy360
Donor
Posts: 8
Joined: 16 Mar 2013, 09:59

Re: [Script] Email yourself missing and upcoming episodes

Post by c.murphy360 »

Ok, so I've been working on this a little, noticed the regex you sent me was trying to test the episode title instead of series name. Also noticed that not all of my shows are formatted perfectly and I needed to add some error checking and fault tolerance to your script.

Here is what I have working right now in lieu of lines 114 and 115 use:

Code: Select all

def splitName = it.getNameWithoutExtension() =~ /(.+)\.S(\d+)E(\d+)\.(.+)/
			try {
				
				myEpisodes.addEpisode( splitName[0][1], null, splitName[0][2].toInteger(), splitName[0][3].toInteger(), null)
			} catch(e) {
				print "ERROR \n"
				print it
			}	
It allows the script to gracefully handle malformed input.
G_G inks
Power User
Posts: 8
Joined: 04 Mar 2013, 10:34

Re: [Script] Email yourself missing and upcoming episodes

Post by G_G inks »

Yep, my bad, I shouldn't have changed the indices.

Seems like you've got it all under control.

Please let me know if you have any other suggestions.
User avatar
bonelifer
Power User
Posts: 83
Joined: 23 Mar 2013, 18:27

Re: [Script] Email yourself missing and upcoming episodes

Post by bonelifer »

Could you give me the regex for:

/media/Store/Videos/TV/Bones/Season 01/Bones - [01x01] - Pilot.mkv
G_G inks
Power User
Posts: 8
Joined: 04 Mar 2013, 10:34

Re: [Script] Email yourself missing and upcoming episodes

Post by G_G inks »

bonelifer wrote:Could you give me the regex for:

/media/Store/Videos/TV/Bones/Season 01/Bones - [01x01] - Pilot.mkv
For use in this script (It expects to run on the name without extension) you should replace the current expression with:

Code: Select all

/(.+) - \[(\d+)x(\d+)\] - (.+)/
User avatar
bonelifer
Power User
Posts: 83
Joined: 23 Mar 2013, 18:27

Re: [Script] Email yourself missing and upcoming episodes

Post by bonelifer »

Thanks everyone for the help. On my MythBuntu 11.10 system I had implement c.murphy360's code change(with the new regex) to get it to work. I ended up removing "missed", because I really don't need it and it was telling me that I was missing every episode of M*A*S*H, despite having the majority of them. I also didn't need "missing dates". This script was easy enough to tell which parts needed deleting so it was easy to remove those. It really is going to be nice to see ahead of time when my shows are about to start a new season or resume for those that take a week or two here and there.
User avatar
rednoah
The Source
Posts: 23934
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [Script] Email yourself missing and upcoming episodes

Post by rednoah »

The nice thing about filebot/groovy is that I already provide you with lots of tools for these kinda things.

e.g.

Code: Select all

def sxe = parseEpisodeNumber("Bones - [01x01] - Pilot.mkv")
println sxe.season
println sxe.episode
:idea: Please read the FAQ and How to Request Help.
User avatar
bonelifer
Power User
Posts: 83
Joined: 23 Mar 2013, 18:27

Re: [Script] Email yourself missing and upcoming episodes

Post by bonelifer »

G_G inks could you possibly add a new function so that it can be called to instead write out the html in a directory on the computer? I keep a cheap($27.00 shipped 7" android tablet in the living room) and it would be nice to check via the Dolphin web browser in those cases.
G_G inks
Power User
Posts: 8
Joined: 04 Mar 2013, 10:34

Re: [Script] Email yourself missing and upcoming episodes

Post by G_G inks »

bonelifer wrote:G_G inks could you possibly add a new function so that it can be called to instead write out the html in a directory on the computer? I keep a cheap($27.00 shipped 7" android tablet in the living room) and it would be nice to check via the Dolphin web browser in those cases.
That does sound like a practical use case for a HTPC. I'm not too confident with that section of code though so don't hold your breath.

Do you not like email because you would have to sign into the tablet? You could use the same dedicated email account to send and receive the email and not worry about staying logged into it on the tablet.
User avatar
bonelifer
Power User
Posts: 83
Joined: 23 Mar 2013, 18:27

Re: [Script] Email yourself missing and upcoming episodes

Post by bonelifer »

I already have Apache running on the system due to it being a mythtv system, so having Filebot write out html to the same name in the same directory would be easier than having to check an account. I've actually set up a filter in GMAIL for the Filebot email so it's not a problem, but would be easier if all I had to do was click on a bookmark in Dolphin browser on the tablet. I can always wait. I think it should be an added feature instead of replacing the email entirely, so waiting isn't an issue. I already tried to figure out what to do but can't find anything on the net that was easy to understand. I'm mostly a copy'n'paste type person, I have a little programming experience from college, but my knowledge has pretty much evaporated and it wasn't in JAVA, so wouldn't of been much help.
ptatwridfw
Posts: 1
Joined: 20 Aug 2013, 03:39

Re: [Script] Email yourself missing and upcoming episodes

Post by ptatwridfw »

bonelifer wrote:G_G inks could you possibly add a new function so that it can be called to instead write out the html in a directory on the computer? I keep a cheap($27.00 shipped 7" dbuying.com android tablet in the living room) and it would be nice to check via the Dolphin web browser in those cases.
Agree! Android tablet would be nice to check via the Dolphin web browser.
jaykumar
Posts: 3
Joined: 27 Jun 2013, 18:00

Re: [Script] Email yourself missing and upcoming episodes

Post by jaykumar »

I need this script, don't see the attachment in the thread. Can someone please upload it somewhere?

Thanks in advance.
G_G inks
Power User
Posts: 8
Joined: 04 Mar 2013, 10:34

Re: [Script] Email yourself missing and upcoming episodes

Post by G_G inks »

jaykumar wrote:I need this script, don't see the attachment in the thread. Can someone please upload it somewhere?

Thanks in advance.
https://github.com/Ginkss/MissingEpisodes

I've stop using this script. Sickbeard does a similar enough thing right out of the box that it's not worth maintaining it.
Post Reply