Skip to content

Commit e6d3347

Browse files
committed
Apply requested codestyle improvements.
1 parent 6950b36 commit e6d3347

2 files changed

Lines changed: 34 additions & 36 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelExtractor.java

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ public void onFetchPage(@Nonnull final Downloader downloader) throws IOException
8989
// we couldn't get information about the channel associated with this URL, if there is one.
9090
if (!channelId[0].equals("channel")) {
9191
final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder(
92-
getExtractorLocalization(), getExtractorContentCountry())
93-
.value("url", "https://www.youtube.com/" + channelPath)
94-
.done())
92+
getExtractorLocalization(), getExtractorContentCountry())
93+
.value("url", "https://www.youtube.com/" + channelPath)
94+
.done())
9595
.getBytes(UTF_8);
9696

9797
final JsonObject jsonResponse = getJsonPostResponse("navigation/resolve_url",
@@ -104,8 +104,8 @@ public void onFetchPage(@Nonnull final Downloader downloader) throws IOException
104104
throw new ContentNotAvailableException("This channel doesn't exist.");
105105
} else {
106106
throw new ContentNotAvailableException("Got error:\""
107-
+ errorJsonObject.getString("status") + "\": "
108-
+ errorJsonObject.getString("message"));
107+
+ errorJsonObject.getString("status") + "\": "
108+
+ errorJsonObject.getString("message"));
109109
}
110110
}
111111

@@ -136,10 +136,10 @@ public void onFetchPage(@Nonnull final Downloader downloader) throws IOException
136136
int level = 0;
137137
while (level < 3) {
138138
final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder(
139-
getExtractorLocalization(), getExtractorContentCountry())
140-
.value("browseId", id)
141-
.value("params", "EgZ2aWRlb3M%3D") // Equal to videos
142-
.done())
139+
getExtractorLocalization(), getExtractorContentCountry())
140+
.value("browseId", id)
141+
.value("params", "EgZ2aWRlb3M%3D") // Equal to videos
142+
.done())
143143
.getBytes(UTF_8);
144144

