about summary refs log tree commit diff stats
path: root/src/watch/mod.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/watch/mod.rs')
-rw-r--r--src/watch/mod.rs11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/watch/mod.rs b/src/watch/mod.rs
index 9eb1c18..376b245 100644
--- a/src/watch/mod.rs
+++ b/src/watch/mod.rs
@@ -8,6 +8,8 @@
 // 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;
+
 use anyhow::Result;
 use events::MpvEventHandler;
 use libmpv2::{events::EventContext, Mpv};
@@ -77,20 +79,21 @@ pub async fn watch(app: &App) -> Result<()> {
         play_things.len()
     );
 
-    let mut playlist_cache: Vec<ExtractorHash> = Vec::with_capacity(play_things.len());
+    let mut playlist_cache: HashMap<String, ExtractorHash> =
+        HashMap::with_capacity(play_things.len());
 
     for play_thing in play_things {
         debug!("Adding '{}' to playlist.", play_thing.title);
 
         let orig_cache_path = play_thing.cache_path.expect("Is cached and thus some");
         let cache_path = orig_cache_path.to_str().expect("Should be vaild utf8");
-        let cache_path = format!("\"{}\"", cache_path);
+        let fmt_cache_path = format!("\"{}\"", cache_path);
 
-        let args = &[&cache_path, "append-play"];
+        let args = &[&fmt_cache_path, "append-play"];
 
         mpv.execute("loadfile", args)?;
 
-        playlist_cache.push(play_thing.extractor_hash);
+        playlist_cache.insert(cache_path.to_owned(), play_thing.extractor_hash);
     }
 
     let mut mpv_event_handler = MpvEventHandler::from_playlist(playlist_cache);