feat(tv): search indexers by series tvdb id
This commit is contained in:
@@ -409,7 +409,7 @@ impl SeriesResource {
|
||||
title: row.title.clone(),
|
||||
sort_title: row.title.to_lowercase(),
|
||||
year: row.year.unwrap_or_default(),
|
||||
tvdb_id: 0,
|
||||
tvdb_id: row.tvdb_id.unwrap_or(0),
|
||||
tmdb_id: row.tmdb_id,
|
||||
title_slug: title_slug(&row.title, row.tmdb_id),
|
||||
path: format!("{}/{folder}", row.root_path),
|
||||
|
||||
@@ -15,6 +15,7 @@ use crate::CompatState;
|
||||
pub(crate) struct SeriesRow {
|
||||
pub(crate) id: i64,
|
||||
pub(crate) tmdb_id: i64,
|
||||
pub(crate) tvdb_id: Option<i64>,
|
||||
pub(crate) title: String,
|
||||
pub(crate) year: Option<i64>,
|
||||
pub(crate) root_id: i64,
|
||||
@@ -98,10 +99,11 @@ pub(crate) async fn add(
|
||||
|
||||
let mut tx = state.pool().begin().await?;
|
||||
let series_id = sqlx::query(
|
||||
"INSERT INTO series (tmdb_id, title, year, original_language, root_id, auto_track, upstream_ended) \
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?) RETURNING id",
|
||||
"INSERT INTO series (tmdb_id, tvdb_id, title, year, original_language, root_id, auto_track, upstream_ended) \
|
||||
VALUES (?, ?, ?, ?, ?, ?, ?, ?) RETURNING id",
|
||||
)
|
||||
.bind(input.tmdb_id)
|
||||
.bind(metadata.tvdb_id.map(i64::from))
|
||||
.bind(input.title.trim())
|
||||
.bind(input.year.or_else(|| metadata.year().map(i64::from)))
|
||||
.bind(&metadata.original_language)
|
||||
@@ -227,7 +229,7 @@ async fn load_series(
|
||||
tmdb_id: Option<i64>,
|
||||
) -> Result<Vec<SeriesRow>, CompatError> {
|
||||
let rows = sqlx::query!(
|
||||
r#"SELECT s.id AS "id!: i64", s.tmdb_id AS "tmdb_id!: i64",
|
||||
r#"SELECT s.id AS "id!: i64", s.tmdb_id AS "tmdb_id!: i64", s.tvdb_id,
|
||||
s.title AS "title!: String", s.year, s.root_id AS "root_id!: i64",
|
||||
r.path AS "root_path!: String",
|
||||
s.upstream_ended AS "upstream_ended!: bool",
|
||||
@@ -251,6 +253,7 @@ async fn load_series(
|
||||
.map(|row| SeriesRow {
|
||||
id: row.id,
|
||||
tmdb_id: row.tmdb_id,
|
||||
tvdb_id: row.tvdb_id,
|
||||
title: row.title,
|
||||
year: row.year,
|
||||
root_id: row.root_id,
|
||||
|
||||
Reference in New Issue
Block a user