Skip to content

Commit 48d897e

Browse files
committed
Add final and adjust utils class name
1 parent 60794ae commit 48d897e

4 files changed

Lines changed: 14 additions & 13 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeThrottlingDecrypter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import org.schabi.newpipe.extractor.exceptions.ParsingException;
44
import org.schabi.newpipe.extractor.utils.JavaScript;
55
import org.schabi.newpipe.extractor.utils.Parser;
6-
import org.schabi.newpipe.extractor.utils.StringUtil;
6+
import org.schabi.newpipe.extractor.utils.StringUtils;
77

88
import javax.annotation.Nonnull;
99
import java.util.HashMap;
@@ -81,7 +81,7 @@ private String parseDecodeFunction(final String playerJsCode, final String funct
8181

8282
private String parseWithParenthesisMatching(final String playerJsCode, final String functionName) {
8383
final String functionBase = functionName + "=function";
84-
return functionBase + StringUtil.matchToClosingParenthesis(playerJsCode, functionBase) + ";";
84+
return functionBase + StringUtils.matchToClosingParenthesis(playerJsCode, functionBase) + ";";
8585
}
8686

8787
private String parseWithRegex(final String playerJsCode, final String functionName) throws Parser.RegexException {

extractor/src/main/java/org/schabi/newpipe/extractor/utils/Parser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,13 @@ public static String matchGroup(Pattern pat, String input, int group) throws Reg
7979
}
8080

8181
public static boolean isMatch(String pattern, String input) {
82-
Pattern pat = Pattern.compile(pattern);
83-
Matcher mat = pat.matcher(input);
82+
final Pattern pat = Pattern.compile(pattern);
83+
final Matcher mat = pat.matcher(input);
8484
return mat.find();
8585
}
8686

8787
public static boolean isMatch(Pattern pattern, String input) {
88-
Matcher mat = pattern.matcher(input);
88+
final Matcher mat = pattern.matcher(input);
8989
return mat.find();
9090
}
9191

extractor/src/main/java/org/schabi/newpipe/extractor/utils/StringUtil.java renamed to extractor/src/main/java/org/schabi/newpipe/extractor/utils/StringUtils.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,21 @@
11
package org.schabi.newpipe.extractor.utils;
22

3-
import edu.umd.cs.findbugs.annotations.NonNull;
43

5-
public class StringUtil {
4+
import javax.annotation.Nonnull;
65

7-
private StringUtil() {
6+
public class StringUtils {
7+
8+
private StringUtils() {
89
}
910

1011
/**
1112
* @param string The string to search in
1213
* @param start A string from which to start searching.
1314
* @return A substring where each '{' matches a '}'
14-
* @throws IndexOutOfBoundsException If {@ string} does not contain {@code start}
15+
* @throws IndexOutOfBoundsException If {@code string} does not contain {@code start}
1516
*/
16-
@NonNull
17-
public static String matchToClosingParenthesis(@NonNull final String string, @NonNull final String start) {
17+
@Nonnull
18+
public static String matchToClosingParenthesis(@Nonnull final String string, @Nonnull final String start) {
1819
int startIndex = string.indexOf(start);
1920
if (startIndex < 0) {
2021
throw new IndexOutOfBoundsException();

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubeThrottlingDecrypterTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ public void setup() throws IOException {
2323

2424
@Test
2525
public void testExtractFunction__success() throws ParsingException {
26-
String[] videoIds = {"jE1USQrs1rw", "CqxjzfudGAc", "goH-9MfQI7w", "KYIdr_7H5Yw", "J1WeqmGbYeI"};
26+
final String[] videoIds = {"jE1USQrs1rw", "CqxjzfudGAc", "goH-9MfQI7w", "KYIdr_7H5Yw", "J1WeqmGbYeI"};
2727

2828
final String encryptedUrl = "https://r6---sn-4g5ednek.googlevideo.com/videoplayback?expire=1626562120&ei=6AnzYO_YBpql1gLGkb_IBQ&ip=127.0.0.1&id=o-ANhBEf36Z5h-8U9DDddtPDqtS0ZNwf0XJAAigudKI2uI&itag=278&aitags=133%2C134%2C135%2C136%2C137%2C160%2C242%2C243%2C244%2C247%2C248%2C278&source=youtube&requiressl=yes&vprv=1&mime=video%2Fwebm&ns=TvecOReN0vPuXb3j_zq157IG&gir=yes&clen=2915100&dur=270.203&lmt=1608157174907785&keepalive=yes&fexp=24001373,24007246&c=WEB&txp=5535432&n=N9BWSTFT7vvBJrvQ&sparams=expire%2Cei%2Cip%2Cid%2Caitags%2Csource%2Crequiressl%2Cvprv%2Cmime%2Cns%2Cgir%2Cclen%2Cdur%2Clmt&alr=yes&sig=AOq0QJ8wRQIgW6XnUDKPDSxiT0_KE_tDDMpcaCJl2Un5p0Fu9qZNQGkCIQDWxsDHi_s2BEmRqIbd1C5g_gzfihB7RZLsScKWNMwzzA%3D%3D&cpn=9r2yt3BqcYmeb2Yu&cver=2.20210716.00.00&redirect_counter=1&cm2rm=sn-4g5ezy7s&cms_redirect=yes&mh=Y5&mm=34&mn=sn-4g5ednek&ms=ltu&mt=1626540524&mv=m&mvi=6&pl=43&lsparams=mh,mm,mn,ms,mv,mvi,pl&lsig=AG3C_xAwRQIhAIUzxTn9Vw1-vm-_7OQ5-0h1M6AZsY9Bx1FlCCTeMICzAiADtGggbn4Znsrh2EnvyOsGnYdRGcbxn4mW9JMOQiInDQ%3D%3D&range=259165-480735&rn=11&rbuf=20190";
2929

30-
for (String videoId : videoIds) {
30+
for (final String videoId : videoIds) {
3131
try {
3232
final String decryptedUrl = new YoutubeThrottlingDecrypter(videoId).apply(encryptedUrl);
3333
assertNotEquals(encryptedUrl, decryptedUrl);

0 commit comments

Comments
 (0)