sweeper/webif/plugin/sweeper/macro.js

332 lines
6.7 KiB
JavaScript

var macros = {
seriesfiler: {
desc: 'Series-Filer',
rules: [
{
"raw": "action {fileunder ""}",
"name": "Emulate Seriesfiler",
"type": "folder",
"enabled": "1",
"criteria": [
{
"negate": 0,
"cmd": "series",
"arg": ""
}
],
"action": {
"cmd": "fileunder",
"arg": ""
}
}
]
},
newk: {
desc: 'Remove New: prefix',
rules: [
{
"raw": "title New:* action {settitle {%orig%regsub,New:\\s*,,}}",
"name": "Remove New: prefix.",
"type": "global",
"enabled": "1",
"criteria": [
{
"negate": 0,
"cmd": "title",
"arg": "New:*"
}
],
"action": {
"cmd": "settitle",
"arg": "%orig%regsub,New:\\s*,,"
}
},
{
"raw": "filename New_* action {renamefile {%orig%regsub,New_\\s*,,}}",
"name": "Remove New_ prefix.",
"type": "global",
"enabled": "1",
"criteria": [
{
"negate": 0,
"cmd": "filename",
"arg": "New_*"
}
],
"action": {
"cmd": "renamefile",
"arg": "%orig%regsub,New_\\s*,,"
}
}
]
},
dedup: {
desc: 'De-duplicate/tidy',
rules: [
{
"raw": "!flag Deduped intmatch {%episode~~> 0} action {set {newname=s%format:%02d:%series:e%format:%02d:%episode: - %epname}}",
"name": "For a new recording with detected episode number, create a new title and store it in the 'newname' variable",
"type": "file",
"enabled": "1",
"criteria": [
{
"negate": 1,
"cmd": "flag",
"arg": "Deduped"
},
{
"negate": 0,
"cmd": "intmatch",
"arg": "%episode~~> 0"
}
],
"action": {
"cmd": "set",
"arg": "newname=s%format:%02d:%series:e%format:%02d:%episode: - %epname"
}
},
{
"raw": "lastrule "" action {set newfile=%asfilename/%%newname/}",
"name": "Set the new filename too",
"type": "file",
"enabled": "1",
"criteria": [
{
"negate": 0,
"cmd": "lastrule",
"arg": ""
}
],
"action": {
"cmd": "set",
"arg": "newfile=%asfilename/%%newname/"
}
},
{
"raw": "lastrule "" textmatch %basename~~%%newfile action {flag dedup}",
"name": "If this recording already has this name, then flag as already de-duped.",
"type": "file",
"enabled": "1",
"criteria": [
{
"negate": 0,
"cmd": "lastrule",
"arg": ""
},
{
"negate": 0,
"cmd": "textmatch",
"arg": "%basename~~%%newfile"
}
],
"action": {
"cmd": "flag",
"arg": "dedup"
}
},
{
"raw": "!flag Deduped varset newfile fileexists %%newfile.ts action delete",
"name": "If still not de-duped and another file with the new name already exists, then delete this one.",
"type": "file",
"enabled": "1",
"criteria": [
{
"negate": 1,
"cmd": "flag",
"arg": "Deduped"
},
{
"negate": 0,
"cmd": "varset",
"arg": "newfile"
},
{
"negate": 0,
"cmd": "fileexists",
"arg": "%%newfile.ts"
}
],
"action": {
"cmd": "delete",
"arg": ""
}
},
{
"raw": "!flag Deduped varset newname action {settitle %%newname}",
"name": "Otherwise set the recording title.",
"type": "file",
"enabled": "1",
"criteria": [
{
"negate": 1,
"cmd": "flag",
"arg": "Deduped"
},
{
"negate": 0,
"cmd": "varset",
"arg": "newname"
}
],
"action": {
"cmd": "settitle",
"arg": "%%newname"
}
},
{
"raw": "lastrule "" action {renamefile %%newname}",
"name": "and recording filename.",
"type": "file",
"enabled": "1",
"criteria": [
{
"negate": 0,
"cmd": "lastrule",
"arg": ""
}
],
"action": {
"cmd": "renamefile",
"arg": "%%newname"
}
},
{
"raw": "lastrule "" action {flag dedup}",
"name": "Finally, flag recording as de-duped.",
"type": "file",
"enabled": "1",
"criteria": [
{
"negate": 0,
"cmd": "lastrule",
"arg": ""
}
],
"action": {
"cmd": "flag",
"arg": "dedup"
}
}
]
},
example: {
desc: 'Example rules',
rules: [
{
"raw": "lcn {>= 70} lcn {<= 79} or {duration {>= 90} genre Film } action {move Children/Films}",
"name": "Move any Children's films",
"type": "file",
"enabled": "0",
"criteria": [
{
"negate": 0,
"cmd": "lcn",
"arg": ">= 70"
},
{
"negate": 0,
"cmd": "lcn",
"arg": "<= 79"
},
{
"negate": 0,
"cmd": "or",
"arg": "duration {>= 90} genre Film ",
"criteria": [
{
"negate": 0,
"cmd": "duration",
"arg": ">= 90"
},
{
"negate": 0,
"cmd": "genre",
"arg": "Film"
}
]
}
],
"action": {
"cmd": "move",
"arg": "Children/Films"
}
},
{
"raw": "lcn {>= 70} lcn {<= 79} action {move Children/Miscellaneous}",
"name": "Move anything else recorded from a children's channel",
"type": "file",
"enabled": "0",
"criteria": [
{
"cmd": "lcn",
"arg": ">= 70"
},
{
"cmd": "lcn",
"arg": "<= 79"
}
],
"action": {
"cmd": "move",
"arg": "Children/Miscellaneous"
}
},
{
"raw": "lcn {>= 70} lcn {<= 79} action {fileundercreate Children}",
"name": "Move any series recordings from a Children's channel (folder rule)",
"type": "folder",
"enabled": "0",
"criteria": [
{
"cmd": "lcn",
"arg": ">= 70"
},
{
"cmd": "lcn",
"arg": "<= 79"
}
],
"action": {
"cmd": "fileundercreate",
"arg": "Children"
}
},
{
"raw": "title {Formula 1} action {move F1}",
"name": "Move any one-off Formula 1 recordings into the F1 folder",
"type": "file",
"enabled": "0",
"criteria": [
{
"cmd": "title",
"arg": "Formula 1"
}
],
"action": {
"cmd": "move",
"arg": "F1"
}
},
{
"raw": "age {> 120} action {movecreate Misc}",
"name": "Move any one-off recordings into a folder called Misc after a while",
"type": "file",
"enabled": "0",
"criteria": [
{
"cmd": "age",
"arg": "> 120"
}
],
"action": {
"cmd": "movecreate",
"arg": "Misc"
}
}
]
}
};