Compare commits
2
Commits
v0.6.0
...
4da7cc7b1c
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4da7cc7b1c | ||
|
|
9372b8ea07 |
+2
-2
@@ -1,4 +1,4 @@
|
||||
ROOT_DIRECTORY=/usr/local/bin
|
||||
ICARUS_BASE_API_URL=http://api:8000
|
||||
ICARUS_AUTH_BASE_API_URL=http://auth_api:8001
|
||||
SOARICARUS_BASE_API_URL=http://api:8000
|
||||
SOARICARUS_AUTH_BASE_API_URL=http://auth_api:8001
|
||||
SERVICE_PASSPHRASE=iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
ROOT_DIRECTORY=/tmp
|
||||
ICARUS_BASE_API_URL=http://localhost:8000
|
||||
ICARUS_AUTH_BASE_API_URL=http://localhost:8001
|
||||
SOARICARUS_BASE_API_URL=http://localhost:8000
|
||||
SOARICARUS_AUTH_BASE_API_URL=http://localhost:8001
|
||||
SERVICE_PASSPHRASE=iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
ROOT_DIRECTORY=/home/songparser/mydata
|
||||
ICARUS_BASE_API_URL=http://localhost:3000
|
||||
ICARUS_AUTH_BASE_API_URL=http://localhost:3001
|
||||
SERVICE_PASSPHRASE=iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH
|
||||
@@ -10,14 +10,14 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v5
|
||||
uses: actions/checkout@v6
|
||||
with:
|
||||
fetch-depth: 0 # Important for git describe --tags
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.95
|
||||
toolchain: 1.97
|
||||
components: cargo
|
||||
|
||||
- name: Extract Version from Cargo.toml
|
||||
|
||||
@@ -1,24 +1,27 @@
|
||||
name: Rust Build
|
||||
name: songparser
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- devel
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- devel
|
||||
|
||||
concurrency:
|
||||
group: ${{ github.workflow }}-${{ github.ref }}
|
||||
cancel-in-progress: true
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Check
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.95
|
||||
toolchain: 1.97
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
||||
@@ -28,33 +31,16 @@ jobs:
|
||||
ssh-add -v ~/.ssh/gitlab_deploy_key
|
||||
cargo check
|
||||
|
||||
test:
|
||||
name: Test Suite
|
||||
runs-on: ubuntu-24.04
|
||||
needs: setup_ssh
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.95
|
||||
- run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
||||
chmod 600 ~/.ssh/gitlab_deploy_key
|
||||
ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts
|
||||
eval $(ssh-agent -s)
|
||||
ssh-add -v ~/.ssh/gitlab_deploy_key
|
||||
cargo test
|
||||
|
||||
fmt:
|
||||
name: Rustfmt
|
||||
runs-on: ubuntu-24.04
|
||||
needs: setup_ssh
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.95
|
||||
toolchain: 1.97
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: rustup component add rustfmt
|
||||
- run: |
|
||||
mkdir -p ~/.ssh
|
||||
@@ -70,10 +56,11 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
needs: setup_ssh
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.95
|
||||
toolchain: 1.97
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: rustup component add clippy
|
||||
- run: |
|
||||
mkdir -p ~/.ssh
|
||||
@@ -89,10 +76,11 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
needs: setup_ssh
|
||||
steps:
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.95
|
||||
toolchain: 1.97
|
||||
- uses: Swatinem/rust-cache@v2
|
||||
- run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
||||
|
||||
Generated
+213
-536
File diff suppressed because it is too large
Load Diff
+12
-10
@@ -1,18 +1,20 @@
|
||||
[package]
|
||||
name = "songparser"
|
||||
version = "0.6.0"
|
||||
version = "0.6.1"
|
||||
edition = "2024"
|
||||
rust-version = "1.95"
|
||||
license = "MIT"
|
||||
description = "Service to parse songs queued for processing"
|
||||
|
||||
[dependencies]
|
||||
tokio = { version = "1.52.2", features = ["full"] }
|
||||
tokio = { version = "1.52.3", features = ["full"] }
|
||||
futures = { version = "0.3.32" }
|
||||
reqwest = { version = "0.13.3", features = ["json", "stream", "multipart"] }
|
||||
reqwest = { version = "0.13.4", features = ["json", "stream", "multipart"] }
|
||||
openssl = { version = "0.10.81", features = ["vendored"] }
|
||||
serde = { version = "1.0.228", features = ["derive"] }
|
||||
serde_json = { version = "1.0.149" }
|
||||
time = { version = "0.3.47", features = ["macros", "serde"] }
|
||||
uuid = { version = "1.23.1", features = ["v4", "serde"] }
|
||||
rand = { version = "0.10.1" }
|
||||
icarus_meta = { git = "ssh://git@git.kundeng.us/phoenix/icarus_meta.git", tag = "v0.6.0" }
|
||||
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.11.1" }
|
||||
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.7.0" }
|
||||
serde_json = { version = "1.0.150" }
|
||||
time = { version = "0.3.53", features = ["macros", "serde"] }
|
||||
uuid = { version = "1.23.5", features = ["v4", "serde"] }
|
||||
simeta = { git = "ssh://git@git.kundeng.us/phoenix/simeta.git", tag = "v0.6.1-main-b690995806-680" }
|
||||
simodels = { git = "ssh://git@git.kundeng.us/phoenix/simodels.git", tag = "v0.11.3-main-fe9d101bd0-111" }
|
||||
sienvy = { git = "ssh://git@git.kundeng.us/phoenix/sienvy.git", tag = "v0.8.0-main-d06c8fdf49-006" }
|
||||
|
||||
+2
-28
@@ -1,63 +1,37 @@
|
||||
# Stage 1: Build the application
|
||||
# Use a specific Rust version for reproducibility. Choose one that matches your development environment.
|
||||
# Using slim variant for smaller base image
|
||||
FROM rust:1.95 as builder
|
||||
FROM rust:1.97 as builder
|
||||
|
||||
# Set the working directory inside the container
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# Install build dependencies if needed (e.g., git for cloning)
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
pkg-config libssl3 \
|
||||
ca-certificates \
|
||||
openssh-client git \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# << --- ADD HOST KEY HERE --- >>
|
||||
# Replace 'yourgithost.com' with the actual hostname (e.g., github.com)
|
||||
RUN mkdir -p -m 0700 ~/.ssh && \
|
||||
ssh-keyscan git.kundeng.us >> ~/.ssh/known_hosts
|
||||
|
||||
# Copy Cargo manifests
|
||||
COPY Cargo.toml Cargo.lock ./
|
||||
|
||||
# Build *only* dependencies to leverage Docker cache
|
||||
# This dummy build caches dependencies as a separate layer
|
||||
RUN --mount=type=ssh mkdir src && \
|
||||
echo "fn main() {println!(\"if you see this, the build broke\")}" > src/main.rs && \
|
||||
cargo build --release --quiet && \
|
||||
rm -rf src target/release/deps/songparser* # Clean up dummy build artifacts (replace songparser)
|
||||
rm -rf src target/release/deps/songparser*
|
||||
|
||||
# Copy the actual source code
|
||||
COPY src ./src
|
||||
# If you have other directories like `templates` or `static`, copy them too
|
||||
COPY .env ./.env
|
||||
|
||||
# << --- SSH MOUNT ADDED HERE --- >>
|
||||
# Build *only* dependencies to leverage Docker cache
|
||||
# This dummy build caches dependencies as a separate layer
|
||||
# Mount the SSH agent socket for this command
|
||||
RUN --mount=type=ssh \
|
||||
cargo build --release --quiet
|
||||
|
||||
# Stage 2: Create the final, smaller runtime image
|
||||
# Use a minimal base image like debian-slim or even distroless for security/size
|
||||
FROM debian:trixie-slim
|
||||
|
||||
# Install runtime dependencies if needed (e.g., SSL certificates)
|
||||
RUN apt-get update && apt-get install -y ca-certificates libssl-dev libssl3 && rm -rf /var/lib/apt/lists/*
|
||||
|
||||
# Set the working directory
|
||||
WORKDIR /usr/local/bin
|
||||
|
||||
# Copy the compiled binary from the builder stage
|
||||
# Replace 'songparser' with the actual name of your binary (usually the crate name)
|
||||
COPY --from=builder /usr/src/app/target/release/songparser .
|
||||
|
||||
# Copy other necessary files like .env (if used for runtime config) or static assets
|
||||
# It's generally better to configure via environment variables in Docker though
|
||||
COPY --from=builder /usr/src/app/.env .
|
||||
|
||||
# Set the command to run your application
|
||||
# Ensure this matches the binary name copied above
|
||||
CMD ["./songparser"]
|
||||
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2026 Kun Deng
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
@@ -1,4 +1,4 @@
|
||||
# Songparser
|
||||
# songparser
|
||||
A service that edits the metadata of a queued song and populates it with data.
|
||||
|
||||
|
||||
@@ -11,10 +11,10 @@ it can be changed.
|
||||
|
||||
The `SERVICE_PASSPHRASE` env variable should not be changed, but it could be changed. The
|
||||
value for this variable should match the value in the `passphrase` table. This would be
|
||||
found in the `icarus_auth` project.
|
||||
found in the `soaricarus_auth` project.
|
||||
|
||||
Ensure that the URLs for the two APIs are correctly set for the respective env variables
|
||||
`ICARUS_BASE_API_URL` for Icarus API and `ICARUS_AUTH_BASE_API_URL` for `icarus_auth`.
|
||||
`SOARICARUS_BASE_API_URL` for soaricarus API and `SOARICARUS_AUTH_BASE_API_URL` for `soaricarus_auth`.
|
||||
|
||||
If the values are properly set, next is to build the image. The docker image should be
|
||||
built from the main icarus web API.
|
||||
|
||||
+4
-5
@@ -1,12 +1,11 @@
|
||||
version: '3.8' # Use a recent version
|
||||
|
||||
services:
|
||||
# Your Rust Application Service
|
||||
songparser:
|
||||
build: # Tells docker-compose to build the Dockerfile in the current directory
|
||||
build:
|
||||
context: .
|
||||
ssh: ["default"] # Uses host's SSH agent
|
||||
container_name: songparser # Optional: Give the container a specific name
|
||||
ssh: ["default"]
|
||||
container_name: songparser
|
||||
env_file:
|
||||
- .env
|
||||
restart: unless-stopped # Optional: Restart policy
|
||||
restart: unless-stopped
|
||||
|
||||
+5
-5
@@ -162,7 +162,7 @@ pub mod service_token {
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct Response {
|
||||
pub message: String,
|
||||
pub data: Vec<icarus_models::login_result::LoginResult>,
|
||||
pub data: Vec<simodels::login_result::LoginResult>,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -172,7 +172,7 @@ pub mod refresh_token {
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct Response {
|
||||
pub message: String,
|
||||
pub data: Vec<icarus_models::login_result::LoginResult>,
|
||||
pub data: Vec<simodels::login_result::LoginResult>,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -253,7 +253,7 @@ pub mod create_song {
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct Response {
|
||||
pub message: String,
|
||||
pub data: Vec<icarus_models::song::Song>,
|
||||
pub data: Vec<simodels::song::Song>,
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -261,7 +261,7 @@ pub mod create_song {
|
||||
pub mod create_coverart {
|
||||
pub async fn create(
|
||||
app: &crate::config::App,
|
||||
song: &icarus_models::song::Song,
|
||||
song: &simodels::song::Song,
|
||||
queued_coverart: &crate::queued_item::QueuedCoverArt,
|
||||
) -> Result<reqwest::Response, reqwest::Error> {
|
||||
let client = reqwest::Client::builder().build()?;
|
||||
@@ -284,7 +284,7 @@ pub mod create_coverart {
|
||||
#[derive(Debug, serde::Deserialize, serde::Serialize)]
|
||||
pub struct Response {
|
||||
pub message: String,
|
||||
pub data: Vec<icarus_models::coverart::CoverArt>,
|
||||
pub data: Vec<simodels::coverart::CoverArt>,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -1,12 +1,12 @@
|
||||
pub async fn get_token(
|
||||
app: &crate::config::App,
|
||||
) -> Result<icarus_models::login_result::LoginResult, std::io::Error> {
|
||||
) -> Result<simodels::login_result::LoginResult, std::io::Error> {
|
||||
let client = reqwest::Client::new();
|
||||
let endpoint = String::from("api/v2/service/login");
|
||||
let api_url = format!("{}/{endpoint}", app.auth_uri);
|
||||
|
||||
let payload = serde_json::json!({
|
||||
"passphrase": icarus_envy::environment::get_service_passphrase().await.value,
|
||||
"passphrase": sienvy::environment::get_service_passphrase().value,
|
||||
});
|
||||
|
||||
match client.post(api_url).json(&payload).send().await {
|
||||
@@ -29,7 +29,7 @@ pub async fn get_token(
|
||||
|
||||
pub async fn get_refresh_token(
|
||||
app: &crate::config::App,
|
||||
) -> Result<icarus_models::login_result::LoginResult, std::io::Error> {
|
||||
) -> Result<simodels::login_result::LoginResult, std::io::Error> {
|
||||
let client = reqwest::Client::new();
|
||||
let endpoint = String::from("api/v2/token/refresh");
|
||||
let api_url = format!("{}/{endpoint}", app.auth_uri);
|
||||
|
||||
+4
-8
@@ -2,7 +2,7 @@
|
||||
pub struct App {
|
||||
pub uri: String,
|
||||
pub auth_uri: String,
|
||||
pub token: icarus_models::login_result::LoginResult,
|
||||
pub token: simodels::login_result::LoginResult,
|
||||
pub root_directory: String,
|
||||
}
|
||||
|
||||
@@ -15,13 +15,9 @@ impl App {
|
||||
|
||||
pub async fn initialize_app_config() -> App {
|
||||
App {
|
||||
uri: icarus_envy::environment::get_icarus_base_api_url()
|
||||
.await
|
||||
.value,
|
||||
auth_uri: icarus_envy::environment::get_icarus_auth_base_api_url()
|
||||
.await
|
||||
.value,
|
||||
root_directory: icarus_envy::environment::get_root_directory().await.value,
|
||||
uri: sienvy::environment::get_soaricarus_base_api_url().value,
|
||||
auth_uri: sienvy::environment::get_soaricarus_auth_base_api_url().value,
|
||||
root_directory: sienvy::environment::get_root_directory().value,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
+34
-42
@@ -5,101 +5,96 @@ pub async fn apply_metadata(
|
||||
metadata: &crate::api::get_metadata_queue::response::Metadata,
|
||||
) -> Result<bool, std::io::Error> {
|
||||
// Apply metadata fields
|
||||
let types = icarus_meta::types::all_metadata_types();
|
||||
let types = simeta::types::all_metadata_types();
|
||||
|
||||
for t in types {
|
||||
match t {
|
||||
icarus_meta::types::Type::Album => {
|
||||
let meta_type =
|
||||
icarus_meta::types::MetadataType::from_string(metadata.album.clone());
|
||||
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
simeta::types::Type::Album => {
|
||||
let meta_type = simeta::types::MetadataType::from_string(metadata.album.clone());
|
||||
match simeta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
Ok(_) => {}
|
||||
Err(_err) => {
|
||||
return Err(_err);
|
||||
}
|
||||
}
|
||||
}
|
||||
icarus_meta::types::Type::AlbumArtist => {
|
||||
simeta::types::Type::AlbumArtist => {
|
||||
let meta_type =
|
||||
icarus_meta::types::MetadataType::from_string(metadata.album_artist.clone());
|
||||
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
simeta::types::MetadataType::from_string(metadata.album_artist.clone());
|
||||
match simeta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
Ok(_) => {}
|
||||
Err(_err) => {
|
||||
return Err(_err);
|
||||
}
|
||||
}
|
||||
}
|
||||
icarus_meta::types::Type::Artist => {
|
||||
let meta_type =
|
||||
icarus_meta::types::MetadataType::from_string(metadata.artist.clone());
|
||||
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
simeta::types::Type::Artist => {
|
||||
let meta_type = simeta::types::MetadataType::from_string(metadata.artist.clone());
|
||||
match simeta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
Ok(_) => {}
|
||||
Err(_err) => {
|
||||
return Err(_err);
|
||||
}
|
||||
}
|
||||
}
|
||||
icarus_meta::types::Type::Date => {
|
||||
simeta::types::Type::Date => {
|
||||
// TODO: Do something about this discrepancy
|
||||
let meta_type =
|
||||
icarus_meta::types::MetadataType::from_string(metadata.year.to_string());
|
||||
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
let meta_type = simeta::types::MetadataType::from_string(metadata.year.to_string());
|
||||
match simeta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
Ok(_) => {}
|
||||
Err(_err) => {
|
||||
return Err(_err);
|
||||
}
|
||||
}
|
||||
}
|
||||
icarus_meta::types::Type::Disc => {
|
||||
let meta_type = icarus_meta::types::MetadataType::from_int(metadata.disc);
|
||||
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
simeta::types::Type::Disc => {
|
||||
let meta_type = simeta::types::MetadataType::from_int(metadata.disc);
|
||||
match simeta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
Ok(_) => {}
|
||||
Err(_err) => {
|
||||
return Err(_err);
|
||||
}
|
||||
}
|
||||
}
|
||||
icarus_meta::types::Type::Genre => {
|
||||
let meta_type =
|
||||
icarus_meta::types::MetadataType::from_string(metadata.genre.clone());
|
||||
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
simeta::types::Type::Genre => {
|
||||
let meta_type = simeta::types::MetadataType::from_string(metadata.genre.clone());
|
||||
match simeta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
Ok(_) => {}
|
||||
Err(_err) => {
|
||||
return Err(_err);
|
||||
}
|
||||
}
|
||||
}
|
||||
icarus_meta::types::Type::Title => {
|
||||
let meta_type =
|
||||
icarus_meta::types::MetadataType::from_string(metadata.title.clone());
|
||||
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
simeta::types::Type::Title => {
|
||||
let meta_type = simeta::types::MetadataType::from_string(metadata.title.clone());
|
||||
match simeta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
Ok(_) => {}
|
||||
Err(_err) => {
|
||||
return Err(_err);
|
||||
}
|
||||
}
|
||||
}
|
||||
icarus_meta::types::Type::Track => {
|
||||
let meta_type = icarus_meta::types::MetadataType::from_int(metadata.track);
|
||||
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
simeta::types::Type::Track => {
|
||||
let meta_type = simeta::types::MetadataType::from_int(metadata.track);
|
||||
match simeta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
Ok(_) => {}
|
||||
Err(_err) => {
|
||||
return Err(_err);
|
||||
}
|
||||
}
|
||||
}
|
||||
icarus_meta::types::Type::TrackCount => {
|
||||
let meta_type = icarus_meta::types::MetadataType::from_int(metadata.track_count);
|
||||
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
simeta::types::Type::TrackCount => {
|
||||
let meta_type = simeta::types::MetadataType::from_int(metadata.track_count);
|
||||
match simeta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
Ok(_) => {}
|
||||
Err(_err) => {
|
||||
return Err(_err);
|
||||
}
|
||||
}
|
||||
}
|
||||
icarus_meta::types::Type::DiscCount => {
|
||||
let meta_type = icarus_meta::types::MetadataType::from_int(metadata.disc_count);
|
||||
match icarus_meta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
simeta::types::Type::DiscCount => {
|
||||
let meta_type = simeta::types::MetadataType::from_int(metadata.disc_count);
|
||||
match simeta::meta::metadata::set_meta_value(t, &queued_song.path, meta_type) {
|
||||
Ok(_) => {}
|
||||
Err(_err) => {
|
||||
return Err(_err);
|
||||
@@ -110,11 +105,11 @@ pub async fn apply_metadata(
|
||||
}
|
||||
|
||||
// Apply coverart
|
||||
match icarus_meta::meta::coverart::contains_coverart(&queued_song.path) {
|
||||
match simeta::meta::coverart::contains_coverart(&queued_song.path) {
|
||||
Ok((exists, size)) => {
|
||||
if exists {
|
||||
println!("Coverart exists: {size:?} size");
|
||||
match icarus_meta::meta::coverart::remove_coverart(&queued_song.path) {
|
||||
match simeta::meta::coverart::remove_coverart(&queued_song.path) {
|
||||
Ok(_data) => {}
|
||||
Err(err) => {
|
||||
return Err(err);
|
||||
@@ -122,10 +117,7 @@ pub async fn apply_metadata(
|
||||
}
|
||||
}
|
||||
|
||||
match icarus_meta::meta::coverart::set_coverart(
|
||||
&queued_song.path,
|
||||
&queued_coverart.path,
|
||||
) {
|
||||
match simeta::meta::coverart::set_coverart(&queued_song.path, &queued_coverart.path) {
|
||||
Ok(_data) => {
|
||||
if _data.is_empty() {
|
||||
println!("There was an issue");
|
||||
|
||||
+20
-21
@@ -4,8 +4,8 @@ pub async fn some_work(
|
||||
user_id: &uuid::Uuid,
|
||||
) -> Result<
|
||||
(
|
||||
icarus_models::song::Song,
|
||||
icarus_models::coverart::CoverArt,
|
||||
simodels::song::Song,
|
||||
simodels::coverart::CoverArt,
|
||||
crate::api::get_metadata_queue::response::Metadata,
|
||||
crate::queued_item::QueuedSong,
|
||||
crate::queued_item::QueuedCoverArt,
|
||||
@@ -30,9 +30,8 @@ pub async fn some_work(
|
||||
println!("Updated queued song");
|
||||
println!("Response: {_inner_response:?}");
|
||||
|
||||
let song_type = String::from(
|
||||
icarus_meta::detection::song::constants::FLAC_TYPE,
|
||||
);
|
||||
let song_type =
|
||||
String::from(simeta::detection::song::constants::FLAC_TYPE);
|
||||
|
||||
match crate::api::create_song::create(
|
||||
app, &metadata, user_id, &song_type,
|
||||
@@ -104,10 +103,10 @@ pub async fn prep_song(
|
||||
// Process data here...
|
||||
match crate::api::parsing::parse_response_into_bytes(response).await {
|
||||
Ok(song_bytes) => {
|
||||
let song = icarus_models::song::Song {
|
||||
directory: icarus_envy::environment::get_root_directory().await.value,
|
||||
filename: icarus_models::song::generate_filename(
|
||||
icarus_models::types::MusicType::FlacExtension,
|
||||
let song = simodels::song::Song {
|
||||
directory: sienvy::environment::get_root_directory().value,
|
||||
filename: simodels::song::generate_filename(
|
||||
simodels::types::MusicType::FlacExtension,
|
||||
true,
|
||||
)
|
||||
.unwrap(),
|
||||
@@ -223,18 +222,18 @@ async fn init_queued_coverart(
|
||||
bytes: Vec<u8>,
|
||||
) -> crate::queued_item::QueuedCoverArt {
|
||||
// TODO: Consider separating song and coverart when saving to the filesystem
|
||||
let covart_type = if file_type == icarus_meta::detection::coverart::constants::PNG_TYPE {
|
||||
icarus_models::types::CoverArtType::PngExtension
|
||||
} else if file_type == icarus_meta::detection::coverart::constants::JPEG_TYPE {
|
||||
icarus_models::types::CoverArtType::JpegExtension
|
||||
} else if file_type == icarus_meta::detection::coverart::constants::JPG_TYPE {
|
||||
icarus_models::types::CoverArtType::JpgExtension
|
||||
let covart_type = if file_type == simeta::detection::coverart::constants::PNG_TYPE {
|
||||
simodels::types::CoverArtType::PngExtension
|
||||
} else if file_type == simeta::detection::coverart::constants::JPEG_TYPE {
|
||||
simodels::types::CoverArtType::JpegExtension
|
||||
} else if file_type == simeta::detection::coverart::constants::JPG_TYPE {
|
||||
simodels::types::CoverArtType::JpgExtension
|
||||
} else {
|
||||
icarus_models::types::CoverArtType::None
|
||||
simodels::types::CoverArtType::None
|
||||
};
|
||||
let coverart = icarus_models::coverart::CoverArt {
|
||||
directory: icarus_envy::environment::get_root_directory().await.value,
|
||||
filename: match icarus_models::coverart::generate_filename(covart_type, true) {
|
||||
let coverart = simodels::coverart::CoverArt {
|
||||
directory: sienvy::environment::get_root_directory().value,
|
||||
filename: match simodels::coverart::generate_filename(covart_type, true) {
|
||||
Ok(filename) => filename,
|
||||
Err(err) => {
|
||||
eprintln!("Error generating CoverArt filename: {err:?}");
|
||||
@@ -255,8 +254,8 @@ async fn init_queued_coverart(
|
||||
}
|
||||
|
||||
pub async fn cleanup(
|
||||
song: &icarus_models::song::Song,
|
||||
coverart: &icarus_models::coverart::CoverArt,
|
||||
song: &simodels::song::Song,
|
||||
coverart: &simodels::coverart::CoverArt,
|
||||
) -> Result<(), std::io::Error> {
|
||||
match song.remove_from_filesystem() {
|
||||
Ok(_) => {}
|
||||
|
||||
+2
-2
@@ -1,13 +1,13 @@
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct QueuedSong {
|
||||
pub id: uuid::Uuid,
|
||||
pub song: icarus_models::song::Song,
|
||||
pub song: simodels::song::Song,
|
||||
pub path: String,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
pub struct QueuedCoverArt {
|
||||
pub id: uuid::Uuid,
|
||||
pub coverart: icarus_models::coverart::CoverArt,
|
||||
pub coverart: simodels::coverart::CoverArt,
|
||||
pub path: String,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user