about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-25 17:30:02 +0200
committerBenedikt Peetz <benedikt.peetz@b-peetz.de>2024-08-25 17:30:02 +0200
commita60cd8f2a96aae3f7db8dfccec2aa5cf21f8c411 (patch)
tree24dc96e5384cf9309ae4ec00d6d91497e3253484
parentdocs(yt_dlp/progress_hook): Add a note about the possibility to calculate vid... (diff)
downloadyt-a60cd8f2a96aae3f7db8dfccec2aa5cf21f8c411.tar.gz
yt-a60cd8f2a96aae3f7db8dfccec2aa5cf21f8c411.zip
refactor(treewide): Conform to `cargo clippy`
-rw-r--r--crates/yt_dlp/src/lib.rs8
-rw-r--r--crates/yt_dlp/src/logging.rs5
-rw-r--r--src/comments/mod.rs2
-rw-r--r--src/config/default.rs2
-rw-r--r--src/config/file_system.rs2
-rw-r--r--src/download/mod.rs22
-rw-r--r--src/main.rs4
-rw-r--r--src/select/cmds.rs12
-rw-r--r--src/select/mod.rs4
-rw-r--r--src/select/selection_file/display.rs2
-rw-r--r--src/select/selection_file/mod.rs2
-rw-r--r--src/status/mod.rs2
-rw-r--r--src/storage/video_database/downloader.rs8
-rw-r--r--src/storage/video_database/extractor_hash.rs3
-rw-r--r--src/storage/video_database/getters.rs4
-rw-r--r--src/subscribe/mod.rs26
-rw-r--r--src/update/mod.rs9
-rw-r--r--src/videos/mod.rs2
-rw-r--r--src/watch/events/mod.rs33
-rw-r--r--src/watch/events/playlist_handler.rs4
-rw-r--r--src/watch/mod.rs2
21 files changed, 76 insertions, 82 deletions
diff --git a/crates/yt_dlp/src/lib.rs b/crates/yt_dlp/src/lib.rs
index b0dffa4..2f554a9 100644
--- a/crates/yt_dlp/src/lib.rs
+++ b/crates/yt_dlp/src/lib.rs
@@ -81,7 +81,7 @@ signal.signal(signal.SIGINT, signal.SIG_DFL)
 }
 
 #[pyfunction]
