| Crates.io | opensubs |
| lib.rs | opensubs |
| version | 0.1.3 |
| created_at | 2025-06-29 15:46:33.142272+00 |
| updated_at | 2025-09-15 23:19:48.80442+00 |
| description | Library to search subtitles from opensubtitles.org |
| homepage | https://github.com/javiorfo/opensubs#readme |
| repository | https://github.com/javiorfo/opensubs |
| max_upload_size | |
| id | 1730861 |
| size | 101,806 |
Library to search subtitles from opensubtitles.org
This crate provides a high-level, ergonomic API for searching and retrieving subtitles and related metadata from opensubtitles.org.
It offers both asynchronous and blocking (synchronous) interfaces, with flexible filtering and ordering options.
It uses a web scraper to build the api
Add this crate to your Cargo.toml:
[dependencies]
opensubs = "0.1.2"
[dependencies]
opensubs = { version = "0.1.2", features = ["blocking"] }
use opensubs::{Filters, Language, OrderBy, SearchBy};
#[tokio::main]
async fn main() -> opensubs::Result {
// async search movie "holdovers", spanish subs, order by rating
let results = opensubs::search(SearchBy::MovieAndFilter(
"holdovers",
Filters::default()
.languages(&[Language::Spanish])
.order_by(OrderBy::Rating)
.build(),
))
.await?;
println!("Subtitles {results:#?}");
Ok(())
}
use opensubs::{Filters, Language, OrderBy, Response, SearchBy};
fn main() -> opensubs::Result {
// blocking search movie "the godfather"
// year 1972, french and german subs, order by rating
let results = opensubs::blocking::search(SearchBy::MovieAndFilter(
"the godfather",
Filters::default()
.year(1972)
.languages(&[Language::French, Language::German])
.order_by(OrderBy::Downloads)
.build(),
))?;
match results {
Response::Movie(movies) => {
// If results is Movie type, get the subtitles_link property
// and find subtitles for it
if let Some(movie) = movies.first() {
let subs = opensubs::blocking::search(SearchBy::Url(&movie.subtitles_link))?;
println!("Subtitles {subs:#?}");
}
}
// else print the subtitles
_ => println!("Subtitles {results:#?}"),
}
Ok(())
}
opensubtitles.org could return a list of movies or a list of subtitles of the movie searched (if the text and filter are more exactly). For that matter the Response is an enum.wgetFind all the configuration options in the full documentation.