Skip to content

Commit 5aa7da3

Browse files
authored
39 per language sync (#53)
* Add language filter option for subtitle actions * Add missing ID to build-and-push step in Docker workflow
1 parent cc913e7 commit 5aa7da3

File tree

4 files changed

+54
-0
lines changed

4 files changed

+54
-0
lines changed

.github/workflows/docker.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ jobs:
5151
type=raw,value=latest,enable={{is_default_branch}}
5252
5353
- name: Build and push Docker image
54+
id: build-and-push
5455
uses: docker/build-push-action@v5
5556
with:
5657
context: .

README.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,7 @@ Options:
200200
--offset <OFFSET> Skip N records (ignored if ids are specified) [default: skip none] [default: 0]
201201
--limit <LIMIT> Limit to N records (ignored if ids are specified) [default: unlimited]
202202
--skip-processed Skip previously processed items (uses local database to track processed subtitles)
203+
-l, --language <LANGUAGE> Filter subtitles by language code (e.g., en, es, fr)
203204
-h, --help Print help
204205
```
205206
@@ -226,6 +227,7 @@ Options:
226227
--offset <OFFSET> Skip N records (ignored if ids are specified) [default: skip none] [default: 0]
227228
--limit <LIMIT> Limit to N records (ignored if ids are specified) [default: unlimited]
228229
--skip-processed Skip previously processed items (uses local database to track processed subtitles)
230+
-l, --language <LANGUAGE> Filter subtitles by language code (e.g., en, es, fr)
229231
-h, --help Print help
230232
```
231233
@@ -244,3 +246,30 @@ Options:
244246
-g Use Golden-Section search [default: false]
245247
-h, --help Print help
246248
```
249+
250+
## Usage Examples
251+
252+
### Sync all English subtitles for movies
253+
254+
```bash
255+
bb --config config.json movies --language en sync
256+
```
257+
258+
### Perform OCR fixes only on Spanish subtitles for TV shows
259+
260+
```bash
261+
bb --config config.json tv-shows --language es ocr-fixes
262+
```
263+
264+
### Sync specific movies by ID with language filter
265+
266+
```bash
267+
bb --config config.json movies --ids 123,456,789 --language en sync
268+
```
269+
270+
### Remove hearing impaired tags from French subtitles with skip-processed
271+
272+
```bash
273+
bb --config config.json movies --language fr --skip-processed remove-hearing-impaired
274+
```
275+

src/actions.rs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ pub struct Action {
2727
pub offset: u32,
2828
pub limit: Option<u32>,
2929
pub skip_processed: bool,
30+
pub language_code: Option<String>,
3031
pub pb: ProgressBar,
3132
pub db_conn: Arc<Mutex<Connection>>,
3233
pub is_tty: bool,
@@ -52,6 +53,7 @@ impl Action {
5253
ids: Vec::new(),
5354
offset: 0,
5455
skip_processed: false,
56+
language_code: None,
5557
limit: None,
5658
pb,
5759
db_conn,
@@ -89,6 +91,15 @@ impl Action {
8991
}
9092
}
9193

94+
/// Check if subtitle matches the language filter (if specified)
95+
fn matches_language_filter(&self, subtitle_code: Option<&String>) -> bool {
96+
match (&self.language_code, subtitle_code) {
97+
(Some(lang_code), Some(subtitle_code)) => lang_code == subtitle_code,
98+
(Some(_), None) => false,
99+
(None, _) => true,
100+
}
101+
}
102+
92103
async fn get_all<T>(&self, url: Url) -> Result<PaginatedResponse<T>, Box<dyn std::error::Error>>
93104
where
94105
T: DeserializeOwned,
@@ -147,6 +158,10 @@ impl Action {
147158
continue;
148159
}
149160

161+
if !self.matches_language_filter(subtitle.audio_language_item.code2.as_ref()) {
162+
continue;
163+
}
164+
150165
let msg = format!(
151166
"Performing action {} on {} subtitle of episode {}",
152167
self.action.to_string(),
@@ -200,6 +215,10 @@ impl Action {
200215
continue;
201216
}
202217

218+
if !self.matches_language_filter(subtitle.audio_language_item.code2.as_ref()) {
219+
continue;
220+
}
221+
203222
let msg = format!(
204223
"Performing action {} on {} subtitle of movie {}",
205224
self.action.to_string(),

src/cli.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,9 @@ pub struct CommonArgs {
5959
/// Must have all subtitles processed to be skipped.
6060
#[arg(long, default_value_t = false, required = false)]
6161
skip_processed: bool,
62+
/// Filter subtitles by language code (e.g., en, es, fr)
63+
#[arg(long, short = 'l')]
64+
language: Option<String>,
6265
/// List available actions
6366
#[command(subcommand)]
6467
subcommand: ActionCommands,
@@ -105,6 +108,7 @@ impl Commands {
105108
action.limit = c.limit;
106109
action.offset = c.offset;
107110
action.skip_processed = c.skip_processed;
111+
action.language_code = c.language;
108112
action.movies().await
109113
}
110114
Commands::TVShows(c) => {
@@ -113,6 +117,7 @@ impl Commands {
113117
action.limit = c.limit;
114118
action.offset = c.offset;
115119
action.skip_processed = c.skip_processed;
120+
action.language_code = c.language;
116121
action.tv_shows().await
117122
}
118123
}

0 commit comments

Comments
 (0)