-pub fn progress_hook<'a>(py: Python, input: Bound<'_, PyDict>) -> PyResult<()> {
+pub fn progress_hook(py: Python, input: Bound<'_, PyDict>) -> PyResult<()> {
     // Only add the handler, if the log-level is higher than Debug (this avoids covering debug
     // messages).
     if log_enabled!(Level::Debug) {
@@ -350,7 +350,9 @@ pub async fn download(
         let result_string = if let Some(filename) = info_json.filename {
             filename
         } else {
-            (&info_json.requested_downloads.expect("This must exist")[0].filename).to_owned()
+            info_json.requested_downloads.expect("This must exist")[0]
+                .filename
+                .to_owned()
         };
 
         out_paths.push(result_string);
@@ -407,7 +409,7 @@ fn json_loads(py: Python, input: String) -> PyResult<Bound<PyDict>> {
         .clone())
 }
 
-fn get_yt_dlp_utils<'a>(py: Python<'a>) -> PyResult<Bound<'a, PyAny>> {
+fn get_yt_dlp_utils(py: Python<'_>) -> PyResult<Bound<'_, PyAny>> {
     let yt_dlp = PyModule::import_bound(py, "yt_dlp")?;
     let utils = yt_dlp.getattr("utils")?;
 
diff --git a/crates/yt_dlp/src/logging.rs b/crates/yt_dlp/src/logging.rs
index cca917c..02af3ff 100644
--- a/crates/yt_dlp/src/logging.rs
+++ b/crates/yt_dlp/src/logging.rs
@@ -20,7 +20,7 @@ use pyo3::{
 
 /// Consume a Python `logging.LogRecord` and emit a Rust `Log` instead.
 #[pyfunction]
-fn host_log<'a>(record: Bound<'a, PyAny>, rust_target: &str) -> PyResult<()> {
+fn host_log(record: Bound<'_, PyAny>, rust_target: &str) -> PyResult<()> {
     let level = record.getattr("levelno")?;
     let message = record.getattr("getMessage")?.call0()?.to_string();
     let pathname = record.getattr("pathname")?.to_string();
@@ -42,8 +42,7 @@ fn host_log<'a>(record: Bound<'a, PyAny>, rust_target: &str) -> PyResult<()> {
     };
 
     let target = full_target
-        .as_ref()
-        .map(|x| x.as_str())
+        .as_deref()
         .unwrap_or(rust_target);
 
     // error
diff --git a/src/comments/mod.rs b/src/comments/mod.rs
index aa4cc06..5fbc3fb 100644
--- a/src/comments/mod.rs
+++ b/src/comments/mod.rs
@@ -32,7 +32,7 @@ mod display;
 
 pub async fn get_comments(app: &App) -> Result<Comments> {
     let currently_playing_video: Video =
-        if let Some(video) = get_currently_playing_video(&app).await? {
+        if let Some(video) = get_currently_playing_video(app).await? {
             video
         } else {
             bail!("Could not find a currently playing video!");
diff --git a/src/config/default.rs b/src/config/default.rs
index 8eedb18..59063f5 100644
--- a/src/config/default.rs
+++ b/src/config/default.rs
@@ -34,7 +34,7 @@ fn get_config_path(name: &'static str) -> Result<PathBuf> {
 pub(super) fn create_path(path: PathBuf) -> Result<PathBuf> {
     if !path.exists() {
         if let Some(parent) = path.parent() {
-            std::fs::create_dir_all(&parent)
+            std::fs::create_dir_all(parent)
                 .with_context(|| format!("Failed to create the '{}' directory", path.display()))?
         }
     }
diff --git a/src/config/file_system.rs b/src/config/file_system.rs
index fd3a8d8..5751583 100644
--- a/src/config/file_system.rs
+++ b/src/config/file_system.rs
@@ -72,7 +72,7 @@ impl Config {
         config_path: Option<PathBuf>,
     ) -> Result<Self> {
         let config_file_path = config_path
-            .map(|val| Ok(val))
+            .map(Ok)
             .unwrap_or_else(|| -> Result<_> { paths::config_path() })?;
 
         let config: super::definitions::ConfigFile =
diff --git a/src/download/mod.rs b/src/download/mod.rs
index b2d0b06..51f1a66 100644
--- a/src/download/mod.rs
+++ b/src/download/mod.rs
@@ -71,6 +71,12 @@ pub struct Downloader {
     cached_cache_allocation: Option<u64>,
 }
 
+impl Default for Downloader {
+    fn default() -> Self {
+        Self::new()
+    }
+}
+
 impl Downloader {
     pub fn new() -> Self {
         Self {
@@ -95,8 +101,8 @@ impl Downloader {
                 return Ok(CacheSizeCheck::Fits);
             }
         }
-        let cache_allocation = Self::get_current_cache_allocation(&app).await?;
-        let video_size = self.get_approx_video_size(&app, &next_video).await?;
+        let cache_allocation = Self::get_current_cache_allocation(app).await?;
+        let video_size = self.get_approx_video_size(app, next_video).await?;
 
         if video_size >= max_cache_size {
             error!(
@@ -159,7 +165,7 @@ impl Downloader {
                 CacheSizeCheck::ExceedsMaxCacheSize => bail!("Giving up."),
             };
 
-            if let Some(_) = &self.current_download {
+            if self.current_download.is_some() {
                 let current_download = self.current_download.take().expect("Is Some");
 
                 if current_download.task_handle.is_finished() {
@@ -233,9 +239,9 @@ impl Downloader {
             let add_opts = YtDlpOptions {
                 subtitle_langs: "".to_owned(),
             };
-            let opts = &download_opts(&app, add_opts);
+            let opts = &download_opts(app, add_opts);
 
-            let result = yt_dlp::extract_info(&opts, &video.url, false, true)
+            let result = yt_dlp::extract_info(opts, &video.url, false, true)
                 .await
                 .with_context(|| {
                     format!("Failed to extract video information: '{}'", video.title)
@@ -274,16 +280,16 @@ impl Downloader {
     async fn actually_cache_video(app: &App, video: &Video) -> Result<()> {
         debug!("Download started: {}", &video.title);
 
-        let addional_opts = get_video_yt_dlp_opts(&app, &video.extractor_hash).await?;
+        let addional_opts = get_video_yt_dlp_opts(app, &video.extractor_hash).await?;
 
-        let result = yt_dlp::download(&[video.url.clone()], &download_opts(&app, addional_opts))
+        let result = yt_dlp::download(&[video.url.clone()], &download_opts(app, addional_opts))
             .await
             .with_context(|| format!("Failed to download video: '{}'", video.title))?;
 
         assert_eq!(result.len(), 1);
         let result = &result[0];
 
-        set_video_cache_path(app, &video.extractor_hash, Some(&result)).await?;
+        set_video_cache_path(app, &video.extractor_hash, Some(result)).await?;
 
         info!(
             "Video '{}' was downlaoded to path: {}",
diff --git a/src/main.rs b/src/main.rs
index 304b99f..c5115ac 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -8,7 +8,7 @@
 // You should have received a copy of the License along with this program.
 // If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
 
-use std::{collections::HashMap, fs, sync::Arc, u8};
+use std::{collections::HashMap, fs, sync::Arc};
 
 use anyhow::{bail, Context, Result};
 use app::App;
@@ -148,7 +148,7 @@ async fn main() -> Result<()> {
             let all_subs = get_subscriptions(&app).await?;
 
             for sub in &subscriptions {
-                if let None = all_subs.0.get(sub) {
+                if !all_subs.0.contains_key(sub) {
                     bail!(
                         "Your specified subscription to update '{}' is not a subscription!",
                         sub
diff --git a/src/select/cmds.rs b/src/select/cmds.rs
index 2b36fe8..31589f2 100644
--- a/src/select/cmds.rs
+++ b/src/select/cmds.rs
@@ -36,10 +36,10 @@ pub async fn handle_select_cmd(
             handle_status_change(app, shared, line_number, VideoStatus::Watched).await?;
         }
         SelectCommand::Watch { shared } => {
-            let hash = shared.hash.clone().realize(&app).await?;
+            let hash = shared.hash.clone().realize(app).await?;
 
             let video = get_video_by_hash(app, &hash).await?;
-            if let Some(_) = video.cache_path {
+            if video.cache_path.is_some() {
                 handle_status_change(app, shared, line_number, VideoStatus::Cached).await?;
             } else {
                 handle_status_change(app, shared, line_number, VideoStatus::Watch).await?;
@@ -63,7 +63,7 @@ async fn handle_status_change(
     line_number: Option<i64>,
     new_status: VideoStatus,
 ) -> Result<()> {
-    let hash = shared.hash.realize(&app).await?;
+    let hash = shared.hash.realize(app).await?;
     let video_options = VideoOptions::new(
         shared
             .subtitle_langs
@@ -81,9 +81,5 @@ async fn handle_status_change(
 fn compute_priority(line_number: Option<i64>, priority: Option<i64>) -> Option<i64> {
     if let Some(pri) = priority {
         Some(pri)
-    } else if let Some(pri) = line_number {
-        Some(pri)
-    } else {
-        None
-    }
+    } else { line_number }
 }
diff --git a/src/select/mod.rs b/src/select/mod.rs
index 695e7ed..2663a04 100644
--- a/src/select/mod.rs
+++ b/src/select/mod.rs
@@ -62,7 +62,7 @@ pub async fn select(app: &App, done: bool, use_last_selection: bool) -> Result<(
 
         // Warmup the cache for the display rendering of the videos.
         // Otherwise the futures would all try to warm it up at the same time.
-        if let Some(vid) = matching_videos.get(0) {
+        if let Some(vid) = matching_videos.first() {
             let _ = vid.to_select_file_display(app).await?;
         }
 
@@ -136,7 +136,7 @@ pub async fn select(app: &App, done: bool, use_last_selection: bool) -> Result<(
             };
 
             handle_select_cmd(
-                &app,
+                app,
                 cmd.expect("This value should always be some here"),
                 Some(line_number),
             )
diff --git a/src/select/selection_file/display.rs b/src/select/selection_file/display.rs
index 1f4e09b..8ff6a15 100644
--- a/src/select/selection_file/display.rs
+++ b/src/select/selection_file/display.rs
@@ -32,7 +32,7 @@ impl Video {
 
         let opts = get_video_opts(app, &self.extractor_hash)
             .await?
-            .to_cli_flags(&app);
+            .to_cli_flags(app);
         let opts_white = if !opts.is_empty() { " " } else { "" };
 
         let publish_date = if let Some(date) = self.publish_date {
diff --git a/src/select/selection_file/mod.rs b/src/select/selection_file/mod.rs
index bdb0866..d228023 100644
--- a/src/select/selection_file/mod.rs
+++ b/src/select/selection_file/mod.rs
@@ -28,7 +28,7 @@ pub fn process_line(line: &str) -> Result<Option<Vec<String>>> {
 
         let mut vec = Vec::with_capacity(tri.arguments().len() + 1);
         vec.push(tri.command().to_owned());
-        vec.extend(tri.arguments().to_vec().into_iter());
+        vec.extend(tri.arguments().to_vec());
 
         Ok(Some(vec))
     }
diff --git a/src/status/mod.rs b/src/status/mod.rs
index 688ac9a..7ffe8d7 100644
--- a/src/status/mod.rs
+++ b/src/status/mod.rs
@@ -72,7 +72,7 @@ pub async fn show(app: &App) -> Result<()> {
     let drop_videos_changing = get!(@changing all_videos, Drop);
     let dropped_videos_changing = get!(@changing all_videos, Dropped);
 
-    let subscriptions = get_subscriptions(&app).await?;
+    let subscriptions = get_subscriptions(app).await?;
     let subscriptions_len = subscriptions.0.len();
 
     let cache_usage_raw = Downloader::get_current_cache_allocation(app)
diff --git a/src/storage/video_database/downloader.rs b/src/storage/video_database/downloader.rs
index bba2b0a..c5490f3 100644
--- a/src/storage/video_database/downloader.rs
+++ b/src/storage/video_database/downloader.rs
@@ -43,11 +43,7 @@ pub async fn get_next_uncached_video(app: &App) -> Result<Option<Video>> {
     } else {
         let base = result?;
 
-        let thumbnail_url = if let Some(url) = &base.thumbnail_url {
-            Some(Url::parse(&url).expect("Parsing this as url should always work"))
-        } else {
-            None
-        };
+        let thumbnail_url = base.thumbnail_url.as_ref().map(|url| Url::parse(url).expect("Parsing this as url should always work"));
 
         let status_change = if base.status_change == 1 {
             true
@@ -57,7 +53,7 @@ pub async fn get_next_uncached_video(app: &App) -> Result<Option<Video>> {
         };
 
         let video = Video {
-            cache_path: base.cache_path.as_ref().map(|val| PathBuf::from(val)),
+            cache_path: base.cache_path.as_ref().map(PathBuf::from),
             description: base.description.clone(),
             duration: base.duration,
             extractor_hash: ExtractorHash::from_hash(
diff --git a/src/storage/video_database/extractor_hash.rs b/src/storage/video_database/extractor_hash.rs
index 09ca2ea..62a9eda 100644
--- a/src/storage/video_database/extractor_hash.rs
+++ b/src/storage/video_database/extractor_hash.rs
@@ -90,7 +90,6 @@ impl ExtractorHash {
             self.hash()
                 .to_hex()
                 .chars()
-                .into_iter()
                 .take(needed_chars)
                 .collect::<String>(),
         ))
@@ -102,7 +101,7 @@ impl ExtractorHash {
         let needed_chars = s.0.len();
 
         for hash in all_hashes {
-            if &hash.to_hex()[..needed_chars] == s.0 {
+            if hash.to_hex()[..needed_chars] == s.0 {
                 return Ok(hash);
             }
         }
diff --git a/src/storage/video_database/getters.rs b/src/storage/video_database/getters.rs
index 176ebbb..f2b0507 100644
--- a/src/storage/video_database/getters.rs
+++ b/src/storage/video_database/getters.rs
@@ -113,7 +113,7 @@ pub async fn get_videos(
             "Failed to query videos with states: '{}'",
             allowed_states.iter().fold(String::new(), |mut acc, state| {
                 acc.push(' ');
-                acc.push_str(&state.as_str());
+                acc.push_str(state.as_str());
                 acc
             }),
         )
@@ -126,7 +126,7 @@ pub async fn get_videos(
                 cache_path: base
                     .get::<Option<String>, &str>("cache_path")
                     .as_ref()
-                    .map(|val| PathBuf::from(val)),
+                    .map(PathBuf::from),
                 description: base.get::<Option<String>, &str>("description").clone(),
                 duration: base.get("duration"),
                 extractor_hash: ExtractorHash::from_hash(
diff --git a/src/subscribe/mod.rs b/src/subscribe/mod.rs
index 1cb3092..74d88b4 100644
--- a/src/subscribe/mod.rs
+++ b/src/subscribe/mod.rs
@@ -27,10 +27,10 @@ use crate::{
 };
 
 pub async fn unsubscribe(app: &App, name: String) -> Result<()> {
-    let present_subscriptions = get_subscriptions(&app).await?;
+    let present_subscriptions = get_subscriptions(app).await?;
 
     if let Some(subscription) = present_subscriptions.0.get(&name) {
-        remove_subscription(&app, subscription).await?;
+        remove_subscription(app, subscription).await?;
     } else {
         bail!("Couldn't find subscription: '{}'", &name);
     }
@@ -44,7 +44,7 @@ pub async fn import<W: AsyncBufRead + AsyncBufReadExt + Unpin>(
     force: bool,
 ) -> Result<()> {
     if force {
-        remove_all_subscriptions(&app).await?;
+        remove_all_subscriptions(app).await?;
     }
 
     let mut lines = reader.lines();
@@ -59,7 +59,7 @@ pub async fn import<W: AsyncBufRead + AsyncBufReadExt + Unpin>(
             Err(err) => eprintln!(
                 "Error while subscribing to '{}': '{}'",
                 line,
-                err.source().expect("Should have a source").to_string()
+                err.source().expect("Should have a source")
             ),
         }
     }
@@ -84,7 +84,7 @@ pub async fn subscribe(app: &App, name: Option<String>, url: Url) -> Result<()>
         if let Some(name) = name {
             let out: Result<()> = async move {
                 actual_subscribe(
-                    &app,
+                    app,
                     Some(name.clone() + " {Videos}"),
                     url.join("videos/").expect("Works"),
                 )
@@ -94,7 +94,7 @@ pub async fn subscribe(app: &App, name: Option<String>, url: Url) -> Result<()>
                 })?;
 
                 actual_subscribe(
-                    &app,
+                    app,
                     Some(name.clone() + " {Streams}"),
                     url.join("streams/").expect("Works"),
                 )
@@ -104,7 +104,7 @@ pub async fn subscribe(app: &App, name: Option<String>, url: Url) -> Result<()>
                 })?;
 
                 actual_subscribe(
-                    &app,
+                    app,
                     Some(name.clone() + " {Shorts}"),
                     url.join("shorts/").expect("Works"),
                 )
@@ -118,20 +118,20 @@ pub async fn subscribe(app: &App, name: Option<String>, url: Url) -> Result<()>
 
             out?
         } else {
-            actual_subscribe(&app, None, url.join("videos/").expect("Works"))
+            actual_subscribe(app, None, url.join("videos/").expect("Works"))
                 .await
                 .with_context(|| format!("Failed to subscribe to the '{}' variant", "{Videos}"))?;
 
-            actual_subscribe(&app, None, url.join("streams/").expect("Works"))
+            actual_subscribe(app, None, url.join("streams/").expect("Works"))
                 .await
                 .with_context(|| format!("Failed to subscribe to the '{}' variant", "{Streams}"))?;
 
-            actual_subscribe(&app, None, url.join("shorts/").expect("Works"))
+            actual_subscribe(app, None, url.join("shorts/").expect("Works"))
                 .await
                 .with_context(|| format!("Failed to subscribe to the '{}' variant", "{Shorts}"))?;
         }
     } else {
-        actual_subscribe(&app, name, url).await?;
+        actual_subscribe(app, name, url).await?;
     }
 
     Ok(())
@@ -164,7 +164,7 @@ async fn actual_subscribe(app: &App, name: Option<String>, url: Url) -> Result<(
         }
     };
 
-    let present_subscriptions = get_subscriptions(&app).await?;
+    let present_subscriptions = get_subscriptions(app).await?;
 
     if let Some(subs) = present_subscriptions.0.get(&name) {
         bail!(
@@ -178,7 +178,7 @@ async fn actual_subscribe(app: &App, name: Option<String>, url: Url) -> Result<(
 
     let sub = Subscription { name, url };
 
-    add_subscription(&app, &sub).await?;
+    add_subscription(app, &sub).await?;
 
     Ok(())
 }
diff --git a/src/update/mod.rs b/src/update/mod.rs
index ce31c7b..69551ed 100644
--- a/src/update/mod.rs
+++ b/src/update/mod.rs
@@ -37,7 +37,7 @@ pub async fn update(
     subs_to_update: Vec<String>,
     verbosity: u8,
 ) -> Result<()> {
-    let subscriptions = get_subscriptions(&app).await?;
+    let subscriptions = get_subscriptions(app).await?;
     let mut back_subs: HashMap<Url, Subscription> = HashMap::new();
     let logging = verbosity > 0;
     let log_level = match verbosity {
@@ -71,7 +71,7 @@ pub async fn update(
         .arg(urls.len().to_string())
         .arg(log_level.to_string())
         .args(&urls)
-        .args(&hashes.iter().map(|haz| haz.to_string()).collect::<Vec<_>>())
+        .args(hashes.iter().map(|haz| haz.to_string()).collect::<Vec<_>>())
         .stdout(Stdio::piped())
         .stderr(if logging {
             Stdio::inherit()
@@ -124,7 +124,7 @@ async fn process_subscription(
     app: &App,
     sub: &Subscription,
     entry: InfoJson,
-    hashes: &Vec<blake3::Hash>,
+    hashes: &[blake3::Hash],
 ) -> Result<()> {
     macro_rules! unwrap_option {
         ($option:expr) => {
@@ -181,8 +181,7 @@ async fn process_subscription(
 
         // TODO: The algorithm is not exactly the best <2024-05-28>
         (Some(thumbnails), None) => Some(
-            thumbnails
-                .get(0)
+            thumbnails.first()
                 .expect("At least one should exist")
                 .url
                 .clone(),
diff --git a/src/videos/mod.rs b/src/videos/mod.rs
index b51e469..3876bd1 100644
--- a/src/videos/mod.rs
+++ b/src/videos/mod.rs
@@ -24,7 +24,7 @@ pub async fn query(app: &App, limit: Option<usize>, search_query: Option<String>
     let all_videos = get_videos(app, VideoStatus::ALL, None).await?;
 
     // turn one video to a color display, to pre-warm the hash shrinking cache
-    if let Some(val) = all_videos.get(0) {
+    if let Some(val) = all_videos.first() {
         val.to_color_display(app).await?;
     }
 
diff --git a/src/watch/events/mod.rs b/src/watch/events/mod.rs
index 9ca12fd..1459147 100644
--- a/src/watch/events/mod.rs
+++ b/src/watch/events/mod.rs
@@ -8,7 +8,7 @@
 // You should have received a copy of the License along with this program.
 // If not, see <https://www.gnu.org/licenses/gpl-3.0.txt>.
 
-use std::{collections::HashMap, env::current_exe, mem, time::Duration, usize};
+use std::{collections::HashMap, env::current_exe, mem, time::Duration};
 
 use anyhow::{bail, Result};
 use libmpv2::{
@@ -58,9 +58,9 @@ impl MpvEventHandler {
         let play_things = get_videos(app, &[VideoStatus::Cached], Some(false)).await?;
 
         // There is nothing to watch
-        if play_things.len() == 0 {
+        if play_things.is_empty() {
             if force_message {
-                Self::message(&mpv, "No new videos available to add", "3000")?;
+                Self::message(mpv, "No new videos available to add", "3000")?;
             }
             return Ok(0);
         }
@@ -72,8 +72,7 @@ impl MpvEventHandler {
             .filter(|val| {
                 !current_playlist
                     .values()
-                    .find(|a| *a == &val.extractor_hash)
-                    .is_some()
+                    .any(|a| a == &val.extractor_hash)
             })
             .filter(|val| {
                 if self
@@ -112,7 +111,7 @@ impl MpvEventHandler {
 
         if force_message || num > 0 {
             Self::message(
-                &mpv,
+                mpv,
                 format!(
                     "Added {} videos ({} are marked as watch later)",
                     num, blocked_videos
@@ -163,7 +162,7 @@ impl MpvEventHandler {
     async fn mark_video_watched(&self, app: &App, hash: &ExtractorHash) -> Result<()> {
         let video = get_video_by_hash(app, hash).await?;
         debug!("MPV handler will mark video '{}' watched.", video.title);
-        set_video_watched(&app, &video).await?;
+        set_video_watched(app, &video).await?;
         Ok(())
     }
 
@@ -178,7 +177,7 @@ impl MpvEventHandler {
             .get(&playlist_index)
             .expect("The video index should always be correctly tracked");
 
-        set_state_change(&app, video_hash, false).await?;
+        set_state_change(app, video_hash, false).await?;
         Ok(())
     }
     async fn mark_video_active(
@@ -192,7 +191,7 @@ impl MpvEventHandler {
             .get(&playlist_index)
             .expect("The video index should always be correctly tracked");
 
-        set_state_change(&app, video_hash, true).await?;
+        set_state_change(app, video_hash, true).await?;
         Ok(())
     }
 
@@ -259,9 +258,9 @@ impl MpvEventHandler {
                     // draining the playlist is okay, as mpv is done playing
                     let mut handler = mem::take(&mut self.playlist_handler);
                     let videos = handler.playlist_ids(mpv)?;
-                    for (_, hash) in videos {
-                        self.mark_video_watched(app, &hash).await?;
-                        set_state_change(&app, &hash, false).await?;
+                    for hash in videos.values() {
+                        self.mark_video_watched(app, hash).await?;
+                        set_state_change(app, hash, false).await?;
                     }
                     return Ok(true);
                 }
@@ -273,7 +272,7 @@ impl MpvEventHandler {
                 }
             },
             Event::StartFile(entry_id) => {
-                self.possibly_add_new_videos(app, &mpv, false).await?;
+                self.possibly_add_new_videos(app, mpv, false).await?;
 
                 // We don't need to check, whether other videos are still active, as they should
                 // have been marked inactive in the `Stop` handler.
@@ -297,7 +296,7 @@ impl MpvEventHandler {
                         }
 
                         let status = Command::new("alacritty")
-                            .args(&[
+                            .args([
                                 "--title",
                                 "floating please",
                                 "--command",
@@ -338,7 +337,7 @@ impl MpvEventHandler {
                     }
                     &["yt-description"] => {
                         // let description = description(app).await?;
-                        Self::message(&mpv, "<YT Description>", "6000")?;
+                        Self::message(mpv, "<YT Description>", "6000")?;
                     }
                     &["yt-mark-watch-later"] => {
                         mpv.execute("write-watch-later-config", &[])?;
@@ -350,13 +349,13 @@ impl MpvEventHandler {
                             "A video should not be blocked *and* in the playlist"
                         );
 
-                        Self::message(&mpv, "Marked the video to be watched later", "3000")?;
+                        Self::message(mpv, "Marked the video to be watched later", "3000")?;
                     }
                     &["yt-mark-done-and-go-next"] => {
                         let cvideo_hash = self.remove_cvideo_from_playlist(mpv)?;
                         self.mark_video_watched(app, &cvideo_hash).await?;
 
-                        Self::message(&mpv, "Marked the video watched", "3000")?;
+                        Self::message(mpv, "Marked the video watched", "3000")?;
                     }
                     &["yt-check-new-videos"] => {
                         self.possibly_add_new_videos(app, mpv, true).await?;
diff --git a/src/watch/events/playlist_handler.rs b/src/watch/events/playlist_handler.rs
index 8f2f322..0933856 100644
--- a/src/watch/events/playlist_handler.rs
+++ b/src/watch/events/playlist_handler.rs
@@ -86,9 +86,7 @@ impl PlaylistHandler {
         }
 
         for (id, hash) in playlist {
-            if !self.playlist_ids.contains_key(&id) {
-                self.playlist_ids.insert(id, hash);
-            }
+            self.playlist_ids.entry(id).or_insert(hash);
         }
 
         Ok(&self.playlist_ids)
diff --git a/src/watch/mod.rs b/src/watch/mod.rs
index 376b245..3bcf1fc 100644
--- a/src/watch/mod.rs
+++ b/src/watch/mod.rs
@@ -98,7 +98,7 @@ pub async fn watch(app: &App) -> Result<()> {
 
     let mut mpv_event_handler = MpvEventHandler::from_playlist(playlist_cache);
     loop {
-        while mpv_event_handler.check_idle(&app, &mpv).await? {}
+        while mpv_event_handler.check_idle(app, &mpv).await? {}
 
         if let Some(ev) = ev_ctx.wait_event(600.) {
             match ev {