Struct dim_database::mediafile::MediaFile
source · pub struct MediaFile {Show 18 fields
pub id: i64,
pub media_id: Option<i64>,
pub library_id: i64,
pub target_file: String,
pub raw_name: String,
pub raw_year: Option<i64>,
pub quality: Option<String>,
pub codec: Option<String>,
pub container: Option<String>,
pub audio: Option<String>,
pub original_resolution: Option<String>,
pub duration: Option<i64>,
pub episode: Option<i64>,
pub season: Option<i64>,
pub corrupt: Option<bool>,
pub channels: Option<i64>,
pub profile: Option<String>,
pub audio_language: Option<String>,
}
Expand description
MediaFile struct which represents a media file on the filesystem. This struct holds some basic information which the video player on the front end might require.
Fields§
§id: i64
Unique identifier of a mediafile.
media_id: Option<i64>
Foreign key linking this entry to the media table or Media
struct
library_id: i64
Library foreign key linking this entry to the library table or Library
struct
target_file: String
String representing the file path of the file we target. This should be a real path on the filesystem.
raw_name: String
Raw name that we extract from the filename using regex and the parse-torrent-name library
raw_year: Option<i64>
Raw year we might be able to extract from the filename using regex and the parse-torrent-name library
quality: Option<String>
Quality string that we might get from ffprobe when running it against our file
codec: Option<String>
Codec that we might get from ffprobe when running it against our file
container: Option<String>
Container descriptor that we might get from ffprobe
audio: Option<String>
Audio codec specifier that we might get from ffprobe
original_resolution: Option<String>
Video resolution that we can obtain from ffprobe
duration: Option<i64>
Duration of the video file that we obtain from ffprobe
episode: Option<i64>
Episode number that we might get from using regex and the parse-torrent-name crate. This is specific to tv shows only.
season: Option<i64>
Season number that we might get from using regexa and the parse-torrent-name crate. This is specific to tv shows only.
corrupt: Option<bool>
Flag which tells us if the file is corrupted or not. ie if ffprobe cant open the file and reports no metadata this flag will be set.
channels: Option<i64>
Audio channels count
profile: Option<String>
avc_profile
audio_language: Option<String>
Primary audio language
Implementations§
source§impl MediaFile
impl MediaFile
sourcepub async fn get_by_lib(
conn: &mut Transaction<'_>,
library_id: i64
) -> Result<Vec<Self>, DatabaseError>
pub async fn get_by_lib(
conn: &mut Transaction<'_>,
library_id: i64
) -> Result<Vec<Self>, DatabaseError>
Method returns all mediafiles associated with a library.
Arguments
conn
- mutable reference to a sqlx transaction.lib
- reference to a Library object that we will match against
sourcepub async fn get_by_lib_null_media(
conn: &mut Transaction<'_>,
library_id: i64
) -> Result<Vec<Self>, DatabaseError>
pub async fn get_by_lib_null_media(
conn: &mut Transaction<'_>,
library_id: i64
) -> Result<Vec<Self>, DatabaseError>
Method returns all mediafiles associated with a library and filters for those not associated with a media
Arguments
conn
- mutable reference to a sqlx transaction.lib
- reference to a Library object that we will match against
sourcepub async fn get_of_media(
conn: &mut Transaction<'_>,
media_id: i64
) -> Result<Vec<Self>, DatabaseError>
pub async fn get_of_media(
conn: &mut Transaction<'_>,
media_id: i64
) -> Result<Vec<Self>, DatabaseError>
Method returns all mediafiles associated with a Media object.
Arguments
conn
- mutable reference to a sqlx transaction.lib
- reference to a Library object that we will match against
pub async fn get_of_show(
conn: &mut Transaction<'_>,
id: i64
) -> Result<Vec<Self>, DatabaseError>
sourcepub async fn get_one(
conn: &mut Transaction<'_>,
id: i64
) -> Result<Self, DatabaseError>
pub async fn get_one(
conn: &mut Transaction<'_>,
id: i64
) -> Result<Self, DatabaseError>
Method returns all metadata of a mediafile based on the id supplied.
Arguments
conn
- mutable reference to a sqlx transaction._id
- id of the mediafile object we are targetting
sourcepub async fn get_many(
conn: &mut Transaction<'_>,
ids: &[i64]
) -> Result<Vec<Self>, DatabaseError>
pub async fn get_many(
conn: &mut Transaction<'_>,
ids: &[i64]
) -> Result<Vec<Self>, DatabaseError>
Method returns all metadata for a set of mediafile ids.
Arguments
conn
- mutable reference to a sqlx transaction.ids
- list of mediafile ids
sourcepub async fn exists_by_file(conn: &mut Transaction<'_>, file: &str) -> bool
pub async fn exists_by_file(conn: &mut Transaction<'_>, file: &str) -> bool
Method checks whether a mediafile entry with the filepath supplied exists or not, returning a bool.
Arguments
conn
- mutable reference to a sqlx transaction.file
- string slice containing our filepath
pub async fn get_by_file(
conn: &mut Transaction<'_>,
file: &str
) -> Result<Self, DatabaseError>
sourcepub async fn get_largest_duration(
conn: &mut Transaction<'_>,
media_id: i64
) -> Result<i64, DatabaseError>
pub async fn get_largest_duration(
conn: &mut Transaction<'_>,
media_id: i64
) -> Result<i64, DatabaseError>
Function will return the largest duration for a media.
sourcepub async fn delete(
conn: &mut Transaction<'_>,
id: i64
) -> Result<usize, DatabaseError>
pub async fn delete(
conn: &mut Transaction<'_>,
id: i64
) -> Result<usize, DatabaseError>
Method deletes mediafile matching the id supplied
Arguments
conn
- mutable reference to a sqlx transaction._id
- id of the mediafile entry we want to delete
sourcepub async fn delete_by_lib_id(
conn: &mut Transaction<'_>,
lib_id: i64
) -> Result<usize, DatabaseError>
pub async fn delete_by_lib_id(
conn: &mut Transaction<'_>,
lib_id: i64
) -> Result<usize, DatabaseError>
Function deletes all mediafiles with library_id
of lib_id. This function is used when
deleting a library with a sqlite backend.