145145
final JsonObject jsonResponse = getJsonPostResponse("browse", body,
@@ -273,16 +273,15 @@ public String getFeedUrl() throws ParsingException {
273273
public long getSubscriberCount() throws ParsingException {
274274
final JsonObject c4TabbedHeaderRenderer = initialData.getObject("header")
275275
.getObject("c4TabbedHeaderRenderer");
276-
if (c4TabbedHeaderRenderer.has("subscriberCountText")) {
277-
try {
278-
return Utils.mixedNumberWordToLong(getTextFromObject(c4TabbedHeaderRenderer
279-
.getObject("subscriberCountText")));
280-
} catch (final NumberFormatException e) {
281-
throw new ParsingException("Could not get subscriber count", e);
282-
}
283-
} else {
276+
if (!c4TabbedHeaderRenderer.has("subscriberCountText")) {
284277
return UNKNOWN_SUBSCRIBER_COUNT;
285278
}
279+
try {
280+
return Utils.mixedNumberWordToLong(getTextFromObject(c4TabbedHeaderRenderer
281+
.getObject("subscriberCountText")));
282+
} catch (final NumberFormatException e) {
283+
throw new ParsingException("Could not get subscriber count", e);
284+
}
286285
}
287286

288287
@Override
@@ -385,9 +384,9 @@ private Page getNextPageFrom(final JsonObject continuations,
385384
.getString("token");
386385

387386
final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder(getExtractorLocalization(),
388-
getExtractorContentCountry())
389-
.value("continuation", continuation)
390-
.done())
387+
getExtractorContentCountry())
388+
.value("continuation", continuation)
389+
.done())
391390
.getBytes(UTF_8);
392391

393392
return new Page(YOUTUBEI_V1_URL + "browse?key=" + getKey(), null, channelIds, null, body);

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ public String getTextualUploadDate() throws ParsingException {
180180
// TODO: this parses English formatted dates only, we need a better approach to parse
181181
// the textual date
182182
final LocalDate localDate = LocalDate.parse(getTextFromObject(
183-
getVideoPrimaryInfoRenderer().getObject("dateText")),
183+
getVideoPrimaryInfoRenderer().getObject("dateText")),
184184
DateTimeFormatter.ofPattern("dd MMM yyyy", Locale.ENGLISH));
185185
return DateTimeFormatter.ISO_LOCAL_DATE.format(localDate);
186186
} catch (final Exception ignored) {
@@ -440,15 +440,14 @@ public String getUploaderAvatarUrl() throws ParsingException {
440440
@Override
441441
public long getUploaderSubscriberCount() throws ParsingException {
442442
final JsonObject videoOwnerRenderer = JsonUtils.getObject(videoSecondaryInfoRenderer, "owner.videoOwnerRenderer");
443-
if (videoOwnerRenderer.has("subscriberCountText")) {
444-
try {
445-
return Utils.mixedNumberWordToLong(getTextFromObject(videoOwnerRenderer.getObject("subscriberCountText")));
446-
} catch (final NumberFormatException e) {
447-
throw new ParsingException("Could not get uploader subscriber count", e);
448-
}
449-
} else {
443+
if (!videoOwnerRenderer.has("subscriberCountText")) {
450444
return UNKNOWN_SUBSCRIBER_COUNT;
451445
}
446+
try {
447+
return Utils.mixedNumberWordToLong(getTextFromObject(videoOwnerRenderer.getObject("subscriberCountText")));
448+
} catch (final NumberFormatException e) {
449+
throw new ParsingException("Could not get uploader subscriber count", e);
450+
}
452451
}
453452

454453
@Nonnull
@@ -680,9 +679,9 @@ public void onFetchPage(@Nonnull final Downloader downloader)
680679
final Localization localization = getExtractorLocalization();
681680
final ContentCountry contentCountry = getExtractorContentCountry();
682681
final byte[] body = JsonWriter.string(prepareDesktopJsonBuilder(
683-
localization, contentCountry)
684-
.value("videoId", videoId)
685-
.done())
682+
localization, contentCountry)
683+
.value("videoId", videoId)
684+
.done())
686685
.getBytes(UTF_8);
687686

688687
// Put the sts string if we already know it so we don't have to fetch again the player
@@ -731,8 +730,8 @@ public void onFetchPage(@Nonnull final Downloader downloader)
731730

732731
if (ageRestricted) {
733732
final byte[] ageRestrictedBody = JsonWriter.string(prepareDesktopEmbedVideoJsonBuilder(
734-
localization, contentCountry, videoId)
735-
.done())
733+
localization, contentCountry, videoId)
734+
.done())
736735
.getBytes(UTF_8);
737736
nextResponse = getJsonPostResponse("next", ageRestrictedBody, localization);
738737
} else {
@@ -814,7 +813,7 @@ private void fetchAndroidMobileJsonPlayer(final ContentCountry contentCountry,
814813
final String videoId)
815814
throws IOException, ExtractionException {
816815
final byte[] mobileBody = JsonWriter.string(prepareAndroidMobileJsonBuilder(
817-
localization, contentCountry)
816+
localization, contentCountry)
818817
.value("videoId", videoId)
819818
.done())
820819
.getBytes(UTF_8);
@@ -887,8 +886,8 @@ private void fetchAndroidEmbedJsonPlayer(final ContentCountry contentCountry,
887886
final String videoId)
888887
throws IOException, ExtractionException {
889888
final byte[] androidMobileEmbedBody = JsonWriter.string(
890-
prepareAndroidMobileEmbedVideoJsonBuilder(localization, contentCountry, videoId)
891-
.done())
889+
prepareAndroidMobileEmbedVideoJsonBuilder(localization, contentCountry, videoId)
890+
.done())
892891
.getBytes(UTF_8);
893892
final JsonObject androidMobileEmbedPlayerResponse = getJsonMobilePostResponse("player",
894893
androidMobileEmbedBody, contentCountry, localization);

0 commit comments

Comments
 (0)