if %variable% or $function ?


#1

I'm writing a source script for TheTVDB. Unfortunately, their API does not allow a search for a specific season. You can search for a show, a specific episode, or all of it.

The docs are a bit unclear on how to use If statements - there is a $if, but not closing $endif for a code block. 'If' is a bit annoying to search for, so I'm sorry if this has been answered already.

Anyway. As with most people, my shows are organized thusly:

W:\_TV\Show
+--Season 1
|  +--Show S01E01 - Pilot.m4v
|  +--Show S01E02 - Title2.m4v
\--Season 2
   +--Show S02E01 - Title1.m4v
   +--Show S02E02 - Title2.m4v

As it stands, my source script works fine, but it shows all the episodes ever - as a result, I a) have to manually nudge the files into the appropriate location, and :sunglasses: cannot set the appropriate COVERURL for the season.

My index SearchBy field looks like this:

[SearchBy]=$replace(%_parent_directory%, ,+)+$replace(%_directory%,Season ,)

In the album area, I would like to do this :

FindLine "<Episode>"
Do
    JoinUntil "</Episode>"
    FindLine "<SeasonNumber>"
    FindInLine "<SeasonNumber>"
    If $replace(%_directory%,Season ,)
        Only do this if the season matches
    endif
While blah

Instead of a direct string, that If statement compares the current position with the return value of $Replace. Is that possible at all?


#2

No.


#3

Okay, thanks. I'd concluded as much after downloading multiple scripts and seeing no such code. Oh well.


#4
QUOTE (Laga Mahesa @ May 12 2013, 06:53) <{POST_SNAPBACK}>
FindLine ""
 Do
     JoinUntil "</Episode>"
     FindLine "<SeasonNumber>"
     FindInLine "<SeasonNumber>"
     If $replace(%_directory%,Season ,)
         Only do this if the season matches
     endif
 While blah<!--QuoteEnd--></div><!--QuoteEEnd-->

A workaround:
Since $replace(%_directory%,Season ,) has a limited ouput (numbers from 1 to 30 (i guess), 1 to 10 will do in most cases), you could copy your scirpt when it is finished and do different versions for each season number, like:

TheTVDB#Season &1.src
TheTVDB#Season &2.src
TheTVDB#Season &3.src
...


#5

Yeah, I'll probably do that, thanks. Right now I'm just leaving it as a single file and fiddling with the delightful 'shift up/down buttons' (delightful because using them with multiple tracks moves them multiple rows) as TheTVDB is a fallback in case iTunes doesn't have the series.