mirror of
https://github.com/markuryy/shark.git
synced 2026-07-26 15:01:02 +00:00
feat(settings): add button to open app data folder
This commit is contained in:
@@ -23,8 +23,7 @@ pub fn generate_blowfish_key(track_id: &str) -> Vec<u8> {
|
||||
|
||||
/// Decrypt a single 2048-byte chunk using Blowfish CBC
|
||||
pub fn decrypt_chunk(chunk: &[u8], blowfish_key: &[u8]) -> Vec<u8> {
|
||||
let cipher = Blowfish::<BigEndian>::new_from_slice(blowfish_key)
|
||||
.expect("Invalid key length");
|
||||
let cipher = Blowfish::<BigEndian>::new_from_slice(blowfish_key).expect("Invalid key length");
|
||||
|
||||
let mut result = chunk.to_vec();
|
||||
let iv = [0u8, 1, 2, 3, 4, 5, 6, 7];
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use tauri_plugin_sql::{Migration, MigrationKind};
|
||||
|
||||
mod tagger;
|
||||
mod metadata;
|
||||
mod deezer_crypto;
|
||||
mod metadata;
|
||||
mod tagger;
|
||||
|
||||
// Learn more about Tauri commands at https://tauri.app/develop/calling-rust/
|
||||
#[tauri::command]
|
||||
@@ -58,10 +58,10 @@ async fn download_and_decrypt_track(
|
||||
is_encrypted: bool,
|
||||
window: tauri::Window,
|
||||
) -> Result<(), String> {
|
||||
use tokio::io::AsyncWriteExt;
|
||||
use tokio::fs::File;
|
||||
use deezer_crypto::StreamingDecryptor;
|
||||
use tauri::Emitter;
|
||||
use tokio::fs::File;
|
||||
use tokio::io::AsyncWriteExt;
|
||||
|
||||
// Build HTTP client
|
||||
let client = reqwest::Client::builder()
|
||||
@@ -117,11 +117,14 @@ async fn download_and_decrypt_track(
|
||||
|
||||
if rounded_percentage > last_reported_percentage || percentage == 100 {
|
||||
last_reported_percentage = rounded_percentage;
|
||||
let _ = window.emit("download-progress", serde_json::json!({
|
||||
"downloaded": downloaded_bytes,
|
||||
"total": total_size as u64,
|
||||
"percentage": percentage
|
||||
}));
|
||||
let _ = window.emit(
|
||||
"download-progress",
|
||||
serde_json::json!({
|
||||
"downloaded": downloaded_bytes,
|
||||
"total": total_size as u64,
|
||||
"percentage": percentage
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -154,11 +157,14 @@ async fn download_and_decrypt_track(
|
||||
|
||||
if rounded_percentage > last_reported_percentage || percentage == 100 {
|
||||
last_reported_percentage = rounded_percentage;
|
||||
let _ = window.emit("download-progress", serde_json::json!({
|
||||
"downloaded": downloaded_bytes,
|
||||
"total": total_size as u64,
|
||||
"percentage": percentage
|
||||
}));
|
||||
let _ = window.emit(
|
||||
"download-progress",
|
||||
serde_json::json!({
|
||||
"downloaded": downloaded_bytes,
|
||||
"total": total_size as u64,
|
||||
"percentage": percentage
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -293,6 +299,7 @@ pub fn run() {
|
||||
}];
|
||||
|
||||
tauri::Builder::default()
|
||||
.plugin(tauri_plugin_os::init())
|
||||
.plugin(tauri_plugin_process::init())
|
||||
.plugin(
|
||||
tauri_plugin_sql::Builder::new()
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
use metaflac::Tag as FlacTag;
|
||||
use id3::{Tag as ID3Tag, TagLike};
|
||||
use metaflac::Tag as FlacTag;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::path::Path;
|
||||
|
||||
@@ -40,8 +40,8 @@ pub fn read_audio_metadata(path: &str) -> Result<AudioMetadata, String> {
|
||||
|
||||
/// Read metadata from MP3 file
|
||||
fn read_mp3_metadata(path: &str) -> Result<AudioMetadata, String> {
|
||||
let tag = ID3Tag::read_from_path(path)
|
||||
.map_err(|e| format!("Failed to read MP3 tags: {}", e))?;
|
||||
let tag =
|
||||
ID3Tag::read_from_path(path).map_err(|e| format!("Failed to read MP3 tags: {}", e))?;
|
||||
|
||||
Ok(AudioMetadata {
|
||||
title: tag.title().map(|s| s.to_string()),
|
||||
@@ -55,8 +55,8 @@ fn read_mp3_metadata(path: &str) -> Result<AudioMetadata, String> {
|
||||
|
||||
/// Read metadata from FLAC file
|
||||
fn read_flac_metadata(path: &str) -> Result<AudioMetadata, String> {
|
||||
let tag = FlacTag::read_from_path(path)
|
||||
.map_err(|e| format!("Failed to read FLAC tags: {}", e))?;
|
||||
let tag =
|
||||
FlacTag::read_from_path(path).map_err(|e| format!("Failed to read FLAC tags: {}", e))?;
|
||||
|
||||
// Helper to get first value from vorbis comment
|
||||
let get_first = |key: &str| -> Option<String> {
|
||||
@@ -66,8 +66,7 @@ fn read_flac_metadata(path: &str) -> Result<AudioMetadata, String> {
|
||||
};
|
||||
|
||||
// Parse track number
|
||||
let track_number = get_first("TRACKNUMBER")
|
||||
.and_then(|s| s.parse::<u32>().ok());
|
||||
let track_number = get_first("TRACKNUMBER").and_then(|s| s.parse::<u32>().ok());
|
||||
|
||||
// Get duration from streaminfo block (in samples)
|
||||
let duration = tag.get_streaminfo().map(|info| {
|
||||
|
||||
Reference in New Issue
Block a user