File tree Expand file tree Collapse file tree 1 file changed +4
-16
lines changed Expand file tree Collapse file tree 1 file changed +4
-16
lines changed Original file line number Diff line number Diff line change @@ -4,28 +4,16 @@ use std::fs;
4
4
use std:: process:: Command ;
5
5
6
6
pub fn get_media_info ( input : & str ) -> OutputMetadata {
7
- let re = Regex :: new ( r"(\d{4}(?:-|\.)\d{2}(?:-|\.)\d{2})?(?:-|\.)*(.+).(mp4)" ) . unwrap ( ) ;
8
-
9
- let captures = re. captures ( input) . expect ( "expect YYYY-MM-DD-File-Name.mp4" ) ;
10
-
11
- println ! ( "captures len {}" , captures. len( ) ) ;
12
- for cap in 0 ..captures. len ( ) {
13
- println ! (
14
- "{}: {}" ,
15
- cap,
16
- format!( "{}" , captures. get( cap) . unwrap( ) . as_str( ) )
17
- ) ;
18
7
if !fs:: metadata ( & input) . is_ok ( ) {
19
8
println ! ( "{} is not found." , & input) ;
20
9
std:: process:: exit ( 1 ) ;
21
10
}
22
11
23
- // TODO: Make the date optional
24
- // let mut date = "";
25
- // if captures.len() < 4 {
26
- // }
12
+ let re = Regex :: new ( r"(\d{4}(?:-|\.)\d{2}(?:-|\.)\d{2})?(?:-|\.)*(.+).(mp4|mov)" ) . unwrap ( ) ;
13
+
14
+ let captures = re. captures ( input) . expect ( "expect YYYY-MM-DD-File-Name.mp4" ) ;
27
15
28
- let date = captures. get ( 1 ) . unwrap ( ) . as_str ( ) ;
16
+ let date = captures. get ( 1 ) . map_or ( "No Date" , |x| x . as_str ( ) ) ;
29
17
let extracted_filename = captures. get ( 2 ) . unwrap ( ) . as_str ( ) ;
30
18
let extension = captures. get ( 3 ) . unwrap ( ) . as_str ( ) ;
31
19
You can’t perform that action at this time.
0 commit comments