Page 1 of 1

[AMC]Find whether content is TV Series or Movie from cmdline

Posted: 18 May 2016, 06:50
by Arion
I wanted to change the way filebot sent Pushbullet notifications so I used a CLI tool for pushbullet and used this hook to send me notifications:

Code: Select all

--def "exec=pushbullet -apikey \"apikey\" -title \"[Filebot] New episode of {n} is here! \" -message \"{s00e00} - {t} has been downloaded.\""
Now I want filebot to send me different notifications based on whether the content is a TV Series or a Movie.

I tried using this below code in a batch file and calling the batch file from "exec=/path/to/batch" but it turns out calling a batch file doesn't parse the filebot arguments.

Code: Select all

@echo off
title PUSHBULLET

IF "%$group%" == "tvs" goto tvs
IF "%$group%" == "mov" goto mov

:tvs
pushbullet -apikey "apikey" -title "[Filebot] New episode of {n} is here! " -message "{s00e00} - {t} has been downloaded."

:mov
pushbullet -apikey "apikey" -title "[Filebot] The movie {n} has been downloaded! " -message "Ready to be watched."

exit
So I was wondering if I can use an IF-ELSE statement within the "exec=" statement to find whether the content is TV Series or Movie and send a different message for each of them.

Re: [AMC]Find whether content is TV Series or Movie from cmd

Posted: 18 May 2016, 07:46
by rednoah
This will give you either "Movie" or "Episode":

Code: Select all

{movie; 'Movie'}{episode; 'Episode'}
Also, you could pass the {json} value to your shell script and figure it out there:

Code: Select all

{json}

Re: [AMC]Find whether content is TV Series or Movie from cmd

Posted: 18 May 2016, 10:47
by Arion
Is this how I use it?

Code: Select all

--def "exec={movie; 'pushbullet -apikey \"apikey\" -title \"The movie {n} has been downloaded!\" -message \"Ready to be watched.\"'}"
It doesn't seem to work so I guess I'm on the wrong track here.

Re: [AMC]Find whether content is TV Series or Movie from cmd

Posted: 18 May 2016, 10:54
by rednoah
I'd start with this:

Code: Select all

--def "exec=echo {movie; 'Movie'}{episode; 'Episode'}"
When in doubt, open the Format Editor and play with it. ;)


Also, you probably want to avoid passing complex arguments on the command-line: viewtopic.php?f=3&t=3244

Re: [AMC]Find whether content is TV Series or Movie from cmd

Posted: 18 May 2016, 12:21
by Arion
In your above script, whatever's inside the single quotes {movie; 'movie'} is pushed as it is and doesn't work with the filebot parameters. How do I make it work?

I need a different messages pushed depending on whether the content is tv series/movie.

Re: [AMC]Find whether content is TV Series or Movie from cmd

Posted: 18 May 2016, 12:30
by rednoah
1. Have you tried using the Format Editor? What did you learn?
2. Have you tried using my snipped to see what it does? What did you learn?

e.g.

Code: Select all

...
Parameter: exec = echo 'This is a {movie; 'Movie'}{episode; 'Episode'}'
Input: Avatar 2009.mp4
Input: Firefly - 1x01.mp4
...
Processed 1 files
Execute: echo 'This is a Movie'
This is a Movie
Execute: echo 'This is a Episode'
This is a Episode

Re: [AMC]Find whether content is TV Series or Movie from cmd

Posted: 18 May 2016, 12:52
by Arion
So I can set it to send me a push like

"The movie/episode has been downloaded" but I want it to contain the filename as well like I mentioned in the OP:

If episode-
-title "[Filebot] New episode of {n} is here! " -message "{s00e00} - {t} has been downloaded."

If movie-
-title "[Filebot] The movie {n} has been downloaded!" -message "Ready to be watched."

How do I access the Format Editor? There's no program in the filebot directory and I couldn't find anything in the GUI as well.

UPDATE: Nevermind, found the format editor. But how do I set the {movie; 'Movie'}{episode; 'Episode'} line to work with filebot parameters?

Re: [AMC]Find whether content is TV Series or Movie from cmd

Posted: 18 May 2016, 18:54
by Arion
Is there a solution for this?

Re: [AMC]Find whether content is TV Series or Movie from cmd

Posted: 18 May 2016, 19:21
by rednoah
Yes. I gave you all the puzzle pieces. Copy & pasting it together is your job. ;)


PS: I am known to indulge the lazy people, if said lazy people were to click the donate button :lol:

Re: [AMC]Find whether content is TV Series or Movie from cmd

Posted: 18 May 2016, 19:27
by Arion
I'm using this for testing movies:

Code: Select all

--def "exec=pushbullet -apikey \"apikey\" -title \"{movie; {ny}}{episode; 'Episode'} is here! \" -message \"{movie; {ny}}{episode; 'Episode'}has been downloaded\""
And it's returning this error:

Code: Select all

SyntaxError: Ambiguous expression could be either a parameterless closure expression or an isolated open code block

Re: [AMC]Find whether content is TV Series or Movie from cmd

Posted: 18 May 2016, 19:32
by Arion
I'm not lazy man, I just need some time to figure things out. I got this far solely from your AMC threads and cmdline manuals, I just need to figure out the proper syntax.

You didn't mention anywhere about the {movie; 'Movie'}{episode; 'Episode'} line in your man pages so I had no way of knowing it existed. I just need to know proper syntax to parse filebot arguments like {n} and {s00e00} in side the {movie; }{episode; } line.

Re: [AMC]Find whether content is TV Series or Movie from cmd

Posted: 18 May 2016, 20:03
by rednoah
1. Prototype in the Format Editor (live preview helps with learning)
2. Copy exec format expression into text file
3. Use --def exec=@/path/to/exec-format.txt (so you don't have to deal with command-line escaping)


Learn how FileBot Formats work:
http://www.filebot.net/naming.html


Learn why {movie; 'Movie'} works the way it works:
viewtopic.php?f=5&t=1895


Here's one more puzzle piece ;)

Code: Select all

{"$movie has been downloaded."}
You'll probably be happy with just this though :lol:

Code: Select all

{movie}{episode} has been downloaded.

Re: [AMC]Find whether content is TV Series or Movie from cmd

Posted: 23 May 2016, 18:26
by Arion
Hey! So I figured it out this weekend.

For Pushbullet, I'm using an unofficial CLI tool built by dendory [https://github.com/dendory/pushbullet_cli]. I added the pushbullet.exe I got from the repo to my System32 folder.

Using

Code: Select all

--def "exec=@Path/to/args.txt"
I don't need to mess around with escape characters anymore, thanks to rednoah.

This is what my args.txt contains:

Code: Select all

pushbullet -apikey "Your-apikey" -title "{movie}{episode; n}" -message "{movie; 'The movie'}{episode; s00e00}{episode; ' - '}{episode; t} is ready."
The output of the message is:
1. TV SERIES:
Title: SeriesName
Message: s00e00 - t is ready.

2. MOVIE:
Title: MovieName (y)
Message: The movie is ready.

Example:
1. TV SERIES:
Title: Daredevil
Message: S02E04 - Penny and Dime is ready.

2. MOVIE:
Title: Deadpool (2016)
Message: The movie is ready.

Since I couldn't fit "s00e00 - t" inside a single {episode} expression, I used three of them to properly space and separate the episode no. and episode title.

Thanks for the great help you've been, Rednoah :)

I've been wondering if I download an entire season, Can I send a push telling me that "{Season+'s'} has been downloaded"?