AniAdd: Difference between revisions

2,395 bytes added ,  1 January 2016
m
Der Idiot moved page User talk:Dvdkhl to AniAdd without leaving a redirect
m (Der Idiot moved page User talk:Dvdkhl to AniAdd without leaving a redirect)
 
(37 intermediate revisions by 3 users not shown)
Line 12: Line 12:
And there will be a lot of examples I promise.
And there will be a lot of examples I promise.


If you want a quick tour:
If you want a quick tour:<br />
Goto the example section copy paste the code there into the codebox (client) and play with it a bit.
Goto the example section copy paste the code there into the codebox (client) and play with it a bit.
If there is something you don't understand, come back here and goto the relevant section for explanations.
If there is something you don't understand, come back here and goto the relevant section for explanations.
Line 26: Line 26:




The following CFG evaluates to all possible syntactical correct "programs" (new & non-public version):
The following CFG evaluates to all possible syntactical correct "programs" (new & not yet public version):
  START -> ASSIGN '/n' START | ASSIGN
START -> ASSIGN [COMMENT] '\n' START | ASSIGN [COMMENT]
  ASSIGN -> (NAME ':=' )+ EXPRLST | NAME'(' [NAME (, NAME)* ] ')'
START -> [COMMENT|COMMENTBLOCK] '\n' START | [COMMENT|COMMENTBLOCK] '\n'
  EXPRLST -> EXPR EXPRLST | EXPR
ASSIGN -> (NAME ':=' )+ EXPRLST | NAME'(' [NAME (, NAME)* ] ')'
  EXPR -> FIRSTAVAIL | IFTHENELSE | FUNCTION | VARIABLE | STRING | COMMENT
EXPRLST -> [COMMENTBLOCK] (EXPR EXPRLST | EXPR) [COMMENTBLOCK]
  FIRSTAVAIL -> '[' EXPRLST ( ',' EXPRLST )* ']'
EXPR -> FIRSTAVAIL | IFTHENELSE | FUNCTION | VARIABLE | STRING
  IFTHENELSE -> '{' EXPRLST '=' EXPRLST '?' EXPRLST ':' EXPRLST '}'
FIRSTAVAIL -> '[' EXPRLST ( ',' EXPRLST )* ']'
  FUNCTION -> '$'NAME'(' EXPRLST ( ',' EXPRLST )* ')'
IFTHENELSE -> '{' EXPRLST '=' EXPRLST '?' EXPRLST ':' EXPRLST '}'
  VARIABLE -> '%'NAME'%'
FUNCTION -> '$'NAME'(' EXPRLST ( ',' EXPRLST )* ')'
  STRING -> ('"'<Any string exept ">'"') | ("'" <Any string exept '> "'")
VARIABLE -> '%'NAME'%'
  NAME -> < Any String without the following characters := []'{}(),"%$? >
STRING -> ('"'<Any string except ">'"') | ("'" <Any string except '> "'")
  COMMENT -> #< Any string >
NAME -> < Any String without the following characters := []'{}(),"%$? >
COMMENT -> #< Any string >
COMMENTBLOCK -> /*< Any string >*/


Note:
Note:
* Any string within '' is a terminal, all capital words are non-terminals
* Any string within ' ' is a terminal, all capital words are non-terminals
* To simplify the CFG, possible (redundant) spaces aren't represented as terminals. (Every unquoted space within the CFG represents any count of spaces)
* To simplify the CFG, possible (redundant) spaces aren't represented as terminals. (Every unquoted space within the CFG represents any count of spaces)
* * stands for any count of repetition of the preceding element (including 0 repetitions)
* * stands for any count of repetition of the preceding element (including 0 repetitions)
Line 50: Line 52:
=== Basics ===
=== Basics ===
'''The Code'''<br />
'''The Code'''<br />
Every line you write is independent from the other lines, which means you don't have to worry about the other ones. (Not the complete truth, I'll see why soon)
Every line you write is independent from the other lines, which means you don't have to worry about the other ones. (Not the complete truth, you'll see why soon)


Every line begins with the Assign construct, which consists of a variable name and an expression list.
Every line begins with the Assign construct, which consists of a variable name and an expression list.
The expression list is evaluated and then assigned to the new created variable, with the name which was specified.
The expression list is evaluated and then assigned to the new created variable, with the name which was specified.


