Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
biezhihua committed Feb 18, 2024
1 parent a038737 commit 48a688d
Show file tree
Hide file tree
Showing 27 changed files with 57 additions and 13 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ cargo build

## 未来计划

- 支持配置tmdb的key
- scrape的config配置拆分,每次刮削的config都应该是隔离的。

## 开源协议

Expand Down
3 changes: 2 additions & 1 deletion soda_resource_tools_lib/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
cache
cache
test_cache
8 changes: 5 additions & 3 deletions soda_resource_tools_lib/src/soda/entity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,15 +178,17 @@ impl EmbyRenameStyle {
mt_meta.title_en.clone()
};

let release_year = mt_meta.release_year.clone().unwrap_or(mt_meta.year.clone());

// \Glee (2009)\Season 1\S01E01.mp4
if !title.is_empty()
&& !mt_meta.year.is_empty()
&& !release_year.is_empty()
&& !mt_meta.season.is_empty()
&& !mt_meta.episode.is_empty()
&& !mt_meta.extension.is_empty()
{
let path = PathBuf::new()
.join(format!("{} ({})", title, mt_meta.year))
.join(format!("{} ({})", title, release_year))
.join(format!("Season {}", mt_meta.season_number().unwrap_or(1)))
.join(format!(
"S{:02}E{:02}.{}",
Expand All @@ -202,7 +204,7 @@ impl EmbyRenameStyle {

// \Glee\Season 1\S01E01.mp4
if !title.is_empty()
&& mt_meta.year.is_empty()
&& release_year.is_empty()
&& (mt_meta.season.is_empty() || !mt_meta.season.is_empty())
&& !mt_meta.episode.is_empty()
&& !mt_meta.extension.is_empty()
Expand Down
49 changes: 49 additions & 0 deletions soda_resource_tools_lib/tests/integration_1_soda_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -409,6 +409,17 @@ mod soda_tests {
);
}

// #[test]
// fn test_scrape_tv_29() {
// test_scrape_emby_tv(
// "test_scrape_tv_29",
// "Rick.and.Morty.S02E01.A.Rickle.in.Time.1080p.BluRay.REMUX.VC-1.TrueHD.5.1-NOGRP.mkv",
// "瑞克和莫蒂 (2013)",
// "Season 2",
// "S02E01.mkv",
// )
// }

fn test_scrape_tv2(tag: &str, path: &PathBuf, root: &str, season: &str, episode: &str) {
use soda_resource_tools_lib::soda::entity::{ResourceType, TransferType};

Expand Down Expand Up @@ -439,6 +450,36 @@ mod soda_tests {
clean_dir(&test_dir);
}

fn test_scrape_emby_tv(tag: &str, path: &str, root: &str, season: &str, episode: &str) {
use soda_resource_tools_lib::soda::entity::{ResourceType, TransferType};

init_tracing();

emby_lib_config();
let scrape_config = default_scrape_config();

let test_dir = tests_dir().join(tag);
clean_dir(&test_dir);

create_file(&test_dir.join(path));

soda::scrape(
ResourceType::MT,
TransferType::Copy,
scrape_config.clone(),
test_dir.to_str().unwrap().to_string(),
test_dir.to_str().unwrap().to_string(),
);

let target_file: std::path::PathBuf = test_dir.join(root).join(season).join(episode);

tracing::debug!("test_scrape_tv target_file = {:?} exist = {}", target_file, target_file.exists());

assert_eq!(true, target_file.exists());

clean_dir(&test_dir);
}

fn test_scrape_tv(tag: &str, path: &str, root: &str, season: &str, episode: &str) {
use soda_resource_tools_lib::soda::entity::{ResourceType, TransferType};

Expand Down Expand Up @@ -544,4 +585,12 @@ mod soda_tests {
config.transfer_rename_format_movie = "$title_cn$.$title_en$.$year$.$resolution$.$source$.$video_codec$.$audio_codec$/$title_cn$.$title_en$.$year$.$resolution$.$source$.$video_codec$.$audio_codec$.$extension$".to_string();
soda::update_lib_config(config);
}

fn emby_lib_config() {
let mut config = soda::get_lib_config();
config.cache_path = tests_dir().join("test_cache").to_string_lossy().to_string();
config.metadata_skip_special = true;
config.rename_style = Some(soda::entity::RenameStyle::Emby);
soda::update_lib_config(config);
}
}
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

This file was deleted.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
4 changes: 0 additions & 4 deletions soda_resource_tools_lib/tests/test_cache/imdb_http_cache/conf

This file was deleted.

Binary file not shown.
Binary file not shown.

0 comments on commit 48a688d

Please sign in to comment.