Rustboxd
A fast, async Rust library for scraping Letterboxd data.
Features
- Async/Await Support: Built on tokio for high-performance concurrent operations
- Type Safety: Full Rust type safety with serde serialization
- Comprehensive API: Access users, movies, films, lists, and search functionality
- Error Handling: Detailed error types with context
- Rate Limiting: Built-in respect for server resources
- No Dependencies on Python: Pure Rust implementation
Quick Start
Add this to your Cargo.toml:
[]
= "0.1.0"
= { = "1.0", = ["full"] }
Basic Usage
use ;
async
}
User Operations
Basic User Information
use User;
let user = new.await?;
// Basic profile information
println!;
println!;
println!;
// Statistics
if let Some = &user.stats
User Film Data
// Get all films watched by user
let films = user.get_films.await?;
println!;
// Get films by specific rating
let five_star_films = user.get_films_by_rating.await?;
println!;
// Get watchlist
let watchlist = user.get_watchlist.await?;
println!;
// Get liked films
let liked_films = user.get_films_liked.await?;
println!;
User Activity and Social
// Get user's diary
let diary = user.get_diary.await?;
println!;
// Get reviews
let reviews = user.get_reviews.await?;
println!;
// Get social connections
let followers = user.get_followers.await?;
let following = user.get_following.await?;
println!;
// Get lists created by user
let lists = user.get_lists.await?;
println!;
Movie Operations
Movie Details
use Movie;
let movie = new.await?;
// Basic information
println!;
println!;
println!;
println!;
// Genres and themes
println!;
println!;
// Cast and crew
println!;
println!;
Movie Community Data
// Get reviews for the movie
let reviews = movie.get_reviews.await?;
println!;
// Get similar films
let similar = movie.get_similar.await?;
println!;
// Get users who watched this movie
let watchers = movie.get_watchers.await?;
println!;
Search Operations
Film Search
use Search;
// Search for films
let search = new.await?;
println!;
for film in search.results.films.iter.take
Multi-type Search
// Search all content types
let search = new.await?;
println!;
println!;
println!;
println!;
println!;
Lists
List Information
use List;
let list = new.await?;
println!;
println!;
println!;
println!;
// Access films in the list
for film in list.films.iter.take
List Comments
// Get comments on the list
let comments = list.get_comments.await?;
println!;
for comment in comments.iter.take
Films Collection
Collection Analysis
use Films;
let films = new.await?;
println!;
// Filter by rating
let high_rated = films.filter_by_rating;
println!;
// Filter by year
let recent = films.filter_by_year;
println!;
// Filter by genre
let horror = films.filter_by_genre;
println!;
Error Handling
Rustboxd provides detailed error types:
use ;
match new.await
Async Best Practices
Concurrent Operations
use tokio;
// Run multiple operations concurrently
let = try_join!?;
Rate Limiting
use ;
// Be respectful to the server
for username in usernames
Advanced Examples
For more comprehensive examples, see the examples documentation and performance guide.
Documentation
- API Documentation - Detailed API reference
- Examples - Comprehensive usage examples
- Performance Guide - Optimization and best practices
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer
This library is for educational and personal use. Please respect Letterboxd's robots.txt and terms of service. Consider implementing appropriate rate limiting and caching to minimize server load.
Ok(())
}
### Search and Discovery
```rust
use rustboxd::Search;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Search films
let film_search = Search::new("christopher nolan", Some("films")).await?;
// Search reviews
let review_search = Search::new("masterpiece", Some("reviews")).await?;
// Search users
let user_search = Search::new("film critic", Some("members")).await?;
// Search lists
let list_search = Search::new("best of 2024", Some("lists")).await?;
Ok(())
}
Project Structure
rustboxd/
├── src/
│ ├── core/ # Core functionality (HTTP client, errors, constants)
│ ├── models/ # Data models (User, Movie, Search, Films, List)
│ ├── pages/ # Page-specific scrapers and parsers
│ ├── utils/ # Utility functions for parsing and validation
│ └── lib.rs # Library entry point
├── examples/ # Usage examples
├── tests/ # Integration and unit tests
└── docs/ # Documentation
Features by Module
Core
- HTTP client with proper headers and error handling
- Comprehensive error types with detailed messages
- Constants for Letterboxd URLs, selectors, and validation
Models
- User: Complete user profile data and statistics
- Movie: Full film metadata including cast, crew, and reviews
- Search: Multi-type search with filtering capabilities
- Films: Collection handling with pagination support
- List: User list data with film entries and metadata
Pages
- Individual page scrapers for different Letterboxd sections
- Specialized parsers for user activity, diary, films, reviews, etc.
- Async implementation for concurrent data fetching
Utils
- HTML parsing utilities with error handling
- Data transformation and normalization functions
- Input validation and sanitization
- URL building and manipulation helpers
Error Handling
Rustboxd provides comprehensive error handling:
use ;
match new.await
Performance
- Async/await for non-blocking I/O operations
- HTTP connection reuse for multiple requests
- Efficient HTML parsing with the
scrapercrate - Memory-efficient data structures with
serde
Validation
Built-in validation for:
- Usernames (alphanumeric and underscore only)
- Film slugs (lowercase letters, numbers, hyphens)
- Ratings (0.5-5.0 in 0.5 increments)
- Search filters (predefined valid options)
- URLs and date formats
Contributing
We welcome contributions! Please see CONTRIBUTING.md for guidelines.
Development
-
Clone the repository:
-
Install Rust and dependencies:
| -
Run tests:
-
Run examples:
License
This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer
This is an unofficial library for educational and research purposes. Please respect Letterboxd's terms of service and implement appropriate rate limiting in your applications.
Related Projects
- letterboxdpy - Python library that inspired this project
- letterboxd-api - Official Letterboxd API (requires authentication) letterboxd webscraper in rust