Skip to content

Commit 16a78b7

Browse files
committed
Add utility scripts for statistics generation - Add stats_generator.go to create detailed movie collection analytics - Add letterboxd_stats_poster.go to share statistics on Letterboxd - Create comprehensive documentation in English
1 parent f653dd1 commit 16a78b7

File tree

3 files changed

+1114
-0
lines changed

3 files changed

+1114
-0
lines changed

scripts/utils/README.md

Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
# Utilities for Export Trakt for Letterboxd
2+
3+
This directory contains utility tools to work with the exports generated by the application.
4+
5+
## Statistics Generator
6+
7+
The `stats_generator.go` script analyzes your CSV export files and generates a detailed statistical report about your movie collection.
8+
9+
### Features
10+
11+
- Basic statistics (total number of movies, watched, rated, etc.)
12+
- Rating distribution
13+
- Movies by decade
14+
- Popular genres
15+
- Favorite directors
16+
- Frequent actors
17+
- Monthly watching activity
18+
- Interesting facts (oldest movie, longest movie, etc.)
19+
20+
### Installation
21+
22+
Compile the script with Go:
23+
24+
```bash
25+
cd scripts/utils
26+
go build -o stats_generator stats_generator.go
27+
```
28+
29+
### Usage
30+
31+
```bash
32+
# Basic usage with specific files
33+
./stats_generator \
34+
--watched "/path/to/watched_movies.csv" \
35+
--ratings "/path/to/ratings.csv" \
36+
--watchlist "/path/to/watchlist.csv" \
37+
--output "my_stats.md"
38+
39+
# Or simply point to the exports directory
40+
./stats_generator --dir "/path/to/exports" --output "my_stats.md"
41+
```
42+
43+
### Options
44+
45+
- `--watched`: Path to the watched movies CSV file
46+
- `--ratings`: Path to the ratings CSV file
47+
- `--watchlist`: Path to the watchlist CSV file
48+
- `--dir`: Path to the directory containing export files (alternative to specifying individual files)
49+
- `--output`: Path to the output report file (default: "movie_stats.md")
50+
51+
### Sample Report
52+
53+
The generated report is in Markdown format and looks like this:
54+
55+
```markdown
56+
# Movie Collection Statistics
57+
58+
_Generated on January 31, 2025_
59+
60+
## Overview
61+
62+
Total unique movies: **1,253**
63+
64+
- Watched movies: **873**
65+
- Rated movies: **724**
66+
- Watchlisted movies: **412**
67+
68+
Average rating: **7.4/10**
69+
70+
## Interesting Facts
71+
72+
- Oldest movie: **The Birth of a Nation (1915)**
73+
- Newest movie: **Dune: Part Two (2024)**
74+
- Longest movie: **The Lord of the Rings: The Return of the King (201 minutes)**
75+
- Shortest movie: **World of Tomorrow (16 minutes)**
76+
77+
## Rating Distribution
78+
79+
| Rating | Count | Percentage |
80+
| ------ | ----- | ---------- |
81+
| 1/10 | 5 | 0.7% |
82+
| 2/10 | 12 | 1.7% |
83+
| 3/10 | 24 | 3.3% |
84+
| 4/10 | 37 | 5.1% |
85+
| 5/10 | 79 | 10.9% |
86+
| 6/10 | 108 | 14.9% |
87+
| 7/10 | 207 | 28.6% |
88+
| 8/10 | 164 | 22.7% |
89+
| 9/10 | 76 | 10.5% |
90+
| 10/10 | 12 | 1.7% |
91+
92+
[... and more sections ...]
93+
```
94+
95+
### Limitations
96+
97+
- The script expects CSV files in the format generated by Export Trakt for Letterboxd
98+
- The following columns are used if available: "Name", "Year", "WatchedDate", "Runtime", "Genres", "Directors", "Cast", "Rating"
99+
100+
## Letterboxd Stats Poster
101+
102+
The `letterboxd_stats_poster.go` script automatically posts your statistics to Letterboxd as a review.
103+
104+
### Features
105+
106+
- Automatic login to Letterboxd
107+
- Converts your statistics into a nicely formatted review
108+
- Supports custom titles and tags
109+
- Configurable privacy settings (public, friends, private)
110+
111+
### Installation
112+
113+
Compile the script with Go:
114+
115+
```bash
116+
cd scripts/utils
117+
go build -o letterboxd_poster letterboxd_stats_poster.go
118+
```
119+
120+
You'll need to install the required dependency:
121+
122+
```bash
123+
go get golang.org/x/net/publicsuffix
124+
```
125+
126+
### Usage
127+
128+
```bash
129+
# Basic usage with command line arguments
130+
./letterboxd_poster \
131+
--username "your_letterboxd_username" \
132+
--password "your_letterboxd_password" \
133+
--stats "path/to/your/stats.md" \
134+
--title "My Movie Collection Statistics" \
135+
--tags "statistics,trakt,export" \
136+
--visibility "public"
137+
138+
# Or using a configuration file
139+
./letterboxd_poster --config "path/to/config.json"
140+
```
141+
142+
### Options
143+
144+
- `--username`: Your Letterboxd username
145+
- `--password`: Your Letterboxd password
146+
- `--stats`: Path to the generated statistics Markdown file
147+
- `--title`: Title for the review (default: "My Movie Collection Statistics")
148+
- `--tags`: Comma-separated list of tags (default: "statistics,trakt,export")
149+
- `--visibility`: Visibility setting ("public", "friends", or "private") (default: "public")
150+
- `--config`: Path to a JSON configuration file (alternative to command line args)
151+
152+
### Configuration File Format
153+
154+
```json
155+
{
156+
"Username": "your_letterboxd_username",
157+
"Password": "your_letterboxd_password",
158+
"StatsFile": "path/to/stats.md",
159+
"Title": "My Yearly Movie Stats",
160+
"Tags": ["statistics", "trakt", "export", "year-in-review"],
161+
"Visibility": "public"
162+
}
163+
```
164+
165+
### Notes
166+
167+
- The script will post your statistics as a review of "The General" (1926), a classic film that's often used as a placeholder
168+
- The review is dated with the current date
169+
- Markdown formatting is preserved in the Letterboxd review

0 commit comments

Comments
 (0)