
Enables querying multiple torrent providers in one request, handling results, and resolving torrent information. Supports custom caching and includes a web demo for debugging.
Multiplatform Torrent and NZB Provider API client written in Kotlin.
TorrentSearch-Kotlin enables you to query multiple torrent & NZB provides in one request and handle all the results. Supported
providers can be found in src/commonMain/kotlin/providers.
val torrentSearch = TorrentSearch()
// Only the content string or imdbId/tmdbId/tvdbId is required
val result = torrentSearch.search {
content = "big buck bunny"
category = Category.ALL // Optional: Filter by category
imdbId = "tt..." // Optional: Find by IMDB id instead of content
tmdbId = 534 // Optional: Find by TMDB id instead of content
tvdbId = 874 // Optional: Find by TVDB id instead of content
limit = 20 // Optional: Limit results per provider endpoint
}
println(result.torrents().toList())
// [TorrentDescription(provider=Libre, title=Big Buck Bunny, magnetUrl=magnet:?xt=urn:btih:...]Some providers may require additional requests to resolve download information for a TorrentDescription.
This can be checked on the individual TorrentDescriptions or for the whole collection returned by a provider.
val searchResult = torrentSearch.search { /* ... */ }
val unresolved = searchResult.providerResults().filter { it.requiresResolution }.toList()
val resultSet = torrentSearch.resolve(unresolved.flatMap { it.torrents })
val torrent = resultSet.torrents.first()
// Now you can access `torrent.magnetUrl` and `torrent.infoHash`An optional TorrentProviderCache
can be provided to TorrentSearch enabled caching for authentication tokens and search results.
The default cache will store auth tokens in memory and does not cache torrent results. To add custom caching behavior,
implement a TorrentProviderCache and use it when
constructing TorrentSearch.
The web demo helps with debugging the api and provider implementations, it can be run with
./gradlew jsBrowserProductionRun and open http://localhost:8080 in your browser.
repositories {
mavenCentral()
// Or snapshots
maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
dependencies {
implementation("org.drewcarlson:torrentsearch:$torrentsearch_version")
// For Jvm only:
implementation("org.drewcarlson:torrentsearch-jvm:$torrentsearch_version")
}Note: it is required to specify a Ktor client engine implementation. (Documentation)
dependencies {
// Jvm/Android
implementation("io.ktor:ktor-client-okhttp:$ktor_version")
implementation("io.ktor:ktor-client-android:$ktor_version")
// iOS
implementation("io.ktor:ktor-client-darwin:$ktor_version")
// macOS/Windows/Linux
implementation("io.ktor:ktor-client-curl:$ktor_version")
// Javascript/NodeJS
implementation("io.ktor:ktor-client-js:$ktor_version")
}MIT, see LICENSE
Multiplatform Torrent and NZB Provider API client written in Kotlin.
TorrentSearch-Kotlin enables you to query multiple torrent & NZB provides in one request and handle all the results. Supported
providers can be found in src/commonMain/kotlin/providers.
val torrentSearch = TorrentSearch()
// Only the content string or imdbId/tmdbId/tvdbId is required
val result = torrentSearch.search {
content = "big buck bunny"
category = Category.ALL // Optional: Filter by category
imdbId = "tt..." // Optional: Find by IMDB id instead of content
tmdbId = 534 // Optional: Find by TMDB id instead of content
tvdbId = 874 // Optional: Find by TVDB id instead of content
limit = 20 // Optional: Limit results per provider endpoint
}
println(result.torrents().toList())
// [TorrentDescription(provider=Libre, title=Big Buck Bunny, magnetUrl=magnet:?xt=urn:btih:...]Some providers may require additional requests to resolve download information for a TorrentDescription.
This can be checked on the individual TorrentDescriptions or for the whole collection returned by a provider.
val searchResult = torrentSearch.search { /* ... */ }
val unresolved = searchResult.providerResults().filter { it.requiresResolution }.toList()
val resultSet = torrentSearch.resolve(unresolved.flatMap { it.torrents })
val torrent = resultSet.torrents.first()
// Now you can access `torrent.magnetUrl` and `torrent.infoHash`An optional TorrentProviderCache
can be provided to TorrentSearch enabled caching for authentication tokens and search results.
The default cache will store auth tokens in memory and does not cache torrent results. To add custom caching behavior,
implement a TorrentProviderCache and use it when
constructing TorrentSearch.
The web demo helps with debugging the api and provider implementations, it can be run with
./gradlew jsBrowserProductionRun and open http://localhost:8080 in your browser.
repositories {
mavenCentral()
// Or snapshots
maven(url = "https://s01.oss.sonatype.org/content/repositories/snapshots/")
}
dependencies {
implementation("org.drewcarlson:torrentsearch:$torrentsearch_version")
// For Jvm only:
implementation("org.drewcarlson:torrentsearch-jvm:$torrentsearch_version")
}Note: it is required to specify a Ktor client engine implementation. (Documentation)
dependencies {
// Jvm/Android
implementation("io.ktor:ktor-client-okhttp:$ktor_version")
implementation("io.ktor:ktor-client-android:$ktor_version")
// iOS
implementation("io.ktor:ktor-client-darwin:$ktor_version")
// macOS/Windows/Linux
implementation("io.ktor:ktor-client-curl:$ktor_version")
// Javascript/NodeJS
implementation("io.ktor:ktor-client-js:$ktor_version")
}MIT, see LICENSE