Apply requested codestyle improvements.
This commit is contained in:
parent
6950b362f2
commit
e6d334765d
2 changed files with 34 additions and 36 deletions
|
@ -89,9 +89,9 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
// we couldn't get information about the channel associated with this URL, if there is one.
|
||||
if (!channelId[0].equals("channel")) {
|
||||
final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder(
|
||||
getExtractorLocalization(), getExtractorContentCountry())
|
||||
.value("url", "https://www.youtube.com/" + channelPath)
|
||||
.done())
|
||||
getExtractorLocalization(), getExtractorContentCountry())
|
||||
.value("url", "https://www.youtube.com/" + channelPath)
|
||||
.done())
|
||||
.getBytes(UTF_8);
|
||||
|
||||
final JsonObject jsonResponse = getJsonPostResponse("navigation/resolve_url",
|
||||
|
@ -104,8 +104,8 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
throw new ContentNotAvailableException("This channel doesn't exist.");
|
||||
} else {
|
||||
throw new ContentNotAvailableException("Got error:\""
|
||||
+ errorJsonObject.getString("status") + "\": "
|
||||
+ errorJsonObject.getString("message"));
|
||||
+ errorJsonObject.getString("status") + "\": "
|
||||
+ errorJsonObject.getString("message"));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -136,10 +136,10 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
int level = 0;
|
||||
while (level < 3) {
|
||||
final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder(
|
||||
getExtractorLocalization(), getExtractorContentCountry())
|
||||
.value("browseId", id)
|
||||
.value("params", "EgZ2aWRlb3M%3D") // Equal to videos
|
||||
.done())
|
||||
getExtractorLocalization(), getExtractorContentCountry())
|
||||
.value("browseId", id)
|
||||
.value("params", "EgZ2aWRlb3M%3D") // Equal to videos
|
||||
.done())
|
||||
.getBytes(UTF_8);
|
||||
|
||||
final JsonObject jsonResponse = getJsonPostResponse("browse", body,
|
||||
|
@ -273,16 +273,15 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
public long getSubscriberCount() throws ParsingException {
|
||||
final JsonObject c4TabbedHeaderRenderer = initialData.getObject("header")
|
||||
.getObject("c4TabbedHeaderRenderer");
|
||||
if (c4TabbedHeaderRenderer.has("subscriberCountText")) {
|
||||
try {
|
||||
return Utils.mixedNumberWordToLong(getTextFromObject(c4TabbedHeaderRenderer
|
||||
.getObject("subscriberCountText")));
|
||||
} catch (final NumberFormatException e) {
|
||||
throw new ParsingException("Could not get subscriber count", e);
|
||||
}
|
||||
} else {
|
||||
if (!c4TabbedHeaderRenderer.has("subscriberCountText")) {
|
||||
return UNKNOWN_SUBSCRIBER_COUNT;
|
||||
}
|
||||
try {
|
||||
return Utils.mixedNumberWordToLong(getTextFromObject(c4TabbedHeaderRenderer
|
||||
.getObject("subscriberCountText")));
|
||||
} catch (final NumberFormatException e) {
|
||||
throw new ParsingException("Could not get subscriber count", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -385,9 +384,9 @@ public class YoutubeChannelExtractor extends ChannelExtractor {
|
|||
.getString("token");
|
||||
|
||||
final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder(getExtractorLocalization(),
|
||||
getExtractorContentCountry())
|
||||
.value("continuation", continuation)
|
||||
.done())
|
||||
getExtractorContentCountry())
|
||||
.value("continuation", continuation)
|
||||
.done())
|
||||
.getBytes(UTF_8);
|
||||
|
||||
return new Page(YOUTUBEI_V1_URL + "browse?key=" + getKey(), null, channelIds, null, body);
|
||||
|
|
|
@ -180,7 +180,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
// TODO: this parses English formatted dates only, we need a better approach to parse
|
||||
// the textual date
|
||||
final LocalDate localDate = LocalDate.parse(getTextFromObject(
|
||||
getVideoPrimaryInfoRenderer().getObject("dateText")),
|
||||
getVideoPrimaryInfoRenderer().getObject("dateText")),
|
||||
DateTimeFormatter.ofPattern("dd MMM yyyy", Locale.ENGLISH));
|
||||
return DateTimeFormatter.ISO_LOCAL_DATE.format(localDate);
|
||||
} catch (final Exception ignored) {
|
||||
|
@ -440,15 +440,14 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
@Override
|
||||
public long getUploaderSubscriberCount() throws ParsingException {
|
||||
final JsonObject videoOwnerRenderer = JsonUtils.getObject(videoSecondaryInfoRenderer, "owner.videoOwnerRenderer");
|
||||
if (videoOwnerRenderer.has("subscriberCountText")) {
|
||||
try {
|
||||
return Utils.mixedNumberWordToLong(getTextFromObject(videoOwnerRenderer.getObject("subscriberCountText")));
|
||||
} catch (final NumberFormatException e) {
|
||||
throw new ParsingException("Could not get uploader subscriber count", e);
|
||||
}
|
||||
} else {
|
||||
if (!videoOwnerRenderer.has("subscriberCountText")) {
|
||||
return UNKNOWN_SUBSCRIBER_COUNT;
|
||||
}
|
||||
try {
|
||||
return Utils.mixedNumberWordToLong(getTextFromObject(videoOwnerRenderer.getObject("subscriberCountText")));
|
||||
} catch (final NumberFormatException e) {
|
||||
throw new ParsingException("Could not get uploader subscriber count", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
@ -680,9 +679,9 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
final Localization localization = getExtractorLocalization();
|
||||
final ContentCountry contentCountry = getExtractorContentCountry();
|
||||
final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder(
|
||||
localization, contentCountry)
|
||||
.value("videoId", videoId)
|
||||
.done())
|
||||
localization, contentCountry)
|
||||
.value("videoId", videoId)
|
||||
.done())
|
||||
.getBytes(UTF_8);
|
||||
|
||||
// Put the sts string if we already know it so we don't have to fetch again the player
|
||||
|
@ -731,8 +730,8 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
|
||||
if (ageRestricted) {
|
||||
final byte[] ageRestrictedBody = JsonWriter.string(prepareDesktopEmbedVideoJsonBuilder(
|
||||
localization, contentCountry, videoId)
|
||||
.done())
|
||||
localization, contentCountry, videoId)
|
||||
.done())
|
||||
.getBytes(UTF_8);
|
||||
nextResponse = getJsonPostResponse("next", ageRestrictedBody, localization);
|
||||
} else {
|
||||
|
@ -814,7 +813,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
final String videoId)
|
||||
throws IOException, ExtractionException {
|
||||
final byte[] mobileBody = JsonWriter.string(prepareAndroidMobileJsonBuilder(
|
||||
localization, contentCountry)
|
||||
localization, contentCountry)
|
||||
.value("videoId", videoId)
|
||||
.done())
|
||||
.getBytes(UTF_8);
|
||||
|
@ -887,8 +886,8 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
final String videoId)
|
||||
throws IOException, ExtractionException {
|
||||
final byte[] androidMobileEmbedBody = JsonWriter.string(
|
||||
prepareAndroidMobileEmbedVideoJsonBuilder(localization, contentCountry, videoId)
|
||||
.done())
|
||||
prepareAndroidMobileEmbedVideoJsonBuilder(localization, contentCountry, videoId)
|
||||
.done())
|
||||
.getBytes(UTF_8);
|
||||
final JsonObject androidMobileEmbedPlayerResponse = getJsonMobilePostResponse("player",
|
||||
androidMobileEmbedBody, contentCountry, localization);
|
||||
|
|
Loading…
Reference in a new issue