Skip to content

Commit 68ed95a

Browse files
committed
[*] refactor: video editor
1 parent dff621b commit 68ed95a

File tree

10 files changed

+204
-448
lines changed

10 files changed

+204
-448
lines changed

lib/video-editor/examples/media_basic_demo.rs

Lines changed: 0 additions & 142 deletions
This file was deleted.

lib/video-editor/examples/media_library_demo.rs

Lines changed: 4 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ fn main() -> Result<()> {
2727
for file_path in &test_files {
2828
match library.add_file(PathBuf::from(file_path)) {
2929
Ok(id) => {
30-
if let Some(item) = library.get_item(&id) {
30+
if let Some(item) = library.get_item(id) {
3131
log::info!(" ✓ Added: {} (ID: {})", item.name, id);
3232
log::info!(" Type: {}", item.media_type.as_str());
3333
log::info!(" Duration: {}", item.format_duration());
@@ -114,10 +114,6 @@ fn main() -> Result<()> {
114114
if !item.tags.is_empty() {
115115
log::info!(" Tags: {}", item.tags.join(", "));
116116
}
117-
118-
if let Some(folder_id) = &item.folder_id {
119-
log::info!(" Folder: {}", folder_id);
120-
}
121117
}
122118
}
123119

@@ -138,12 +134,12 @@ fn main() -> Result<()> {
138134
log::info!("=== Tag Management Demo ===");
139135
let items = library.all_items();
140136
if let Some(first_item) = items.first() {
141-
let item_id = first_item.id.clone();
137+
let item_id = first_item.id;
142138
let first_item_name = first_item.name.clone();
143139

144140
// Add tags to the first item
145141
let tags = vec!["demo".to_string(), "example".to_string()];
146-
if let Some(item) = library.get_item_mut(&item_id) {
142+
if let Some(item) = library.get_item_mut(item_id) {
147143
*item = item.clone().with_tags(tags.clone());
148144
log::info!("Added tags to item '{}': {:?}", first_item_name, tags);
149145
}
@@ -153,31 +149,7 @@ fn main() -> Result<()> {
153149
log::info!("Items tagged with 'demo': {}", tagged_items.len());
154150
}
155151

156-
// Step 9: Demonstrate folder functionality
157-
log::info!("=== Folder Organization Demo ===");
158-
let folder_id = "test_folder".to_string();
159-
160-
// Add some items to a folder
161-
let all_items = library.all_items();
162-
let item_ids: Vec<String> = all_items
163-
.iter()
164-
.take(2)
165-
.map(|item| item.id.clone())
166-
.collect();
167-
168-
for item_id in item_ids {
169-
if let Some(item_mut) = library.get_item_mut(&item_id) {
170-
*item_mut = item_mut.clone().with_folder(folder_id.clone());
171-
}
172-
}
173-
174-
let folder_items = library.items_by_folder(&folder_id);
175-
log::info!("Items in folder '{}': {}", folder_id, folder_items.len());
176-
for item in folder_items {
177-
log::info!(" - {}", item.name);
178-
}
179-
180-
// Step 10: Demonstrate offline/online status
152+
// Step 9: Demonstrate offline/online status
181153
log::info!("=== File Status Demo ===");
182154
library.check_all_status();
183155
let offline_items = library.offline_items();

lib/video-editor/examples/playlist_demo.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
use std::{path::PathBuf, time::Duration};
2-
use video_editor::{media::MediaType, playlist::Playlist};
2+
use video_editor::media::{MediaType, playlist::Playlist};
33

44
fn main() -> Result<(), Box<dyn std::error::Error>> {
55
env_logger::init();
@@ -89,9 +89,10 @@ fn main() -> Result<(), Box<dyn std::error::Error>> {
8989
match Playlist::from_json(&modified_json) {
9090
Ok(restored_playlist) => {
9191
log::info!(" Successfully restored playlist from JSON");
92+
let count: usize = restored_playlist.item_count();
9293
log::info!(
9394
" Restored playlist has {} items",
94-
restored_playlist.item_count()
95+
count
9596
);
9697
log::info!(" Cache is configured: {}", restored_playlist.has_cache());
9798

lib/video-editor/src/lib.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ pub mod filters;
44
pub mod font;
55
pub mod media;
66
pub mod metadata;
7-
pub mod playlist;
87
pub mod preview;
98
pub mod project;
109
pub mod tracks;

lib/video-editor/src/media.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
pub mod cache;
22
pub mod import;
33
pub mod library;
4+
pub mod media_type;
5+
pub mod playlist;
46

57
pub use cache::{MediaCache, MediaThumbnail};
68
pub use import::{ImportOptions, ImportProgress, MediaImporter};
7-
pub use library::{MediaItem, MediaItemStatus, MediaLibrary, MediaType};
9+
pub use library::{MediaItem, MediaItemStatus, MediaLibrary};
10+
pub use media_type::MediaType;

0 commit comments

Comments
 (0)