-
-
Notifications
You must be signed in to change notification settings - Fork 543
Expand regex to match n param decrypt function #696
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 3 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1c78976
[YouTube] Expand regex to match n param decrypt function
XiangRongLin 2967d1a
[YouTube] Compile YoutubeThrottlingDecrypter pattern statically
XiangRongLin 60794ae
[YouTube] Add parenthesis matching as way to parse decrypt function
XiangRongLin 48d897e
Add final and adjust utils class name
XiangRongLin 852a65f
Add tests for StringUtils
XiangRongLin 37df225
Remove length check from StringUtils.matchToClosingParenthesis
XiangRongLin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
extractor/src/main/java/org/schabi/newpipe/extractor/utils/StringUtil.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,47 @@ | ||
| package org.schabi.newpipe.extractor.utils; | ||
|
|
||
| import edu.umd.cs.findbugs.annotations.NonNull; | ||
|
XiangRongLin marked this conversation as resolved.
Outdated
|
||
|
|
||
| public class StringUtil { | ||
|
XiangRongLin marked this conversation as resolved.
Outdated
|
||
|
|
||
| private StringUtil() { | ||
| } | ||
|
|
||
| /** | ||
| * @param string The string to search in | ||
| * @param start A string from which to start searching. | ||
| * @return A substring where each '{' matches a '}' | ||
| * @throws IndexOutOfBoundsException If {@ string} does not contain {@code start} | ||
| */ | ||
| @NonNull | ||
| public static String matchToClosingParenthesis(@NonNull final String string, @NonNull final String start) { | ||
| int startIndex = string.indexOf(start); | ||
| if (startIndex < 0) { | ||
| throw new IndexOutOfBoundsException(); | ||
| } | ||
|
|
||
| startIndex += start.length(); | ||
| int endIndex = startIndex; | ||
| while (string.charAt(endIndex) != '{') { | ||
| ++endIndex; | ||
| } | ||
| ++endIndex; | ||
|
|
||
| int openParenthesis = 1; | ||
| while (openParenthesis > 0) { | ||
| switch (string.charAt(endIndex)) { | ||
| case '{': | ||
| ++openParenthesis; | ||
| break; | ||
| case '}': | ||
| --openParenthesis; | ||
| break; | ||
| default: | ||
| break; | ||
| } | ||
| ++endIndex; | ||
| } | ||
|
|
||
| return string.substring(startIndex, endIndex); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.