### ncmdump CLI Usage Examples Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Demonstrates various command-line options for the ncmdump-bin tool, including single file conversion, batch conversion, specifying output directories, verbose output, and using glob patterns. ```bash # Install via Cargo cargo install ncmdump-bin # Convert single file (output in same directory) ncmdump music.ncm # Convert multiple files ncmdump song1.ncm song2.ncm song3.qmcflac # Convert with custom output directory ncmdump -o /path/to/output music.ncm # Verbose output showing processing details ncmdump -v music.ncm # Convert all NCM files in current directory using glob ncmdump *.ncm # Show help ncmdump --help ``` -------------------------------- ### Ncmdump::from_reader - Complete Conversion Example with Metadata Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt A comprehensive example demonstrating how to convert an NCM file, including extracting and saving metadata and cover art. ```APIDOC ## Complete Conversion Example with Metadata Full example showing how to convert an NCM file while preserving metadata and cover art. ### Method `Ncmdump::from_reader`, `Ncmdump::get_info`, `Ncmdump::get_image`, `Ncmdump::get_data` ### Endpoint N/A (Library functions) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust use std::fs::File; use std::io::Write; use ncmdump::Ncmdump; fn main() -> anyhow::Result<()> { let input_path = "music.ncm"; let file = File::open(input_path)?; let mut ncm = Ncmdump::from_reader(file)?; // Get metadata first let info = ncm.get_info()?; println!("Converting: {} by {:?}", info.name, info.artist.iter().map(|(n, _)| n.as_str()).collect::>()); // Determine output filename from format let output_path = format!("{}.{{}}", info.name, info.format); // Extract and save cover art if let Ok(cover) = ncm.get_image() { let cover_path = format!("{}_cover.jpg", info.name); let mut cover_file = File::create(&cover_path)?; cover_file.write_all(&cover)?; println!("Saved cover art to: {}", cover_path); } // Convert audio let audio_data = ncm.get_data()?; let mut output = File::create(&output_path)?; output.write_all(&audio_data)?; println!("Converted to: {} ({} bytes)", output_path, audio_data.len()); Ok(()) } ``` ### Response #### Success Response (200) Audio file and optionally cover art are saved to disk. Console output indicates progress and details. #### Response Example ``` Converting: Song Name by ["Artist Name"] Saved cover art to: Song Name_cover.jpg Converted to: Song Name.flac (1234567 bytes) ``` ``` -------------------------------- ### Install ncmdump Binary Source: https://github.com/iqiziqi/ncmdump.rs/blob/master/README.md Install the ncmdump command-line tool using Cargo. Ensure you have Rust and Cargo installed. ```shell cargo install ncmdump-bin ``` -------------------------------- ### Complete NCM Conversion with Metadata and Cover Art Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt A comprehensive example showing how to convert an NCM file, extract and save its metadata (name, artist, format), preserve cover art, and write the decrypted audio data to a file. ```rust use std::fs::File; use std::io::Write; use ncmdump::Ncmdump; fn main() -> anyhow::Result<()> { let input_path = "music.ncm"; let file = File::open(input_path)?; let mut ncm = Ncmdump::from_reader(file)?; // Get metadata first let info = ncm.get_info()?; println!("Converting: {} by {:?}", info.name, info.artist.iter().map(|(n, _)| n.as_str()).collect::>()); // Determine output filename from format let output_path = format!("{}.{}", info.name, info.format); // Extract and save cover art if let Ok(cover) = ncm.get_image() { let cover_path = format!("{}_cover.jpg", info.name); let mut cover_file = File::create(&cover_path)?; cover_file.write_all(&cover)?; println!("Saved cover art to: {}", cover_path); } // Convert audio let audio_data = ncm.get_data()?; let mut output = File::create(&output_path)?; output.write_all(&audio_data)?; println!("Converted to: {} ({} bytes)", output_path, audio_data.len()); Ok(()) } ``` -------------------------------- ### Install ncmdump Crate with cargo-edit Source: https://github.com/iqiziqi/ncmdump.rs/blob/master/README.md Install the ncmdump crate directly into your project using the cargo add command, provided you have cargo-edit installed. ```shell cargo add ncmdump ``` -------------------------------- ### Error Handling with ncmdump Errors Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Demonstrates how to handle potential errors during file opening and NCM/QMC processing using the library's specific error types. This example shows matching against different error variants like IO, InvalidFileType, and DecryptError. ```rust use std::fs::File; use ncmdump::Ncmdump; use ncmdump::error::Errors; fn main() { let result = File::open("test.ncm") .map_err(|e| Errors::IO(e.to_string())) .and_then(|f| Ncmdump::from_reader(f)); match result { Ok(mut ncm) => { match ncm.get_info() { Ok(info) => println!("Song: {}", info.name), Err(Errors::InfoDecodeError) => eprintln!("Failed to decode metadata"), Err(e) => eprintln!("Error: {}", e), } } Err(Errors::InvalidFileType) => eprintln!("Not a valid NCM file"), Err(Errors::DecryptError) => eprintln!("Decryption failed"), Err(e) => eprintln!("Error opening file: {}", e), } } ``` -------------------------------- ### Command Line Interface Usage Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Instructions for using the `ncmdump-bin` command-line tool for batch conversion of encrypted music files. ```APIDOC ## Command Line Interface Usage The ncmdump-bin provides a command-line tool for batch conversion of encrypted music files. ### Installation ```bash # Install via Cargo cargo install ncmdump-bin ``` ### Usage Examples - **Convert single file (output in same directory):** ```bash ncmdump music.ncm ``` - **Convert multiple files:** ```bash ncmdump song1.ncm song2.ncm song3.qmcflac ``` - **Convert with custom output directory:** ```bash ncmdump -o /path/to/output music.ncm ``` - **Verbose output showing processing details:** ```bash ncmdump -v music.ncm ``` - **Convert all NCM files in current directory using glob:** ```bash ncmdump *.ncm ``` - **Show help:** ```bash ncmdump --help ``` ### Parameters - `-o, --output `: Specify output directory. - `-v, --verbose`: Enable verbose output. - `[INPUT]...`: One or more input files to convert. ``` -------------------------------- ### Basic Library Usage in Rust Source: https://github.com/iqiziqi/ncmdump.rs/blob/master/README.md Demonstrates how to use the ncmdump library in Rust to read an .ncm file, extract its data, and write it to a .flac file. Requires `anyhow` for error handling. ```rust use std::fs::File; use std::path::Path; use anyhow::Result; use ncmdump::Ncmdump; fn main() -> Result<()> { use std::io::Write; let file = File::open("res/test.ncm")?; let mut ncm = Ncmdump::from_reader(file)?; let music = ncm.get_data()?; let mut target = File::options() .create(true) .write(true) .open("res/test.flac")?; target.write_all(&music)?; Ok(()) } ``` -------------------------------- ### Create QMC File Handler with QmcDump::from_reader Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Instantiate a QmcDump handler from a reader. Ensure the reader provides access to a QQ Music encrypted file (e.g., qmcflac, qmc0, qmc3). ```rust use std::fs::File; use ncmdump::QmcDump; fn main() -> std::io::Result<()> { let file = File::open("music.qmcflac")?; let qmc = QmcDump::from_reader(file).expect("Failed to create QMC handler"); Ok(()) } ``` -------------------------------- ### QmcDump::from_reader - Create QMC File Handler Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Instantiate a QmcDump handler from a reader for processing QQ Music encrypted files. ```APIDOC ## QmcDump::from_reader - Create QMC File Handler Creates a new QmcDump instance from any reader for processing QQ Music encrypted files (qmcflac, qmc0, qmc3, etc.). ### Method Associated function (constructor) ### Endpoint N/A (Library function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust use std::fs::File; use ncmdump::QmcDump; fn main() -> std::io::Result<()> { let file = File::open("music.qmcflac")?; let qmc = QmcDump::from_reader(file).expect("Failed to create QMC handler"); // ... use qmc handler ... Ok(()) } ``` ### Response #### Success Response (200) An instance of `QmcDump` ready for processing. #### Response Example (Instance of QmcDump) ``` -------------------------------- ### ncmdump Binary Options Source: https://github.com/iqiziqi/ncmdump.rs/blob/master/README.md View available options for the ncmdump command-line tool, including output directory and verbosity settings. ```text Usage: ncmdump [OPTIONS] [FILES]... Arguments: [FILES]... Specified the files to convert Options: -o, --output Specified the output directory. Default it's the same directory with input file -v, --verbose Verbosely list files processing -h, --help Print help -V, --version Print version ``` -------------------------------- ### Basic Binary Usage Source: https://github.com/iqiziqi/ncmdump.rs/blob/master/README.md Convert .ncm files to other formats using the ncmdump binary. Specify the files to convert as arguments. ```shell ncmdump [FILES]... ``` -------------------------------- ### Create NCM File Handler with Ncmdump::from_reader Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Initializes an Ncmdump instance from a seekable reader, such as a File or Cursor, to parse headers and prepare for decryption. ```rust use std::fs::File; use std::io::{Cursor, Read}; use ncmdump::Ncmdump; fn main() -> std::io::Result<()> { // From a file let file = File::open("music.ncm")?; let mut ncm = Ncmdump::from_reader(file).expect("Failed to parse NCM file"); // From in-memory data using Cursor let mut file = File::open("music.ncm")?; let mut data = Vec::new(); file.read_to_end(&mut data)?; let cursor = Cursor::new(data); let mut ncm = Ncmdump::from_reader(cursor).expect("Failed to parse NCM data"); Ok(()) } ``` -------------------------------- ### Extract Decrypted QMC Audio with QmcDump::get_data Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Read and decrypt the entire audio data from a QMC file into a byte vector. This function requires an initialized QmcDump instance and writes the decrypted data to a new file. ```rust use std::fs::File; use std::io::Write; use ncmdump::QmcDump; fn main() -> anyhow::Result<()> { let file = File::open("music.qmcflac")?; let mut qmc = QmcDump::from_reader(file)?; // Get decrypted audio let music_data = qmc.get_data()?; // Write to FLAC file let mut output = File::options() .create(true) .write(true) .truncate(true) .open("output.flac")?; output.write_all(&music_data)?; Ok(()) } ``` -------------------------------- ### is_ncm_file / is_qmc_file - Format Check Utilities Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Helper functions to quickly determine if a file is specifically an NCM or QMC file. ```APIDOC ## is_ncm_file / is_qmc_file - Format Check Utilities Quick helper functions to check if a file is a specific encrypted format. ### Method `is_ncm_file`, `is_qmc_file` ### Endpoint N/A (Library functions) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust use std::fs::File; use ncmdump::utils::{is_ncm_file, is_qmc_file}; fn main() -> anyhow::Result<()> { let mut file = File::open("music.ncm")?; if is_ncm_file(&mut file)? { println!("This is an NCM file"); } let mut qmc_file = File::open("music.qmcflac")?; if is_qmc_file(&mut qmc_file)? { println!("This is a QMC file"); } Ok(()) } ``` ### Response #### Success Response (200) A boolean value: `true` if the file matches the format, `false` otherwise. #### Response Example `true` or `false` ``` -------------------------------- ### Ncmdump::from_reader - Create NCM File Handler Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Creates a new Ncmdump instance from any seekable reader (typically a File or Cursor). This parses the NCM file header, extracts the decryption key, and prepares the handler for reading metadata and audio data. ```APIDOC ## Ncmdump::from_reader - Create NCM File Handler ### Description Creates a new Ncmdump instance from any seekable reader (typically a File or Cursor). This parses the NCM file header, extracts the decryption key, and prepares the handler for reading metadata and audio data. ### Method `Ncmdump::from_reader` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust use std::fs::File; use std::io::{Cursor, Read}; use ncmdump::Ncmdump; fn main() -> std::io::Result<()> { // From a file let file = File::open("music.ncm")?; let mut ncm = Ncmdump::from_reader(file).expect("Failed to parse NCM file"); // From in-memory data using Cursor let mut file = File::open("music.ncm")?; let mut data = Vec::new(); file.read_to_end(&mut data)?; let cursor = Cursor::new(data); let mut ncm = Ncmdump::from_reader(cursor).expect("Failed to parse NCM data"); Ok(()) } ``` ### Response #### Success Response (200) Returns a `Ncmdump` instance. #### Response Example (No specific response body example provided, as it returns an instance of the struct.) ``` -------------------------------- ### Error Handling Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Demonstrates how to handle various errors that can occur during file processing and decryption using the library's error types. ```APIDOC ## Error Handling The library provides specific error types for different failure scenarios. ### Method Various library functions return `Result` types that can be matched against `ncmdump::error::Errors`. ### Endpoint N/A (Library functions) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust use std::fs::File; use ncmdump::Ncmdump; use ncmdump::error::Errors; fn main() { let result = File::open("test.ncm") .map_err(|e| Errors::IO(e.to_string())) .and_then(|f| Ncmdump::from_reader(f)); match result { Ok(mut ncm) => { match ncm.get_info() { Ok(info) => println!("Song: {}", info.name), Err(Errors::InfoDecodeError) => eprintln!("Failed to decode metadata"), Err(e) => eprintln!("Error: {}", e), } } Err(Errors::InvalidFileType) => eprintln!("Not a valid NCM file"), Err(Errors::DecryptError) => eprintln!("Decryption failed"), Err(e) => eprintln!("Error opening file: {}", e), } } ``` ### Response #### Success Response (200) (No direct response, but successful execution implies no errors were encountered). #### Response Example (Console output indicating success, e.g., song name) #### Error Responses - `Errors::IO(String)`: For file I/O errors. - `Errors::InvalidFileType`: If the input file is not a recognized NCM or QMC format. - `Errors::DecryptError`: If decryption of the audio data fails. - `Errors::InfoDecodeError`: If the metadata within the file cannot be decoded. - Other `Errors` variants as defined in the library. ``` -------------------------------- ### QmcDump::get_data - Extract Decrypted QMC Audio Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Reads and decrypts the entire audio data from a QMC file into a byte vector. ```APIDOC ## QmcDump::get_data - Extract Decrypted QMC Audio Reads and decrypts the entire audio data from a QMC file into a byte vector. ### Method `QmcDump::get_data` ### Endpoint N/A (Library function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust use std::fs::File; use std::io::Write; use ncmdump::QmcDump; fn main() -> anyhow::Result<()> { let file = File::open("music.qmcflac")?; let mut qmc = QmcDump::from_reader(file)?; // Get decrypted audio let music_data = qmc.get_data()?; // Write to FLAC file let mut output = File::options() .create(true) .write(true) .truncate(true) .open("output.flac")?; output.write_all(&music_data)?; Ok(()) } ``` ### Response #### Success Response (200) A `Vec` containing the decrypted audio data. #### Response Example (Byte vector representing audio data) ``` -------------------------------- ### Add ncmdump Crate to Cargo.toml Source: https://github.com/iqiziqi/ncmdump.rs/blob/master/README.md Add the ncmdump crate as a dependency to your Rust project by modifying your Cargo.toml file. ```toml ncmdump = "0.8.0" ``` -------------------------------- ### Extract Music Metadata with Ncmdump::get_info Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Retrieves embedded metadata such as song title, artist, album, and technical audio specifications. ```rust use std::fs::File; use ncmdump::Ncmdump; fn main() -> anyhow::Result<()> { let file = File::open("music.ncm")?; let mut ncm = Ncmdump::from_reader(file)?; let info = ncm.get_info()?; println!("Song: {}", info.name); println!("Music ID: {}", info.id); println!("Album: {}", info.album); println!("Format: {}", info.format); println!("Bitrate: {} bps", info.bitrate); println!("Duration: {} ms", info.duration); // Artist info: Vec<(name, id)> for (artist_name, artist_id) in &info.artist { println!("Artist: {} (ID: {})", artist_name, artist_id); } // Optional fields if let Some(mv_id) = info.mv_id { println!("MV ID: {}", mv_id); } if let Some(aliases) = &info.alias { println!("Aliases: {:?}", aliases); } Ok(()) } ``` -------------------------------- ### Check File Type with is_ncm_file and is_qmc_file Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Convenience functions to quickly check if a file is specifically an NCM or QMC encrypted format. These functions require a mutable file reference. ```rust use std::fs::File; use ncmdump::utils::{is_ncm_file, is_qmc_file}; fn main() -> anyhow::Result<()> { let mut file = File::open("music.ncm")?; if is_ncm_file(&mut file)? { println!("This is an NCM file"); } let mut qmc_file = File::open("music.qmcflac")?; if is_qmc_file(&mut qmc_file)? { println!("This is a QMC file"); } Ok(()) } ``` -------------------------------- ### Detect Encrypted File Format with FileType::parse Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Determine if a file is NCM, QMC, or another format by examining its header. This utility function takes a mutable file reference and returns a FileType enum. ```rust use std::fs::File; use ncmdump::utils::FileType; fn main() -> anyhow::Result<()> { let mut file = File::open("music_file")?; let file_type = FileType::parse(&mut file)?; match file_type { FileType::Ncm => println!("Detected NCM format (Netease Cloud Music)"), FileType::Qmc => println!("Detected QMC format (QQ Music)"), FileType::Other => println!("Unknown or unsupported format"), } Ok(()) } ``` -------------------------------- ### Extract Album Cover Art with Ncmdump::get_image Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Retrieves the embedded album cover image as raw bytes, typically in JPEG format. ```rust use std::fs::File; use std::io::Write; use ncmdump::Ncmdump; fn main() -> anyhow::Result<()> { let file = File::open("music.ncm")?; let mut ncm = Ncmdump::from_reader(file)?; let image_data = ncm.get_image()?; // Save cover art as JPEG let mut cover_file = File::options() .create(true) .write(true) .open("cover.jpg")?; cover_file.write_all(&image_data)?; println!("Extracted {} bytes of cover art", image_data.len()); Ok(()) } ``` -------------------------------- ### Extract Decrypted Audio Data with Ncmdump::get_data Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Reads and decrypts the entire audio content into a byte vector for writing to a file. ```rust use std::fs::File; use std::io::Write; use ncmdump::Ncmdump; fn main() -> anyhow::Result<()> { let file = File::open("music.ncm")?; let mut ncm = Ncmdump::from_reader(file)?; // Get decrypted audio data let music_data = ncm.get_data()?; // Write to output file let mut output = File::options() .create(true) .write(true) .truncate(true) .open("output.flac")?; output.write_all(&music_data)?; println!("Converted {} bytes of audio data", music_data.len()); Ok(()) } ``` -------------------------------- ### FileType::parse - Detect Encrypted File Format Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Utility function to detect the format (NCM, QMC, or other) of a file by examining its header. ```APIDOC ## FileType::parse - Detect Encrypted File Format Utility function to detect whether a file is NCM, QMC, or another format by reading the file header. ### Method `FileType::parse` ### Endpoint N/A (Library function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust use std::fs::File; use ncmdump::utils::FileType; fn main() -> anyhow::Result<()> { let mut file = File::open("music_file")?; let file_type = FileType::parse(&mut file)?; match file_type { FileType::Ncm => println!("Detected NCM format (Netease Cloud Music)"), FileType::Qmc => println!("Detected QMC format (QQ Music)"), FileType::Other => println!("Unknown or unsupported format"), } Ok(()) } ``` ### Response #### Success Response (200) A `FileType` enum variant indicating the detected format (`Ncm`, `Qmc`, or `Other`). #### Response Example `FileType::Ncm` or `FileType::Qmc` or `FileType::Other` ``` -------------------------------- ### Stream Decrypted Audio with Read Trait Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Uses the standard Read trait to process decrypted audio in chunks, which is memory-efficient for large files. ```rust use std::fs::File; use std::io::{Read, Write}; use ncmdump::Ncmdump; fn main() -> std::io::Result<()> { let file = File::open("music.ncm")?; let mut ncm = Ncmdump::from_reader(file).expect("Failed to parse NCM"); let mut output = File::options() .create(true) .write(true) .truncate(true) .open("output.flac")?; // Stream in 1KB chunks let mut buffer = [0u8; 1024]; loop { let bytes_read = ncm.read(&mut buffer)?; if bytes_read == 0 { break; } output.write_all(&buffer[..bytes_read])?; } Ok(()) } ``` -------------------------------- ### Ncmdump Read Trait - Stream Decrypted Audio Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Ncmdump implements the standard Read trait, allowing you to stream decrypted audio data in chunks rather than loading it all into memory at once. ```APIDOC ## Ncmdump Read Trait - Stream Decrypted Audio ### Description Ncmdump implements the standard Read trait, allowing you to stream decrypted audio data in chunks rather than loading it all into memory at once. ### Method `read()` (from `std::io::Read` trait) ### Endpoint N/A (Method on `Ncmdump` instance) ### Parameters - **buffer** (&mut [u8]) - A mutable byte slice to read the decrypted data into. ### Request Example ```rust use std::fs::File; use std::io::{Read, Write}; use ncmdump::Ncmdump; fn main() -> std::io::Result<()> { let file = File::open("music.ncm")?; let mut ncm = Ncmdump::from_reader(file).expect("Failed to parse NCM"); let mut output = File::options() .create(true) .write(true) .truncate(true) .open("output.flac")?; // Stream in 1KB chunks let mut buffer = [0u8; 1024]; loop { let bytes_read = ncm.read(&mut buffer)?; if bytes_read == 0 { break; } output.write_all(&buffer[..bytes_read])?; } Ok(()) } ``` ### Response #### Success Response (200) - **bytes_read** (usize) - The number of bytes read into the buffer. #### Response Example (The decrypted audio data is written to the output file.) ``` -------------------------------- ### Ncmdump::get_info - Extract Music Metadata Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Retrieves embedded metadata from the NCM file including song name, artist information, album name, bitrate, duration, and audio format. ```APIDOC ## Ncmdump::get_info - Extract Music Metadata ### Description Retrieves embedded metadata from the NCM file including song name, artist information, album name, bitrate, duration, and audio format. ### Method `get_info()` ### Endpoint N/A (Method on `Ncmdump` instance) ### Parameters None ### Request Example ```rust use std::fs::File; use ncmdump::Ncmdump; fn main() -> anyhow::Result<()> { let file = File::open("music.ncm")?; let mut ncm = Ncmdump::from_reader(file)?; let info = ncm.get_info()?; println!("Song: {}", info.name); println!("Music ID: {}", info.id); println!("Album: {}", info.album); println!("Format: {}", info.format); println!("Bitrate: {} bps", info.bitrate); println!("Duration: {} ms", info.duration); // Artist info: Vec<(name, id)> for (artist_name, artist_id) in &info.artist { println!("Artist: {} (ID: {})", artist_name, artist_id); } // Optional fields if let Some(mv_id) = info.mv_id { println!("MV ID: {}", mv_id); } if let Some(aliases) = &info.alias { println!("Aliases: {:?}", aliases); } Ok(()) } ``` ### Response #### Success Response (200) - **info** (struct) - Contains metadata fields: - **name** (String) - Song name. - **id** (u32) - Music ID. - **album** (String) - Album name. - **format** (String) - Audio format (e.g., "flac", "mp3"). - **bitrate** (u32) - Bitrate in bits per second. - **duration** (u32) - Duration in milliseconds. - **artist** (Vec<(String, u32)>) - List of artists, each as a tuple of (name, id). - **mv_id** (Option) - Optional MV ID. - **alias** (Option>) - Optional list of aliases. #### Response Example ``` Song: Example Song Name Music ID: 123456 Album: Example Album Format: flac Bitrate: 123456 bps Duration: 180000 ms Artist: Example Artist (ID: 789) ``` ``` -------------------------------- ### Ncmdump::get_image - Extract Album Cover Art Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Extracts the embedded album cover image from the NCM file as raw bytes (typically JPEG format). ```APIDOC ## Ncmdump::get_image - Extract Album Cover Art ### Description Extracts the embedded album cover image from the NCM file as raw bytes (typically JPEG format). ### Method `get_image()` ### Endpoint N/A (Method on `Ncmdump` instance) ### Parameters None ### Request Example ```rust use std::fs::File; use std::io::Write; use ncmdump::Ncmdump; fn main() -> anyhow::Result<()> { let file = File::open("music.ncm")?; let mut ncm = Ncmdump::from_reader(file)?; let image_data = ncm.get_image()?; // Save cover art as JPEG let mut cover_file = File::options() .create(true) .write(true) .open("cover.jpg")?; cover_file.write_all(&image_data)?; println!("Extracted {} bytes of cover art", image_data.len()); Ok(()) } ``` ### Response #### Success Response (200) - **image_data** (Vec) - A byte vector containing the raw image data (e.g., JPEG). #### Response Example (Output message: "Extracted X bytes of cover art") ``` -------------------------------- ### Ncmdump::get_data - Extract Decrypted Audio Data Source: https://context7.com/iqiziqi/ncmdump.rs/llms.txt Reads and decrypts the entire audio data from the NCM file into a byte vector. The returned data is the raw audio content (FLAC or MP3) that can be written directly to a file. ```APIDOC ## Ncmdump::get_data - Extract Decrypted Audio Data ### Description Reads and decrypts the entire audio data from the NCM file into a byte vector. The returned data is the raw audio content (FLAC or MP3) that can be written directly to a file. ### Method `get_data()` ### Endpoint N/A (Method on `Ncmdump` instance) ### Parameters None ### Request Example ```rust use std::fs::File; use std::io::Write; use ncmdump::Ncmdump; fn main() -> anyhow::Result<()> { let file = File::open("music.ncm")?; let mut ncm = Ncmdump::from_reader(file)?; // Get decrypted audio data let music_data = ncm.get_data()?; // Write to output file let mut output = File::options() .create(true) .write(true) .truncate(true) .open("output.flac")?; output.write_all(&music_data)?; println!("Converted {} bytes of audio data", music_data.len()); Ok(()) } ``` ### Response #### Success Response (200) - **music_data** (Vec) - A byte vector containing the decrypted audio data. #### Response Example (Output message: "Converted X bytes of audio data") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.