Skip to content

Commit 7d75026

Browse files
committed
feat: initial commit, basic data parsing
0 parents  commit 7d75026

File tree

7 files changed

+508
-0
lines changed

7 files changed

+508
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

Cargo.lock

Lines changed: 259 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[package]
2+
name = "tape-encoder"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[dependencies]
9+
clap = { version = "3.0.0" }
10+
regex = "1.8.1"
11+
serde = { version = "1.0.96", features = ["derive"] }
12+
serde_json = "1.0"

src/fileio.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
use crate::metadata::*;
2+
use std::fs;
3+
use std::fs::File;
4+
use std::io::Write;
5+
6+
pub fn write_metadata(data: OutputMetadata) {
7+
let directory = data.title.replace("_", "-").replace(" ", "-").replace(".", "-");
8+
9+
if !fs::metadata(&directory).is_ok() {
10+
fs::create_dir(&directory).unwrap();
11+
}
12+
13+
let json = serde_json::to_string(&data).unwrap();
14+
let outpath = format!("{}/{}.json", &directory, data.title);
15+
let mut file = File::create(outpath).unwrap();
16+
file.write_all(json.as_bytes()).unwrap();
17+
}

src/main.rs

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
use clap::{App, Arg};
2+
use std::process;
3+
4+
mod fileio;
5+
mod media_info;
6+
mod metadata;
7+
8+
fn main() {
9+
let matches = App::new("tape-encoder")
10+
.version("1.0")
11+
.author("Matt Carrier")
12+
.about("Convert video to streamable pieces")
13+
.arg(
14+
Arg::with_name("input")
15+
.short('i')
16+
.long("input")
17+
.value_name("FILE")
18+
.help("Sets the input file to use")
19+
.takes_value(true),
20+
)
21+
.get_matches();
22+
23+
let input = matches.value_of("input").unwrap_or("help");
24+
// println!("Input file: {}", input);
25+
26+
if input == "help" {
27+
println!("Usage: <TODO>");
28+
29+
process::exit(1);
30+
}
31+
32+
let out = media_info::get_media_info(&input);
33+
println!("{:#?}", out);
34+
fileio::write_metadata(out);
35+
36+
/*
37+
TODO:
38+
[x] Take filename as argument to process
39+
[x] Read metadata from filename
40+
[x] Read metadata with mediainfo from video file
41+
[x] Make directory for metadata
42+
[x] Store Metadata in JSON
43+
44+
[ ] FFMPEG to generate media
45+
[ ] thumbnails
46+
[ ] gif
47+
[ ] preview image
48+
[ ] HLS
49+
[ ] DASH
50+
[ ] Metadata
51+
[ ] Upload metadata to database
52+
53+
[ ] Create queue watcher to start running jobs (watches queueu every 5 seconds)
54+
- On new item run generator process
55+
*/
56+
}

0 commit comments

Comments
 (0)