Those variables can be used in the following lines.
Those variables can be retrieved on the next lines.
This way you can structure & simplify you code.
This way you can structure & simplify your code.
(If you wanted you could write everything in a single line, but it would be very hard to read and error prone)
(If you wanted you could write everything in a single line, but it would be very hard to read and error prone)


Line 84: Line 86:
   AnotherVar := YetAnother := "Another Expression list"
   AnotherVar := YetAnother := "Another Expression list"


Not yet public
It is also possible to create functions:
It is also possible to create functions:
To create a function instead of a variable, the variablename is followed by <tt>'()'</tt>.
To create a function instead of a variable, the variable name is followed by <tt>'()'</tt>.
The parenthesis my contain parameters seperated by a comma (same naming conventions as variablename applies).
The parenthesis my contain parameters separated by a comma (same naming conventions as variable name applies).
The parameters are only accessible within the function and don't change the 'main' variables in any way.
The parameters are only accessible within the function and don't change the 'main' variables in any way.


Line 94: Line 95:
   AnotherFunc(a, b) := %a% %b%
   AnotherFunc(a, b) := %a% %b%
To use the new defined function see Function construct
To use the new defined function see Function construct


==== Condition ====
==== Condition ====
Line 107: Line 107:


If you want to test if something is empty, the second value and the equal sign can be omitted.
If you want to test if something is empty, the second value and the equal sign can be omitted.
''Example:''
''Example:''
   SomeVar := "Bla"
   SomeVar := "Bla"
Line 113: Line 114:
''Other Example:''
''Other Example:''
   SomeVar := "4"
   SomeVar := "4"
   MyVar := {%SomeVar% = "1" ? "One" : {%SomeVar% = "2" ? "Two" : {%SomeVar% = "3" ? "Three" : "Zero or lower; Four or bigger" } } }
   MyVar := {%SomeVar%="1"?"One": {%SomeVar%="2"?"Two": {%SomeVar%="3"?"Three":"Zero or lower; Four or bigger"} } }
 


==== Choose ====
==== Choose ====
Line 146: Line 146:


''Example:''
''Example:''
   Func(a) := "[" %a% "]"
   Max4(a,b,c,d) := $max($max(a,b), $max(c,d))
   GroupName := $Func(%GrpName%)
   HighestNum := $Max4("0","3","6","20")
 


==== Variable ====
==== Variable ====
Line 171: Line 170:


==== Comment ====
==== Comment ====
Not public yet
Anything after a <tt>#</tt> is ignored and may be used to comment code sections.
Anything after a <tt>#</tt> is ignored and may be used to comment code sections.


Line 177: Line 175:
   #Get prefered language
   #Get prefered language
   PreferedTitle := [%E%, %R%, %K%] #English, Romaji, Kanji
   PreferedTitle := [%E%, %R%, %K%] #English, Romaji, Kanji


=== Predefined Variables ===
=== Predefined Variables ===
==== Titles ====
==== Titles ====
* ATr, ATe, ATk - Anime title, r: romaji, e: english, k: kanji
* ATr, ATe, ATk, ATs, ATo - Anime title, r: romaji, e: english, k: kanji, s: synonym, o: other
* ETr, ETe, ETk - Episode title, languages as above
* ETr, ETe, ETk - Episode title, languages as above
* GTs, GTl - Group title, s: short, l: long
* GTs, GTl - Group title, s: short, l: long
Line 188: Line 185:
* EpHiNo - Highest (subbed) episode number
* EpHiNo - Highest (subbed) episode number
* EpCount - Anime Episode count
* EpCount - Anime Episode count
* AYearBegin, AYearEnd - The beginning & ending year of the anime
* ACatList - The Categories associated with the anime.
==== Episode information ====
* EpNo - File's Episode number


