mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2025-04-29 00:10:35 +05:30
[YouTube] Quote signature deobfuscation function name and add semicolon only where needed
This commit is contained in:
parent
1fa85ec6ca
commit
588c6a8422
@ -6,6 +6,7 @@ import org.schabi.newpipe.extractor.utils.Parser;
|
|||||||
import org.schabi.newpipe.extractor.utils.jsextractor.JavaScriptExtractor;
|
import org.schabi.newpipe.extractor.utils.jsextractor.JavaScriptExtractor;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility class to get the signature timestamp of YouTube's base JavaScript player and deobfuscate
|
* Utility class to get the signature timestamp of YouTube's base JavaScript player and deobfuscate
|
||||||
@ -94,7 +95,7 @@ final class YoutubeSignatureUtils {
|
|||||||
+ deobfuscationFunctionName
|
+ deobfuscationFunctionName
|
||||||
+ "(a);}";
|
+ "(a);}";
|
||||||
|
|
||||||
return helperObject + deobfuscationFunction + callerFunction;
|
return helperObject + deobfuscationFunction + ";" + callerFunction;
|
||||||
} catch (final Exception e) {
|
} catch (final Exception e) {
|
||||||
throw new ParsingException("Could not parse deobfuscation function", e);
|
throw new ParsingException("Could not parse deobfuscation function", e);
|
||||||
}
|
}
|
||||||
@ -124,7 +125,7 @@ final class YoutubeSignatureUtils {
|
|||||||
@Nonnull final String deobfuscationFunctionName) throws ParsingException {
|
@Nonnull final String deobfuscationFunctionName) throws ParsingException {
|
||||||
final String functionBase = deobfuscationFunctionName + "=function";
|
final String functionBase = deobfuscationFunctionName + "=function";
|
||||||
return functionBase + JavaScriptExtractor.matchToClosingBrace(
|
return functionBase + JavaScriptExtractor.matchToClosingBrace(
|
||||||
javaScriptPlayerCode, functionBase) + ";";
|
javaScriptPlayerCode, functionBase);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -132,9 +133,9 @@ final class YoutubeSignatureUtils {
|
|||||||
@Nonnull final String javaScriptPlayerCode,
|
@Nonnull final String javaScriptPlayerCode,
|
||||||
@Nonnull final String deobfuscationFunctionName) throws ParsingException {
|
@Nonnull final String deobfuscationFunctionName) throws ParsingException {
|
||||||
final String functionPattern = DEOBF_FUNC_REGEX_START
|
final String functionPattern = DEOBF_FUNC_REGEX_START
|
||||||
+ deobfuscationFunctionName.replace("$", "\\$")
|
+ Pattern.quote(deobfuscationFunctionName)
|
||||||
+ DEOBF_FUNC_REGEX_END;
|
+ DEOBF_FUNC_REGEX_END;
|
||||||
return "var " + Parser.matchGroup1(functionPattern, javaScriptPlayerCode) + ";";
|
return "var " + Parser.matchGroup1(functionPattern, javaScriptPlayerCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -142,7 +143,7 @@ final class YoutubeSignatureUtils {
|
|||||||
@Nonnull final String helperObjectName)
|
@Nonnull final String helperObjectName)
|
||||||
throws ParsingException {
|
throws ParsingException {
|
||||||
final String helperPattern = SIG_DEOBF_HELPER_OBJ_REGEX_START
|
final String helperPattern = SIG_DEOBF_HELPER_OBJ_REGEX_START
|
||||||
+ helperObjectName.replace("$", "\\$")
|
+ Pattern.quote(helperObjectName)
|
||||||
+ SIG_DEOBF_HELPER_OBJ_REGEX_END;
|
+ SIG_DEOBF_HELPER_OBJ_REGEX_END;
|
||||||
return Parser.matchGroup1(helperPattern, javaScriptPlayerCode)
|
return Parser.matchGroup1(helperPattern, javaScriptPlayerCode)
|
||||||
.replace("\n", "");
|
.replace("\n", "");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user