Fix problems with the regex

This commit is contained in:
techmetx11 2024-07-11 00:11:10 +01:00
parent cdeddbd07e
commit 446120f5c9
No known key found for this signature in database
GPG Key ID: E60B63635FF4E062
2 changed files with 4 additions and 4 deletions

View File

@ -6,7 +6,7 @@ pub static TEST_YOUTUBE_VIDEO: &str = "https://www.youtube.com/watch?v=jNQXAC9IV
pub static REGEX_PLAYER_ID: &Lazy<Regex> = regex!("\\/s\\/player\\/([0-9a-f]{8})");
pub static NSIG_FUNCTION_ARRAY: &Lazy<Regex> = 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<nfunc>[a-zA-Z0-9$]+)(?:\[(?P<idx>\d+)\])?\([a-zA-Z0-9]\)"#
);
pub static REGEX_SIGNATURE_TIMESTAMP: &Lazy<Regex> = regex!("signatureTimestamp[=:](\\d+)");

View File

@ -60,9 +60,9 @@ pub async fn fetch_update(state: Arc<GlobalState>) -> 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::<usize>()
@ -97,7 +97,7 @@ pub async fn fetch_update(state: Arc<GlobalState>) -> 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();