==== File information ====
==== File information ====
Line 194: Line 197:
* Cen - File is censored if the value is '1'
* Cen - File is censored if the value is '1'
* Ver - File version
* Ver - File version
* Source - Where the file came from (HDTV, DTV, WWW, etc)
* Quality - How good the quality of the file is (Very Good, Good, Eye Cancer)
* AniDBFN - Default AniDB filename
* CurrentFN - Current Filename
* FCrc - The file's crc
* FVideoRes - Video Resolution (e.g. 1920x1080)
* FALng - List of available audio languages (japanese, english'japanese'german)
* FSLng - List of available subtitle languages (japanese, english'japanese'german)
* FACodec - Codecs used for the Audiostreams
* FVCodec - Codecs used for the Videostreams
* Watched - File is watched if the value is '1' otherwise unwatched and ""


More predefined variables will be added on request.
More predefined variables will be added on request.


=== Predefined Functions ===
=== Predefined Functions ===
* NUM $max(NUM, NUM) - Both NUMs need to be numerical string. Returns the greater NUM
* NUM $min/max(NUM, NUM) - Both NUMs need to be numerical string. Returns the smaller/greater NUM
* NUM $len(STR) - Returns a numerical string represinting the character count of STR
* NUM $len(STR) - Returns a numerical string represinting the character count of STR
* STR $pad(STR, NUM, CHAR) - STR: String to be padded, NUM min string length, CHAR: The character used to pad the string
* STR $pad(STR, NUM, CHAR) - STR: String to be padded; NUM min string length; CHAR: The character used to pad the string
* STR $repl(SRC, REGEX, REPL) - SRC: Source, REGEX: Regex used to match, REPL: replaces every match with REPL
* STR $repl(SRC, REGEX, REPL) - SRC: Source; REGEX: Regex used to match; REPL: replaces every match with REPL
* STR $match(STR, REGEX) STR: Source; REGEX: Match; Returns "1" if STR has a match for REGEX, otherwise unwatched and ""
* STR $uc/lc(STR) Convert string to uppercase/lowercase
* NUM $add/sub/mul/div(NUM, NUM) Add/Substract/Multiply/Divide two numerical strings
* STR $substr(STR, NUM[, NUM]) Returns the substring beginning from seconds param index to end or optionally to the third param index
* NUM $[l]indexof(STR, STR) Returns the first/last index of the substring specified in the second param in the first param string, -1 if there are no occurrences.


More predefined functions will be added on request.
More predefined functions will be added on request.
Line 245: Line 264:
Why not write write <tt>EpNoPad := $pad(%EpNo%, $len(%EpCount%), "0")</tt> and be done with it?
Why not write write <tt>EpNoPad := $pad(%EpNo%, $len(%EpCount%), "0")</tt> and be done with it?
There are a lot of ongoing anime series where the <tt>EpCount</tt> variable is not yet available.
There are a lot of ongoing anime series where the <tt>EpCount</tt> variable is not yet available.
In that case <tt>EpCount</tt> would contain the variable <tt>"0"</tt> (Think of Gintama, Conan etc.) and
In that case <tt>EpCount</tt> would contain the value <tt>"0"</tt> (Think of Gintama, Conan etc.) and
padding would never occur (well it would after its episode count is set).
padding would never occur (well it would after its episode count is set).
Now <tt>EpHiNo</tt> comes to the rescue: It contains the highest released episode number.
Now <tt>EpHiNo</tt> comes to the rescue: It contains the highest released episode number.
Now we only need to determine which one is longer, and pass it to the <tt>pad</tt> function,
Now we only need to determine which one is longer, and pass it to the <tt>pad</tt> function,
what is exactly what we have done in the example.
what is exactly what we have done in the example.


=== Different formats for Movies & TV Series ===
=== Different formats for Movies & TV Series ===
Line 269: Line 287:
   Depr := {%Depr% ? "[Depr]" : ""}
   Depr := {%Depr% ? "[Depr]" : ""}
Here the predefined variables are overwritten with formatted ones:
Here the predefined variables are overwritten with formatted ones:
<tt>Ver</tt> is <tt>""</tt> when it is version 1 otherwise <tt>"v"%Ver%</tt>
<tt>Ver</tt> is <tt>""</tt> when it is version 1 otherwise <tt>"v"%Ver%</tt><br />
<tt>Cen</tt> is <tt>""</tt> if it is not censored otherwise <tt>"[Cen]"</tt>
<tt>Cen</tt> is <tt>""</tt> if it is not censored otherwise <tt>"[Cen]"</tt><br />
<tt>Depr</tt> is <tt>""</tt> if it is not deprecated otherwise <tt>"[Depr]"</tt>
<tt>Depr</tt> is <tt>""</tt> if it is not deprecated otherwise <tt>"[Depr]"</tt>


