Skip to content

Commit f179b3a

Browse files
committed
Avoid usingjson.json.getNumber and remove dislike extraction
* Dislikes are always 0
1 parent 886d1ff commit f179b3a

File tree

5 files changed

+16
-24
lines changed

5 files changed

+16
-24
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ public String getFeedUrl() {
112112

113113
@Override
114114
public long getSubscriberCount() {
115-
return json.getNumber("subCount").longValue();
115+
return json.getLong("subCount");
116116
}
117117

118118
@Override

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

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public InvidiousCommentsInfoItemExtractor(
2727

2828
@Override
2929
public int getLikeCount() {
30-
return json.getNumber("likeCount").intValue();
30+
return json.getInt("likeCount");
3131
}
3232

3333
@Override
@@ -43,8 +43,7 @@ public String getTextualUploadDate() {
4343
@Nullable
4444
@Override
4545
public DateWrapper getUploadDate() {
46-
return InvidiousParsingHelper.getUploadDateFromEpochTime(
47-
json.getNumber("published").longValue());
46+
return InvidiousParsingHelper.getUploadDateFromEpochTime(json.getLong("published"));
4847
}
4948

5049
@Override

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,7 @@ public String getUploaderAvatarUrl() {
5555

5656
@Override
5757
public long getStreamCount() {
58-
final Number number = json.getNumber("videoCount");
59-
return number == null ? -1 : number.longValue();
58+
return json.getLong("videoCount", -1);
6059
}
6160

6261
@Nonnull

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

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,15 +71,13 @@ public String getTextualUploadDate() {
7171
@Nullable
7272
@Override
7373
public DateWrapper getUploadDate() {
74-
return InvidiousParsingHelper.getUploadDateFromEpochTime(
75-
json.getNumber("published").longValue());
74+
return InvidiousParsingHelper.getUploadDateFromEpochTime(json.getLong("published"));
7675
}
7776

7877
@Nonnull
7978
@Override
8079
public String getThumbnailUrl() {
81-
final JsonArray thumbnail = json.getArray("authorThumbnails");
82-
return InvidiousParsingHelper.getThumbnailUrl(thumbnail);
80+
return InvidiousParsingHelper.getThumbnailUrl(json.getArray("videoThumbnails"));
8381
}
8482

8583
@Nonnull
@@ -100,7 +98,7 @@ public int getAgeLimit() {
10098

10199
@Override
102100
public long getLength() {
103-
return json.getNumber("lengthSeconds").longValue();
101+
return json.getLong("lengthSeconds");
104102
}
105103

106104
@Override
@@ -111,17 +109,12 @@ public long getTimeStamp() throws ParsingException {
111109

112110
@Override
113111
public long getViewCount() {
114-
return json.getNumber("viewCount").longValue();
112+
return json.getLong("viewCount");
115113
}
116114

117115
@Override
118116
public long getLikeCount() {
119-
return json.getNumber("likeCount").longValue();
120-
}
121-
122-
@Override
123-
public long getDislikeCount() {
124-
return json.getNumber("dislikeCount").longValue();
117+
return json.getLong("likeCount");
125118
}
126119

127120
@Nonnull

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

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ public boolean isAd() throws ParsingException {
4242

4343
@Override
4444
public long getDuration() {
45-
final Number number = json.getNumber("lengthSeconds");
46-
return number == null ? -1 : number.longValue();
45+
return json.getLong("lengthSeconds", -1);
4746
}
4847

4948
@Override
@@ -74,12 +73,14 @@ public String getTextualUploadDate() {
7473
@Nullable
7574
@Override
7675
public DateWrapper getUploadDate() {
77-
final Number epochTime = json.getNumber("published");
78-
if (epochTime != null) {
79-
return getUploadDateFromEpochTime(epochTime.longValue());
76+
final long epochTime = json.getLong("published", -1);
77+
78+
// Time is not always provided e.g. on related videos of a video it's missing
79+
if (epochTime == -1) {
80+
return null;
8081
}
8182

82-
return null;
83+
return getUploadDateFromEpochTime(epochTime);
8384
}
8485

8586
@Override

0 commit comments

Comments
 (0)