Fix missing imports and Checkstyle issues

This commit is contained in:
TiA4f8R 2022-03-27 20:51:30 +02:00
parent 6d27996ac4
commit dfa4239661
No known key found for this signature in database
GPG Key ID: E6D3E7F5949450DD
9 changed files with 18 additions and 9 deletions

View File

@ -589,7 +589,8 @@ public final class YoutubeParsingHelper {
INNERTUBE_CONTEXT_CLIENT_VERSION_REGEXES, 1); INNERTUBE_CONTEXT_CLIENT_VERSION_REGEXES, 1);
key = getStringResultFromRegexArray(response, INNERTUBE_API_KEY_REGEXES, 1); key = getStringResultFromRegexArray(response, INNERTUBE_API_KEY_REGEXES, 1);
} catch (final Parser.RegexException e) { } catch (final Parser.RegexException e) {
throw new ParsingException("Could not extract YouTube WEB InnerTube client version and API key from sw.js", e); throw new ParsingException("Could not extract YouTube WEB InnerTube client version "
+ "and API key from sw.js", e);
} }
keyAndVersionExtracted = true; keyAndVersionExtracted = true;
} }
@ -649,8 +650,8 @@ public final class YoutubeParsingHelper {
try { try {
key = getStringResultFromRegexArray(html, INNERTUBE_API_KEY_REGEXES, 1); key = getStringResultFromRegexArray(html, INNERTUBE_API_KEY_REGEXES, 1);
} catch (final Parser.RegexException e) { } catch (final Parser.RegexException e) {
throw new ParsingException( throw new ParsingException("Could not extract YouTube WEB InnerTube client version "
"Could not extract YouTube WEB InnerTube client version and API key from HTML search results page", e); + "and API key from HTML search results page", e);
} }
keyAndVersionExtracted = true; keyAndVersionExtracted = true;
} }
@ -823,7 +824,7 @@ public final class YoutubeParsingHelper {
musicClientName = Parser.matchGroup1(INNERTUBE_CLIENT_NAME_REGEX, html); musicClientName = Parser.matchGroup1(INNERTUBE_CLIENT_NAME_REGEX, html);
} }
youtubeMusicKey = new String[] { musicKey, musicClientName, musicClientVersion }; youtubeMusicKey = new String[] {musicKey, musicClientName, musicClientVersion};
return youtubeMusicKey; return youtubeMusicKey;
} }
@ -1050,7 +1051,7 @@ public final class YoutubeParsingHelper {
final byte[] body, final byte[] body,
@Nonnull final Localization localization, @Nonnull final Localization localization,
@Nonnull final String userAgent, @Nonnull final String userAgent,
@Nonnull final String key, @Nonnull final String innerTubeApiKey,
@Nullable final String endPartOfUrlRequest) throws IOException, ExtractionException { @Nullable final String endPartOfUrlRequest) throws IOException, ExtractionException {
final Map<String, List<String>> headers = new HashMap<>(); final Map<String, List<String>> headers = new HashMap<>();
headers.put("Content-Type", Collections.singletonList("application/json")); headers.put("Content-Type", Collections.singletonList("application/json"));
@ -1058,7 +1059,7 @@ public final class YoutubeParsingHelper {
headers.put("X-Goog-Api-Format-Version", Collections.singletonList("2")); headers.put("X-Goog-Api-Format-Version", Collections.singletonList("2"));
final String baseEndpointUrl = "https://youtubei.googleapis.com/youtubei/v1/" + endpoint final String baseEndpointUrl = "https://youtubei.googleapis.com/youtubei/v1/" + endpoint
+ "?key=" + key + DISABLE_PRETTY_PRINT_PARAMETER; + "?key=" + innerTubeApiKey + DISABLE_PRETTY_PRINT_PARAMETER;
final Response response = getDownloader().post(isNullOrEmpty(endPartOfUrlRequest) final Response response = getDownloader().post(isNullOrEmpty(endPartOfUrlRequest)
? baseEndpointUrl : baseEndpointUrl + endPartOfUrlRequest, ? baseEndpointUrl : baseEndpointUrl + endPartOfUrlRequest,
@ -1363,6 +1364,7 @@ public final class YoutubeParsingHelper {
* @see #CONSENT_COOKIE * @see #CONSENT_COOKIE
* @param headers the headers which should be completed * @param headers the headers which should be completed
*/ */
@SuppressWarnings("ArraysAsListWithZeroOrOneArgument")
public static void addCookieHeader(@Nonnull final Map<String, List<String>> headers) { public static void addCookieHeader(@Nonnull final Map<String, List<String>> headers) {
if (headers.get("Cookie") == null) { if (headers.get("Cookie") == null) {
headers.put("Cookie", Arrays.asList(generateConsentCookie())); headers.put("Cookie", Arrays.asList(generateConsentCookie()));

View File

@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor.services.youtube.extractors; package org.schabi.newpipe.extractor.services.youtube.extractors;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.DISABLE_PRETTY_PRINT_PARAMETER;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.YOUTUBEI_V1_URL; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.YOUTUBEI_V1_URL;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.addClientInfoHeaders; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.addClientInfoHeaders;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.fixThumbnailUrl; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.fixThumbnailUrl;

View File

@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor.services.youtube.extractors; package org.schabi.newpipe.extractor.services.youtube.extractors;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.DISABLE_PRETTY_PRINT_PARAMETER;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.YOUTUBEI_V1_URL; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.YOUTUBEI_V1_URL;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.addClientInfoHeaders; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.addClientInfoHeaders;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.extractCookieValue; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.extractCookieValue;

View File

@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor.services.youtube.extractors; package org.schabi.newpipe.extractor.services.youtube.extractors;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.DISABLE_PRETTY_PRINT_PARAMETER;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.fixThumbnailUrl; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.fixThumbnailUrl;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getTextFromObject;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getUrlFromNavigationEndpoint; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getUrlFromNavigationEndpoint;

View File

@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor.services.youtube.extractors; package org.schabi.newpipe.extractor.services.youtube.extractors;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.DISABLE_PRETTY_PRINT_PARAMETER;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.YOUTUBEI_V1_URL; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.YOUTUBEI_V1_URL;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.addClientInfoHeaders; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.addClientInfoHeaders;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.extractPlaylistTypeFromPlaylistUrl; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.extractPlaylistTypeFromPlaylistUrl;

View File

@ -1,5 +1,6 @@
package org.schabi.newpipe.extractor.services.youtube.extractors; package org.schabi.newpipe.extractor.services.youtube.extractors;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.DISABLE_PRETTY_PRINT_PARAMETER;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.YOUTUBEI_V1_URL; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.YOUTUBEI_V1_URL;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getJsonPostResponse; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getJsonPostResponse;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getKey; import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.getKey;

View File

@ -1079,7 +1079,8 @@ public class YoutubeStreamExtractor extends StreamExtractor {
} }
} }
private static String getDeobfuscationFuncName(final String thePlayerCode) throws DeobfuscateException { private static String getDeobfuscationFuncName(final String thePlayerCode)
throws DeobfuscateException {
Parser.RegexException exception = null; Parser.RegexException exception = null;
for (final String regex : REGEXES) { for (final String regex : REGEXES) {
try { try {

View File

@ -17,7 +17,8 @@ public final class RandomStringFromAlphabetGenerator {
* *
* @param alphabet the characters' alphabet to use * @param alphabet the characters' alphabet to use
* @param length the length of the returned string (> 0) * @param length the length of the returned string (> 0)
* @param random {@link Random} (or better {@link java.security.SecureRandom}) used for generating the random string * @param random {@link Random} (or better {@link java.security.SecureRandom}) used for
* generating the random string
* @return a random string of the requested length made of only characters from the provided * @return a random string of the requested length made of only characters from the provided
* alphabet * alphabet
*/ */

View File

@ -282,7 +282,7 @@ public final class Utils {
* @param map the {@link Map map} on which check if it's null or empty * @param map the {@link Map map} on which check if it's null or empty
* @return whether the {@link Map map} is null or empty * @return whether the {@link Map map} is null or empty
*/ */
public static <K,V> boolean isNullOrEmpty(final Map<K, V> map) { public static <K, V> boolean isNullOrEmpty(final Map<K, V> map) {
return map == null || map.isEmpty(); return map == null || map.isEmpty();
} }