Skip to content

Commit bb3815d

Browse files
authored
Merge pull request #701 from Stypox/v0.21.8
V0.21.8
2 parents b62fe71 + 5b38b3a commit bb3815d

264 files changed

Lines changed: 48771 additions & 15852 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ NewPipe Extractor is available at JitPack's Maven repo.
1111
If you're using Gradle, you could add NewPipe Extractor as a dependency with the following steps:
1212

1313
1. Add `maven { url 'https://jitpack.io' }` to the `repositories` in your `build.gradle`.
14-
2. Add `implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.21.7'`the `dependencies` in your `build.gradle`. Replace `v0.21.7` with the latest release.
14+
2. Add `implementation 'com.github.TeamNewPipe:NewPipeExtractor:v0.21.8'`the `dependencies` in your `build.gradle`. Replace `v0.21.8` with the latest release.
1515

1616
**Note:** To use NewPipe Extractor in projects with a `minSdkVersion` below 26, [API desugaring](https://developer.android.com/studio/write/java8-support#library-desugaring) is required.
1717

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ allprojects {
88
sourceCompatibility = 1.8
99
targetCompatibility = 1.8
1010

11-
version 'v0.21.7'
11+
version 'v0.21.8'
1212
group 'com.github.TeamNewPipe'
1313

1414
repositories {

extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsExtractor.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,24 @@
22

33
import org.schabi.newpipe.extractor.ListExtractor;
44
import org.schabi.newpipe.extractor.StreamingService;
5+
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
56
import org.schabi.newpipe.extractor.exceptions.ParsingException;
67
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
78

89
import javax.annotation.Nonnull;
910

1011
public abstract class CommentsExtractor extends ListExtractor<CommentsInfoItem> {
1112

12-
public CommentsExtractor(StreamingService service, ListLinkHandler uiHandler) {
13+
public CommentsExtractor(final StreamingService service, final ListLinkHandler uiHandler) {
1314
super(service, uiHandler);
14-
// TODO Auto-generated constructor stub
15+
}
16+
17+
/**
18+
* @apiNote Warning: This method is experimental and may get removed in a future release.
19+
* @return <code>true</code> if the comments are disabled otherwise <code>false</code> (default)
20+
*/
21+
public boolean isCommentsDisabled() throws ExtractionException {
22+
return false;
1523
}
1624

1725
@Nonnull

extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfo.java

Lines changed: 44 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -13,45 +13,56 @@
1313

1414
public class CommentsInfo extends ListInfo<CommentsInfoItem> {
1515

16-
private CommentsInfo(int serviceId, ListLinkHandler listUrlIdHandler, String name) {
16+
private CommentsInfo(
17+
final int serviceId,
18+
final ListLinkHandler listUrlIdHandler,
19+
final String name) {
1720
super(serviceId, listUrlIdHandler, name);
1821
}
1922

20-
public static CommentsInfo getInfo(String url) throws IOException, ExtractionException {
23+
public static CommentsInfo getInfo(final String url) throws IOException, ExtractionException {
2124
return getInfo(NewPipe.getServiceByUrl(url), url);
2225
}
2326

24-
public static CommentsInfo getInfo(StreamingService serviceByUrl, String url) throws ExtractionException, IOException {
27+
public static CommentsInfo getInfo(final StreamingService serviceByUrl, final String url)
28+
throws ExtractionException, IOException {
2529
return getInfo(serviceByUrl.getCommentsExtractor(url));
2630
}
2731

28-
public static CommentsInfo getInfo(CommentsExtractor commentsExtractor) throws IOException, ExtractionException {
32+
public static CommentsInfo getInfo(final CommentsExtractor commentsExtractor)
33+
throws IOException, ExtractionException {
2934
// for services which do not have a comments extractor
30-
if (null == commentsExtractor) {
35+
if (commentsExtractor == null) {
3136
return null;
3237
}
3338

3439
commentsExtractor.fetchPage();
35-
String name = commentsExtractor.getName();
36-
int serviceId = commentsExtractor.getServiceId();
37-
ListLinkHandler listUrlIdHandler = commentsExtractor.getLinkHandler();
38-
CommentsInfo commentsInfo = new CommentsInfo(serviceId, listUrlIdHandler, name);
40+
41+
final String name = commentsExtractor.getName();
42+
final int serviceId = commentsExtractor.getServiceId();
43+
final ListLinkHandler listUrlIdHandler = commentsExtractor.getLinkHandler();
44+
45+
final CommentsInfo commentsInfo = new CommentsInfo(serviceId, listUrlIdHandler, name);
3946
commentsInfo.setCommentsExtractor(commentsExtractor);
40-
InfoItemsPage<CommentsInfoItem> initialCommentsPage = ExtractorHelper.getItemsPageOrLogError(commentsInfo,
41-
commentsExtractor);
47+
final InfoItemsPage<CommentsInfoItem> initialCommentsPage =
48+
ExtractorHelper.getItemsPageOrLogError(commentsInfo, commentsExtractor);
49+
commentsInfo.setCommentsDisabled(commentsExtractor.isCommentsDisabled());
4250
commentsInfo.setRelatedItems(initialCommentsPage.getItems());
4351
commentsInfo.setNextPage(initialCommentsPage.getNextPage());
4452

4553
return commentsInfo;
4654
}
4755

48-
public static InfoItemsPage<CommentsInfoItem> getMoreItems(CommentsInfo commentsInfo, Page page)
49-
throws ExtractionException, IOException {
56+
public static InfoItemsPage<CommentsInfoItem> getMoreItems(
57+
final CommentsInfo commentsInfo,
58+
final Page page) throws ExtractionException, IOException {
5059
return getMoreItems(NewPipe.getService(commentsInfo.getServiceId()), commentsInfo, page);
5160
}
5261

53-
public static InfoItemsPage<CommentsInfoItem> getMoreItems(StreamingService service, CommentsInfo commentsInfo,
54-
Page page) throws IOException, ExtractionException {
62+
public static InfoItemsPage<CommentsInfoItem> getMoreItems(
63+
final StreamingService service,
64+
final CommentsInfo commentsInfo,
65+
final Page page) throws IOException, ExtractionException {
5566
if (null == commentsInfo.getCommentsExtractor()) {
5667
commentsInfo.setCommentsExtractor(service.getCommentsExtractor(commentsInfo.getUrl()));
5768
commentsInfo.getCommentsExtractor().fetchPage();
@@ -60,13 +71,30 @@ public static InfoItemsPage<CommentsInfoItem> getMoreItems(StreamingService serv
6071
}
6172

6273
private transient CommentsExtractor commentsExtractor;
74+
private boolean commentsDisabled = false;
6375

6476
public CommentsExtractor getCommentsExtractor() {
6577
return commentsExtractor;
6678
}
6779

68-
public void setCommentsExtractor(CommentsExtractor commentsExtractor) {
80+
public void setCommentsExtractor(final CommentsExtractor commentsExtractor) {
6981
this.commentsExtractor = commentsExtractor;
7082
}
7183

84+
/**
85+
* @apiNote Warning: This method is experimental and may get removed in a future release.
86+
* @return <code>true</code> if the comments are disabled otherwise <code>false</code> (default)
87+
* @see CommentsExtractor#isCommentsDisabled()
88+
*/
89+
public boolean isCommentsDisabled() {
90+
return commentsDisabled;
91+
}
92+
93+
/**
94+
* @apiNote Warning: This method is experimental and may get removed in a future release.
95+
* @param commentsDisabled <code>true</code> if the comments are disabled otherwise <code>false</code>
96+
*/
97+
public void setCommentsDisabled(final boolean commentsDisabled) {
98+
this.commentsDisabled = commentsDisabled;
99+
}
72100
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ public String getDashMpdUrl() {
199199
@Nonnull
200200
@Override
201201
public String getHlsUrl() {
202-
return "";
202+
return json.getArray("streamingPlaylists").getObject(0).getString("playlistUrl");
203203
}
204204

205205
@Override
@@ -227,6 +227,11 @@ public List<VideoStream> getVideoStreams() throws ExtractionException {
227227
throw new ParsingException("Could not get video streams", e);
228228
}
229229

230+
if (getStreamType() == StreamType.LIVE_STREAM) {
231+
final String url = getHlsUrl();
232+
videoStreams.add(new VideoStream(url, MediaFormat.MPEG_4, "720p"));
233+
}
234+
230235
return videoStreams;
231236
}
232237

@@ -283,7 +288,7 @@ public List<SubtitlesStream> getSubtitles(final MediaFormat format) {
283288

284289
@Override
285290
public StreamType getStreamType() {
286-
return StreamType.VIDEO_STREAM;
291+
return json.getBoolean("isLive") ? StreamType.LIVE_STREAM : StreamType.VIDEO_STREAM;
287292
}
288293

289294
@Nullable

extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamInfoItemExtractor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ public DateWrapper getUploadDate() throws ParsingException {
8282

8383
@Override
8484
public StreamType getStreamType() {
85-
return StreamType.VIDEO_STREAM;
85+
return item.getBoolean("isLive") ? StreamType.LIVE_STREAM : StreamType.VIDEO_STREAM;
8686
}
8787

8888
@Override

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,12 @@ public class ItagItem {
4646
/// VIDEO ONLY ////////////////////////////////////////////
4747
// ID Type Format Resolution FPS ///
4848
/////////////////////////////////////////////////////////
49-
// Don't add VideoOnly streams that have normal variants
5049
new ItagItem(160, VIDEO_ONLY, MPEG_4, "144p"),
5150
new ItagItem(133, VIDEO_ONLY, MPEG_4, "240p"),
52-
// new ItagItem(134, VIDEO_ONLY, MPEG_4, "360p"),
51+
new ItagItem(134, VIDEO_ONLY, MPEG_4, "360p"),
5352
new ItagItem(135, VIDEO_ONLY, MPEG_4, "480p"),
5453
new ItagItem(212, VIDEO_ONLY, MPEG_4, "480p"),
55-
// new ItagItem(136, VIDEO_ONLY, MPEG_4, "720p"),
54+
new ItagItem(136, VIDEO_ONLY, MPEG_4, "720p"),
5655
new ItagItem(298, VIDEO_ONLY, MPEG_4, "720p60", 60),
5756
new ItagItem(137, VIDEO_ONLY, MPEG_4, "1080p"),
5857
new ItagItem(299, VIDEO_ONLY, MPEG_4, "1080p60", 60),
@@ -75,6 +74,7 @@ public class ItagItem {
7574
new ItagItem(313, VIDEO_ONLY, WEBM, "2160p"),
7675
new ItagItem(315, VIDEO_ONLY, WEBM, "2160p60", 60)
7776
};
77+
7878
/*//////////////////////////////////////////////////////////////////////////
7979
// Utils
8080
//////////////////////////////////////////////////////////////////////////*/

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,14 @@ public static String extractJavaScriptCode() throws ParsingException {
6060
return extractJavaScriptCode("d4IGg5dqeO8");
6161
}
6262

63+
/**
64+
* Reset the JavaScript code. It will be fetched again the next time
65+
* {@link #extractJavaScriptCode()} or {@link #extractJavaScriptCode(String)} is called.
66+
*/
67+
public static void resetJavaScriptCode() {
68+
cachedJavaScriptCode = null;
69+
}
70+
6371
private static String extractJavaScriptUrl(final String videoId) throws ParsingException {
6472
try {
6573
final String embedUrl = "https://www.youtube.com/embed/" + videoId;

0 commit comments

Comments
 (0)