AniDB O'Matic - Documentation: Local file renaming: Difference between revisions

From AniDB
Jump to navigation Jump to search
Line 122: Line 122:


{|
{|
|-
|colspan=3|'''A / ANIME'''
! scope="col" width="180" | Name
! scope="col" width="180" | Name
! scope="col" width="60" | Type
! scope="col" width="60" | Type
! scope="col" | Description
! scope="col" | Description
|-
|colspan=3|'''A / ANIME'''
|-valign=top
|-valign=top
|Category||integer||Anime Type<br>
|Category||integer||Anime Type<br>

Revision as of 13:07, 28 May 2011

File renaming patterns

AoM contains a comprehensive number of patterns to fully customize file names and paths. In order for the pattern to allow very complex rules it essentially allows light scripting. The path can be a complete path or a partial path, in case of a partial path the current file manager is used to place the file based on a known root or from the root folder of the file manager, see file managers below for more details. File extensions are automatically added to the end of the pattern.

Sample patters

English anime title with fallback

set('atitle', at('en'))
if(length(atitle)=0, set('atitle', at('x-jat')))
if(length(atitle)=0, set('atitle', at('ja')))
if(length(atitle)=0, set('atitle', A.Name))

Japanese transcription anime title with fallback

set('atitle', at('x-jat'))
if(length(atitle)=0, set('atitle', at('en')))
if(length(atitle)=0, set('atitle', A.Name))

Japanese kanji anime title with fallback

set('atitle', at('ja'))
if(length(atitle)=0, set('atitle', at('x-jat')))
if(length(atitle)=0, set('atitle', at('en')))
if(length(atitle)=0, set('atitle', A.Name))

English episode title with fallback

set('etitle', et('en'))
if(length(etitle)=0, set('etitle', et('x-jat')))
if(length(etitle)=0, set('etitle', et('ja')))
if(length(etitle)=0, set('etitle', E.Name))

Japanese transcription episode title with fallback

set('etitle', et('x-jat'))
if(length(etitle)=0, set('etitle', et('en')))
if(length(etitle)=0, set('etitle', E.Name))

Japanese kanji episode title with fallback

set('etitle', et('ja'))
if(length(etitle)=0, set('etitle', et('x-jat')))
if(length(etitle)=0, set('etitle', et('en')))
if(length(etitle)=0, set('etitle', E.Name))

File version

set('version', if(F.Version>1, 'v'+F.Version,))

Padded episode number

set('mepno', max(A.TotalEpisodeCount, E.EpisodeTypeCount))
set('epno', padl(E.EpisodeNo, max(1, length(mepno)), '0'))
if(E.TypeId=2, set('epno', 'S'+epno))
if(E.TypeId=3, set('epno', 'C'+epno))
if(E.TypeId=4, set('epno', 'T'+epno))
if(E.TypeId=5, set('epno', 'P'+epno))
if(E.TypeId=6, set('epno', 'O'+epno))

First letter for organizing by letter

set('head', copy(atitle, 1, 1))
if(numeric(head), set('head', '0-9'))

Group name

set('groupname', if(G, if(length(G.Name)>0, G.Name, G.Shortname), 'no group'))
set('groupname', if(length(groupname)>0, '['+groupname+']'))

Group short name

set('groupname', if(G, if(length(G.Shortname)>0, G.Shortname, G.Name), 'no group'))
set('groupname', if(length(groupname)>0, '['+groupname+']'))

CRC32

set('crc', if(H, H.Crc32, F.Crc))
if(length(crc)>0, set('crc', '('+uc(crc)+')')

Default pattern

set('atitle', at('x-jat'))
if(length(atitle)=0, set('atitle', at('en')))
if(length(atitle)=0, set('atitle', A.Name))
set('atitle', replace(atitle, '\', ' '))
set('etitle', et('en'))
if(length(etitle)=0, set('etitle', et('x-jat')))
if(length(etitle)=0, set('etitle', et('ja')))
if(length(etitle)=0, set('etitle', E.Name))
set('etitle', replace(etitle, '\', ' '))
set('version', if(F.Version>1, 'v'+F.Version, ''))
set('mepno', max(A.TotalEpisodeCount, E.EpisodeTypeCount))
set('epno', padl(E.EpisodeNo, max(1, length(mepno)), '0') + version)
if(E.TypeId=2, set('epno', 'S'+epno))
if(E.TypeId=3, set('epno', 'C'+epno))
if(E.TypeId=4, set('epno', 'T'+epno))
if(E.TypeId=5, set('epno', 'P'+epno))
if(E.TypeId=6, set('epno', 'O'+epno))
set('groupname', if(G, if(length(G.Shortname)>0, G.Shortname, G.Name), 'no group'))
set('groupname', if(length(groupname)>0, '['+groupname+']'))
set('groupname', replace(groupname, '\', ' '))
set('crc', if(H, H.Crc32, F.Crc))
if(length(crc)>0, set('crc', '('+uc(crc)+')'))
set('filename', limit(limit(limit(atitle, 90) + ' - ' + epno + ' - ' + etitle, 200) + ' ' + groupname, 235) + crc + '.' + F.FileType)
set('filename', replace(filename, '*', ' '))
set('filename', replace(filename, '/', ' '))
set('filename', replace(filename, '?', ' '))
set('filename', replace(filename, ':', ' '))
set('filename', replace(filename, '"', ' '))
set('filename', replace(filename, '<', ' '))
set('filename', replace(filename, '>', ' '))
set('filename', replace(filename, '|', ' '))
set('filename', replace(filename, '`', "'"))
set('filename', replace(filename, '  ', ' '))
filename

Objects

A / ANIME Name Type Description
Category integer Anime Type

1: Unknown
2: TV Series
3: OVA
4: Movie
5: Other
6: Web
7: TV Special
8: Music Video

CategoryStr string Category text value.
Name string Anime main title
ReviewAverage integer Average review score
ReviewCount integer Total number of reviews
TotalEpisodeCount integer Number of episodes according to AniDB. 0 if unknown.
VoteAverage integer Average voter score
VoteCount integer Total number of votes
Year string Anime airing year(s). For example 2007-2008.
EpisodeCount integer Number of normal episodes according to AoM.
SpecialEpisodeCount integer Number of special episodes according to AoM.
DownloadState String Current download state according to AoM:

adsIgnore: not yet calculated
adsComplete: have all normal episodes
adsHaveAll: have all available normal episodes
adsIncomplete: have some of the available normal episodes
adsHaveNone: have no files in mylist for this anime

WatchedState string Current watched state according to AoM:

awsIgnore: not yet calculated
awsAll: All episodes watched
awsPartial: Some episodes watched
awsNone: No episodes watched

StatusState string Current status of mylist entries according to AoM, my contain multiple values separated by commas:

assIgnore: not yet calculated
assUnknown: Uknown
assOnHDD: On HDD
assOnCD: On CD
assDeleted: Deleted

StartYear integer Numeric start year from AirDate.
EndYear integer Numeric end year from EndDate.
AirDate integer Air date in unix time, AniDB format.
EndDate integer End date in unix time, AniDB format.
Restricted boolean True for hentai, otherwise false.
MylistCurrentEpisodeCount integer Number of episodes in mylist.
MylistSpecialEpisodeCount integer Number of special episodes in mylist.
WatchedCount integer Number of episodes watched.
SpecialWatchedCount integer Number of special episodes watched.
E / EPISODE
AirDate integer Episode first air date.
EpisodeNo integer AniDB episode number.
EpisodeStr string Episode number with type prefix.
EpisodeStrPadded string Episode number with type prefix padded based on the total number of episodes of that particular type.
EpisodeTypeCount integer Number of episodes in this anime with the same type.
IsSpecial boolean True if not a normal episode. False otherwise.
Length integer Length in minutes.
Name string AniDB main title.
Other string Description field from AniDB.
TypeId integer Episode type:

1: Regular Episode
2: Special
3: Opening/Ending/Credits
4: Trailer/Promo/Ads
5: Parody/Fandub
6: Other

IsRecap boolean True if episode is a recap.
F / FILE
Crc string AniDB CRC32 value.
CrcStatus string CRC32 status according to AnIDB:

crcUnknown: unkwnown
crcOk: known valid
crcInvalid: known invalid

Ed2k string AniDB ED2K value.
EpisodeStart integer Lowest related episode number of the same type within this anime.
EpisodeEnd integer Highest related episode number of the same type within this anime.
EpisodeList integer List of episodes within this anime covered by this file. Format: 1,2,3,7,17,93,O1,C3,U77
FileType string File extension.
Length integer File length in seconds.
Md5 string AniDB MD5 value.
Other string File description.
Quality integer File quality, possible values:

unknown
very high
high
med
low
very low
corrupted
eyecancer

Released integer Release date in unix time.
ResolutionHeight integer Video height in pixels.
ResolutionWidth integer Video width in pixels.
Sha1 string AniDB SHA1 value.
Size int64 Size in bytes.
State integer AniDB state bitmap.
Source string Source media, possible values:

unknown
camcorder
TV
VHS
DTV
LD
DVD
SVCD
VCD
HKDVD
www
HDTV
HD-DVD
Blu-ray

TypeState integer Source ID.
UserCount integer Number of users with this file. (Wildly inaccurate.)
Version integer File version from state.
GroupShort string Short group name.
GroupLong string Long group name.
ResolutionString string Video WidthxHeight.
G / GROUP
Warning, this object might be unassigned. If so all values return False.
Name string Group name.
Other string Group description.
Rating integer Average vote rating for this group.
Shortname string Short group name.
Votes integer Number of votes for this group.
H / HASH
Warning, this object might be unassigned. If so all values return False.
Crc32 string AoM CRC32 value.
Ed2k string AoM ED2K value.
Md5 string AoM MD5 value.
Sha1 string AoM SHA1 value.
Size integer AoM size in bytes.
M / MYLIST
Warning, this object might be unassigned. If so all values return False.
Other string Entry other/description text.
Source string Entry source text.
State integer Entry state, possible values:

0: unknown
1: internal storage (hdd)
2: external storage (cd/dvd/...)
3: deleted

Storage string Entry storage text.
Watched boolean True if watched, otherwise false.
WatchedDate integer Watched date in unixtime.

Properties

PATH string Current path to the file. May be .
BASEPATH string Base path of the current file manager. May be .

Functions

at(lang) text Returns a main/official anime title in lang. lang can be either a text or a number.
Example: at(2) = japanese title
Example: at('japanese (transcription)') = japanese transcription
Example: at('en') = english title
contains(find, text) boolean Returns true if find is found in text.
Example: contains('bcd', 'abcdef') = true
copy(text, start[, length]) string Returns length letters from letter number start of text.
Example: copy('abcdefgh', 3, 2) = 'cd'
et(lang) text Returns an episode title in lang. lang can be either a text or a number.
Example: et(2) = japanese title
Example: et('en') = english title
if(test, trueval[, falseval]) any If statement, returns trueval if test is true, otherwise returns falseval.
Example: if(23=23, 'equal', 'not equal') = 'equal'
in(find, text...) boolean Checks if find is present in a number of text parameters.
Example: in('bb', 'aa', 'bb', 'cc', 'dd') = true
join(glue, text...) string Joins together two or more texts, empty parameters are ignored with no glue added.
Example: join(' ', 'a', 'b', 'c') = 'a b c'
lc(text) string Converts text to lower case.
Example: lc('ABCDEF') = 'abcdef'
length(text) number Returns the length of text.
Example: length('abcdef') = 6
limit(text, length[, end]) string Limits the length of text to at most length characters. End is optional, if specified and the text is cropped, it'll be added at the end of text.
Example: limit(e, 100) or limit('abcdefghijklmnop', 7, '...') = 'abcd...'
max(number...) number Returns the highest supplied number
Example: max(1, 7, 3, 9, 2) = 9
min(number...) number Returns the lowest supplied number
Example: min(1, 7, 3, 9, 2) = 1
numeric(var) boolean Returns true if var contains a numeric value.
Example: numeric('11') = true
pad(text, newlength[, padchar]) string Pads text on both sides to make it length characters long.
Example ?pad('hello', 9, '_') = '__hello__'
padl(text, newlength[, padchar]) string Pads text on the left side to make it length characters long.
Example ?padl('hello', 9, '_') = '____hello'
padr(text, newlength[, padchar]) string Pads text on the right side to make it length characters long.
Example ?padr('hello', 9, '_') = 'hello____'
replace(text, find[, replace]) string Replaces all occurences of find with replace in text.
Example: replace('HELLO THERE!', 'THERE', 'TREES') = 'HELLO TREES!'
replacei(text, find[, replace]) string Case insensitive replace of all occurences of find with replace in text.
Example: replace('HELLO tHeRe!', 'ThErE', 'TREES') = 'HELLO TREES!'
replacerepeat(text, find[, replace]) string Runs replace repeatedly until the result stops changing.
sc(text) string Converts text to sentence case.
Example: sc('HELLO THERE!') = 'Hello there!'
set(name, data) nothing Declares a new variable called name containing data.
Example: set('temp', 'text')
split(text, find, index) string Splits text on find and returns the specified index. Index starts from 1.
Example: split('2011-05-19', '-', 2) = 05
start(text, find) boolean Checks if find matches the start of text.
Example: start('1999', '199') = true
starti(text, find) boolean Checks if find matches the start of text. Case insensitive.
Example: start('1999', '199') = true
substr(text, start[, length]) string Alias for copy.
tc(text) string Converts text to title case.
Example: tc('HELLO THERE!') = 'Hello There!'
trim(text) string Removes leading and trailing spaces from text.
uc(text) string Converts text to upper case.
Example: uc('abcd') = 'ABCD'

Operators

Arithmetic operators

A+B returns A plus B
A-B returns A minus B
A*B returns A multiplied B
A/B returns A divided by B

Comparison operators

A=B true if A equals B
A<>B true if A does not equal B
A<B true if A is less than B
A>B true if A is more than B
A<=B true if A is less or equal to B
A>=B true if A is more or equal to B

Logical operators

A and B true if both A and B are true
A or B true if either A or B is true
A xor B true if either A or B is true but not both
not A true if A is false

Constant expressions

There are two ways to specify string literals:
'text'
or
"text"

Number literals are simply written as numbers:
1234

There are also boolean constants:
true
false

Comments

Start a line with // if you wish to write a comment:

// This is a comment

File managers

File managers are used to automatically manage file renaming / removing and adding / updating files in your MyList.