Struct imdb_index::Index
[−]
[src]
pub struct Index { /* fields omitted */ }
An index into IMDb titles and their associated data.
This index consists of a set of on disk index data structures in addition
to the uncompressed IMDb tsv
files. The on disk index structures are used
to provide access to the records in the tsv
files efficiently.
With this index, one can do the following things:
- Return a ranked list
Title
records matching a fuzzy name query. - Access any
Title
record by ID in constant time. - Access all
AKA
records for anyTitle
in constant time. - Access the
Rating
for anyTitle
in constant time. - Access the complete set of
Episode
records for any TV show in constant time. - Access the specific
Episode
given its ID in constant time.
Methods
impl Index
[src]
pub fn open<P1: AsRef<Path>, P2: AsRef<Path>>(
data_dir: P1,
index_dir: P2
) -> Result<Index>
[src]
data_dir: P1,
index_dir: P2
) -> Result<Index>
Open an existing index using default settings. If the index does not exist, or if there was a problem opening it, then this returns an error.
Generally, this method is cheap to call. It opens some file descriptors, but otherwise does no work.
data_dir
should be the directory containing decompressed IMDb
tsv
files. See: https://www.imdb.com/interfaces/
index_dir
should be the directory containing a previously created
index using Index::create
.
pub fn create<P1: AsRef<Path>, P2: AsRef<Path>>(
data_dir: P1,
index_dir: P2
) -> Result<Index>
[src]
data_dir: P1,
index_dir: P2
) -> Result<Index>
Create a new index using default settings.
Calling this method is expensive, and one should expect this to take dozens of seconds or more to complete.
data_dir
should be the directory containing decompressed IMDb tsvfiles. See: https://www.imdb.com/interfaces/
index_dir
should be the directory containing a previously created
index using Index::create
.
This will overwrite any previous index that may have existed in
index_dir
.
pub fn try_clone(&self) -> Result<Index>
[src]
Attempt to clone this index, returning a distinct Index
.
This is as cheap to call as Index::open
and returns an error if there
was a problem reading the underlying index.
This is useful when one wants to query the same Index
on disk from
multiple threads.
pub fn search(&mut self, query: &NameQuery) -> Result<SearchResults<Title>>
[src]
Search this index for Title
records whose name matches the given
query.
The query controls the following things:
- The name to search for.
- The maximum number of results returned.
- The scorer to use to rank results.
The name can be any string. It is normalized and broken down into component pieces, which are then used to quickly search all existing titles quickly and fuzzily.
This returns an error if there was a problem reading the index or the underlying CSV data.
pub fn entity(&mut self, id: &str) -> Result<Option<MediaEntity>>
[src]
Returns the MediaEntity
for the given IMDb ID.
An entity includes an Episode
and
Rating
records if they exist for the title.
This returns an error if there was a problem reading the underlying
index. If no such title exists for the given ID, then None
is
returned.
pub fn entity_from_title(&mut self, title: Title) -> Result<MediaEntity>
[src]
Returns the MediaEntity
for the given Title
.
This is like the entity
method, except it takes a Title
record as
given.
pub fn title(&mut self, id: &str) -> Result<Option<Title>>
[src]
Returns the Title
record for the given IMDb ID.
This returns an error if there was a problem reading the underlying
index. If no such title exists for the given ID, then None
is
returned.
pub fn aka_records(&mut self, id: &str) -> Result<AKARecordIter>
[src]
Returns an iterator over all AKA
records for the given IMDb ID.
If no AKA records exist for the given ID, then an empty iterator is returned.
If there was a problem reading the index, then an error is returned.
pub fn rating(&mut self, id: &str) -> Result<Option<Rating>>
[src]
Returns the Rating
associated with the given IMDb ID.
If no rating exists for the given ID, then this returns None
.
If there was a problem reading the index, then an error is returned.
pub fn seasons(&mut self, tvshow_id: &str) -> Result<Vec<Episode>>
[src]
Returns all of the episodes for the given TV show. The TV show should be identified by its IMDb ID.
If the given ID isn't a TV show or if the TV show doesn't have any episodes, then an empty list is returned.
The episodes returned are sorted in order of their season and episode numbers. Episodes without a season or episode number are sorted after episodes with a season or episode number.
If there was a problem reading the index, then an error is returned.
pub fn episodes(&mut self, tvshow_id: &str, season: u32) -> Result<Vec<Episode>>
[src]
Returns all of the episodes for the given TV show and season number.
The TV show should be identified by its IMDb ID, and the season should
be identified by its number. (Season numbers generally start at 1
.)
If the given ID isn't a TV show or if the TV show doesn't have any episodes for the given season, then an empty list is returned.
The episodes returned are sorted in order of their episode numbers. Episodes without an episode number are sorted after episodes with an episode number.
If there was a problem reading the index, then an error is returned.
pub fn episode(&mut self, episode_id: &str) -> Result<Option<Episode>>
[src]
Return the episode corresponding to the given IMDb ID.
If the ID doesn't correspond to an episode, then None
is returned.
If there was a problem reading the index, then an error is returned.
pub fn data_dir(&self) -> &Path
[src]
Returns the data directory that this index returns results for.
pub fn index_dir(&self) -> &Path
[src]
Returns the directory containing this index's files.