=== Replacing invalid characters ===
=== Replacing invalid characters ===
Line 282: Line 299:
Look up the <tt>repl</tt> function in the Predefined Functions section.
Look up the <tt>repl</tt> function in the Predefined Functions section.
If you don't feel like learning a bit regex (the seconds parameter),
If you don't feel like learning a bit regex (the seconds parameter),
everything within the <tt>[]</tt> brackets is replaced by the third parameter.
every character within the <tt>[]</tt> brackets are replaced by the third parameter.


=== Piecing everything together ===
AT:=[%ATr%,%ATe%,%ATk%]
ET:=[%ETe%,%ETr%,%ETk%]
GT:="[" [%GTs%,%GTl%] "]"
EpNoPad:=$pad(%EpNo%,$max($len(%EpHiNo%),$len(%EpCount%)),"0")
Src:="["%Source%"]"
Depr:={%Depr%?"[Depr]":""}
Cen:={%Cen%?"[Cen]":""}
Ver:={%Ver%="1"?"":"v"%Ver%}
Movie := %AT%" - "%ET%" "%GT% %Depr% %Cen% %Src% %Ver%
Other := %AT%" "%EpNoPad% %Ver% " - "%ET%" "%GT% %Depr% %Cen% %Src%
FileName:= {%Type% = "Movie"? %Movie% : %Other%}
PathName:="E:\My\Path\Name\" $repl(%AT%,'[\\":/*|<>?]',"")


=== Piecing everything together ===
== Presets ==
Original preset with few tweaks. Filename as [group] [title] <epno><version> [uppercase CRC] [source][resolution][video codec].ext
Episode number isn't used only for normal episodes in animes with only 1 of those, but always used is special eps regardless of total eps.
   AT:=[%ATr%,%ATe%,%ATk%]
   AT:=[%ATr%,%ATe%,%ATk%]
   ET:=[%ETe%,%ETr%,%ETk%]
   ET:=[%ETe%,%ETr%,%ETk%]
Line 292: Line 328:
   EpNoPad:=$pad(%EpNo%,$max($len(%EpHiNo%),$len(%EpCount%)),"0")
   EpNoPad:=$pad(%EpNo%,$max($len(%EpHiNo%),$len(%EpCount%)),"0")
    
    
   Src:="["%Source%"]"
   Src:="["$repl(%Source%,"B-R","BluRay")"]"
   Depr:={%Depr%?"[Depr]":""}
   Ver:={%Ver%="1"?"":"v"%Ver%}
   Cen:={%Cen%?"[Cen]":""}
   Res:="["%FVideoRes%"]"
   Ver:={%Ver%="1"?"":"v"%Ver%}
  CRC:="["$uc(%FCrc%)"]"
   Codec:="["$repl(%FVCodec%,"H264/AVC","h264")"]"
    
    
   Movie := %AT%" - "%ET%" "%GT% %Depr% %Cen% %Src% %Ver%
   IsNotNormal:=$match($repl(%EpNo%,"[1234567890]",""),'[SCTPO]')
   Other := %AT%" "%EpNoPad% %Ver% " - "%ET%" "%GT% %Depr% %Cen% %Src%
   EpNoV:={%IsNotNormal%="1"?"- "%EpNoPad%:{%EpCount%="1"?:"- "%EpNoPad%}}
    
    
   FileName:= {%Type% = "Movie"? %Movie% : %Other%}
   FileName:=$repl(%GT%" "%AT%" "%EpNoV%%Ver%" "%CRC%" "%Src% %Res% %Codec%,"  "," ")
   PathName:="E:\Anime\!Processed\" $repl(%AT%,'[\\":/*|<>?]',"")
   PathName:="F:\" $repl(%AT%,'[\\\":/*|<>?]',"")
 
== Presets ==
MediaWiki spam blocked by CleanTalk.
MediaWiki spam blocked by CleanTalk.