Skip to content

Commit

Permalink
Merge pull request #701 from Stypox/v0.21.8
Browse files Browse the repository at this point in the history
V0.21.8
  • Loading branch information
Stypox authored Aug 3, 2021
2 parents b62fe71 + 5b38b3a commit bb3815d
Show file tree
Hide file tree
Showing 264 changed files with 48,771 additions and 15,852 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ NewPipe Extractor is available at JitPack's Maven repo.
If you're using Gradle, you could add NewPipe Extractor as a dependency with the following steps:

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

**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.

Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ allprojects {
sourceCompatibility = 1.8
targetCompatibility = 1.8

version 'v0.21.7'
version 'v0.21.8'
group 'com.github.TeamNewPipe'

repositories {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,24 @@

import org.schabi.newpipe.extractor.ListExtractor;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;

import javax.annotation.Nonnull;

public abstract class CommentsExtractor extends ListExtractor<CommentsInfoItem> {

public CommentsExtractor(StreamingService service, ListLinkHandler uiHandler) {
public CommentsExtractor(final StreamingService service, final ListLinkHandler uiHandler) {
super(service, uiHandler);
// TODO Auto-generated constructor stub
}

/**
* @apiNote Warning: This method is experimental and may get removed in a future release.
* @return <code>true</code> if the comments are disabled otherwise <code>false</code> (default)
*/
public boolean isCommentsDisabled() throws ExtractionException {
return false;
}

@Nonnull
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,45 +13,56 @@

public class CommentsInfo extends ListInfo<CommentsInfoItem> {

private CommentsInfo(int serviceId, ListLinkHandler listUrlIdHandler, String name) {
private CommentsInfo(
final int serviceId,
final ListLinkHandler listUrlIdHandler,
final String name) {
super(serviceId, listUrlIdHandler, name);
}

public static CommentsInfo getInfo(String url) throws IOException, ExtractionException {
public static CommentsInfo getInfo(final String url) throws IOException, ExtractionException {
return getInfo(NewPipe.getServiceByUrl(url), url);
}

public static CommentsInfo getInfo(StreamingService serviceByUrl, String url) throws ExtractionException, IOException {
public static CommentsInfo getInfo(final StreamingService serviceByUrl, final String url)
throws ExtractionException, IOException {
return getInfo(serviceByUrl.getCommentsExtractor(url));
}

public static CommentsInfo getInfo(CommentsExtractor commentsExtractor) throws IOException, ExtractionException {
public static CommentsInfo getInfo(final CommentsExtractor commentsExtractor)
throws IOException, ExtractionException {
// for services which do not have a comments extractor
if (null == commentsExtractor) {
if (commentsExtractor == null) {
return null;
}

commentsExtractor.fetchPage();
String name = commentsExtractor.getName();
int serviceId = commentsExtractor.getServiceId();
ListLinkHandler listUrlIdHandler = commentsExtractor.getLinkHandler();
CommentsInfo commentsInfo = new CommentsInfo(serviceId, listUrlIdHandler, name);

final String name = commentsExtractor.getName();
final int serviceId = commentsExtractor.getServiceId();
final ListLinkHandler listUrlIdHandler = commentsExtractor.getLinkHandler();

final CommentsInfo commentsInfo = new CommentsInfo(serviceId, listUrlIdHandler, name);
commentsInfo.setCommentsExtractor(commentsExtractor);
InfoItemsPage<CommentsInfoItem> initialCommentsPage = ExtractorHelper.getItemsPageOrLogError(commentsInfo,
commentsExtractor);
final InfoItemsPage<CommentsInfoItem> initialCommentsPage =
ExtractorHelper.getItemsPageOrLogError(commentsInfo, commentsExtractor);
commentsInfo.setCommentsDisabled(commentsExtractor.isCommentsDisabled());
commentsInfo.setRelatedItems(initialCommentsPage.getItems());
commentsInfo.setNextPage(initialCommentsPage.getNextPage());

return commentsInfo;
}

public static InfoItemsPage<CommentsInfoItem> getMoreItems(CommentsInfo commentsInfo, Page page)
throws ExtractionException, IOException {
public static InfoItemsPage<CommentsInfoItem> getMoreItems(
final CommentsInfo commentsInfo,
final Page page) throws ExtractionException, IOException {
return getMoreItems(NewPipe.getService(commentsInfo.getServiceId()), commentsInfo, page);
}

public static InfoItemsPage<CommentsInfoItem> getMoreItems(StreamingService service, CommentsInfo commentsInfo,
Page page) throws IOException, ExtractionException {
public static InfoItemsPage<CommentsInfoItem> getMoreItems(
final StreamingService service,
final CommentsInfo commentsInfo,
final Page page) throws IOException, ExtractionException {
if (null == commentsInfo.getCommentsExtractor()) {
commentsInfo.setCommentsExtractor(service.getCommentsExtractor(commentsInfo.getUrl()));
commentsInfo.getCommentsExtractor().fetchPage();
Expand All @@ -60,13 +71,30 @@ public static InfoItemsPage<CommentsInfoItem> getMoreItems(StreamingService serv
}

private transient CommentsExtractor commentsExtractor;
private boolean commentsDisabled = false;

public CommentsExtractor getCommentsExtractor() {
return commentsExtractor;
}

public void setCommentsExtractor(CommentsExtractor commentsExtractor) {
public void setCommentsExtractor(final CommentsExtractor commentsExtractor) {
this.commentsExtractor = commentsExtractor;
}

/**
* @apiNote Warning: This method is experimental and may get removed in a future release.
* @return <code>true</code> if the comments are disabled otherwise <code>false</code> (default)
* @see CommentsExtractor#isCommentsDisabled()
*/
public boolean isCommentsDisabled() {
return commentsDisabled;
}

/**
* @apiNote Warning: This method is experimental and may get removed in a future release.
* @param commentsDisabled <code>true</code> if the comments are disabled otherwise <code>false</code>
*/
public void setCommentsDisabled(final boolean commentsDisabled) {
this.commentsDisabled = commentsDisabled;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ public String getDashMpdUrl() {
@Nonnull
@Override
public String getHlsUrl() {
return "";
return json.getArray("streamingPlaylists").getObject(0).getString("playlistUrl");
}

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

if (getStreamType() == StreamType.LIVE_STREAM) {
final String url = getHlsUrl();
videoStreams.add(new VideoStream(url, MediaFormat.MPEG_4, "720p"));
}

return videoStreams;
}

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

@Override
public StreamType getStreamType() {
return StreamType.VIDEO_STREAM;
return json.getBoolean("isLive") ? StreamType.LIVE_STREAM : StreamType.VIDEO_STREAM;
}

@Nullable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public DateWrapper getUploadDate() throws ParsingException {

@Override
public StreamType getStreamType() {
return StreamType.VIDEO_STREAM;
return item.getBoolean("isLive") ? StreamType.LIVE_STREAM : StreamType.VIDEO_STREAM;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,12 @@ public class ItagItem {
/// VIDEO ONLY ////////////////////////////////////////////
// ID Type Format Resolution FPS ///
/////////////////////////////////////////////////////////
// Don't add VideoOnly streams that have normal variants
new ItagItem(160, VIDEO_ONLY, MPEG_4, "144p"),
new ItagItem(133, VIDEO_ONLY, MPEG_4, "240p"),
// new ItagItem(134, VIDEO_ONLY, MPEG_4, "360p"),
new ItagItem(134, VIDEO_ONLY, MPEG_4, "360p"),
new ItagItem(135, VIDEO_ONLY, MPEG_4, "480p"),
new ItagItem(212, VIDEO_ONLY, MPEG_4, "480p"),
// new ItagItem(136, VIDEO_ONLY, MPEG_4, "720p"),
new ItagItem(136, VIDEO_ONLY, MPEG_4, "720p"),
new ItagItem(298, VIDEO_ONLY, MPEG_4, "720p60", 60),
new ItagItem(137, VIDEO_ONLY, MPEG_4, "1080p"),
new ItagItem(299, VIDEO_ONLY, MPEG_4, "1080p60", 60),
Expand All @@ -75,6 +74,7 @@ public class ItagItem {
new ItagItem(313, VIDEO_ONLY, WEBM, "2160p"),
new ItagItem(315, VIDEO_ONLY, WEBM, "2160p60", 60)
};

/*//////////////////////////////////////////////////////////////////////////
// Utils
//////////////////////////////////////////////////////////////////////////*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ public static String extractJavaScriptCode() throws ParsingException {
return extractJavaScriptCode("d4IGg5dqeO8");
}

/**
* Reset the JavaScript code. It will be fetched again the next time
* {@link #extractJavaScriptCode()} or {@link #extractJavaScriptCode(String)} is called.
*/
public static void resetJavaScriptCode() {
cachedJavaScriptCode = null;
}

private static String extractJavaScriptUrl(final String videoId) throws ParsingException {
try {
final String embedUrl = "https://www.youtube.com/embed/" + videoId;
Expand Down
Loading

0 comments on commit bb3815d

Please sign in to comment.