Skip to content

Commit

Permalink
version bump, clippy
Browse files Browse the repository at this point in the history
  • Loading branch information
ddboline committed Oct 15, 2024
1 parent 48fb6c2 commit c22e171
Show file tree
Hide file tree
Showing 12 changed files with 65 additions and 38 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "movie_collection_rust"
version = "0.10.47"
version = "0.10.48"
authors = ["Daniel Boline <[email protected]>"]
edition = "2018"

Expand All @@ -15,7 +15,7 @@ Utilities for maintaining a collection of videos."""
[dependencies]
anyhow = "1.0"
clap = {version="4.0", features=["derive"]}
derive_more = "0.99"
derive_more = {version="1.0", features=["full"]}
env_logger = "0.11"
futures = "0.3"
log = "0.4"
Expand Down
4 changes: 2 additions & 2 deletions movie_collection_http/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "movie_collection_http"
version = "0.10.47"
version = "0.10.48"
authors = ["Daniel Boline <[email protected]>"]
edition = "2018"

Expand All @@ -11,7 +11,7 @@ async-graphql-warp = "7.0"
async-trait = "0.1"
authorized_users = { git = "https://github.com/ddboline/auth_server_rust.git", tag="0.11.15"}
bytes = "1.0"
derive_more = "0.99"
derive_more = {version="1.0", features=["full"]}
dioxus = "0.5"
dioxus-core = "0.5"
dioxus-ssr = "0.5"
Expand Down
6 changes: 3 additions & 3 deletions movie_collection_lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "movie_collection_lib"
version = "0.10.47"
version = "0.10.48"
authors = ["Daniel Boline <[email protected]>"]
edition = "2018"

Expand All @@ -10,7 +10,7 @@ async-trait = "0.1"
base64 = "0.22"
bytes = "1.0"
clap = {version="4.0", features=["derive"]}
derive_more = "0.99"
derive_more = {version="1.0", features=["full"]}
dirs = "5.0"
dotenv = "0.15"
deadpool = "0.12"
Expand All @@ -24,7 +24,7 @@ maplit = "1.0"
once_cell = "1.0"
postgres_query = {git = "https://github.com/ddboline/rust-postgres-query", tag = "0.3.8", features=["deadpool"]}
postgres-types = "0.2"
procfs = "0.16"
procfs = "0.17"
rand = "0.8"
rayon = "1.5"
reqwest = {version="0.12", features=["cookies", "json", "rustls-tls"], default-features=false}
Expand Down
9 changes: 7 additions & 2 deletions movie_collection_lib/src/imdb_episodes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,10 @@ mod tests {
use futures::TryStreamExt;

use crate::{
config::Config, imdb_episodes::{ImdbEpisodes, ImdbSeason}, imdb_ratings::ImdbRatings, pgpool::PgPool
config::Config,
imdb_episodes::{ImdbEpisodes, ImdbSeason},
imdb_ratings::ImdbRatings,
pgpool::PgPool,
};

#[tokio::test]
Expand Down Expand Up @@ -333,7 +336,9 @@ mod tests {
.try_collect()
.await?;
assert_eq!(seasons.len(), 6);
let show = ImdbRatings::get_show_by_link("the_sopranos", &pool).await?.unwrap();
let show = ImdbRatings::get_show_by_link("the_sopranos", &pool)
.await?
.unwrap();
assert_eq!(show.show, episode.show);
Ok(())
}
Expand Down
2 changes: 1 addition & 1 deletion movie_collection_lib/src/make_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use crate::{

#[derive(Debug, Display, Clone)]
pub enum PathOrIndex {
#[display(fmt = "{_0:?}")]
#[display("{_0:?}")]
Path(PathBuf),
Index(i32),
}
Expand Down
41 changes: 24 additions & 17 deletions movie_collection_lib/src/plex_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -83,20 +83,18 @@ pub struct EventOutput {
pub grandparent_title: Option<StackString>,
pub filename: Option<StackString>,
pub last_modified: OffsetDateTime,
pub show: Option<StackString>,
pub season: Option<i32>,
pub episode: Option<i32>,
pub show_url: Option<StackString>,
pub epurl: Option<StackString>,
}

impl PlexEvent {
/// # Errors
/// Return error if deserialization fails
pub fn get_from_payload(buf: &[u8]) -> Result<Self, Error> {
info!(
"buf {}",
if let Ok(s) = std::str::from_utf8(buf) {
s
} else {
""
}
);
info!("buf {}", std::str::from_utf8(buf).unwrap_or_default());
let object: WebhookPayload = serde_json::from_slice(buf)?;
info!("{:#?}", object);
object.try_into()
Expand Down Expand Up @@ -194,9 +192,13 @@ impl PlexEvent {
let query = query!(
r#"
SELECT a.id, a.event, a.metadata_type, a.section_title, a.title, a.parent_title,
a.grandparent_title, b.filename, a.last_modified
a.grandparent_title, b.filename, a.last_modified,
c.show, d.season, d.episode, e.link as show_url, d.epurl
FROM plex_event a
LEFT JOIN plex_filename b ON a.metadata_key = b.metadata_key
LEFT JOIN movie_collection c ON c.idx = b.collection_id
LEFT JOIN imdb_episodes d ON d.id = c.episode_id
LEFT JOIN imdb_ratings e ON e.show = c.show
WHERE a.id = $id
"#,
id = id,
Expand Down Expand Up @@ -234,9 +236,13 @@ impl PlexEvent {
let query = format_sstr!(
"
SELECT a.id, a.event, a.metadata_type, a.section_title, a.title, a.parent_title,
a.grandparent_title, b.filename, a.last_modified
a.grandparent_title, b.filename, a.last_modified,
c.show, d.season, d.episode, e.link as show_url, d.epurl
FROM plex_event a
LEFT JOIN plex_filename b ON a.metadata_key = b.metadata_key
LEFT JOIN movie_collection c ON c.idx = b.collection_id
LEFT JOIN imdb_episodes d ON d.id = c.episode_id
LEFT JOIN imdb_ratings e ON e.show = c.show
{where_str}
ORDER BY a.last_modified DESC
{limit}
Expand Down Expand Up @@ -587,7 +593,8 @@ impl PlexFilename {
}

async fn _update<C>(&self, conn: &C) -> Result<(), Error>
where C: GenericClient + Sync
where
C: GenericClient + Sync,
{
if self.collection_id.is_some() {
let query = query!(
Expand All @@ -596,8 +603,8 @@ impl PlexFilename {
SET collection_id=$collection_id
WHERE metadata_key=$metadata_key
",
collection_id=self.collection_id,
metadata_key=self.metadata_key,
collection_id = self.collection_id,
metadata_key = self.metadata_key,
);
query.execute(&conn).await?;
}
Expand All @@ -608,8 +615,8 @@ impl PlexFilename {
SET music_collection_id=$music_collection_id
WHERE metadata_key=$metadata_key
",
music_collection_id=self.music_collection_id,
metadata_key=self.metadata_key,
music_collection_id = self.music_collection_id,
metadata_key = self.metadata_key,
);
query.execute(&conn).await?;
}
Expand Down Expand Up @@ -911,7 +918,7 @@ impl PlexMetadata {
if Self::get_by_key(pool, parent_key).await?.is_none() {
let mut parent_metadata =
Self::get_metadata_by_key(config, parent_key).await?;
parent_metadata.show = metadata.show.clone();
parent_metadata.show.clone_from(&metadata.show);
parent_metadata.insert(pool).await?;
println!("insert parent {parent_metadata:?}");
}
Expand All @@ -920,7 +927,7 @@ impl PlexMetadata {
if Self::get_by_key(pool, grandparent_key).await?.is_none() {
let mut grandparent_metadata =
Self::get_metadata_by_key(config, grandparent_key).await?;
grandparent_metadata.show = metadata.show.clone();
grandparent_metadata.show.clone_from(&metadata.show);
grandparent_metadata.insert(pool).await?;
println!("insert grandparent {grandparent_metadata:?}");
}
Expand Down
2 changes: 1 addition & 1 deletion movie_collection_lib/src/trakt_connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ impl TraktConnection {
.map(|entry| {
let imdb: StackString = entry.show.ids.imdb.unwrap_or_else(|| "".into());
TraktCalEntry {
ep_link: entry.episode.ids.imdb.as_ref().map(Clone::clone),
ep_link: entry.episode.ids.imdb.clone(),
episode: entry.episode.number,
link: imdb,
season: entry.episode.season,
Expand Down
12 changes: 11 additions & 1 deletion movie_collection_lib/src/trakt_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,17 @@ async fn get_imdb_url_from_show(
show: &str,
) -> Result<Option<StackString>, Error> {
let imdb_shows = mc.print_imdb_shows(show, false).await?;
let result = if imdb_shows.len() > 1 {
let result = if imdb_shows.is_empty() {
let shows = mc.print_imdb_shows(show, true).await?;
if shows.len() == 1 {
Some(shows[0].link.clone())
} else {
for show in imdb_shows {
debug!("{}", show);
}
None
}
} else if imdb_shows.len() > 1 {
for show in imdb_shows {
debug!("{}", show);
}
Expand Down
13 changes: 8 additions & 5 deletions movie_collection_lib/src/transcode_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ use crate::{
pgpool::PgPool, utils::parse_file_stem,
};

static ACCEPT_PATHS: [&str; 2] = ["/usr/bin/run-encoding", "/usr/bin/HandBrakeCLI"];
static ENCODING_PATH: &str = "/usr/bin/run-encoding";
static HANDBRAKE_PATH: &str = "/usr/bin/HandBrakeCLI";

static ACCEPT_PATHS: [&str; 2] = [ENCODING_PATH, HANDBRAKE_PATH];

#[derive(Serialize, Deserialize, Debug, PartialEq, Clone, Copy, Eq)]
pub enum JobType {
Expand Down Expand Up @@ -357,7 +360,7 @@ impl TranscodeService {
let stdout_path = debug_output_path.with_extension("out");
let stderr_path = debug_output_path.with_extension("err");

let mut p = Command::new("HandBrakeCLI")
let mut p = Command::new(HANDBRAKE_PATH)
.args([
"-i",
input_file.to_string_lossy().as_ref(),
Expand Down Expand Up @@ -876,7 +879,7 @@ mod tests {
init_env,
transcode_service::{
get_current_jobs, get_last_line, get_paths, get_procs, get_upcoming_jobs,
transcode_status, JobType, ProcInfo, TranscodeServiceRequest,
transcode_status, JobType, ProcInfo, TranscodeServiceRequest, HANDBRAKE_PATH,
},
};

Expand Down Expand Up @@ -976,13 +979,13 @@ mod tests {
let p = ProcInfo {
pid: 25625,
name: "HandBrakeCLI".into(),
exe: "/usr/bin/HandBrakeCLI".into(),
exe: HANDBRAKE_PATH.into(),
cmdline: cmdline.clone(),
};
assert_eq!(
StackString::from_display(p),
format_sstr!(
"25625\tHandBrakeCLI\t/usr/bin/HandBrakeCLI\t{}",
"25625\tHandBrakeCLI\t{HANDBRAKE_PATH}\t{}",
cmdline.join(" ")
)
);
Expand Down
2 changes: 2 additions & 0 deletions scripts/bootstrap_db.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ sudo -u postgres createuser -E -e $USER
sudo -u postgres psql -c "CREATE ROLE $USER PASSWORD '$PASSWORD' NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;"
sudo -u postgres psql -c "ALTER ROLE $USER PASSWORD '$PASSWORD' NOSUPERUSER NOCREATEDB NOCREATEROLE INHERIT LOGIN;"
sudo -u postgres createdb $DB
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE $DB TO $USER;"
sudo -u postgres psql $DB -c "GRANT ALL ON SCHEMA public TO $USER;"

mkdir -p ${HOME}/.config/movie_collection_rust/

Expand Down
4 changes: 2 additions & 2 deletions transcode_lib/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "transcode_lib"
version = "0.10.47"
version = "0.10.48"
authors = ["Daniel Boline <[email protected]>"]
edition = "2018"

Expand All @@ -11,7 +11,7 @@ anyhow = "1.0"
deadpool = "0.12"
deadpool-lapin = {version="0.12", features=["serde"]}
lapin = {version="2.0", default-features=false, features=["rustls"]}
derive_more = "0.99"
derive_more = {version="1.0", features=["full"]}
futures = "0.3"
log = "0.4"
serde = {version="1.0", features=["derive"]}
Expand Down
4 changes: 2 additions & 2 deletions transcode_lib/src/transcode_channel.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use anyhow::{format_err, Error};
use deadpool_lapin::Config as LapinConfig;
use deadpool_lapin::{Config as LapinConfig, Runtime};
use derive_more::{Deref, DerefMut};
use futures::StreamExt;
use lapin::{
Expand All @@ -20,7 +20,7 @@ pub struct TranscodeChannel(Channel);
impl TranscodeChannel {
pub async fn open_channel() -> Result<Self, Error> {
let cfg = LapinConfig::default();
let pool = cfg.create_pool(None)?;
let pool = cfg.create_pool(Some(Runtime::Tokio1))?;
let conn = pool.get().await?;
conn.create_channel().await.map_err(Into::into).map(Self)
}
Expand Down

0 comments on commit c22e171

Please sign in to comment.