Skip to content

Commit

Permalink
refactor: rename ximalaya to ximalaya_android
Browse files Browse the repository at this point in the history
  • Loading branch information
jixunmoe committed Feb 13, 2024
1 parent e38e77b commit 9942906
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
18 changes: 9 additions & 9 deletions src/bin/cli/cli_handle_ximalaya_android.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ use std::io::{Read, Write};

use argh::{FromArgValue, FromArgs};

use parakeet_crypto::crypto::ximalaya;
use parakeet_crypto::crypto::ximalaya::keys::SCRAMBLED_HEADER_LEN;
use parakeet_crypto::crypto::ximalaya_android;
use parakeet_crypto::crypto::ximalaya_android::keys::SCRAMBLED_HEADER_LEN;

use crate::cli::cli_error::ParakeetCliError;
use crate::cli::{logger::CliLogger, utils::CliFilePath};

#[derive(Debug, PartialEq, Copy, Clone)]
struct XimalayaType(ximalaya::keys::Type);
struct CmdKeyType(ximalaya_android::keys::Type);

impl FromArgValue for XimalayaType {
impl FromArgValue for CmdKeyType {
fn from_arg_value(value: &str) -> Result<Self, String> {
match value.to_lowercase().as_str() {
"x2m" => Ok(Self(ximalaya::keys::Type::X2M)),
"x3m" => Ok(Self(ximalaya::keys::Type::X3M)),
"x2m" => Ok(Self(ximalaya_android::keys::Type::X2M)),
"x3m" => Ok(Self(ximalaya_android::keys::Type::X3M)),
_ => Err("Invalid type".into()),
}
}
Expand All @@ -28,7 +28,7 @@ impl FromArgValue for XimalayaType {
pub struct Options {
/// x2m / x3m key. Accepted values are "x2m" and "x3m".
#[argh(option, short = 't', long = "type")]
key_type: XimalayaType,
key_type: CmdKeyType,

/// input file name/path
#[argh(option, short = 'i', long = "input")]
Expand All @@ -49,8 +49,8 @@ pub fn handle(args: Options) -> Result<(), ParakeetCliError> {
src.read_exact(&mut hdr)
.map_err(ParakeetCliError::SourceIoError)?;

let (content_key, scramble_table) = ximalaya::keys::get_key(args.key_type.0);
let hdr = ximalaya::decrypt_header(&hdr, content_key, scramble_table);
let (content_key, scramble_table) = ximalaya_android::keys::get_key(args.key_type.0);
let hdr = ximalaya_android::decrypt_header(&hdr, content_key, scramble_table);

dst.write_all(&hdr)
.map_err(ParakeetCliError::DestinationIoError)?;
Expand Down
2 changes: 1 addition & 1 deletion src/crypto/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ pub mod byte_offset_cipher;
pub mod kugou;
pub mod kuwo;
pub mod tencent;
pub mod ximalaya;
pub mod ximalaya_android;
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::crypto::ximalaya::keys::{ContentKey, ScrambleTable, SCRAMBLED_HEADER_LEN};
use crate::crypto::ximalaya_android::keys::{ContentKey, ScrambleTable, SCRAMBLED_HEADER_LEN};

pub fn decrypt_header(
header: &[u8; SCRAMBLED_HEADER_LEN],
Expand Down
File renamed without changes.
File renamed without changes.

0 comments on commit 9942906

Please sign in to comment.