DataManager :: get_film_details now handles optional source properly
This commit is contained in:
parent
20326fde8f
commit
8bea2088a0
1 changed files with 27 additions and 12 deletions
|
@ -63,6 +63,7 @@ impl DataManager {
|
|||
films . release_date ,
|
||||
films . runtime_minutes ,
|
||||
films . poster_file_path ,
|
||||
films . source ,
|
||||
sources . video_file_path ,
|
||||
sources . video_track ,
|
||||
sources . audio_file_path ,
|
||||
|
@ -176,6 +177,9 @@ pub struct FilmDetails {
|
|||
pub release_date : String ,
|
||||
pub runtime_minutes : u32 ,
|
||||
pub poster_file_path : Option <PathBuf> ,
|
||||
pub source : Option <SourceDetails> ,
|
||||
}
|
||||
pub struct SourceDetails {
|
||||
pub video_file_path : PathBuf ,
|
||||
pub video_track : Option <u32> ,
|
||||
pub audio_file_path : PathBuf ,
|
||||
|
@ -191,12 +195,28 @@ fn row_to_film_details ( row : & Row ) -> rusqlite :: Result <FilmDetails> {
|
|||
let release_date = row . get (3) ? ;
|
||||
let runtime_minutes = row . get (4) ? ;
|
||||
let poster_file_path = row . get :: < _ , Option <String> > (5) ? . map ( PathBuf :: from ) ;
|
||||
let video_file_path = PathBuf :: from ( row . get :: < _ , String > (6) ? ) ;
|
||||
let video_track = row . get (7) ? ;
|
||||
let audio_file_path = PathBuf :: from ( row . get :: < _ , String > (8) ? ) ;
|
||||
let audio_track = row . get (9) ? ;
|
||||
let subtitle_file_path = row . get :: < _ , Option <String> > (10) ? . map ( PathBuf :: from ) ;
|
||||
let subtitle_track = row . get (11) ? ;
|
||||
|
||||
let source_uuid = row . get :: < _ , Option <String> > (6) ? ;
|
||||
let source = match source_uuid {
|
||||
Some (_) => {
|
||||
let video_file_path = PathBuf :: from ( row . get :: < _ , String > (7) ? ) ;
|
||||
let video_track = row . get (8) ? ;
|
||||
let audio_file_path = PathBuf :: from ( row . get :: < _ , String > (9) ? ) ;
|
||||
let audio_track = row . get (10) ? ;
|
||||
let subtitle_file_path = row . get :: < _ , Option <String> > (11) ? . map ( PathBuf :: from ) ;
|
||||
let subtitle_track = row . get (12) ? ;
|
||||
|
||||
Some ( SourceDetails {
|
||||
video_file_path ,
|
||||
video_track ,
|
||||
audio_file_path ,
|
||||
audio_track ,
|
||||
subtitle_file_path ,
|
||||
subtitle_track ,
|
||||
} )
|
||||
} ,
|
||||
None => None ,
|
||||
} ;
|
||||
|
||||
Ok ( FilmDetails {
|
||||
uuid ,
|
||||
|
@ -205,12 +225,7 @@ fn row_to_film_details ( row : & Row ) -> rusqlite :: Result <FilmDetails> {
|
|||
release_date ,
|
||||
runtime_minutes ,
|
||||
poster_file_path ,
|
||||
video_file_path ,
|
||||
video_track ,
|
||||
audio_file_path ,
|
||||
audio_track ,
|
||||
subtitle_file_path ,
|
||||
subtitle_track ,
|
||||
source ,
|
||||
} )
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue