subkt / myaa.subkt.tasks / Subs
open class Subs :
ItemGroupContext
(source)
Central object that keeps track of episodes, batches, tasks and user-loaded properties. For tasks to be generated correctly, episodes and optionally batches should be set. Set release if you wish to be able to differentiate between different releases when looking up properties.
Any tasks created directly in the context of Subs will generate one task per episode specified in episodes. Batch tasks can be generated from the context of batchtasks. Tasks created in the context of alltasks will generate tasks for all episodes as well as all batches.
subs {
readProperties("sub.properties")
// read the release argument specified as -Prelease=value when invoking Gradle,
// or default to "TV" if not specified.
release(arg("release") ?: "TV")
episodes("01", "02", "03", "04", "05", "06", "07", "08", "09")
batches(
"vol1" to listOf("01", "02", "03"),
"vol2" to listOf("04", "05", "06"),
"vol3" to listOf("07", "08", "09")
)
merge {
from("$episode/file1.ass", "$episode/file2.ass", "$episode/file3.ass")
}
mux {
from("$episode/video.mkv")
from(merge.item())
out("$episode/muxed.mkv")
}
// per-episode torrents
torrent {
from(mux.item())
out("$episode/$episode.torrent")
}
// per-batch torrents
batchtasks {
torrent {
from(mux.batchItems())
into("My Show - $batch")
out("$batch/$batch.torrent")
}
}
// alternatively, configure all tasks in one go
alltasks {
torrent {
from(mux.batchItems())
if (isBatch) {
into("My Show - $batch")
}
out("$entry/$entry.torrent")
}
}
}
Name | Summary |
---|---|
SubContext | inner class SubContext : BaseContext AbstractContext implementation for getting properties in a Subs context. |
Name | Summary |
---|---|
<init> | Subs(project: Project ) Central object that keeps track of episodes, batches, tasks and user-loaded properties. For tasks to be generated correctly, episodes and optionally batches should be set. Set release if you wish to be able to differentiate between different releases when looking up properties. |
Name | Summary |
---|---|
batches | val batches: MapProperty < String , Iterable < String >> A map of batches to associated episodes. Must be set for per-batch tasks to be generated. |
entries | open val entries: ListProperty < String > A list of entries (episodes or batches) this context should generate tasks for. |
episodes | val episodes: ListProperty < String > A list of all episodes. Must be set for per-episode tasks to be generated. |
project | val project: Project |
properties | val properties: SubProperties A SubProperties instance for looking up properties using get and related functions.. |
release | val release: Property < String !>! The current release. Defaults to "default". |
subs | open val subs: Subs The Subs instance all tasks created in this context should be associated with. |
taskGroups | open val taskGroups: MutableMap < String , TaskGroup <*>> The map to store TaskGroup objects created in this context. |
Name | Summary |
---|---|
alltasks | fun alltasks(action: ItemGroupContext .() -> Unit ): Unit Creates a context for generating both episode and batch tasks. |
arg | fun arg(argName: String ): String ? Reads properties defined in gradle.properties or supplied on the command line using -Pproperty=value . |
batchtasks | fun batchtasks(action: ItemGroupContext .() -> Unit ): Unit Creates a context for generating batch tasks. |
episodes | open fun episodes(entry: String ): List < String > The episodes associated with entry. |
evaluate | fun evaluate(expression: String , entry: String = "", context: AbstractContext ? = null): Provider < List < String >!>! Evaluates a string using Velocity, splits it on ` |
evaluateTemplate | fun evaluateTemplate(expression: String , entry: String = "", context: AbstractContext ? = null): Provider < String !>! Like evaluate but only processes the template syntax, without globbing. |
get | fun get(propertyName: String , entry: String = "", context: AbstractContext ? = null): Provider < String !>! Searches for the given property in the Subs object's SubProperties instance, evaluates its value using evaluate, and returns a single string, assuming that the resulting list contains only one element. |
getAs | fun <T> getAs(propertyName: String , entry: String = "", context: AbstractContext ? = null): Provider < T >! Searches for the given property in the Subs object's SubProperties instance, evaluates its value using evaluate, and returns a single string, cast to the given type using String.asType, assuming that the resulting list contains only one element. |
getFile | fun getFile(filename: String , entry: String = "", context: AbstractContext ? = null): Provider < String !>! fun getFile(filename: Provider < String >, entry: String = "", context: AbstractContext ? = null): Provider < String !>! Reads the specified file and processes it using Velocity. |
getList | fun getList(propertyName: String , entry: String = "", context: AbstractContext ? = null): Provider < List < String >> Searches for the given property in the Subs object's SubProperties instance, and evaluates its value using evaluate. |
getListAs | fun <T> getListAs(propertyName: String , entry: String = "", context: AbstractContext ? = null): Provider < List < T >!>! Searches for the given property in the Subs object's SubProperties instance, evaluates its value using evaluate, and casts the list elements to the given type using String.asType. |
getMap | fun getMap(keys: String , values: String ): Map < String , List < String >!> Constructs a map by looking up [keys](get-map.md#myaa.subkt.tasks.Subs$getMap(kotlin.String, kotlin.String)/keys) in the properties, taking its values to be the keys of the map, and then for each such key, looking up the property with the key as its entry and [values](get-map.md#myaa.subkt.tasks.Subs$getMap(kotlin.String, kotlin.String)/values) as its property name, and taking the value of that property to be the value associated with that key. |
getRaw | fun getRaw(propertyName: String , entry: String = ""): String Searches for the given property in the Subs object's SubProperties instance, and returns the raw string. Raises an error if not found. |
getRawMaybe | fun getRawMaybe(propertyName: String , entry: String = ""): String ? Searches for the given property in the Subs object's SubProperties instance, and returns the raw string, possibly null. |
isBatch | open fun isBatch(entry: String ): Boolean True if entry corresponds to a batch entry. |
propertyExists | fun propertyExists(propertyName: String , entry: String = ""): Boolean Returns true if the given property exists in the Subs object's SubProperties instance for the given context. |
readProperties | fun readProperties(vararg file: String ): Unit Reads properties from one or more files as described in SubProperties. |
tasks | fun tasks(entries: Iterable < String >, action: ItemGroupContext .() -> Unit ): Unit fun tasks(vararg entries: String , action: ItemGroupContext .() -> Unit ): Unit fun tasks(entries: Provider <out Iterable < String >>, action: ItemGroupContext .() -> Unit ): Unit Creates a context for generating tasks for the specified entries. |
Name | Summary |
---|---|
invoke | operator fun <T : Task > TaskGroup < T >.invoke(action: T .() -> Unit ): Unit Create and/or configure tasks of type T for all entries in entries. operator fun <T : Task > String .invoke(action: T .() -> Unit ): TaskGroup < T > Creates a new task group with the name given by the string the function is invoked on, or returns the task group with the given name if it already exists, and configures a task for each entry in the current context using the given closure. operator fun <T : Task > KClass < T >.invoke(action: T .() -> Unit ): TaskCreator < T > Returns a delegate that when accessed returns a task group with the same name as the property it is bound to. Also configures one task for each entry in the current context using the given closure. |
provider | fun <T> provider(action: ValueClosure <*>.() -> T ): ProviderGroup < T > Creates a ProviderGroup that evaluates the given closure lazily, returning a Provider when an item is requested for a given entry. The closure is evaluated by running Provider.get on the returned provider. |
task | fun <T : Task > task(name: String , klass: KClass < T >): TaskGroup < T > Create a new task group, or returns the task group with the given name if it already exists. fun <T : Task > task(name: String , klass: KClass < T >, action: T .() -> Unit ): TaskGroup < T > fun <T : Task > task(name: String , action: T .() -> Unit ): TaskGroup < T > Creates a new task group, or returns the task group with the given name if it already exists, and configures a task for each entry in the current context using the given closure. fun <T : Task > task(name: String ): TaskGroup < T > Creates a new task group, or returns the task group with the given name if it already exists. fun <T : Task > task(action: ( T .() -> Unit )? = null): TaskCreator < T > Returns a delegate that when accessed returns a task group with the same name as the property it is bound to. Optionally configures one task for each entry in the current context using the given closure. |
value | fun <T> value(action: ValueClosure <*>.() -> T ): ValueGroup < T > Creates a ValueGroup, evaluating the given closure immediately for each entry in the given context. |
Name | Summary |
---|---|
anidex | val Subs .anidex: TaskGroup < Anidex > Convenience property that upon use automatically instantiates and returns a TaskGroup of type Anidex with the name anidex . |
chapters | val Subs .chapters: TaskGroup < Chapters > Convenience property that upon use automatically instantiates and returns a TaskGroup of type Chapters with the name chapters . |
discord | val Subs .discord: TaskGroup < Discord > Convenience property that upon use automatically instantiates and returns a TaskGroup of type Discord with the name discord . |
ftp | val Subs .ftp: TaskGroup < FTP > Convenience property that upon use automatically instantiates and returns a TaskGroup of type FTP with the name ftp . |
merge | val Subs .merge: TaskGroup < Merge > Convenience property that upon use automatically instantiates and returns a TaskGroup of type Merge with the name merge . |
mux | val Subs .mux: TaskGroup < Mux > Convenience property that upon use automatically instantiates and returns a TaskGroup of type Mux with the name mux . |
nyaa | val Subs .nyaa: TaskGroup < Nyaa > Convenience property that upon use automatically instantiates and returns a TaskGroup of type Nyaa with the name nyaa . |
sftp | val Subs .sftp: TaskGroup < SFTP > Convenience property that upon use automatically instantiates and returns a TaskGroup of type SFTP with the name sftp . |
swap | val Subs .swap: TaskGroup < Swap > Convenience property that upon use automatically instantiates and returns a TaskGroup of type Swap with the name swap . |
torrent | val Subs .torrent: TaskGroup < Torrent > Convenience property that upon use automatically instantiates and returns a TaskGroup of type Torrent with the name torrent . |