diff --git a/src/consts.rs b/src/consts.rs index 4f060ef..ae6a86d 100644 --- a/src/consts.rs +++ b/src/consts.rs @@ -6,7 +6,7 @@ pub static TEST_YOUTUBE_VIDEO: &str = "https://www.youtube.com/watch?v=jNQXAC9IV pub static REGEX_PLAYER_ID: &Lazy = regex!("\\/s\\/player\\/([0-9a-f]{8})"); pub static NSIG_FUNCTION_ARRAY: &Lazy = regex!( - "b=String\\.fromCharCode\\(110\\),c=a\\.get\\(b\\)\\)&&\\(c=([a-zA-Z0-9$_]+)\\[([0-9]+)\\]" + r#"(?x)(?:\.get\("n"\)\)&&\(b=|b=String\.fromCharCode\(110\),c=a\.get\(b\)\)&&\(c=)(?P[a-zA-Z0-9$]+)(?:\[(?P\d+)\])?\([a-zA-Z0-9]\)"# ); pub static REGEX_SIGNATURE_TIMESTAMP: &Lazy = regex!("signatureTimestamp[=:](\\d+)"); diff --git a/src/player.rs b/src/player.rs index 46c9fcc..92fbb6a 100644 --- a/src/player.rs +++ b/src/player.rs @@ -60,9 +60,9 @@ pub async fn fetch_update(state: Arc) -> Result<(), FetchUpdateStat }; let nsig_function_array = NSIG_FUNCTION_ARRAY.captures(&player_javascript).unwrap(); - let nsig_array_name = nsig_function_array.get(1).unwrap().as_str(); + let nsig_array_name = nsig_function_array.name("nfunc").unwrap().as_str(); let nsig_array_value = nsig_function_array - .get(2) + .name("idx") .unwrap() .as_str() .parse::() @@ -97,7 +97,7 @@ pub async fn fetch_update(state: Arc) -> Result<(), FetchUpdateStat let mut nsig_function_code_regex_str: String = String::new(); nsig_function_code_regex_str += &nsig_function_name.replace("$", "\\$"); nsig_function_code_regex_str += - "=\\s*function([\\S\\s]*?\\}\\s*return [\\w$]+?\\.join\\(\"\"\\)\\s*\\};)"; + "=\\s*function([\\S\\s]*?\\}\\s*return [\\W\\w$]+?\\.call\\([\\w$]+?,\"\"\\)\\s*\\};)"; let nsig_function_code_regex = Regex::new(&nsig_function_code_regex_str).unwrap();