Fix checkstyle issues in subpackages with abstract classes
This commit is contained in:
parent
e4951a0623
commit
8aba2b47b0
|
@ -50,7 +50,7 @@ public class MultiInfoItemsCollector extends InfoItemsCollector<InfoItem, InfoIt
|
||||||
private final ChannelInfoItemsCollector userCollector;
|
private final ChannelInfoItemsCollector userCollector;
|
||||||
private final PlaylistInfoItemsCollector playlistCollector;
|
private final PlaylistInfoItemsCollector playlistCollector;
|
||||||
|
|
||||||
public MultiInfoItemsCollector(int serviceId) {
|
public MultiInfoItemsCollector(final int serviceId) {
|
||||||
super(serviceId);
|
super(serviceId);
|
||||||
streamCollector = new StreamInfoItemsCollector(serviceId);
|
streamCollector = new StreamInfoItemsCollector(serviceId);
|
||||||
userCollector = new ChannelInfoItemsCollector(serviceId);
|
userCollector = new ChannelInfoItemsCollector(serviceId);
|
||||||
|
@ -76,7 +76,7 @@ public class MultiInfoItemsCollector extends InfoItemsCollector<InfoItem, InfoIt
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public InfoItem extract(InfoItemExtractor extractor) throws ParsingException {
|
public InfoItem extract(final InfoItemExtractor extractor) throws ParsingException {
|
||||||
// Use the corresponding collector for each item extractor type
|
// Use the corresponding collector for each item extractor type
|
||||||
if (extractor instanceof StreamInfoItemExtractor) {
|
if (extractor instanceof StreamInfoItemExtractor) {
|
||||||
return streamCollector.extract((StreamInfoItemExtractor) extractor);
|
return streamCollector.extract((StreamInfoItemExtractor) extractor);
|
||||||
|
|
|
@ -30,7 +30,7 @@ public abstract class ChannelExtractor extends ListExtractor<StreamInfoItem> {
|
||||||
|
|
||||||
public static final long UNKNOWN_SUBSCRIBER_COUNT = -1;
|
public static final long UNKNOWN_SUBSCRIBER_COUNT = -1;
|
||||||
|
|
||||||
public ChannelExtractor(StreamingService service, ListLinkHandler linkHandler) {
|
public ChannelExtractor(final StreamingService service, final ListLinkHandler linkHandler) {
|
||||||
super(service, linkHandler);
|
super(service, linkHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -34,27 +34,36 @@ import java.io.IOException;
|
||||||
|
|
||||||
public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
||||||
|
|
||||||
public ChannelInfo(int serviceId, String id, String url, String originalUrl, String name, ListLinkHandler listLinkHandler) {
|
public ChannelInfo(final int serviceId,
|
||||||
super(serviceId, id, url, originalUrl, name, listLinkHandler.getContentFilters(), listLinkHandler.getSortFilter());
|
final String id,
|
||||||
|
final String url,
|
||||||
|
final String originalUrl,
|
||||||
|
final String name,
|
||||||
|
final ListLinkHandler listLinkHandler) {
|
||||||
|
super(serviceId, id, url, originalUrl, name, listLinkHandler.getContentFilters(),
|
||||||
|
listLinkHandler.getSortFilter());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ChannelInfo getInfo(String url) throws IOException, ExtractionException {
|
public static ChannelInfo getInfo(final String url) throws IOException, ExtractionException {
|
||||||
return getInfo(NewPipe.getServiceByUrl(url), url);
|
return getInfo(NewPipe.getServiceByUrl(url), url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ChannelInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
|
public static ChannelInfo getInfo(final StreamingService service, final String url)
|
||||||
ChannelExtractor extractor = service.getChannelExtractor(url);
|
throws IOException, ExtractionException {
|
||||||
|
final ChannelExtractor extractor = service.getChannelExtractor(url);
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
return getInfo(extractor);
|
return getInfo(extractor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static InfoItemsPage<StreamInfoItem> getMoreItems(StreamingService service,
|
public static InfoItemsPage<StreamInfoItem> getMoreItems(final StreamingService service,
|
||||||
String url,
|
final String url,
|
||||||
Page page) throws IOException, ExtractionException {
|
final Page page)
|
||||||
|
throws IOException, ExtractionException {
|
||||||
return service.getChannelExtractor(url).getPage(page);
|
return service.getChannelExtractor(url).getPage(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ChannelInfo getInfo(ChannelExtractor extractor) throws IOException, ExtractionException {
|
public static ChannelInfo getInfo(final ChannelExtractor extractor)
|
||||||
|
throws IOException, ExtractionException {
|
||||||
|
|
||||||
final int serviceId = extractor.getServiceId();
|
final int serviceId = extractor.getServiceId();
|
||||||
final String id = extractor.getId();
|
final String id = extractor.getId();
|
||||||
|
@ -62,60 +71,62 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
||||||
final String originalUrl = extractor.getOriginalUrl();
|
final String originalUrl = extractor.getOriginalUrl();
|
||||||
final String name = extractor.getName();
|
final String name = extractor.getName();
|
||||||
|
|
||||||
final ChannelInfo info = new ChannelInfo(serviceId, id, url, originalUrl, name, extractor.getLinkHandler());
|
final ChannelInfo info =
|
||||||
|
new ChannelInfo(serviceId, id, url, originalUrl, name, extractor.getLinkHandler());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
info.setAvatarUrl(extractor.getAvatarUrl());
|
info.setAvatarUrl(extractor.getAvatarUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.setBannerUrl(extractor.getBannerUrl());
|
info.setBannerUrl(extractor.getBannerUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.setFeedUrl(extractor.getFeedUrl());
|
info.setFeedUrl(extractor.getFeedUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
final InfoItemsPage<StreamInfoItem> itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor);
|
final InfoItemsPage<StreamInfoItem> itemsPage =
|
||||||
|
ExtractorHelper.getItemsPageOrLogError(info, extractor);
|
||||||
info.setRelatedItems(itemsPage.getItems());
|
info.setRelatedItems(itemsPage.getItems());
|
||||||
info.setNextPage(itemsPage.getNextPage());
|
info.setNextPage(itemsPage.getNextPage());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
info.setSubscriberCount(extractor.getSubscriberCount());
|
info.setSubscriberCount(extractor.getSubscriberCount());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.setDescription(extractor.getDescription());
|
info.setDescription(extractor.getDescription());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
info.setParentChannelName(extractor.getParentChannelName());
|
info.setParentChannelName(extractor.getParentChannelName());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
info.setParentChannelUrl(extractor.getParentChannelUrl());
|
info.setParentChannelUrl(extractor.getParentChannelUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
info.setParentChannelAvatarUrl(extractor.getParentChannelAvatarUrl());
|
info.setParentChannelAvatarUrl(extractor.getParentChannelAvatarUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
info.setVerified(extractor.isVerified());
|
info.setVerified(extractor.isVerified());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -137,7 +148,7 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
||||||
return parentChannelName;
|
return parentChannelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParentChannelName(String parentChannelName) {
|
public void setParentChannelName(final String parentChannelName) {
|
||||||
this.parentChannelName = parentChannelName;
|
this.parentChannelName = parentChannelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -145,7 +156,7 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
||||||
return parentChannelUrl;
|
return parentChannelUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParentChannelUrl(String parentChannelUrl) {
|
public void setParentChannelUrl(final String parentChannelUrl) {
|
||||||
this.parentChannelUrl = parentChannelUrl;
|
this.parentChannelUrl = parentChannelUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -153,7 +164,7 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
||||||
return parentChannelAvatarUrl;
|
return parentChannelAvatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParentChannelAvatarUrl(String parentChannelAvatarUrl) {
|
public void setParentChannelAvatarUrl(final String parentChannelAvatarUrl) {
|
||||||
this.parentChannelAvatarUrl = parentChannelAvatarUrl;
|
this.parentChannelAvatarUrl = parentChannelAvatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +172,7 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
||||||
return avatarUrl;
|
return avatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAvatarUrl(String avatarUrl) {
|
public void setAvatarUrl(final String avatarUrl) {
|
||||||
this.avatarUrl = avatarUrl;
|
this.avatarUrl = avatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -169,7 +180,7 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
||||||
return bannerUrl;
|
return bannerUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBannerUrl(String bannerUrl) {
|
public void setBannerUrl(final String bannerUrl) {
|
||||||
this.bannerUrl = bannerUrl;
|
this.bannerUrl = bannerUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,7 +188,7 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
||||||
return feedUrl;
|
return feedUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFeedUrl(String feedUrl) {
|
public void setFeedUrl(final String feedUrl) {
|
||||||
this.feedUrl = feedUrl;
|
this.feedUrl = feedUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,7 +196,7 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
||||||
return subscriberCount;
|
return subscriberCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubscriberCount(long subscriberCount) {
|
public void setSubscriberCount(final long subscriberCount) {
|
||||||
this.subscriberCount = subscriberCount;
|
this.subscriberCount = subscriberCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,7 +204,7 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description) {
|
public void setDescription(final String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -201,7 +212,7 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
||||||
return donationLinks;
|
return donationLinks;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDonationLinks(String[] donationLinks) {
|
public void setDonationLinks(final String[] donationLinks) {
|
||||||
this.donationLinks = donationLinks;
|
this.donationLinks = donationLinks;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,7 +220,7 @@ public class ChannelInfo extends ListInfo<StreamInfoItem> {
|
||||||
return verified;
|
return verified;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVerified(boolean verified) {
|
public void setVerified(final boolean verified) {
|
||||||
this.verified = verified;
|
this.verified = verified;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ public class ChannelInfoItem extends InfoItem {
|
||||||
private long streamCount = -1;
|
private long streamCount = -1;
|
||||||
private boolean verified = false;
|
private boolean verified = false;
|
||||||
|
|
||||||
public ChannelInfoItem(int serviceId, String url, String name) {
|
public ChannelInfoItem(final int serviceId, final String url, final String name) {
|
||||||
super(InfoType.CHANNEL, serviceId, url, name);
|
super(InfoType.CHANNEL, serviceId, url, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -37,7 +37,7 @@ public class ChannelInfoItem extends InfoItem {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(String description) {
|
public void setDescription(final String description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -45,23 +45,23 @@ public class ChannelInfoItem extends InfoItem {
|
||||||
return subscriberCount;
|
return subscriberCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubscriberCount(long subscriber_count) {
|
public void setSubscriberCount(final long subscriberCount) {
|
||||||
this.subscriberCount = subscriber_count;
|
this.subscriberCount = subscriberCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getStreamCount() {
|
public long getStreamCount() {
|
||||||
return streamCount;
|
return streamCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStreamCount(long stream_count) {
|
public void setStreamCount(final long streamCount) {
|
||||||
this.streamCount = stream_count;
|
this.streamCount = streamCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVerified() {
|
public boolean isVerified() {
|
||||||
return verified;
|
return verified;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVerified(boolean verified) {
|
public void setVerified(final boolean verified) {
|
||||||
this.verified = verified;
|
this.verified = verified;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,45 +23,42 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ChannelInfoItemsCollector extends InfoItemsCollector<ChannelInfoItem, ChannelInfoItemExtractor> {
|
public final class ChannelInfoItemsCollector
|
||||||
public ChannelInfoItemsCollector(int serviceId) {
|
extends InfoItemsCollector<ChannelInfoItem, ChannelInfoItemExtractor> {
|
||||||
|
public ChannelInfoItemsCollector(final int serviceId) {
|
||||||
super(serviceId);
|
super(serviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ChannelInfoItem extract(ChannelInfoItemExtractor extractor) throws ParsingException {
|
public ChannelInfoItem extract(final ChannelInfoItemExtractor extractor)
|
||||||
// important information
|
throws ParsingException {
|
||||||
int serviceId = getServiceId();
|
final ChannelInfoItem resultItem = new ChannelInfoItem(
|
||||||
String name = extractor.getName();
|
getServiceId(), extractor.getUrl(), extractor.getName());
|
||||||
String url = extractor.getUrl();
|
|
||||||
|
|
||||||
ChannelInfoItem resultItem = new ChannelInfoItem(serviceId, url, name);
|
|
||||||
|
|
||||||
|
|
||||||
// optional information
|
// optional information
|
||||||
try {
|
try {
|
||||||
resultItem.setSubscriberCount(extractor.getSubscriberCount());
|
resultItem.setSubscriberCount(extractor.getSubscriberCount());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setStreamCount(extractor.getStreamCount());
|
resultItem.setStreamCount(extractor.getStreamCount());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
|
resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setDescription(extractor.getDescription());
|
resultItem.setDescription(extractor.getDescription());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setVerified(extractor.isVerified());
|
resultItem.setVerified(extractor.isVerified());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class CommentsInfo extends ListInfo<CommentsInfoItem> {
|
public final class CommentsInfo extends ListInfo<CommentsInfoItem> {
|
||||||
|
|
||||||
private CommentsInfo(
|
private CommentsInfo(
|
||||||
final int serviceId,
|
final int serviceId,
|
||||||
|
@ -56,7 +56,8 @@ public class CommentsInfo extends ListInfo<CommentsInfoItem> {
|
||||||
public static InfoItemsPage<CommentsInfoItem> getMoreItems(
|
public static InfoItemsPage<CommentsInfoItem> getMoreItems(
|
||||||
final CommentsInfo commentsInfo,
|
final CommentsInfo commentsInfo,
|
||||||
final Page page) throws ExtractionException, IOException {
|
final Page page) throws ExtractionException, IOException {
|
||||||
return getMoreItems(NewPipe.getService(commentsInfo.getServiceId()), commentsInfo.getUrl(), page);
|
return getMoreItems(NewPipe.getService(commentsInfo.getServiceId()), commentsInfo.getUrl(),
|
||||||
|
page);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static InfoItemsPage<CommentsInfoItem> getMoreItems(
|
public static InfoItemsPage<CommentsInfoItem> getMoreItems(
|
||||||
|
@ -86,7 +87,7 @@ public class CommentsInfo extends ListInfo<CommentsInfoItem> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @apiNote Warning: This method is experimental and may get removed in a future release.
|
* @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)
|
* @return {@code true} if the comments are disabled otherwise {@code false} (default)
|
||||||
* @see CommentsExtractor#isCommentsDisabled()
|
* @see CommentsExtractor#isCommentsDisabled()
|
||||||
*/
|
*/
|
||||||
public boolean isCommentsDisabled() {
|
public boolean isCommentsDisabled() {
|
||||||
|
@ -95,7 +96,7 @@ public class CommentsInfo extends ListInfo<CommentsInfoItem> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @apiNote Warning: This method is experimental and may get removed in a future release.
|
* @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>
|
* @param commentsDisabled {@code true} if the comments are disabled otherwise {@code false}
|
||||||
*/
|
*/
|
||||||
public void setCommentsDisabled(final boolean commentsDisabled) {
|
public void setCommentsDisabled(final boolean commentsDisabled) {
|
||||||
this.commentsDisabled = commentsDisabled;
|
this.commentsDisabled = commentsDisabled;
|
||||||
|
|
|
@ -28,7 +28,7 @@ public class CommentsInfoItem extends InfoItem {
|
||||||
public static final int NO_LIKE_COUNT = -1;
|
public static final int NO_LIKE_COUNT = -1;
|
||||||
public static final int NO_STREAM_POSITION = -1;
|
public static final int NO_STREAM_POSITION = -1;
|
||||||
|
|
||||||
public CommentsInfoItem(int serviceId, String url, String name) {
|
public CommentsInfoItem(final int serviceId, final String url, final String name) {
|
||||||
super(InfoType.COMMENT, serviceId, url, name);
|
super(InfoType.COMMENT, serviceId, url, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class CommentsInfoItem extends InfoItem {
|
||||||
return commentId;
|
return commentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCommentId(String commentId) {
|
public void setCommentId(final String commentId) {
|
||||||
this.commentId = commentId;
|
this.commentId = commentId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -44,7 +44,7 @@ public class CommentsInfoItem extends InfoItem {
|
||||||
return commentText;
|
return commentText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCommentText(String commentText) {
|
public void setCommentText(final String commentText) {
|
||||||
this.commentText = commentText;
|
this.commentText = commentText;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ public class CommentsInfoItem extends InfoItem {
|
||||||
return uploaderName;
|
return uploaderName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploaderName(String uploaderName) {
|
public void setUploaderName(final String uploaderName) {
|
||||||
this.uploaderName = uploaderName;
|
this.uploaderName = uploaderName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ public class CommentsInfoItem extends InfoItem {
|
||||||
return uploaderAvatarUrl;
|
return uploaderAvatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploaderAvatarUrl(String uploaderAvatarUrl) {
|
public void setUploaderAvatarUrl(final String uploaderAvatarUrl) {
|
||||||
this.uploaderAvatarUrl = uploaderAvatarUrl;
|
this.uploaderAvatarUrl = uploaderAvatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ public class CommentsInfoItem extends InfoItem {
|
||||||
return uploaderUrl;
|
return uploaderUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploaderUrl(String uploaderUrl) {
|
public void setUploaderUrl(final String uploaderUrl) {
|
||||||
this.uploaderUrl = uploaderUrl;
|
this.uploaderUrl = uploaderUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +76,7 @@ public class CommentsInfoItem extends InfoItem {
|
||||||
return textualUploadDate;
|
return textualUploadDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTextualUploadDate(String textualUploadDate) {
|
public void setTextualUploadDate(final String textualUploadDate) {
|
||||||
this.textualUploadDate = textualUploadDate;
|
this.textualUploadDate = textualUploadDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public class CommentsInfoItem extends InfoItem {
|
||||||
return uploadDate;
|
return uploadDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploadDate(@Nullable DateWrapper uploadDate) {
|
public void setUploadDate(@Nullable final DateWrapper uploadDate) {
|
||||||
this.uploadDate = uploadDate;
|
this.uploadDate = uploadDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -97,7 +97,7 @@ public class CommentsInfoItem extends InfoItem {
|
||||||
return likeCount;
|
return likeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLikeCount(int likeCount) {
|
public void setLikeCount(final int likeCount) {
|
||||||
this.likeCount = likeCount;
|
this.likeCount = likeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,11 +105,11 @@ public class CommentsInfoItem extends InfoItem {
|
||||||
return textualLikeCount;
|
return textualLikeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTextualLikeCount(String textualLikeCount) {
|
public void setTextualLikeCount(final String textualLikeCount) {
|
||||||
this.textualLikeCount = textualLikeCount;
|
this.textualLikeCount = textualLikeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHeartedByUploader(boolean isHeartedByUploader) {
|
public void setHeartedByUploader(final boolean isHeartedByUploader) {
|
||||||
this.heartedByUploader = isHeartedByUploader;
|
this.heartedByUploader = isHeartedByUploader;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,11 +121,11 @@ public class CommentsInfoItem extends InfoItem {
|
||||||
return pinned;
|
return pinned;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPinned(boolean pinned) {
|
public void setPinned(final boolean pinned) {
|
||||||
this.pinned = pinned;
|
this.pinned = pinned;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploaderVerified(boolean uploaderVerified) {
|
public void setUploaderVerified(final boolean uploaderVerified) {
|
||||||
this.uploaderVerified = uploaderVerified;
|
this.uploaderVerified = uploaderVerified;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,12 @@ public class CommentsInfoItem extends InfoItem {
|
||||||
return streamPosition;
|
return streamPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setReplies(@Nullable Page replies) { this.replies = replies; }
|
public void setReplies(@Nullable final Page replies) {
|
||||||
|
this.replies = replies;
|
||||||
|
}
|
||||||
|
|
||||||
public Page getReplies() { return this.replies; }
|
@Nullable
|
||||||
|
public Page getReplies() {
|
||||||
|
return this.replies;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,7 +18,8 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor {
|
||||||
*
|
*
|
||||||
* <br>
|
* <br>
|
||||||
*
|
*
|
||||||
* NOTE: Currently only implemented for YT {@link YoutubeCommentsInfoItemExtractor#getLikeCount()}
|
* NOTE: Currently only implemented for YT {@link
|
||||||
|
* YoutubeCommentsInfoItemExtractor#getLikeCount()}
|
||||||
* with limitations (only approximate like count is returned)
|
* with limitations (only approximate like count is returned)
|
||||||
*
|
*
|
||||||
* @see StreamExtractor#getLikeCount()
|
* @see StreamExtractor#getLikeCount()
|
||||||
|
|
|
@ -1,101 +1,97 @@
|
||||||
package org.schabi.newpipe.extractor.comments;
|
package org.schabi.newpipe.extractor.comments;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.InfoItem;
|
|
||||||
import org.schabi.newpipe.extractor.InfoItemsCollector;
|
import org.schabi.newpipe.extractor.InfoItemsCollector;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CommentsInfoItemsCollector extends InfoItemsCollector<CommentsInfoItem, CommentsInfoItemExtractor> {
|
public final class CommentsInfoItemsCollector
|
||||||
|
extends InfoItemsCollector<CommentsInfoItem, CommentsInfoItemExtractor> {
|
||||||
|
|
||||||
public CommentsInfoItemsCollector(int serviceId) {
|
public CommentsInfoItemsCollector(final int serviceId) {
|
||||||
super(serviceId);
|
super(serviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommentsInfoItem extract(CommentsInfoItemExtractor extractor) throws ParsingException {
|
public CommentsInfoItem extract(final CommentsInfoItemExtractor extractor)
|
||||||
|
throws ParsingException {
|
||||||
// important information
|
final CommentsInfoItem resultItem = new CommentsInfoItem(
|
||||||
int serviceId = getServiceId();
|
getServiceId(), extractor.getUrl(), extractor.getName());
|
||||||
String url = extractor.getUrl();
|
|
||||||
String name = extractor.getName();
|
|
||||||
|
|
||||||
CommentsInfoItem resultItem = new CommentsInfoItem(serviceId, url, name);
|
|
||||||
|
|
||||||
// optional information
|
// optional information
|
||||||
try {
|
try {
|
||||||
resultItem.setCommentId(extractor.getCommentId());
|
resultItem.setCommentId(extractor.getCommentId());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setCommentText(extractor.getCommentText());
|
resultItem.setCommentText(extractor.getCommentText());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setUploaderName(extractor.getUploaderName());
|
resultItem.setUploaderName(extractor.getUploaderName());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
|
resultItem.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setUploaderUrl(extractor.getUploaderUrl());
|
resultItem.setUploaderUrl(extractor.getUploaderUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setTextualUploadDate(extractor.getTextualUploadDate());
|
resultItem.setTextualUploadDate(extractor.getTextualUploadDate());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setUploadDate(extractor.getUploadDate());
|
resultItem.setUploadDate(extractor.getUploadDate());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setLikeCount(extractor.getLikeCount());
|
resultItem.setLikeCount(extractor.getLikeCount());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setTextualLikeCount(extractor.getTextualLikeCount());
|
resultItem.setTextualLikeCount(extractor.getTextualLikeCount());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
|
resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resultItem.setHeartedByUploader(extractor.isHeartedByUploader());
|
resultItem.setHeartedByUploader(extractor.isHeartedByUploader());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resultItem.setPinned(extractor.isPinned());
|
resultItem.setPinned(extractor.isPinned());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resultItem.setStreamPosition(extractor.getStreamPosition());
|
resultItem.setStreamPosition(extractor.getStreamPosition());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resultItem.setReplies(extractor.getReplies());
|
resultItem.setReplies(extractor.getReplies());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,10 +99,10 @@ public class CommentsInfoItemsCollector extends InfoItemsCollector<CommentsInfoI
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void commit(CommentsInfoItemExtractor extractor) {
|
public void commit(final CommentsInfoItemExtractor extractor) {
|
||||||
try {
|
try {
|
||||||
addItem(extract(extractor));
|
addItem(extract(extractor));
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,13 +19,14 @@ public abstract class Downloader {
|
||||||
/**
|
/**
|
||||||
* Do a GET request to get the resource that the url is pointing to.<br>
|
* Do a GET request to get the resource that the url is pointing to.<br>
|
||||||
* <br>
|
* <br>
|
||||||
* This method calls {@link #get(String, Map, Localization)} with the default preferred localization. It should only be
|
* This method calls {@link #get(String, Map, Localization)} with the default preferred
|
||||||
* used when the resource that will be fetched won't be affected by the localization.
|
* localization. It should only be used when the resource that will be fetched won't be affected
|
||||||
|
* by the localization.
|
||||||
*
|
*
|
||||||
* @param url the URL that is pointing to the wanted resource
|
* @param url the URL that is pointing to the wanted resource
|
||||||
* @return the result of the GET request
|
* @return the result of the GET request
|
||||||
*/
|
*/
|
||||||
public Response get(String url) throws IOException, ReCaptchaException {
|
public Response get(final String url) throws IOException, ReCaptchaException {
|
||||||
return get(url, null, NewPipe.getPreferredLocalization());
|
return get(url, null, NewPipe.getPreferredLocalization());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -38,7 +39,8 @@ public abstract class Downloader {
|
||||||
* @param localization the source of the value of the {@code Accept-Language} header
|
* @param localization the source of the value of the {@code Accept-Language} header
|
||||||
* @return the result of the GET request
|
* @return the result of the GET request
|
||||||
*/
|
*/
|
||||||
public Response get(String url, @Nullable Localization localization) throws IOException, ReCaptchaException {
|
public Response get(final String url, @Nullable final Localization localization)
|
||||||
|
throws IOException, ReCaptchaException {
|
||||||
return get(url, null, localization);
|
return get(url, null, localization);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +52,8 @@ public abstract class Downloader {
|
||||||
* Any default headers <b>should</b> be overridden by these.
|
* Any default headers <b>should</b> be overridden by these.
|
||||||
* @return the result of the GET request
|
* @return the result of the GET request
|
||||||
*/
|
*/
|
||||||
public Response get(String url, @Nullable Map<String, List<String>> headers) throws IOException, ReCaptchaException {
|
public Response get(final String url, @Nullable final Map<String, List<String>> headers)
|
||||||
|
throws IOException, ReCaptchaException {
|
||||||
return get(url, headers, NewPipe.getPreferredLocalization());
|
return get(url, headers, NewPipe.getPreferredLocalization());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,7 +68,9 @@ public abstract class Downloader {
|
||||||
* @param localization the source of the value of the {@code Accept-Language} header
|
* @param localization the source of the value of the {@code Accept-Language} header
|
||||||
* @return the result of the GET request
|
* @return the result of the GET request
|
||||||
*/
|
*/
|
||||||
public Response get(String url, @Nullable Map<String, List<String>> headers, @Nullable Localization localization)
|
public Response get(final String url,
|
||||||
|
@Nullable final Map<String, List<String>> headers,
|
||||||
|
@Nullable final Localization localization)
|
||||||
throws IOException, ReCaptchaException {
|
throws IOException, ReCaptchaException {
|
||||||
return execute(Request.newBuilder()
|
return execute(Request.newBuilder()
|
||||||
.get(url)
|
.get(url)
|
||||||
|
@ -80,7 +85,7 @@ public abstract class Downloader {
|
||||||
* @param url the URL that is pointing to the wanted resource
|
* @param url the URL that is pointing to the wanted resource
|
||||||
* @return the result of the HEAD request
|
* @return the result of the HEAD request
|
||||||
*/
|
*/
|
||||||
public Response head(String url) throws IOException, ReCaptchaException {
|
public Response head(final String url) throws IOException, ReCaptchaException {
|
||||||
return head(url, null);
|
return head(url, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -92,7 +97,7 @@ public abstract class Downloader {
|
||||||
* Any default headers <b>should</b> be overridden by these.
|
* Any default headers <b>should</b> be overridden by these.
|
||||||
* @return the result of the HEAD request
|
* @return the result of the HEAD request
|
||||||
*/
|
*/
|
||||||
public Response head(String url, @Nullable Map<String, List<String>> headers)
|
public Response head(final String url, @Nullable final Map<String, List<String>> headers)
|
||||||
throws IOException, ReCaptchaException {
|
throws IOException, ReCaptchaException {
|
||||||
return execute(Request.newBuilder()
|
return execute(Request.newBuilder()
|
||||||
.head(url)
|
.head(url)
|
||||||
|
@ -109,7 +114,9 @@ public abstract class Downloader {
|
||||||
* @param dataToSend byte array that will be sent when doing the request.
|
* @param dataToSend byte array that will be sent when doing the request.
|
||||||
* @return the result of the GET request
|
* @return the result of the GET request
|
||||||
*/
|
*/
|
||||||
public Response post(String url, @Nullable Map<String, List<String>> headers, @Nullable byte[] dataToSend)
|
public Response post(final String url,
|
||||||
|
@Nullable final Map<String, List<String>> headers,
|
||||||
|
@Nullable final byte[] dataToSend)
|
||||||
throws IOException, ReCaptchaException {
|
throws IOException, ReCaptchaException {
|
||||||
return post(url, headers, dataToSend, NewPipe.getPreferredLocalization());
|
return post(url, headers, dataToSend, NewPipe.getPreferredLocalization());
|
||||||
}
|
}
|
||||||
|
@ -126,7 +133,10 @@ public abstract class Downloader {
|
||||||
* @param localization the source of the value of the {@code Accept-Language} header
|
* @param localization the source of the value of the {@code Accept-Language} header
|
||||||
* @return the result of the GET request
|
* @return the result of the GET request
|
||||||
*/
|
*/
|
||||||
public Response post(String url, @Nullable Map<String, List<String>> headers, @Nullable byte[] dataToSend, @Nullable Localization localization)
|
public Response post(final String url,
|
||||||
|
@Nullable final Map<String, List<String>> headers,
|
||||||
|
@Nullable final byte[] dataToSend,
|
||||||
|
@Nullable final Localization localization)
|
||||||
throws IOException, ReCaptchaException {
|
throws IOException, ReCaptchaException {
|
||||||
return execute(Request.newBuilder()
|
return execute(Request.newBuilder()
|
||||||
.post(url, dataToSend)
|
.post(url, dataToSend)
|
||||||
|
@ -140,5 +150,6 @@ public abstract class Downloader {
|
||||||
*
|
*
|
||||||
* @return the result of the request
|
* @return the result of the request
|
||||||
*/
|
*/
|
||||||
public abstract Response execute(@Nonnull Request request) throws IOException, ReCaptchaException;
|
public abstract Response execute(@Nonnull Request request)
|
||||||
|
throws IOException, ReCaptchaException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,24 +2,42 @@ package org.schabi.newpipe.extractor.downloader;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.localization.Localization;
|
import org.schabi.newpipe.extractor.localization.Localization;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
import java.util.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An object that holds request information used when {@link Downloader#execute(Request) executing} a request.
|
* An object that holds request information used when {@link Downloader#execute(Request) executing}
|
||||||
|
* a request.
|
||||||
*/
|
*/
|
||||||
public class Request {
|
public class Request {
|
||||||
private final String httpMethod;
|
private final String httpMethod;
|
||||||
private final String url;
|
private final String url;
|
||||||
private final Map<String, List<String>> headers;
|
private final Map<String, List<String>> headers;
|
||||||
@Nullable private final byte[] dataToSend;
|
@Nullable
|
||||||
@Nullable private final Localization localization;
|
private final byte[] dataToSend;
|
||||||
|
@Nullable
|
||||||
|
private final Localization localization;
|
||||||
|
|
||||||
public Request(String httpMethod, String url, Map<String, List<String>> headers, @Nullable byte[] dataToSend,
|
public Request(final String httpMethod,
|
||||||
@Nullable Localization localization, boolean automaticLocalizationHeader) {
|
final String url,
|
||||||
if (httpMethod == null) throw new IllegalArgumentException("Request's httpMethod is null");
|
@Nullable final Map<String, List<String>> headers,
|
||||||
if (url == null) throw new IllegalArgumentException("Request's url is null");
|
@Nullable final byte[] dataToSend,
|
||||||
|
@Nullable final Localization localization,
|
||||||
|
final boolean automaticLocalizationHeader) {
|
||||||
|
if (httpMethod == null) {
|
||||||
|
throw new IllegalArgumentException("Request's httpMethod is null");
|
||||||
|
}
|
||||||
|
if (url == null) {
|
||||||
|
throw new IllegalArgumentException("Request's url is null");
|
||||||
|
}
|
||||||
|
|
||||||
this.httpMethod = httpMethod;
|
this.httpMethod = httpMethod;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
|
@ -37,7 +55,7 @@ public class Request {
|
||||||
this.headers = Collections.unmodifiableMap(actualHeaders);
|
this.headers = Collections.unmodifiableMap(actualHeaders);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Request(Builder builder) {
|
private Request(final Builder builder) {
|
||||||
this(builder.httpMethod, builder.url, builder.headers, builder.dataToSend,
|
this(builder.httpMethod, builder.url, builder.headers, builder.dataToSend,
|
||||||
builder.localization, builder.automaticLocalizationHeader);
|
builder.localization, builder.automaticLocalizationHeader);
|
||||||
}
|
}
|
||||||
|
@ -94,7 +112,7 @@ public class Request {
|
||||||
public static final class Builder {
|
public static final class Builder {
|
||||||
private String httpMethod;
|
private String httpMethod;
|
||||||
private String url;
|
private String url;
|
||||||
private Map<String, List<String>> headers = new LinkedHashMap<>();
|
private final Map<String, List<String>> headers = new LinkedHashMap<>();
|
||||||
private byte[] dataToSend;
|
private byte[] dataToSend;
|
||||||
private Localization localization;
|
private Localization localization;
|
||||||
private boolean automaticLocalizationHeader = true;
|
private boolean automaticLocalizationHeader = true;
|
||||||
|
@ -105,27 +123,28 @@ public class Request {
|
||||||
/**
|
/**
|
||||||
* A http method (i.e. {@code GET, POST, HEAD}).
|
* A http method (i.e. {@code GET, POST, HEAD}).
|
||||||
*/
|
*/
|
||||||
public Builder httpMethod(String httpMethod) {
|
public Builder httpMethod(final String httpMethodToSet) {
|
||||||
this.httpMethod = httpMethod;
|
this.httpMethod = httpMethodToSet;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The URL that is pointing to the wanted resource.
|
* The URL that is pointing to the wanted resource.
|
||||||
*/
|
*/
|
||||||
public Builder url(String url) {
|
public Builder url(final String urlToSet) {
|
||||||
this.url = url;
|
this.url = urlToSet;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A list of headers that will be used in the request.<br>
|
* A list of headers that will be used in the request.<br>
|
||||||
* Any default headers that the implementation may have, <b>should</b> be overridden by these.
|
* Any default headers that the implementation may have, <b>should</b> be overridden by
|
||||||
|
* these.
|
||||||
*/
|
*/
|
||||||
public Builder headers(@Nullable Map<String, List<String>> headers) {
|
public Builder headers(@Nullable final Map<String, List<String>> headersToSet) {
|
||||||
this.headers.clear();
|
this.headers.clear();
|
||||||
if (headers != null) {
|
if (headersToSet != null) {
|
||||||
this.headers.putAll(headers);
|
this.headers.putAll(headersToSet);
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -137,8 +156,8 @@ public class Request {
|
||||||
* The implementation should make note of some recommended headers
|
* The implementation should make note of some recommended headers
|
||||||
* (for example, {@code Content-Length} in a post request).
|
* (for example, {@code Content-Length} in a post request).
|
||||||
*/
|
*/
|
||||||
public Builder dataToSend(byte[] dataToSend) {
|
public Builder dataToSend(final byte[] dataToSendToSet) {
|
||||||
this.dataToSend = dataToSend;
|
this.dataToSend = dataToSendToSet;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,16 +167,16 @@ public class Request {
|
||||||
* Usually the {@code Accept-Language} will be set to this value (a helper
|
* Usually the {@code Accept-Language} will be set to this value (a helper
|
||||||
* method to do this easily: {@link Request#headersFromLocalization(Localization)}).
|
* method to do this easily: {@link Request#headersFromLocalization(Localization)}).
|
||||||
*/
|
*/
|
||||||
public Builder localization(Localization localization) {
|
public Builder localization(final Localization localizationToSet) {
|
||||||
this.localization = localization;
|
this.localization = localizationToSet;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* If localization headers should automatically be included in the request.
|
* If localization headers should automatically be included in the request.
|
||||||
*/
|
*/
|
||||||
public Builder automaticLocalizationHeader(boolean automaticLocalizationHeader) {
|
public Builder automaticLocalizationHeader(final boolean automaticLocalizationHeaderToSet) {
|
||||||
this.automaticLocalizationHeader = automaticLocalizationHeader;
|
this.automaticLocalizationHeader = automaticLocalizationHeaderToSet;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,22 +189,22 @@ public class Request {
|
||||||
// Http Methods Utils
|
// Http Methods Utils
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
public Builder get(String url) {
|
public Builder get(final String urlToSet) {
|
||||||
this.httpMethod = "GET";
|
this.httpMethod = "GET";
|
||||||
this.url = url;
|
this.url = urlToSet;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder head(String url) {
|
public Builder head(final String urlToSet) {
|
||||||
this.httpMethod = "HEAD";
|
this.httpMethod = "HEAD";
|
||||||
this.url = url;
|
this.url = urlToSet;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder post(String url, @Nullable byte[] dataToSend) {
|
public Builder post(final String urlToSet, @Nullable final byte[] dataToSendToSet) {
|
||||||
this.httpMethod = "POST";
|
this.httpMethod = "POST";
|
||||||
this.url = url;
|
this.url = urlToSet;
|
||||||
this.dataToSend = dataToSend;
|
this.dataToSend = dataToSendToSet;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -193,13 +212,13 @@ public class Request {
|
||||||
// Additional Headers Utils
|
// Additional Headers Utils
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
public Builder setHeaders(String headerName, List<String> headerValueList) {
|
public Builder setHeaders(final String headerName, final List<String> headerValueList) {
|
||||||
this.headers.remove(headerName);
|
this.headers.remove(headerName);
|
||||||
this.headers.put(headerName, headerValueList);
|
this.headers.put(headerName, headerValueList);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder addHeaders(String headerName, List<String> headerValueList) {
|
public Builder addHeaders(final String headerName, final List<String> headerValueList) {
|
||||||
@Nullable List<String> currentHeaderValueList = this.headers.get(headerName);
|
@Nullable List<String> currentHeaderValueList = this.headers.get(headerName);
|
||||||
if (currentHeaderValueList == null) {
|
if (currentHeaderValueList == null) {
|
||||||
currentHeaderValueList = new ArrayList<>();
|
currentHeaderValueList = new ArrayList<>();
|
||||||
|
@ -210,11 +229,11 @@ public class Request {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder setHeader(String headerName, String headerValue) {
|
public Builder setHeader(final String headerName, final String headerValue) {
|
||||||
return setHeaders(headerName, Collections.singletonList(headerValue));
|
return setHeaders(headerName, Collections.singletonList(headerValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Builder addHeader(String headerName, String headerValue) {
|
public Builder addHeader(final String headerName, final String headerValue) {
|
||||||
return addHeaders(headerName, Collections.singletonList(headerValue));
|
return addHeaders(headerName, Collections.singletonList(headerValue));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -226,15 +245,20 @@ public class Request {
|
||||||
|
|
||||||
@SuppressWarnings("WeakerAccess")
|
@SuppressWarnings("WeakerAccess")
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public static Map<String, List<String>> headersFromLocalization(@Nullable Localization localization) {
|
public static Map<String, List<String>> headersFromLocalization(
|
||||||
if (localization == null) return Collections.emptyMap();
|
@Nullable final Localization localization) {
|
||||||
|
if (localization == null) {
|
||||||
|
return Collections.emptyMap();
|
||||||
|
}
|
||||||
|
|
||||||
final Map<String, List<String>> headers = new LinkedHashMap<>();
|
final Map<String, List<String>> headers = new LinkedHashMap<>();
|
||||||
if (!localization.getCountryCode().isEmpty()) {
|
if (!localization.getCountryCode().isEmpty()) {
|
||||||
headers.put("Accept-Language", Collections.singletonList(localization.getLocalizationCode() +
|
headers.put("Accept-Language",
|
||||||
", " + localization.getLanguageCode() + ";q=0.9"));
|
Collections.singletonList(localization.getLocalizationCode()
|
||||||
|
+ ", " + localization.getLanguageCode() + ";q=0.9"));
|
||||||
} else {
|
} else {
|
||||||
headers.put("Accept-Language", Collections.singletonList(localization.getLanguageCode()));
|
headers.put("Accept-Language",
|
||||||
|
Collections.singletonList(localization.getLanguageCode()));
|
||||||
}
|
}
|
||||||
|
|
||||||
return headers;
|
return headers;
|
||||||
|
@ -245,15 +269,19 @@ public class Request {
|
||||||
//////////////////////////////////////////////////////////////////////////*/
|
//////////////////////////////////////////////////////////////////////////*/
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(final Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) {
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
return true;
|
||||||
Request request = (Request) o;
|
}
|
||||||
return httpMethod.equals(request.httpMethod) &&
|
if (o == null || getClass() != o.getClass()) {
|
||||||
url.equals(request.url) &&
|
return false;
|
||||||
headers.equals(request.headers) &&
|
}
|
||||||
Arrays.equals(dataToSend, request.dataToSend) &&
|
final Request request = (Request) o;
|
||||||
Objects.equals(localization, request.localization);
|
return httpMethod.equals(request.httpMethod)
|
||||||
|
&& url.equals(request.url)
|
||||||
|
&& headers.equals(request.headers)
|
||||||
|
&& Arrays.equals(dataToSend, request.dataToSend)
|
||||||
|
&& Objects.equals(localization, request.localization);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -17,11 +17,14 @@ public class Response {
|
||||||
|
|
||||||
private final String latestUrl;
|
private final String latestUrl;
|
||||||
|
|
||||||
public Response(int responseCode, String responseMessage, Map<String, List<String>> responseHeaders,
|
public Response(final int responseCode,
|
||||||
@Nullable String responseBody, @Nullable String latestUrl) {
|
final String responseMessage,
|
||||||
|
@Nullable final Map<String, List<String>> responseHeaders,
|
||||||
|
@Nullable final String responseBody,
|
||||||
|
@Nullable final String latestUrl) {
|
||||||
this.responseCode = responseCode;
|
this.responseCode = responseCode;
|
||||||
this.responseMessage = responseMessage;
|
this.responseMessage = responseMessage;
|
||||||
this.responseHeaders = responseHeaders != null ? responseHeaders : Collections.<String, List<String>>emptyMap();
|
this.responseHeaders = responseHeaders == null ? Collections.emptyMap() : responseHeaders;
|
||||||
|
|
||||||
this.responseBody = responseBody == null ? "" : responseBody;
|
this.responseBody = responseBody == null ? "" : responseBody;
|
||||||
this.latestUrl = latestUrl;
|
this.latestUrl = latestUrl;
|
||||||
|
@ -60,14 +63,15 @@ public class Response {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For easy access to some header value that (usually) don't repeat itself.
|
* For easy access to some header value that (usually) don't repeat itself.
|
||||||
* <p>For getting all the values associated to the header, use {@link #responseHeaders()} (e.g. {@code Set-Cookie}).
|
* <p>For getting all the values associated to the header, use {@link #responseHeaders()} (e.g.
|
||||||
|
* {@code Set-Cookie}).
|
||||||
*
|
*
|
||||||
* @param name the name of the header
|
* @param name the name of the header
|
||||||
* @return the first value assigned to this header
|
* @return the first value assigned to this header
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public String getHeader(String name) {
|
public String getHeader(final String name) {
|
||||||
for (Map.Entry<String, List<String>> headerEntry : responseHeaders.entrySet()) {
|
for (final Map.Entry<String, List<String>> headerEntry : responseHeaders.entrySet()) {
|
||||||
final String key = headerEntry.getKey();
|
final String key = headerEntry.getKey();
|
||||||
if (key != null && key.equalsIgnoreCase(name) && !headerEntry.getValue().isEmpty()) {
|
if (key != null && key.equalsIgnoreCase(name) && !headerEntry.getValue().isEmpty()) {
|
||||||
return headerEntry.getValue().get(0);
|
return headerEntry.getValue().get(0);
|
||||||
|
|
|
@ -11,7 +11,7 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||||
* YouTube is an example of a service that has this alternative available.
|
* YouTube is an example of a service that has this alternative available.
|
||||||
*/
|
*/
|
||||||
public abstract class FeedExtractor extends ListExtractor<StreamInfoItem> {
|
public abstract class FeedExtractor extends ListExtractor<StreamInfoItem> {
|
||||||
public FeedExtractor(StreamingService service, ListLinkHandler listLinkHandler) {
|
public FeedExtractor(final StreamingService service, final ListLinkHandler listLinkHandler) {
|
||||||
super(service, listLinkHandler);
|
super(service, listLinkHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,26 +13,35 @@ import java.util.List;
|
||||||
|
|
||||||
public class FeedInfo extends ListInfo<StreamInfoItem> {
|
public class FeedInfo extends ListInfo<StreamInfoItem> {
|
||||||
|
|
||||||
public FeedInfo(int serviceId, String id, String url, String originalUrl, String name, List<String> contentFilter, String sortFilter) {
|
public FeedInfo(final int serviceId,
|
||||||
|
final String id,
|
||||||
|
final String url,
|
||||||
|
final String originalUrl,
|
||||||
|
final String name,
|
||||||
|
final List<String> contentFilter,
|
||||||
|
final String sortFilter) {
|
||||||
super(serviceId, id, url, originalUrl, name, contentFilter, sortFilter);
|
super(serviceId, id, url, originalUrl, name, contentFilter, sortFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FeedInfo getInfo(String url) throws IOException, ExtractionException {
|
public static FeedInfo getInfo(final String url) throws IOException, ExtractionException {
|
||||||
return getInfo(NewPipe.getServiceByUrl(url), url);
|
return getInfo(NewPipe.getServiceByUrl(url), url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FeedInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
|
public static FeedInfo getInfo(final StreamingService service, final String url)
|
||||||
|
throws IOException, ExtractionException {
|
||||||
final FeedExtractor extractor = service.getFeedExtractor(url);
|
final FeedExtractor extractor = service.getFeedExtractor(url);
|
||||||
|
|
||||||
if (extractor == null) {
|
if (extractor == null) {
|
||||||
throw new IllegalArgumentException("Service \"" + service.getServiceInfo().getName() + "\" doesn't support FeedExtractor.");
|
throw new IllegalArgumentException("Service \"" + service.getServiceInfo().getName()
|
||||||
|
+ "\" doesn't support FeedExtractor.");
|
||||||
}
|
}
|
||||||
|
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
return getInfo(extractor);
|
return getInfo(extractor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FeedInfo getInfo(FeedExtractor extractor) throws IOException, ExtractionException {
|
public static FeedInfo getInfo(final FeedExtractor extractor)
|
||||||
|
throws IOException, ExtractionException {
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
|
|
||||||
final int serviceId = extractor.getServiceId();
|
final int serviceId = extractor.getServiceId();
|
||||||
|
@ -43,7 +52,8 @@ public class FeedInfo extends ListInfo<StreamInfoItem> {
|
||||||
|
|
||||||
final FeedInfo info = new FeedInfo(serviceId, id, url, originalUrl, name, null, null);
|
final FeedInfo info = new FeedInfo(serviceId, id, url, originalUrl, name, null, null);
|
||||||
|
|
||||||
final InfoItemsPage<StreamInfoItem> itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor);
|
final InfoItemsPage<StreamInfoItem> itemsPage
|
||||||
|
= ExtractorHelper.getItemsPageOrLogError(info, extractor);
|
||||||
info.setRelatedItems(itemsPage.getItems());
|
info.setRelatedItems(itemsPage.getItems());
|
||||||
info.setNextPage(itemsPage.getNextPage());
|
info.setNextPage(itemsPage.getNextPage());
|
||||||
|
|
||||||
|
|
|
@ -31,9 +31,9 @@ import javax.annotation.Nonnull;
|
||||||
public abstract class KioskExtractor<T extends InfoItem> extends ListExtractor<T> {
|
public abstract class KioskExtractor<T extends InfoItem> extends ListExtractor<T> {
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
public KioskExtractor(StreamingService streamingService,
|
public KioskExtractor(final StreamingService streamingService,
|
||||||
ListLinkHandler linkHandler,
|
final ListLinkHandler linkHandler,
|
||||||
String kioskId) {
|
final String kioskId) {
|
||||||
super(streamingService, linkHandler);
|
super(streamingService, linkHandler);
|
||||||
this.id = kioskId;
|
this.id = kioskId;
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,6 @@ public abstract class KioskExtractor<T extends InfoItem> extends ListExtractor<T
|
||||||
* In order to get the name of the kiosk in the desired language we have to
|
* In order to get the name of the kiosk in the desired language we have to
|
||||||
* crawl if from the website.
|
* crawl if from the website.
|
||||||
* @return the translated version of id
|
* @return the translated version of id
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -26,34 +26,30 @@ import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.Page;
|
import org.schabi.newpipe.extractor.Page;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
|
||||||
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
|
||||||
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
|
||||||
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
public class KioskInfo extends ListInfo<StreamInfoItem> {
|
public final class KioskInfo extends ListInfo<StreamInfoItem> {
|
||||||
private KioskInfo(int serviceId, ListLinkHandler linkHandler, String name) throws ParsingException {
|
private KioskInfo(final int serviceId, final ListLinkHandler linkHandler, final String name) {
|
||||||
super(serviceId, linkHandler, name);
|
super(serviceId, linkHandler, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ListExtractor.InfoItemsPage<StreamInfoItem> getMoreItems(StreamingService service,
|
public static ListExtractor.InfoItemsPage<StreamInfoItem> getMoreItems(
|
||||||
String url,
|
final StreamingService service, final String url, final Page page)
|
||||||
Page page)
|
|
||||||
throws IOException, ExtractionException {
|
throws IOException, ExtractionException {
|
||||||
KioskList kl = service.getKioskList();
|
return service.getKioskList().getExtractorByUrl(url, page).getPage(page);
|
||||||
KioskExtractor extractor = kl.getExtractorByUrl(url, page);
|
|
||||||
return extractor.getPage(page);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KioskInfo getInfo(String url) throws IOException, ExtractionException {
|
public static KioskInfo getInfo(final String url) throws IOException, ExtractionException {
|
||||||
return getInfo(NewPipe.getServiceByUrl(url), url);
|
return getInfo(NewPipe.getServiceByUrl(url), url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static KioskInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
|
public static KioskInfo getInfo(final StreamingService service, final String url)
|
||||||
KioskList kl = service.getKioskList();
|
throws IOException, ExtractionException {
|
||||||
KioskExtractor extractor = kl.getExtractorByUrl(url, null);
|
final KioskExtractor extractor = service.getKioskList().getExtractorByUrl(url, null);
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
return getInfo(extractor);
|
return getInfo(extractor);
|
||||||
}
|
}
|
||||||
|
@ -63,13 +59,14 @@ public class KioskInfo extends ListInfo<StreamInfoItem> {
|
||||||
*
|
*
|
||||||
* @param extractor an extractor where fetchPage() was already got called on.
|
* @param extractor an extractor where fetchPage() was already got called on.
|
||||||
*/
|
*/
|
||||||
public static KioskInfo getInfo(KioskExtractor extractor) throws ExtractionException {
|
public static KioskInfo getInfo(final KioskExtractor extractor) throws ExtractionException {
|
||||||
|
|
||||||
final KioskInfo info = new KioskInfo(extractor.getServiceId(),
|
final KioskInfo info = new KioskInfo(extractor.getServiceId(),
|
||||||
extractor.getLinkHandler(),
|
extractor.getLinkHandler(),
|
||||||
extractor.getName());
|
extractor.getName());
|
||||||
|
|
||||||
final ListExtractor.InfoItemsPage<StreamInfoItem> itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor);
|
final ListExtractor.InfoItemsPage<StreamInfoItem> itemsPage
|
||||||
|
= ExtractorHelper.getItemsPageOrLogError(info, extractor);
|
||||||
info.setRelatedItems(itemsPage.getItems());
|
info.setRelatedItems(itemsPage.getItems());
|
||||||
info.setNextPage(itemsPage.getNextPage());
|
info.setNextPage(itemsPage.getNextPage());
|
||||||
|
|
||||||
|
|
|
@ -19,9 +19,9 @@ import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
|
||||||
public class KioskList {
|
public class KioskList {
|
||||||
|
|
||||||
public interface KioskExtractorFactory {
|
public interface KioskExtractorFactory {
|
||||||
KioskExtractor createNewKiosk(final StreamingService streamingService,
|
KioskExtractor createNewKiosk(StreamingService streamingService,
|
||||||
final String url,
|
String url,
|
||||||
final String kioskId)
|
String kioskId)
|
||||||
throws ExtractionException, IOException;
|
throws ExtractionException, IOException;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,8 +34,8 @@ public class KioskList {
|
||||||
@Nullable
|
@Nullable
|
||||||
private ContentCountry forcedContentCountry;
|
private ContentCountry forcedContentCountry;
|
||||||
|
|
||||||
private class KioskEntry {
|
private static class KioskEntry {
|
||||||
public KioskEntry(KioskExtractorFactory ef, ListLinkHandlerFactory h) {
|
KioskEntry(final KioskExtractorFactory ef, final ListLinkHandlerFactory h) {
|
||||||
extractorFactory = ef;
|
extractorFactory = ef;
|
||||||
handlerFactory = h;
|
handlerFactory = h;
|
||||||
}
|
}
|
||||||
|
@ -44,11 +44,13 @@ public class KioskList {
|
||||||
final ListLinkHandlerFactory handlerFactory;
|
final ListLinkHandlerFactory handlerFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KioskList(StreamingService service) {
|
public KioskList(final StreamingService service) {
|
||||||
this.service = service;
|
this.service = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addKioskEntry(KioskExtractorFactory extractorFactory, ListLinkHandlerFactory handlerFactory, String id)
|
public void addKioskEntry(final KioskExtractorFactory extractorFactory,
|
||||||
|
final ListLinkHandlerFactory handlerFactory,
|
||||||
|
final String id)
|
||||||
throws Exception {
|
throws Exception {
|
||||||
if (kioskList.get(id) != null) {
|
if (kioskList.get(id) != null) {
|
||||||
throw new Exception("Kiosk with type " + id + " already exists.");
|
throw new Exception("Kiosk with type " + id + " already exists.");
|
||||||
|
@ -56,7 +58,7 @@ public class KioskList {
|
||||||
kioskList.put(id, new KioskEntry(extractorFactory, handlerFactory));
|
kioskList.put(id, new KioskEntry(extractorFactory, handlerFactory));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultKiosk(String kioskType) {
|
public void setDefaultKiosk(final String kioskType) {
|
||||||
defaultKiosk = kioskType;
|
defaultKiosk = kioskType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -65,19 +67,20 @@ public class KioskList {
|
||||||
return getDefaultKioskExtractor(null);
|
return getDefaultKioskExtractor(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public KioskExtractor getDefaultKioskExtractor(Page nextPage)
|
public KioskExtractor getDefaultKioskExtractor(final Page nextPage)
|
||||||
throws ExtractionException, IOException {
|
throws ExtractionException, IOException {
|
||||||
return getDefaultKioskExtractor(nextPage, NewPipe.getPreferredLocalization());
|
return getDefaultKioskExtractor(nextPage, NewPipe.getPreferredLocalization());
|
||||||
}
|
}
|
||||||
|
|
||||||
public KioskExtractor getDefaultKioskExtractor(Page nextPage, Localization localization)
|
public KioskExtractor getDefaultKioskExtractor(final Page nextPage,
|
||||||
|
final Localization localization)
|
||||||
throws ExtractionException, IOException {
|
throws ExtractionException, IOException {
|
||||||
if (!isNullOrEmpty(defaultKiosk)) {
|
if (!isNullOrEmpty(defaultKiosk)) {
|
||||||
return getExtractorById(defaultKiosk, nextPage, localization);
|
return getExtractorById(defaultKiosk, nextPage, localization);
|
||||||
} else {
|
} else {
|
||||||
if (!kioskList.isEmpty()) {
|
if (!kioskList.isEmpty()) {
|
||||||
// if not set get any entry
|
// if not set get any entry
|
||||||
Object[] keySet = kioskList.keySet().toArray();
|
final Object[] keySet = kioskList.keySet().toArray();
|
||||||
return getExtractorById(keySet[0].toString(), nextPage, localization);
|
return getExtractorById(keySet[0].toString(), nextPage, localization);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
|
@ -89,22 +92,28 @@ public class KioskList {
|
||||||
return defaultKiosk;
|
return defaultKiosk;
|
||||||
}
|
}
|
||||||
|
|
||||||
public KioskExtractor getExtractorById(String kioskId, Page nextPage)
|
public KioskExtractor getExtractorById(final String kioskId, final Page nextPage)
|
||||||
throws ExtractionException, IOException {
|
throws ExtractionException, IOException {
|
||||||
return getExtractorById(kioskId, nextPage, NewPipe.getPreferredLocalization());
|
return getExtractorById(kioskId, nextPage, NewPipe.getPreferredLocalization());
|
||||||
}
|
}
|
||||||
|
|
||||||
public KioskExtractor getExtractorById(String kioskId, Page nextPage, Localization localization)
|
public KioskExtractor getExtractorById(final String kioskId,
|
||||||
|
final Page nextPage,
|
||||||
|
final Localization localization)
|
||||||
throws ExtractionException, IOException {
|
throws ExtractionException, IOException {
|
||||||
KioskEntry ke = kioskList.get(kioskId);
|
final KioskEntry ke = kioskList.get(kioskId);
|
||||||
if (ke == null) {
|
if (ke == null) {
|
||||||
throw new ExtractionException("No kiosk found with the type: " + kioskId);
|
throw new ExtractionException("No kiosk found with the type: " + kioskId);
|
||||||
} else {
|
} else {
|
||||||
final KioskExtractor kioskExtractor = ke.extractorFactory.createNewKiosk(service,
|
final KioskExtractor kioskExtractor = ke.extractorFactory.createNewKiosk(service,
|
||||||
ke.handlerFactory.fromId(kioskId).getUrl(), kioskId);
|
ke.handlerFactory.fromId(kioskId).getUrl(), kioskId);
|
||||||
|
|
||||||
if (forcedLocalization != null) kioskExtractor.forceLocalization(forcedLocalization);
|
if (forcedLocalization != null) {
|
||||||
if (forcedContentCountry != null) kioskExtractor.forceContentCountry(forcedContentCountry);
|
kioskExtractor.forceLocalization(forcedLocalization);
|
||||||
|
}
|
||||||
|
if (forcedContentCountry != null) {
|
||||||
|
kioskExtractor.forceContentCountry(forcedContentCountry);
|
||||||
|
}
|
||||||
|
|
||||||
return kioskExtractor;
|
return kioskExtractor;
|
||||||
}
|
}
|
||||||
|
@ -114,15 +123,17 @@ public class KioskList {
|
||||||
return kioskList.keySet();
|
return kioskList.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
public KioskExtractor getExtractorByUrl(String url, Page nextPage)
|
public KioskExtractor getExtractorByUrl(final String url, final Page nextPage)
|
||||||
throws ExtractionException, IOException {
|
throws ExtractionException, IOException {
|
||||||
return getExtractorByUrl(url, nextPage, NewPipe.getPreferredLocalization());
|
return getExtractorByUrl(url, nextPage, NewPipe.getPreferredLocalization());
|
||||||
}
|
}
|
||||||
|
|
||||||
public KioskExtractor getExtractorByUrl(String url, Page nextPage, Localization localization)
|
public KioskExtractor getExtractorByUrl(final String url,
|
||||||
|
final Page nextPage,
|
||||||
|
final Localization localization)
|
||||||
throws ExtractionException, IOException {
|
throws ExtractionException, IOException {
|
||||||
for (Map.Entry<String, KioskEntry> e : kioskList.entrySet()) {
|
for (final Map.Entry<String, KioskEntry> e : kioskList.entrySet()) {
|
||||||
KioskEntry ke = e.getValue();
|
final KioskEntry ke = e.getValue();
|
||||||
if (ke.handlerFactory.acceptUrl(url)) {
|
if (ke.handlerFactory.acceptUrl(url)) {
|
||||||
return getExtractorById(ke.handlerFactory.getId(url), nextPage, localization);
|
return getExtractorById(ke.handlerFactory.getId(url), nextPage, localization);
|
||||||
}
|
}
|
||||||
|
@ -130,15 +141,15 @@ public class KioskList {
|
||||||
throw new ExtractionException("Could not find a kiosk that fits to the url: " + url);
|
throw new ExtractionException("Could not find a kiosk that fits to the url: " + url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListLinkHandlerFactory getListLinkHandlerFactoryByType(String type) {
|
public ListLinkHandlerFactory getListLinkHandlerFactoryByType(final String type) {
|
||||||
return kioskList.get(type).handlerFactory;
|
return kioskList.get(type).handlerFactory;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forceLocalization(@Nullable Localization localization) {
|
public void forceLocalization(@Nullable final Localization localization) {
|
||||||
this.forcedLocalization = localization;
|
this.forcedLocalization = localization;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forceContentCountry(@Nullable ContentCountry contentCountry) {
|
public void forceContentCountry(@Nullable final ContentCountry contentCountry) {
|
||||||
this.forcedContentCountry = contentCountry;
|
this.forcedContentCountry = contentCountry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,13 +10,13 @@ public class LinkHandler implements Serializable {
|
||||||
protected final String url;
|
protected final String url;
|
||||||
protected final String id;
|
protected final String id;
|
||||||
|
|
||||||
public LinkHandler(String originalUrl, String url, String id) {
|
public LinkHandler(final String originalUrl, final String url, final String id) {
|
||||||
this.originalUrl = originalUrl;
|
this.originalUrl = originalUrl;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkHandler(LinkHandler handler) {
|
public LinkHandler(final LinkHandler handler) {
|
||||||
this(handler.originalUrl, handler.url, handler.id);
|
this(handler.originalUrl, handler.url, handler.id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
package org.schabi.newpipe.extractor.linkhandler;
|
package org.schabi.newpipe.extractor.linkhandler;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
|
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
import org.schabi.newpipe.extractor.utils.Utils;
|
import org.schabi.newpipe.extractor.utils.Utils;
|
||||||
|
|
||||||
|
@ -31,10 +30,12 @@ public abstract class LinkHandlerFactory {
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
|
|
||||||
public abstract String getId(String url) throws ParsingException;
|
public abstract String getId(String url) throws ParsingException;
|
||||||
public abstract String getUrl(String id) throws ParsingException;
|
|
||||||
public abstract boolean onAcceptUrl(final String url) throws ParsingException;
|
|
||||||
|
|
||||||
public String getUrl(String id, String baseUrl) throws ParsingException {
|
public abstract String getUrl(String id) throws ParsingException;
|
||||||
|
|
||||||
|
public abstract boolean onAcceptUrl(String url) throws ParsingException;
|
||||||
|
|
||||||
|
public String getUrl(final String id, final String baseUrl) throws ParsingException {
|
||||||
return getUrl(id);
|
return getUrl(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ public abstract class LinkHandlerFactory {
|
||||||
* Builds a {@link LinkHandler} from a url.<br>
|
* Builds a {@link LinkHandler} from a url.<br>
|
||||||
* Be sure to call {@link Utils#followGoogleRedirectIfNeeded(String)} on the url if overriding
|
* Be sure to call {@link Utils#followGoogleRedirectIfNeeded(String)} on the url if overriding
|
||||||
* this function.
|
* this function.
|
||||||
|
*
|
||||||
* @param url the url to extract path and id from
|
* @param url the url to extract path and id from
|
||||||
* @return a {@link LinkHandler} complete with information
|
* @return a {@link LinkHandler} complete with information
|
||||||
*/
|
*/
|
||||||
|
@ -64,12 +66,15 @@ public abstract class LinkHandlerFactory {
|
||||||
* extracted?).<br>
|
* extracted?).<br>
|
||||||
* So do not call {@link Utils#followGoogleRedirectIfNeeded(String)} on the URL if overriding
|
* So do not call {@link Utils#followGoogleRedirectIfNeeded(String)} on the URL if overriding
|
||||||
* this function, since that should be done in {@link #fromUrl(String)}.
|
* this function, since that should be done in {@link #fromUrl(String)}.
|
||||||
* @param url the URL without Google search redirects to extract id from
|
*
|
||||||
|
* @param url the URL without Google search redirects to extract id from
|
||||||
* @param baseUrl the base URL
|
* @param baseUrl the base URL
|
||||||
* @return a {@link LinkHandler} complete with information
|
* @return a {@link LinkHandler} complete with information
|
||||||
*/
|
*/
|
||||||
public LinkHandler fromUrl(String url, String baseUrl) throws ParsingException {
|
public LinkHandler fromUrl(final String url, final String baseUrl) throws ParsingException {
|
||||||
if (url == null) throw new IllegalArgumentException("URL cannot be null");
|
if (url == null) {
|
||||||
|
throw new IllegalArgumentException("URL cannot be null");
|
||||||
|
}
|
||||||
if (!acceptUrl(url)) {
|
if (!acceptUrl(url)) {
|
||||||
throw new ParsingException("URL not accepted: " + url);
|
throw new ParsingException("URL not accepted: " + url);
|
||||||
}
|
}
|
||||||
|
@ -78,14 +83,18 @@ public abstract class LinkHandlerFactory {
|
||||||
return new LinkHandler(url, getUrl(id, baseUrl), id);
|
return new LinkHandler(url, getUrl(id, baseUrl), id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkHandler fromId(String id) throws ParsingException {
|
public LinkHandler fromId(final String id) throws ParsingException {
|
||||||
if (id == null) throw new IllegalArgumentException("id can not be null");
|
if (id == null) {
|
||||||
|
throw new IllegalArgumentException("id can not be null");
|
||||||
|
}
|
||||||
final String url = getUrl(id);
|
final String url = getUrl(id);
|
||||||
return new LinkHandler(url, url, id);
|
return new LinkHandler(url, url, id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public LinkHandler fromId(String id, String baseUrl) throws ParsingException {
|
public LinkHandler fromId(final String id, final String baseUrl) throws ParsingException {
|
||||||
if (id == null) throw new IllegalArgumentException("id can not be null");
|
if (id == null) {
|
||||||
|
throw new IllegalArgumentException("id can not be null");
|
||||||
|
}
|
||||||
final String url = getUrl(id, baseUrl);
|
final String url = getUrl(id, baseUrl);
|
||||||
return new LinkHandler(url, url, id);
|
return new LinkHandler(url, url, id);
|
||||||
}
|
}
|
||||||
|
@ -96,11 +105,6 @@ public abstract class LinkHandlerFactory {
|
||||||
* Return false if this service shall not allow to be called through ACTIONs.
|
* Return false if this service shall not allow to be called through ACTIONs.
|
||||||
*/
|
*/
|
||||||
public boolean acceptUrl(final String url) throws ParsingException {
|
public boolean acceptUrl(final String url) throws ParsingException {
|
||||||
try {
|
return onAcceptUrl(url);
|
||||||
return onAcceptUrl(url);
|
|
||||||
} catch (FoundAdException fe) {
|
|
||||||
throw fe;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,17 +7,17 @@ public class ListLinkHandler extends LinkHandler {
|
||||||
protected final List<String> contentFilters;
|
protected final List<String> contentFilters;
|
||||||
protected final String sortFilter;
|
protected final String sortFilter;
|
||||||
|
|
||||||
public ListLinkHandler(String originalUrl,
|
public ListLinkHandler(final String originalUrl,
|
||||||
String url,
|
final String url,
|
||||||
String id,
|
final String id,
|
||||||
List<String> contentFilters,
|
final List<String> contentFilters,
|
||||||
String sortFilter) {
|
final String sortFilter) {
|
||||||
super(originalUrl, url, id);
|
super(originalUrl, url, id);
|
||||||
this.contentFilters = Collections.unmodifiableList(contentFilters);
|
this.contentFilters = Collections.unmodifiableList(contentFilters);
|
||||||
this.sortFilter = sortFilter;
|
this.sortFilter = sortFilter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListLinkHandler(ListLinkHandler handler) {
|
public ListLinkHandler(final ListLinkHandler handler) {
|
||||||
this(handler.originalUrl,
|
this(handler.originalUrl,
|
||||||
handler.url,
|
handler.url,
|
||||||
handler.id,
|
handler.id,
|
||||||
|
@ -25,9 +25,9 @@ public class ListLinkHandler extends LinkHandler {
|
||||||
handler.sortFilter);
|
handler.sortFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListLinkHandler(LinkHandler handler,
|
public ListLinkHandler(final LinkHandler handler,
|
||||||
List<String> contentFilters,
|
final List<String> contentFilters,
|
||||||
String sortFilter) {
|
final String sortFilter) {
|
||||||
this(handler.originalUrl,
|
this(handler.originalUrl,
|
||||||
handler.url,
|
handler.url,
|
||||||
handler.id,
|
handler.id,
|
||||||
|
|
|
@ -13,17 +13,23 @@ public abstract class ListLinkHandlerFactory extends LinkHandlerFactory {
|
||||||
// To Override
|
// To Override
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
|
|
||||||
public List<String> getContentFilter(String url) throws ParsingException {
|
@SuppressWarnings({"RedundantThrows", "unused"})
|
||||||
|
public List<String> getContentFilter(final String url) throws ParsingException {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSortFilter(String url) throws ParsingException {
|
@SuppressWarnings({"RedundantThrows", "unused"})
|
||||||
|
public String getSortFilter(final String url) throws ParsingException {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract String getUrl(String id, List<String> contentFilter, String sortFilter) throws ParsingException;
|
public abstract String getUrl(String id, List<String> contentFilter, String sortFilter)
|
||||||
|
throws ParsingException;
|
||||||
|
|
||||||
public String getUrl(String id, List<String> contentFilter, String sortFilter, String baseUrl) throws ParsingException {
|
public String getUrl(final String id,
|
||||||
|
final List<String> contentFilter,
|
||||||
|
final String sortFilter,
|
||||||
|
final String baseUrl) throws ParsingException {
|
||||||
return getUrl(id, contentFilter, sortFilter);
|
return getUrl(id, contentFilter, sortFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,55 +45,59 @@ public abstract class ListLinkHandlerFactory extends LinkHandlerFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ListLinkHandler fromUrl(String url, String baseUrl) throws ParsingException {
|
public ListLinkHandler fromUrl(final String url, final String baseUrl) throws ParsingException {
|
||||||
if (url == null) throw new IllegalArgumentException("url may not be null");
|
if (url == null) {
|
||||||
|
throw new IllegalArgumentException("url may not be null");
|
||||||
|
}
|
||||||
|
|
||||||
return new ListLinkHandler(super.fromUrl(url, baseUrl), getContentFilter(url), getSortFilter(url));
|
return new ListLinkHandler(super.fromUrl(url, baseUrl), getContentFilter(url),
|
||||||
|
getSortFilter(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ListLinkHandler fromId(String id) throws ParsingException {
|
public ListLinkHandler fromId(final String id) throws ParsingException {
|
||||||
return new ListLinkHandler(super.fromId(id), new ArrayList<String>(0), "");
|
return new ListLinkHandler(super.fromId(id), new ArrayList<>(0), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ListLinkHandler fromId(String id, String baseUrl) throws ParsingException {
|
public ListLinkHandler fromId(final String id, final String baseUrl) throws ParsingException {
|
||||||
return new ListLinkHandler(super.fromId(id, baseUrl), new ArrayList<String>(0), "");
|
return new ListLinkHandler(super.fromId(id, baseUrl), new ArrayList<>(0), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListLinkHandler fromQuery(String id,
|
public ListLinkHandler fromQuery(final String id,
|
||||||
List<String> contentFilters,
|
final List<String> contentFilters,
|
||||||
String sortFilter) throws ParsingException {
|
final String sortFilter) throws ParsingException {
|
||||||
final String url = getUrl(id, contentFilters, sortFilter);
|
final String url = getUrl(id, contentFilters, sortFilter);
|
||||||
return new ListLinkHandler(url, url, id, contentFilters, sortFilter);
|
return new ListLinkHandler(url, url, id, contentFilters, sortFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ListLinkHandler fromQuery(String id,
|
public ListLinkHandler fromQuery(final String id,
|
||||||
List<String> contentFilters,
|
final List<String> contentFilters,
|
||||||
String sortFilter, String baseUrl) throws ParsingException {
|
final String sortFilter,
|
||||||
|
final String baseUrl) throws ParsingException {
|
||||||
final String url = getUrl(id, contentFilters, sortFilter, baseUrl);
|
final String url = getUrl(id, contentFilters, sortFilter, baseUrl);
|
||||||
return new ListLinkHandler(url, url, id, contentFilters, sortFilter);
|
return new ListLinkHandler(url, url, id, contentFilters, sortFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* For making ListLinkHandlerFactory compatible with LinkHandlerFactory we need to override this,
|
* For making ListLinkHandlerFactory compatible with LinkHandlerFactory we need to override
|
||||||
* however it should not be overridden by the actual implementation.
|
* this, however it should not be overridden by the actual implementation.
|
||||||
*
|
*
|
||||||
* @param id
|
|
||||||
* @return the url corresponding to id without any filters applied
|
* @return the url corresponding to id without any filters applied
|
||||||
*/
|
*/
|
||||||
public String getUrl(String id) throws ParsingException {
|
public String getUrl(final String id) throws ParsingException {
|
||||||
return getUrl(id, new ArrayList<String>(0), "");
|
return getUrl(id, new ArrayList<>(0), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getUrl(String id, String baseUrl) throws ParsingException {
|
public String getUrl(final String id, final String baseUrl) throws ParsingException {
|
||||||
return getUrl(id, new ArrayList<String>(0), "", baseUrl);
|
return getUrl(id, new ArrayList<>(0), "", baseUrl);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will returns content filter the corresponding extractor can handle like "channels", "videos", "music", etc.
|
* Will returns content filter the corresponding extractor can handle like "channels", "videos",
|
||||||
|
* "music", etc.
|
||||||
*
|
*
|
||||||
* @return filter that can be applied when building a query for getting a list
|
* @return filter that can be applied when building a query for getting a list
|
||||||
*/
|
*/
|
||||||
|
@ -96,7 +106,8 @@ public abstract class ListLinkHandlerFactory extends LinkHandlerFactory {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will returns sort filter the corresponding extractor can handle like "A-Z", "oldest first", "size", etc.
|
* Will returns sort filter the corresponding extractor can handle like "A-Z", "oldest first",
|
||||||
|
* "size", etc.
|
||||||
*
|
*
|
||||||
* @return filter that can be applied when building a query for getting a list
|
* @return filter that can be applied when building a query for getting a list
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -4,15 +4,15 @@ import java.util.List;
|
||||||
|
|
||||||
public class SearchQueryHandler extends ListLinkHandler {
|
public class SearchQueryHandler extends ListLinkHandler {
|
||||||
|
|
||||||
public SearchQueryHandler(String originalUrl,
|
public SearchQueryHandler(final String originalUrl,
|
||||||
String url,
|
final String url,
|
||||||
String searchString,
|
final String searchString,
|
||||||
List<String> contentFilters,
|
final List<String> contentFilters,
|
||||||
String sortFilter) {
|
final String sortFilter) {
|
||||||
super(originalUrl, url, searchString, contentFilters, sortFilter);
|
super(originalUrl, url, searchString, contentFilters, sortFilter);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearchQueryHandler(ListLinkHandler handler) {
|
public SearchQueryHandler(final ListLinkHandler handler) {
|
||||||
this(handler.originalUrl,
|
this(handler.originalUrl,
|
||||||
handler.url,
|
handler.url,
|
||||||
handler.id,
|
handler.id,
|
||||||
|
|
|
@ -14,9 +14,11 @@ public abstract class SearchQueryHandlerFactory extends ListLinkHandlerFactory {
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public abstract String getUrl(String query, List<String> contentFilter, String sortFilter) throws ParsingException;
|
public abstract String getUrl(String query, List<String> contentFilter, String sortFilter)
|
||||||
|
throws ParsingException;
|
||||||
|
|
||||||
public String getSearchString(String url) {
|
@SuppressWarnings("unused")
|
||||||
|
public String getSearchString(final String url) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,28 +27,26 @@ public abstract class SearchQueryHandlerFactory extends ListLinkHandlerFactory {
|
||||||
///////////////////////////////////
|
///////////////////////////////////
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getId(String url) {
|
public String getId(final String url) {
|
||||||
return getSearchString(url);
|
return getSearchString(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SearchQueryHandler fromQuery(String query,
|
public SearchQueryHandler fromQuery(final String query,
|
||||||
List<String> contentFilter,
|
final List<String> contentFilter,
|
||||||
String sortFilter) throws ParsingException {
|
final String sortFilter) throws ParsingException {
|
||||||
return new SearchQueryHandler(super.fromQuery(query, contentFilter, sortFilter));
|
return new SearchQueryHandler(super.fromQuery(query, contentFilter, sortFilter));
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearchQueryHandler fromQuery(String query) throws ParsingException {
|
public SearchQueryHandler fromQuery(final String query) throws ParsingException {
|
||||||
return fromQuery(query, new ArrayList<>(0), EMPTY_STRING);
|
return fromQuery(query, new ArrayList<>(0), EMPTY_STRING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* It's not mandatory for NewPipe to handle the Url
|
* It's not mandatory for NewPipe to handle the Url
|
||||||
*
|
|
||||||
* @param url
|
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean onAcceptUrl(String url) {
|
public boolean onAcceptUrl(final String url) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
package org.schabi.newpipe.extractor.localization;
|
package org.schabi.newpipe.extractor.localization;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
@ -9,23 +10,26 @@ import java.util.List;
|
||||||
/**
|
/**
|
||||||
* Represents a country that should be used when fetching content.
|
* Represents a country that should be used when fetching content.
|
||||||
* <p>
|
* <p>
|
||||||
* YouTube, for example, give different results in their feed depending on which country is selected.
|
* YouTube, for example, give different results in their feed depending on which country is
|
||||||
|
* selected.
|
||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class ContentCountry implements Serializable {
|
public class ContentCountry implements Serializable {
|
||||||
public static final ContentCountry DEFAULT = new ContentCountry(Localization.DEFAULT.getCountryCode());
|
public static final ContentCountry DEFAULT =
|
||||||
|
new ContentCountry(Localization.DEFAULT.getCountryCode());
|
||||||
|
|
||||||
@Nonnull private final String countryCode;
|
@Nonnull
|
||||||
|
private final String countryCode;
|
||||||
|
|
||||||
public static List<ContentCountry> listFrom(String... countryCodeList) {
|
public static List<ContentCountry> listFrom(final String... countryCodeList) {
|
||||||
final List<ContentCountry> toReturn = new ArrayList<>();
|
final List<ContentCountry> toReturn = new ArrayList<>();
|
||||||
for (String countryCode : countryCodeList) {
|
for (final String countryCode : countryCodeList) {
|
||||||
toReturn.add(new ContentCountry(countryCode));
|
toReturn.add(new ContentCountry(countryCode));
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableList(toReturn);
|
return Collections.unmodifiableList(toReturn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ContentCountry(@Nonnull String countryCode) {
|
public ContentCountry(@Nonnull final String countryCode) {
|
||||||
this.countryCode = countryCode;
|
this.countryCode = countryCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,11 +44,15 @@ public class ContentCountry implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(final Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) {
|
||||||
if (!(o instanceof ContentCountry)) return false;
|
return true;
|
||||||
|
}
|
||||||
|
if (!(o instanceof ContentCountry)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
ContentCountry that = (ContentCountry) o;
|
final ContentCountry that = (ContentCountry) o;
|
||||||
|
|
||||||
return countryCode.equals(that.countryCode);
|
return countryCode.equals(that.countryCode);
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,7 +9,8 @@ import java.util.Calendar;
|
||||||
import java.util.GregorianCalendar;
|
import java.util.GregorianCalendar;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A wrapper class that provides a field to describe if the date/time is precise or just an approximation.
|
* A wrapper class that provides a field to describe if the date/time is precise or just an
|
||||||
|
* approximation.
|
||||||
*/
|
*/
|
||||||
public class DateWrapper implements Serializable {
|
public class DateWrapper implements Serializable {
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -20,7 +21,8 @@ public class DateWrapper implements Serializable {
|
||||||
* @deprecated Use {@link #DateWrapper(OffsetDateTime)} instead.
|
* @deprecated Use {@link #DateWrapper(OffsetDateTime)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public DateWrapper(@Nonnull Calendar calendar) {
|
public DateWrapper(@Nonnull final Calendar calendar) {
|
||||||
|
//noinspection deprecation
|
||||||
this(calendar, false);
|
this(calendar, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,15 +30,16 @@ public class DateWrapper implements Serializable {
|
||||||
* @deprecated Use {@link #DateWrapper(OffsetDateTime, boolean)} instead.
|
* @deprecated Use {@link #DateWrapper(OffsetDateTime, boolean)} instead.
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public DateWrapper(@Nonnull Calendar calendar, boolean isApproximation) {
|
public DateWrapper(@Nonnull final Calendar calendar, final boolean isApproximation) {
|
||||||
this(OffsetDateTime.ofInstant(calendar.toInstant(), ZoneOffset.UTC), isApproximation);
|
this(OffsetDateTime.ofInstant(calendar.toInstant(), ZoneOffset.UTC), isApproximation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateWrapper(@Nonnull OffsetDateTime offsetDateTime) {
|
public DateWrapper(@Nonnull final OffsetDateTime offsetDateTime) {
|
||||||
this(offsetDateTime, false);
|
this(offsetDateTime, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DateWrapper(@Nonnull OffsetDateTime offsetDateTime, boolean isApproximation) {
|
public DateWrapper(@Nonnull final OffsetDateTime offsetDateTime,
|
||||||
|
final boolean isApproximation) {
|
||||||
this.offsetDateTime = offsetDateTime.withOffsetSameInstant(ZoneOffset.UTC);
|
this.offsetDateTime = offsetDateTime.withOffsetSameInstant(ZoneOffset.UTC);
|
||||||
this.isApproximation = isApproximation;
|
this.isApproximation = isApproximation;
|
||||||
}
|
}
|
||||||
|
@ -60,8 +63,8 @@ public class DateWrapper implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return if the date is considered is precise or just an approximation (e.g. service only returns an approximation
|
* @return if the date is considered is precise or just an approximation (e.g. service only
|
||||||
* like 2 weeks ago instead of a precise date).
|
* returns an approximation like 2 weeks ago instead of a precise date).
|
||||||
*/
|
*/
|
||||||
public boolean isApproximation() {
|
public boolean isApproximation() {
|
||||||
return isApproximation;
|
return isApproximation;
|
||||||
|
|
|
@ -4,8 +4,15 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Localization implements Serializable {
|
public class Localization implements Serializable {
|
||||||
public static final Localization DEFAULT = new Localization("en", "GB");
|
public static final Localization DEFAULT = new Localization("en", "GB");
|
||||||
|
@ -16,11 +23,12 @@ public class Localization implements Serializable {
|
||||||
private final String countryCode;
|
private final String countryCode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param localizationCodeList a list of localization code, formatted like {@link #getLocalizationCode()}
|
* @param localizationCodeList a list of localization code, formatted like {@link
|
||||||
|
* #getLocalizationCode()}
|
||||||
*/
|
*/
|
||||||
public static List<Localization> listFrom(String... localizationCodeList) {
|
public static List<Localization> listFrom(final String... localizationCodeList) {
|
||||||
final List<Localization> toReturn = new ArrayList<>();
|
final List<Localization> toReturn = new ArrayList<>();
|
||||||
for (String localizationCode : localizationCodeList) {
|
for (final String localizationCode : localizationCodeList) {
|
||||||
toReturn.add(fromLocalizationCode(localizationCode));
|
toReturn.add(fromLocalizationCode(localizationCode));
|
||||||
}
|
}
|
||||||
return Collections.unmodifiableList(toReturn);
|
return Collections.unmodifiableList(toReturn);
|
||||||
|
@ -29,10 +37,11 @@ public class Localization implements Serializable {
|
||||||
/**
|
/**
|
||||||
* @param localizationCode a localization code, formatted like {@link #getLocalizationCode()}
|
* @param localizationCode a localization code, formatted like {@link #getLocalizationCode()}
|
||||||
*/
|
*/
|
||||||
public static Localization fromLocalizationCode(String localizationCode) {
|
public static Localization fromLocalizationCode(final String localizationCode) {
|
||||||
final int indexSeparator = localizationCode.indexOf("-");
|
final int indexSeparator = localizationCode.indexOf("-");
|
||||||
|
|
||||||
final String languageCode, countryCode;
|
final String languageCode;
|
||||||
|
final String countryCode;
|
||||||
if (indexSeparator != -1) {
|
if (indexSeparator != -1) {
|
||||||
languageCode = localizationCode.substring(0, indexSeparator);
|
languageCode = localizationCode.substring(0, indexSeparator);
|
||||||
countryCode = localizationCode.substring(indexSeparator + 1);
|
countryCode = localizationCode.substring(indexSeparator + 1);
|
||||||
|
@ -44,15 +53,16 @@ public class Localization implements Serializable {
|
||||||
return new Localization(languageCode, countryCode);
|
return new Localization(languageCode, countryCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Localization(@Nonnull String languageCode, @Nullable String countryCode) {
|
public Localization(@Nonnull final String languageCode, @Nullable final String countryCode) {
|
||||||
this.languageCode = languageCode;
|
this.languageCode = languageCode;
|
||||||
this.countryCode = countryCode;
|
this.countryCode = countryCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Localization(@Nonnull String languageCode) {
|
public Localization(@Nonnull final String languageCode) {
|
||||||
this(languageCode, null);
|
this(languageCode, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
public String getLanguageCode() {
|
public String getLanguageCode() {
|
||||||
return languageCode;
|
return languageCode;
|
||||||
}
|
}
|
||||||
|
@ -66,7 +76,7 @@ public class Localization implements Serializable {
|
||||||
return new Locale(getLanguageCode(), getCountryCode());
|
return new Locale(getLanguageCode(), getCountryCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Localization fromLocale(@Nonnull Locale locale) {
|
public static Localization fromLocale(@Nonnull final Locale locale) {
|
||||||
return new Localization(locale.getLanguage(), locale.getCountry());
|
return new Localization(locale.getLanguage(), locale.getCountry());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,14 +94,18 @@ public class Localization implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(final Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) {
|
||||||
if (!(o instanceof Localization)) return false;
|
return true;
|
||||||
|
}
|
||||||
|
if (!(o instanceof Localization)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
Localization that = (Localization) o;
|
final Localization that = (Localization) o;
|
||||||
|
|
||||||
return languageCode.equals(that.languageCode) &&
|
return languageCode.equals(that.languageCode)
|
||||||
Objects.equals(countryCode, that.countryCode);
|
&& Objects.equals(countryCode, that.countryCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -108,17 +122,19 @@ public class Localization implements Serializable {
|
||||||
* @param code a three letter language code
|
* @param code a three letter language code
|
||||||
* @return the Locale corresponding
|
* @return the Locale corresponding
|
||||||
*/
|
*/
|
||||||
public static Locale getLocaleFromThreeLetterCode(@Nonnull String code) throws ParsingException {
|
public static Locale getLocaleFromThreeLetterCode(@Nonnull final String code)
|
||||||
|
throws ParsingException {
|
||||||
final String[] languages = Locale.getISOLanguages();
|
final String[] languages = Locale.getISOLanguages();
|
||||||
final Map<String, Locale> localeMap = new HashMap<>(languages.length);
|
final Map<String, Locale> localeMap = new HashMap<>(languages.length);
|
||||||
for (String language : languages) {
|
for (final String language : languages) {
|
||||||
final Locale locale = new Locale(language);
|
final Locale locale = new Locale(language);
|
||||||
localeMap.put(locale.getISO3Language(), locale);
|
localeMap.put(locale.getISO3Language(), locale);
|
||||||
}
|
}
|
||||||
if (localeMap.containsKey(code)) {
|
if (localeMap.containsKey(code)) {
|
||||||
return localeMap.get(code);
|
return localeMap.get(code);
|
||||||
} else {
|
} else {
|
||||||
throw new ParsingException("Could not get Locale from this three letter language code" + code);
|
throw new ParsingException(
|
||||||
|
"Could not get Locale from this three letter language code" + code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,16 +25,17 @@ public class TimeAgoParser {
|
||||||
* Instantiate a new {@link TimeAgoParser} every time you extract a new batch of items.
|
* Instantiate a new {@link TimeAgoParser} every time you extract a new batch of items.
|
||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param patternsHolder An object that holds the "time ago" patterns, special cases, and the language word separator.
|
* @param patternsHolder An object that holds the "time ago" patterns, special cases, and the
|
||||||
|
* language word separator.
|
||||||
*/
|
*/
|
||||||
public TimeAgoParser(PatternsHolder patternsHolder) {
|
public TimeAgoParser(final PatternsHolder patternsHolder) {
|
||||||
this.patternsHolder = patternsHolder;
|
this.patternsHolder = patternsHolder;
|
||||||
now = OffsetDateTime.now(ZoneOffset.UTC);
|
now = OffsetDateTime.now(ZoneOffset.UTC);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses a textual date in the format '2 days ago' into a Calendar representation which is then wrapped in a
|
* Parses a textual date in the format '2 days ago' into a Calendar representation which is then
|
||||||
* {@link DateWrapper} object.
|
* wrapped in a {@link DateWrapper} object.
|
||||||
* <p>
|
* <p>
|
||||||
* Beginning with days ago, the date is considered as an approximation.
|
* Beginning with days ago, the date is considered as an approximation.
|
||||||
*
|
*
|
||||||
|
@ -42,10 +43,12 @@ public class TimeAgoParser {
|
||||||
* @return The parsed time (can be approximated)
|
* @return The parsed time (can be approximated)
|
||||||
* @throws ParsingException if the time unit could not be recognized
|
* @throws ParsingException if the time unit could not be recognized
|
||||||
*/
|
*/
|
||||||
public DateWrapper parse(String textualDate) throws ParsingException {
|
public DateWrapper parse(final String textualDate) throws ParsingException {
|
||||||
for (Map.Entry<ChronoUnit, Map<String, Integer>> caseUnitEntry : patternsHolder.specialCases().entrySet()) {
|
for (final Map.Entry<ChronoUnit, Map<String, Integer>> caseUnitEntry
|
||||||
|
: patternsHolder.specialCases().entrySet()) {
|
||||||
final ChronoUnit chronoUnit = caseUnitEntry.getKey();
|
final ChronoUnit chronoUnit = caseUnitEntry.getKey();
|
||||||
for (Map.Entry<String, Integer> caseMapToAmountEntry : caseUnitEntry.getValue().entrySet()) {
|
for (final Map.Entry<String, Integer> caseMapToAmountEntry
|
||||||
|
: caseUnitEntry.getValue().entrySet()) {
|
||||||
final String caseText = caseMapToAmountEntry.getKey();
|
final String caseText = caseMapToAmountEntry.getKey();
|
||||||
final Integer caseAmount = caseMapToAmountEntry.getValue();
|
final Integer caseAmount = caseMapToAmountEntry.getValue();
|
||||||
|
|
||||||
|
@ -58,7 +61,7 @@ public class TimeAgoParser {
|
||||||
int timeAgoAmount;
|
int timeAgoAmount;
|
||||||
try {
|
try {
|
||||||
timeAgoAmount = parseTimeAgoAmount(textualDate);
|
timeAgoAmount = parseTimeAgoAmount(textualDate);
|
||||||
} catch (NumberFormatException e) {
|
} catch (final NumberFormatException e) {
|
||||||
// If there is no valid number in the textual date,
|
// If there is no valid number in the textual date,
|
||||||
// assume it is 1 (as in 'a second ago').
|
// assume it is 1 (as in 'a second ago').
|
||||||
timeAgoAmount = 1;
|
timeAgoAmount = 1;
|
||||||
|
@ -68,16 +71,16 @@ public class TimeAgoParser {
|
||||||
return getResultFor(timeAgoAmount, chronoUnit);
|
return getResultFor(timeAgoAmount, chronoUnit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int parseTimeAgoAmount(String textualDate) throws NumberFormatException {
|
private int parseTimeAgoAmount(final String textualDate) throws NumberFormatException {
|
||||||
String timeValueStr = textualDate.replaceAll("\\D+", "");
|
return Integer.parseInt(textualDate.replaceAll("\\D+", ""));
|
||||||
return Integer.parseInt(timeValueStr);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private ChronoUnit parseChronoUnit(String textualDate) throws ParsingException {
|
private ChronoUnit parseChronoUnit(final String textualDate) throws ParsingException {
|
||||||
for (Map.Entry<ChronoUnit, Collection<String>> entry : patternsHolder.asMap().entrySet()) {
|
for (final Map.Entry<ChronoUnit, Collection<String>> entry
|
||||||
|
: patternsHolder.asMap().entrySet()) {
|
||||||
final ChronoUnit chronoUnit = entry.getKey();
|
final ChronoUnit chronoUnit = entry.getKey();
|
||||||
|
|
||||||
for (String agoPhrase : entry.getValue()) {
|
for (final String agoPhrase : entry.getValue()) {
|
||||||
if (textualDateMatches(textualDate, agoPhrase)) {
|
if (textualDateMatches(textualDate, agoPhrase)) {
|
||||||
return chronoUnit;
|
return chronoUnit;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +90,7 @@ public class TimeAgoParser {
|
||||||
throw new ParsingException("Unable to parse the date: " + textualDate);
|
throw new ParsingException("Unable to parse the date: " + textualDate);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean textualDateMatches(String textualDate, String agoPhrase) {
|
private boolean textualDateMatches(final String textualDate, final String agoPhrase) {
|
||||||
if (textualDate.equals(agoPhrase)) {
|
if (textualDate.equals(agoPhrase)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -98,7 +101,8 @@ public class TimeAgoParser {
|
||||||
final String escapedPhrase = Pattern.quote(agoPhrase.toLowerCase());
|
final String escapedPhrase = Pattern.quote(agoPhrase.toLowerCase());
|
||||||
final String escapedSeparator;
|
final String escapedSeparator;
|
||||||
if (patternsHolder.wordSeparator().equals(" ")) {
|
if (patternsHolder.wordSeparator().equals(" ")) {
|
||||||
// From JDK8 → \h - Treat horizontal spaces as a normal one (non-breaking space, thin space, etc.)
|
// From JDK8 → \h - Treat horizontal spaces as a normal one
|
||||||
|
// (non-breaking space, thin space, etc.)
|
||||||
escapedSeparator = "[ \\t\\xA0\\u1680\\u180e\\u2000-\\u200a\\u202f\\u205f\\u3000]";
|
escapedSeparator = "[ \\t\\xA0\\u1680\\u180e\\u2000-\\u200a\\u202f\\u205f\\u3000]";
|
||||||
} else {
|
} else {
|
||||||
escapedSeparator = Pattern.quote(patternsHolder.wordSeparator());
|
escapedSeparator = Pattern.quote(patternsHolder.wordSeparator());
|
||||||
|
@ -113,7 +117,7 @@ public class TimeAgoParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private DateWrapper getResultFor(int timeAgoAmount, ChronoUnit chronoUnit) {
|
private DateWrapper getResultFor(final int timeAgoAmount, final ChronoUnit chronoUnit) {
|
||||||
OffsetDateTime offsetDateTime = now;
|
OffsetDateTime offsetDateTime = now;
|
||||||
boolean isApproximation = false;
|
boolean isApproximation = false;
|
||||||
|
|
||||||
|
|
|
@ -6,14 +6,18 @@ import org.schabi.newpipe.extractor.timeago.PatternsManager;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
public class TimeAgoPatternsManager {
|
public final class TimeAgoPatternsManager {
|
||||||
@Nullable
|
private TimeAgoPatternsManager() {
|
||||||
private static PatternsHolder getPatternsFor(@Nonnull Localization localization) {
|
|
||||||
return PatternsManager.getPatterns(localization.getLanguageCode(), localization.getCountryCode());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public static TimeAgoParser getTimeAgoParserFor(@Nonnull Localization localization) {
|
private static PatternsHolder getPatternsFor(@Nonnull final Localization localization) {
|
||||||
|
return PatternsManager.getPatterns(localization.getLanguageCode(),
|
||||||
|
localization.getCountryCode());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public static TimeAgoParser getTimeAgoParserFor(@Nonnull final Localization localization) {
|
||||||
final PatternsHolder holder = getPatternsFor(localization);
|
final PatternsHolder holder = getPatternsFor(localization);
|
||||||
|
|
||||||
if (holder == null) {
|
if (holder == null) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import java.io.IOException;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
public final class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mixes are handled as particular playlists in NewPipeExtractor. {@link PlaylistType#NORMAL} is
|
* Mixes are handled as particular playlists in NewPipeExtractor. {@link PlaylistType#NORMAL} is
|
||||||
|
@ -52,23 +52,27 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||||
MIX_GENRE,
|
MIX_GENRE,
|
||||||
}
|
}
|
||||||
|
|
||||||
private PlaylistInfo(int serviceId, ListLinkHandler linkHandler, String name) throws ParsingException {
|
@SuppressWarnings("RedundantThrows")
|
||||||
|
private PlaylistInfo(final int serviceId, final ListLinkHandler linkHandler, final String name)
|
||||||
|
throws ParsingException {
|
||||||
super(serviceId, linkHandler, name);
|
super(serviceId, linkHandler, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlaylistInfo getInfo(String url) throws IOException, ExtractionException {
|
public static PlaylistInfo getInfo(final String url) throws IOException, ExtractionException {
|
||||||
return getInfo(NewPipe.getServiceByUrl(url), url);
|
return getInfo(NewPipe.getServiceByUrl(url), url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static PlaylistInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
|
public static PlaylistInfo getInfo(final StreamingService service, final String url)
|
||||||
PlaylistExtractor extractor = service.getPlaylistExtractor(url);
|
throws IOException, ExtractionException {
|
||||||
|
final PlaylistExtractor extractor = service.getPlaylistExtractor(url);
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
return getInfo(extractor);
|
return getInfo(extractor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static InfoItemsPage<StreamInfoItem> getMoreItems(StreamingService service,
|
public static InfoItemsPage<StreamInfoItem> getMoreItems(final StreamingService service,
|
||||||
String url,
|
final String url,
|
||||||
Page page) throws IOException, ExtractionException {
|
final Page page)
|
||||||
|
throws IOException, ExtractionException {
|
||||||
return service.getPlaylistExtractor(url).getPage(page);
|
return service.getPlaylistExtractor(url).getPage(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,7 +81,8 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||||
*
|
*
|
||||||
* @param extractor an extractor where fetchPage() was already got called on.
|
* @param extractor an extractor where fetchPage() was already got called on.
|
||||||
*/
|
*/
|
||||||
public static PlaylistInfo getInfo(PlaylistExtractor extractor) throws ExtractionException {
|
public static PlaylistInfo getInfo(final PlaylistExtractor extractor)
|
||||||
|
throws ExtractionException {
|
||||||
|
|
||||||
final PlaylistInfo info = new PlaylistInfo(
|
final PlaylistInfo info = new PlaylistInfo(
|
||||||
extractor.getServiceId(),
|
extractor.getServiceId(),
|
||||||
|
@ -85,73 +90,75 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||||
extractor.getName());
|
extractor.getName());
|
||||||
// collect uploader extraction failures until we are sure this is not
|
// collect uploader extraction failures until we are sure this is not
|
||||||
// just a playlist without an uploader
|
// just a playlist without an uploader
|
||||||
List<Throwable> uploaderParsingErrors = new ArrayList<Throwable>(3);
|
final List<Throwable> uploaderParsingErrors = new ArrayList<>();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
info.setOriginalUrl(extractor.getOriginalUrl());
|
info.setOriginalUrl(extractor.getOriginalUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.setStreamCount(extractor.getStreamCount());
|
info.setStreamCount(extractor.getStreamCount());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.setThumbnailUrl(extractor.getThumbnailUrl());
|
info.setThumbnailUrl(extractor.getThumbnailUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.setUploaderUrl(extractor.getUploaderUrl());
|
info.setUploaderUrl(extractor.getUploaderUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.setUploaderUrl("");
|
info.setUploaderUrl("");
|
||||||
uploaderParsingErrors.add(e);
|
uploaderParsingErrors.add(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.setUploaderName(extractor.getUploaderName());
|
info.setUploaderName(extractor.getUploaderName());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.setUploaderName("");
|
info.setUploaderName("");
|
||||||
uploaderParsingErrors.add(e);
|
uploaderParsingErrors.add(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
|
info.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.setUploaderAvatarUrl("");
|
info.setUploaderAvatarUrl("");
|
||||||
uploaderParsingErrors.add(e);
|
uploaderParsingErrors.add(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.setSubChannelUrl(extractor.getSubChannelUrl());
|
info.setSubChannelUrl(extractor.getSubChannelUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
uploaderParsingErrors.add(e);
|
uploaderParsingErrors.add(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.setSubChannelName(extractor.getSubChannelName());
|
info.setSubChannelName(extractor.getSubChannelName());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
uploaderParsingErrors.add(e);
|
uploaderParsingErrors.add(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.setSubChannelAvatarUrl(extractor.getSubChannelAvatarUrl());
|
info.setSubChannelAvatarUrl(extractor.getSubChannelAvatarUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
uploaderParsingErrors.add(e);
|
uploaderParsingErrors.add(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.setBannerUrl(extractor.getBannerUrl());
|
info.setBannerUrl(extractor.getBannerUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.setPlaylistType(extractor.getPlaylistType());
|
info.setPlaylistType(extractor.getPlaylistType());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
// do not fail if everything but the uploader infos could be collected
|
|
||||||
if (!uploaderParsingErrors.isEmpty() &&
|
// do not fail if everything but the uploader infos could be collected (TODO better comment)
|
||||||
(!info.getErrors().isEmpty() || uploaderParsingErrors.size() < 3)) {
|
if (!uploaderParsingErrors.isEmpty()
|
||||||
|
&& (!info.getErrors().isEmpty() || uploaderParsingErrors.size() < 3)) {
|
||||||
info.addAllErrors(uploaderParsingErrors);
|
info.addAllErrors(uploaderParsingErrors);
|
||||||
}
|
}
|
||||||
|
|
||||||
final InfoItemsPage<StreamInfoItem> itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor);
|
final InfoItemsPage<StreamInfoItem> itemsPage
|
||||||
|
= ExtractorHelper.getItemsPageOrLogError(info, extractor);
|
||||||
info.setRelatedItems(itemsPage.getItems());
|
info.setRelatedItems(itemsPage.getItems());
|
||||||
info.setNextPage(itemsPage.getNextPage());
|
info.setNextPage(itemsPage.getNextPage());
|
||||||
|
|
||||||
|
@ -173,7 +180,7 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||||
return thumbnailUrl;
|
return thumbnailUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setThumbnailUrl(String thumbnailUrl) {
|
public void setThumbnailUrl(final String thumbnailUrl) {
|
||||||
this.thumbnailUrl = thumbnailUrl;
|
this.thumbnailUrl = thumbnailUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +188,7 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||||
return bannerUrl;
|
return bannerUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBannerUrl(String bannerUrl) {
|
public void setBannerUrl(final String bannerUrl) {
|
||||||
this.bannerUrl = bannerUrl;
|
this.bannerUrl = bannerUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +196,7 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||||
return uploaderUrl;
|
return uploaderUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploaderUrl(String uploaderUrl) {
|
public void setUploaderUrl(final String uploaderUrl) {
|
||||||
this.uploaderUrl = uploaderUrl;
|
this.uploaderUrl = uploaderUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,7 +204,7 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||||
return uploaderName;
|
return uploaderName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploaderName(String uploaderName) {
|
public void setUploaderName(final String uploaderName) {
|
||||||
this.uploaderName = uploaderName;
|
this.uploaderName = uploaderName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,7 +212,7 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||||
return uploaderAvatarUrl;
|
return uploaderAvatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploaderAvatarUrl(String uploaderAvatarUrl) {
|
public void setUploaderAvatarUrl(final String uploaderAvatarUrl) {
|
||||||
this.uploaderAvatarUrl = uploaderAvatarUrl;
|
this.uploaderAvatarUrl = uploaderAvatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -213,7 +220,7 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||||
return subChannelUrl;
|
return subChannelUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubChannelUrl(String subChannelUrl) {
|
public void setSubChannelUrl(final String subChannelUrl) {
|
||||||
this.subChannelUrl = subChannelUrl;
|
this.subChannelUrl = subChannelUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -221,7 +228,7 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||||
return subChannelName;
|
return subChannelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubChannelName(String subChannelName) {
|
public void setSubChannelName(final String subChannelName) {
|
||||||
this.subChannelName = subChannelName;
|
this.subChannelName = subChannelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -229,7 +236,7 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||||
return subChannelAvatarUrl;
|
return subChannelAvatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubChannelAvatarUrl(String subChannelAvatarUrl) {
|
public void setSubChannelAvatarUrl(final String subChannelAvatarUrl) {
|
||||||
this.subChannelAvatarUrl = subChannelAvatarUrl;
|
this.subChannelAvatarUrl = subChannelAvatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -237,7 +244,7 @@ public class PlaylistInfo extends ListInfo<StreamInfoItem> {
|
||||||
return streamCount;
|
return streamCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStreamCount(long streamCount) {
|
public void setStreamCount(final long streamCount) {
|
||||||
this.streamCount = streamCount;
|
this.streamCount = streamCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ public class PlaylistInfoItem extends InfoItem {
|
||||||
private long streamCount = 0;
|
private long streamCount = 0;
|
||||||
private PlaylistInfo.PlaylistType playlistType;
|
private PlaylistInfo.PlaylistType playlistType;
|
||||||
|
|
||||||
public PlaylistInfoItem(int serviceId, String url, String name) {
|
public PlaylistInfoItem(final int serviceId, final String url, final String name) {
|
||||||
super(InfoType.PLAYLIST, serviceId, url, name);
|
super(InfoType.PLAYLIST, serviceId, url, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,16 +19,16 @@ public class PlaylistInfoItem extends InfoItem {
|
||||||
return uploaderName;
|
return uploaderName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploaderName(String uploader_name) {
|
public void setUploaderName(final String uploaderName) {
|
||||||
this.uploaderName = uploader_name;
|
this.uploaderName = uploaderName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getStreamCount() {
|
public long getStreamCount() {
|
||||||
return streamCount;
|
return streamCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStreamCount(long stream_count) {
|
public void setStreamCount(final long streamCount) {
|
||||||
this.streamCount = stream_count;
|
this.streamCount = streamCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlaylistInfo.PlaylistType getPlaylistType() {
|
public PlaylistInfo.PlaylistType getPlaylistType() {
|
||||||
|
|
|
@ -10,14 +10,12 @@ public interface PlaylistInfoItemExtractor extends InfoItemExtractor {
|
||||||
/**
|
/**
|
||||||
* Get the uploader name
|
* Get the uploader name
|
||||||
* @return the uploader name
|
* @return the uploader name
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
String getUploaderName() throws ParsingException;
|
String getUploaderName() throws ParsingException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the number of streams
|
* Get the number of streams
|
||||||
* @return the number of streams
|
* @return the number of streams
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
long getStreamCount() throws ParsingException;
|
long getStreamCount() throws ParsingException;
|
||||||
|
|
||||||
|
|
|
@ -3,34 +3,32 @@ package org.schabi.newpipe.extractor.playlist;
|
||||||
import org.schabi.newpipe.extractor.InfoItemsCollector;
|
import org.schabi.newpipe.extractor.InfoItemsCollector;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
|
||||||
public class PlaylistInfoItemsCollector extends InfoItemsCollector<PlaylistInfoItem, PlaylistInfoItemExtractor> {
|
public class PlaylistInfoItemsCollector
|
||||||
|
extends InfoItemsCollector<PlaylistInfoItem, PlaylistInfoItemExtractor> {
|
||||||
|
|
||||||
public PlaylistInfoItemsCollector(int serviceId) {
|
public PlaylistInfoItemsCollector(final int serviceId) {
|
||||||
super(serviceId);
|
super(serviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlaylistInfoItem extract(PlaylistInfoItemExtractor extractor) throws ParsingException {
|
public PlaylistInfoItem extract(final PlaylistInfoItemExtractor extractor)
|
||||||
|
throws ParsingException {
|
||||||
String name = extractor.getName();
|
final PlaylistInfoItem resultItem = new PlaylistInfoItem(
|
||||||
int serviceId = getServiceId();
|
getServiceId(), extractor.getUrl(), extractor.getName());
|
||||||
String url = extractor.getUrl();
|
|
||||||
|
|
||||||
PlaylistInfoItem resultItem = new PlaylistInfoItem(serviceId, url, name);
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
resultItem.setUploaderName(extractor.getUploaderName());
|
resultItem.setUploaderName(extractor.getUploaderName());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
|
resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setStreamCount(extractor.getStreamCount());
|
resultItem.setStreamCount(extractor.getStreamCount());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -14,12 +14,12 @@ import java.util.List;
|
||||||
public abstract class SearchExtractor extends ListExtractor<InfoItem> {
|
public abstract class SearchExtractor extends ListExtractor<InfoItem> {
|
||||||
|
|
||||||
public static class NothingFoundException extends ExtractionException {
|
public static class NothingFoundException extends ExtractionException {
|
||||||
public NothingFoundException(String message) {
|
public NothingFoundException(final String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public SearchExtractor(StreamingService service, SearchQueryHandler linkHandler) {
|
public SearchExtractor(final StreamingService service, final SearchQueryHandler linkHandler) {
|
||||||
super(service, linkHandler);
|
super(service, linkHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,11 +34,11 @@ public abstract class SearchExtractor extends ListExtractor<InfoItem> {
|
||||||
* {@link SearchExtractor#isCorrectedSearch()} is true.
|
* {@link SearchExtractor#isCorrectedSearch()} is true.
|
||||||
*
|
*
|
||||||
* @return a suggestion to another query, the corrected query, or an empty String.
|
* @return a suggestion to another query, the corrected query, or an empty String.
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public abstract String getSearchSuggestion() throws ParsingException;
|
public abstract String getSearchSuggestion() throws ParsingException;
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public SearchQueryHandler getLinkHandler() {
|
public SearchQueryHandler getLinkHandler() {
|
||||||
return (SearchQueryHandler) super.getLinkHandler();
|
return (SearchQueryHandler) super.getLinkHandler();
|
||||||
|
@ -66,8 +66,7 @@ public abstract class SearchExtractor extends ListExtractor<InfoItem> {
|
||||||
* Example: on YouTube, if you search for "Covid-19",
|
* Example: on YouTube, if you search for "Covid-19",
|
||||||
* there is a box with information from the WHO about Covid-19 and a link to the WHO's website.
|
* there is a box with information from the WHO about Covid-19 and a link to the WHO's website.
|
||||||
* @return additional meta information about the search query
|
* @return additional meta information about the search query
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public abstract List<MetaInfo> getMetaInfo() throws ParsingException;
|
public abstract List<MetaInfo> getMetaInfo() throws ParsingException;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,11 @@
|
||||||
package org.schabi.newpipe.extractor.search;
|
package org.schabi.newpipe.extractor.search;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.*;
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
|
import org.schabi.newpipe.extractor.ListExtractor;
|
||||||
|
import org.schabi.newpipe.extractor.ListInfo;
|
||||||
|
import org.schabi.newpipe.extractor.MetaInfo;
|
||||||
|
import org.schabi.newpipe.extractor.Page;
|
||||||
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
|
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
|
||||||
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
|
||||||
|
@ -11,26 +16,29 @@ import java.util.List;
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
public class SearchInfo extends ListInfo<InfoItem> {
|
public class SearchInfo extends ListInfo<InfoItem> {
|
||||||
private String searchString;
|
private final String searchString;
|
||||||
private String searchSuggestion;
|
private String searchSuggestion;
|
||||||
private boolean isCorrectedSearch;
|
private boolean isCorrectedSearch;
|
||||||
private List<MetaInfo> metaInfo;
|
private List<MetaInfo> metaInfo;
|
||||||
|
|
||||||
public SearchInfo(int serviceId,
|
public SearchInfo(final int serviceId,
|
||||||
SearchQueryHandler qIHandler,
|
final SearchQueryHandler qIHandler,
|
||||||
String searchString) {
|
final String searchString) {
|
||||||
super(serviceId, qIHandler, "Search");
|
super(serviceId, qIHandler, "Search");
|
||||||
this.searchString = searchString;
|
this.searchString = searchString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static SearchInfo getInfo(StreamingService service, SearchQueryHandler searchQuery) throws ExtractionException, IOException {
|
public static SearchInfo getInfo(final StreamingService service,
|
||||||
SearchExtractor extractor = service.getSearchExtractor(searchQuery);
|
final SearchQueryHandler searchQuery)
|
||||||
|
throws ExtractionException, IOException {
|
||||||
|
final SearchExtractor extractor = service.getSearchExtractor(searchQuery);
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
return getInfo(extractor);
|
return getInfo(extractor);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SearchInfo getInfo(SearchExtractor extractor) throws ExtractionException, IOException {
|
public static SearchInfo getInfo(final SearchExtractor extractor)
|
||||||
|
throws ExtractionException, IOException {
|
||||||
final SearchInfo info = new SearchInfo(
|
final SearchInfo info = new SearchInfo(
|
||||||
extractor.getServiceId(),
|
extractor.getServiceId(),
|
||||||
extractor.getLinkHandler(),
|
extractor.getLinkHandler(),
|
||||||
|
@ -38,26 +46,27 @@ public class SearchInfo extends ListInfo<InfoItem> {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
info.setOriginalUrl(extractor.getOriginalUrl());
|
info.setOriginalUrl(extractor.getOriginalUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.setSearchSuggestion(extractor.getSearchSuggestion());
|
info.setSearchSuggestion(extractor.getSearchSuggestion());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.setIsCorrectedSearch(extractor.isCorrectedSearch());
|
info.setIsCorrectedSearch(extractor.isCorrectedSearch());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
info.setMetaInfo(extractor.getMetaInfo());
|
info.setMetaInfo(extractor.getMetaInfo());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
info.addError(e);
|
info.addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
ListExtractor.InfoItemsPage<InfoItem> page = ExtractorHelper.getItemsPageOrLogError(info, extractor);
|
final ListExtractor.InfoItemsPage<InfoItem> page
|
||||||
|
= ExtractorHelper.getItemsPageOrLogError(info, extractor);
|
||||||
info.setRelatedItems(page.getItems());
|
info.setRelatedItems(page.getItems());
|
||||||
info.setNextPage(page.getNextPage());
|
info.setNextPage(page.getNextPage());
|
||||||
|
|
||||||
|
@ -65,9 +74,9 @@ public class SearchInfo extends ListInfo<InfoItem> {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static ListExtractor.InfoItemsPage<InfoItem> getMoreItems(StreamingService service,
|
public static ListExtractor.InfoItemsPage<InfoItem> getMoreItems(final StreamingService service,
|
||||||
SearchQueryHandler query,
|
final SearchQueryHandler query,
|
||||||
Page page)
|
final Page page)
|
||||||
throws IOException, ExtractionException {
|
throws IOException, ExtractionException {
|
||||||
return service.getSearchExtractor(query).getPage(page);
|
return service.getSearchExtractor(query).getPage(page);
|
||||||
}
|
}
|
||||||
|
@ -85,11 +94,11 @@ public class SearchInfo extends ListInfo<InfoItem> {
|
||||||
return this.isCorrectedSearch;
|
return this.isCorrectedSearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIsCorrectedSearch(boolean isCorrectedSearch) {
|
public void setIsCorrectedSearch(final boolean isCorrectedSearch) {
|
||||||
this.isCorrectedSearch = isCorrectedSearch;
|
this.isCorrectedSearch = isCorrectedSearch;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSearchSuggestion(String searchSuggestion) {
|
public void setSearchSuggestion(final String searchSuggestion) {
|
||||||
this.searchSuggestion = searchSuggestion;
|
this.searchSuggestion = searchSuggestion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,7 +107,7 @@ public class SearchInfo extends ListInfo<InfoItem> {
|
||||||
return metaInfo;
|
return metaInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMetaInfo(@Nonnull List<MetaInfo> metaInfo) {
|
public void setMetaInfo(@Nonnull final List<MetaInfo> metaInfo) {
|
||||||
this.metaInfo = metaInfo;
|
this.metaInfo = metaInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,7 +74,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
|
||||||
try {
|
try {
|
||||||
text = JsonUtils.getString(json, "description");
|
text = JsonUtils.getString(json, "description");
|
||||||
} catch (ParsingException e) {
|
} catch (ParsingException e) {
|
||||||
return Description.emptyDescription;
|
return Description.EMPTY_DESCRIPTION;
|
||||||
}
|
}
|
||||||
if (text.length() == 250 && text.substring(247).equals("...")) {
|
if (text.length() == 250 && text.substring(247).equals("...")) {
|
||||||
//if description is shortened, get full description
|
//if description is shortened, get full description
|
||||||
|
|
|
@ -24,7 +24,7 @@ import org.schabi.newpipe.extractor.MediaFormat;
|
||||||
import org.schabi.newpipe.extractor.services.youtube.ItagItem;
|
import org.schabi.newpipe.extractor.services.youtube.ItagItem;
|
||||||
|
|
||||||
public class AudioStream extends Stream {
|
public class AudioStream extends Stream {
|
||||||
public int average_bitrate = -1;
|
private final int averageBitrate;
|
||||||
|
|
||||||
// Fields for Dash
|
// Fields for Dash
|
||||||
private int itag;
|
private int itag;
|
||||||
|
@ -42,9 +42,11 @@ public class AudioStream extends Stream {
|
||||||
* @param format the format
|
* @param format the format
|
||||||
* @param averageBitrate the average bitrate
|
* @param averageBitrate the average bitrate
|
||||||
*/
|
*/
|
||||||
public AudioStream(String url, MediaFormat format, int averageBitrate) {
|
public AudioStream(final String url,
|
||||||
|
final MediaFormat format,
|
||||||
|
final int averageBitrate) {
|
||||||
super(url, format);
|
super(url, format);
|
||||||
this.average_bitrate = averageBitrate;
|
this.averageBitrate = averageBitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -52,7 +54,7 @@ public class AudioStream extends Stream {
|
||||||
* @param url the url
|
* @param url the url
|
||||||
* @param itag the ItagItem of the Stream
|
* @param itag the ItagItem of the Stream
|
||||||
*/
|
*/
|
||||||
public AudioStream(String url, ItagItem itag) {
|
public AudioStream(final String url, final ItagItem itag) {
|
||||||
this(url, itag.getMediaFormat(), itag.avgBitrate);
|
this(url, itag.getMediaFormat(), itag.avgBitrate);
|
||||||
this.itag = itag.id;
|
this.itag = itag.id;
|
||||||
this.quality = itag.getQuality();
|
this.quality = itag.getQuality();
|
||||||
|
@ -65,9 +67,9 @@ public class AudioStream extends Stream {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equalStats(Stream cmp) {
|
public boolean equalStats(final Stream cmp) {
|
||||||
return super.equalStats(cmp) && cmp instanceof AudioStream &&
|
return super.equalStats(cmp) && cmp instanceof AudioStream
|
||||||
average_bitrate == ((AudioStream) cmp).average_bitrate;
|
&& averageBitrate == ((AudioStream) cmp).averageBitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -75,7 +77,7 @@ public class AudioStream extends Stream {
|
||||||
* @return the average bitrate or -1
|
* @return the average bitrate or -1
|
||||||
*/
|
*/
|
||||||
public int getAverageBitrate() {
|
public int getAverageBitrate() {
|
||||||
return average_bitrate;
|
return averageBitrate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getItag() {
|
public int getItag() {
|
||||||
|
|
|
@ -10,12 +10,12 @@ public class Description implements Serializable {
|
||||||
public static final int HTML = 1;
|
public static final int HTML = 1;
|
||||||
public static final int MARKDOWN = 2;
|
public static final int MARKDOWN = 2;
|
||||||
public static final int PLAIN_TEXT = 3;
|
public static final int PLAIN_TEXT = 3;
|
||||||
public static final Description emptyDescription = new Description(EMPTY_STRING, PLAIN_TEXT);
|
public static final Description EMPTY_DESCRIPTION = new Description(EMPTY_STRING, PLAIN_TEXT);
|
||||||
|
|
||||||
private String content;
|
private final String content;
|
||||||
private int type;
|
private final int type;
|
||||||
|
|
||||||
public Description(String content, int type) {
|
public Description(final String content, final int type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
if (content == null) {
|
if (content == null) {
|
||||||
this.content = "";
|
this.content = "";
|
||||||
|
@ -33,10 +33,14 @@ public class Description implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object o) {
|
public boolean equals(final Object o) {
|
||||||
if (this == o) return true;
|
if (this == o) {
|
||||||
if (o == null || getClass() != o.getClass()) return false;
|
return true;
|
||||||
Description that = (Description) o;
|
}
|
||||||
|
if (o == null || getClass() != o.getClass()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
final Description that = (Description) o;
|
||||||
return type == that.type && Objects.equals(content, that.content);
|
return type == that.type && Objects.equals(content, that.content);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ public final class Frameset implements Serializable {
|
||||||
final int durationPerFrame,
|
final int durationPerFrame,
|
||||||
final int framesPerPageX,
|
final int framesPerPageX,
|
||||||
final int framesPerPageY) {
|
final int framesPerPageY) {
|
||||||
|
|
||||||
this.urls = urls;
|
this.urls = urls;
|
||||||
this.totalCount = totalCount;
|
this.totalCount = totalCount;
|
||||||
this.durationPerFrame = durationPerFrame;
|
this.durationPerFrame = durationPerFrame;
|
||||||
|
@ -84,8 +84,8 @@ public final class Frameset implements Serializable {
|
||||||
* Returns the information for the frame at stream position.
|
* Returns the information for the frame at stream position.
|
||||||
*
|
*
|
||||||
* @param position Position in milliseconds
|
* @param position Position in milliseconds
|
||||||
* @return An <code>int</code>-array containing the bounds and URL where the indexes are specified as
|
* @return An <code>int</code>-array containing the bounds and URL where the indexes are
|
||||||
* followed:
|
* specified as follows:
|
||||||
*
|
*
|
||||||
* <ul>
|
* <ul>
|
||||||
* <li><code>0</code>: Index of the URL</li>
|
* <li><code>0</code>: Index of the URL</li>
|
||||||
|
@ -96,9 +96,9 @@ public final class Frameset implements Serializable {
|
||||||
* </ul>
|
* </ul>
|
||||||
*/
|
*/
|
||||||
public int[] getFrameBoundsAt(final long position) {
|
public int[] getFrameBoundsAt(final long position) {
|
||||||
if (position < 0 || position > ((totalCount + 1) * durationPerFrame)) {
|
if (position < 0 || position > ((long) (totalCount + 1) * durationPerFrame)) {
|
||||||
// Return the first frame as fallback
|
// Return the first frame as fallback
|
||||||
return new int[] { 0, 0, 0, frameWidth, frameHeight };
|
return new int[] {0, 0, 0, frameWidth, frameHeight};
|
||||||
}
|
}
|
||||||
|
|
||||||
final int framesPerStoryboard = framesPerPageX * framesPerPageY;
|
final int framesPerStoryboard = framesPerPageX * framesPerPageY;
|
||||||
|
@ -116,4 +116,4 @@ public final class Frameset implements Serializable {
|
||||||
/* right */ columnIndex * frameWidth + frameWidth,
|
/* right */ columnIndex * frameWidth + frameWidth,
|
||||||
/* bottom */ rowIndex * frameHeight + frameHeight };
|
/* bottom */ rowIndex * frameHeight + frameHeight };
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@ public abstract class Stream implements Serializable {
|
||||||
* @param url the url
|
* @param url the url
|
||||||
* @param format the format
|
* @param format the format
|
||||||
*/
|
*/
|
||||||
public Stream(String url, MediaFormat format) {
|
public Stream(final String url, final MediaFormat format) {
|
||||||
this(url, null, format);
|
this(url, null, format);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,12 +35,14 @@ public abstract class Stream implements Serializable {
|
||||||
* Instantiates a new stream object.
|
* Instantiates a new stream object.
|
||||||
*
|
*
|
||||||
* @param url the url
|
* @param url the url
|
||||||
* @param torrentUrl the url to torrent file, example https://webtorrent.io/torrents/big-buck-bunny.torrent
|
* @param torrentUrl the url to torrent file, example
|
||||||
|
* https://webtorrent.io/torrents/big-buck-bunny.torrent
|
||||||
* @param format the format
|
* @param format the format
|
||||||
*/
|
*/
|
||||||
public Stream(String url, String torrentUrl, MediaFormat format) {
|
public Stream(final String url, final String torrentUrl, final MediaFormat format) {
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.torrentUrl = torrentUrl;
|
this.torrentUrl = torrentUrl;
|
||||||
|
//noinspection deprecation
|
||||||
this.format = format.id;
|
this.format = format.id;
|
||||||
this.mediaFormat = format;
|
this.mediaFormat = format;
|
||||||
}
|
}
|
||||||
|
@ -48,24 +50,29 @@ public abstract class Stream implements Serializable {
|
||||||
/**
|
/**
|
||||||
* Reveals whether two streams have the same stats (format and bitrate, for example)
|
* Reveals whether two streams have the same stats (format and bitrate, for example)
|
||||||
*/
|
*/
|
||||||
public boolean equalStats(Stream cmp) {
|
public boolean equalStats(final Stream cmp) {
|
||||||
return cmp != null && getFormatId() == cmp.getFormatId();
|
return cmp != null && getFormatId() == cmp.getFormatId();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reveals whether two Streams are equal
|
* Reveals whether two Streams are equal
|
||||||
*/
|
*/
|
||||||
public boolean equals(Stream cmp) {
|
public boolean equals(final Stream cmp) {
|
||||||
return equalStats(cmp) && url.equals(cmp.url);
|
return equalStats(cmp) && url.equals(cmp.url);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if the list already contains one stream with equals stats
|
* Check if the list already contains one stream with equals stats
|
||||||
*/
|
*/
|
||||||
public static boolean containSimilarStream(Stream stream, List<? extends Stream> streamList) {
|
public static boolean containSimilarStream(final Stream stream,
|
||||||
if (isNullOrEmpty(streamList)) return false;
|
final List<? extends Stream> streamList) {
|
||||||
for (Stream cmpStream : streamList) {
|
if (isNullOrEmpty(streamList)) {
|
||||||
if (stream.equalStats(cmpStream)) return true;
|
return false;
|
||||||
|
}
|
||||||
|
for (final Stream cmpStream : streamList) {
|
||||||
|
if (stream.equalStats(cmpStream)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,6 +36,7 @@ import org.schabi.newpipe.extractor.utils.Parser;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
import javax.annotation.Nullable;
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
@ -49,7 +50,7 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
public static final int NO_AGE_LIMIT = 0;
|
public static final int NO_AGE_LIMIT = 0;
|
||||||
public static final long UNKNOWN_SUBSCRIBER_COUNT = -1;
|
public static final long UNKNOWN_SUBSCRIBER_COUNT = -1;
|
||||||
|
|
||||||
public StreamExtractor(StreamingService service, LinkHandler linkHandler) {
|
public StreamExtractor(final StreamingService service, final LinkHandler linkHandler) {
|
||||||
super(service, linkHandler);
|
super(service, linkHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +71,8 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A more general {@code Calendar} instance set to the date provided by the service.<br>
|
* A more general {@code Calendar} instance set to the date provided by the service.<br>
|
||||||
* Implementations usually will just parse the date returned from the {@link #getTextualUploadDate()}.
|
* Implementations usually will just parse the date returned from the {@link
|
||||||
|
* #getTextualUploadDate()}.
|
||||||
*
|
*
|
||||||
* <p>If the stream is a live stream, {@code null} should be returned.</p>
|
* <p>If the stream is a live stream, {@code null} should be returned.</p>
|
||||||
*
|
*
|
||||||
|
@ -85,10 +87,10 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will return the url to the thumbnail of the stream. Try to return the medium resolution here.
|
* This will return the url to the thumbnail of the stream. Try to return the medium resolution
|
||||||
|
* here.
|
||||||
*
|
*
|
||||||
* @return The url of the thumbnail.
|
* @return The url of the thumbnail.
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public abstract String getThumbnailUrl() throws ParsingException;
|
public abstract String getThumbnailUrl() throws ParsingException;
|
||||||
|
@ -96,12 +98,12 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
/**
|
/**
|
||||||
* This is the stream description.
|
* This is the stream description.
|
||||||
*
|
*
|
||||||
* @return The description of the stream/video or Description.emptyDescription if the description is empty.
|
* @return The description of the stream/video or {@link Description#EMPTY_DESCRIPTION} if the
|
||||||
* @throws ParsingException
|
* description is empty.
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public Description getDescription() throws ParsingException {
|
public Description getDescription() throws ParsingException {
|
||||||
return Description.emptyDescription;
|
return Description.EMPTY_DESCRIPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -118,7 +120,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* This should return the length of a video in seconds.
|
* This should return the length of a video in seconds.
|
||||||
*
|
*
|
||||||
* @return The length of the stream in seconds or 0 when it has no length (e.g. a livestream).
|
* @return The length of the stream in seconds or 0 when it has no length (e.g. a livestream).
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
public long getLength() throws ParsingException {
|
public long getLength() throws ParsingException {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -130,7 +131,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* If the url has no time stamp simply return zero.
|
* If the url has no time stamp simply return zero.
|
||||||
*
|
*
|
||||||
* @return the timestamp in seconds or 0 when there is no timestamp
|
* @return the timestamp in seconds or 0 when there is no timestamp
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
public long getTimeStamp() throws ParsingException {
|
public long getTimeStamp() throws ParsingException {
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -141,7 +141,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* If the current stream has no view count or its not available simply return -1
|
* If the current stream has no view count or its not available simply return -1
|
||||||
*
|
*
|
||||||
* @return amount of views or -1 if not available.
|
* @return amount of views or -1 if not available.
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
public long getViewCount() throws ParsingException {
|
public long getViewCount() throws ParsingException {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -152,7 +151,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* If the current stream has no likes or its not available simply return -1
|
* If the current stream has no likes or its not available simply return -1
|
||||||
*
|
*
|
||||||
* @return the amount of likes the stream got or -1 if not available.
|
* @return the amount of likes the stream got or -1 if not available.
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
public long getLikeCount() throws ParsingException {
|
public long getLikeCount() throws ParsingException {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -163,7 +161,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* If the current stream has no dislikes or its not available simply return -1
|
* If the current stream has no dislikes or its not available simply return -1
|
||||||
*
|
*
|
||||||
* @return the amount of likes the stream got or -1 if not available.
|
* @return the amount of likes the stream got or -1 if not available.
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
public long getDislikeCount() throws ParsingException {
|
public long getDislikeCount() throws ParsingException {
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -172,12 +169,10 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
/**
|
/**
|
||||||
* The Url to the page of the creator/uploader of the stream. This must not be a homepage,
|
* The Url to the page of the creator/uploader of the stream. This must not be a homepage,
|
||||||
* but the page offered by the service the extractor handles. This url will be handled by the
|
* but the page offered by the service the extractor handles. This url will be handled by the
|
||||||
* {@link ChannelExtractor},
|
* {@link ChannelExtractor}, so be sure to implement that one before you return a value here,
|
||||||
* so be sure to implement that one before you return a value here, otherwise NewPipe will crash if one selects
|
* otherwise NewPipe will crash if one selects this url.
|
||||||
* this url.
|
|
||||||
*
|
*
|
||||||
* @return the url to the page of the creator/uploader of the stream or an empty string
|
* @return the url to the page of the creator/uploader of the stream or an empty string
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public abstract String getUploaderUrl() throws ParsingException;
|
public abstract String getUploaderUrl() throws ParsingException;
|
||||||
|
@ -187,7 +182,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* If the name is not available you can simply return an empty string.
|
* If the name is not available you can simply return an empty string.
|
||||||
*
|
*
|
||||||
* @return the name of the creator/uploader of the stream or an empty tring
|
* @return the name of the creator/uploader of the stream or an empty tring
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public abstract String getUploaderName() throws ParsingException;
|
public abstract String getUploaderName() throws ParsingException;
|
||||||
|
@ -197,7 +191,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* If there is no verification implemented, return <code>false</code>.
|
* If there is no verification implemented, return <code>false</code>.
|
||||||
*
|
*
|
||||||
* @return whether the uploader has been verified by the service's provider
|
* @return whether the uploader has been verified by the service's provider
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
public boolean isUploaderVerified() throws ParsingException {
|
public boolean isUploaderVerified() throws ParsingException {
|
||||||
return false;
|
return false;
|
||||||
|
@ -207,8 +200,8 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* The subscriber count of the uploader.
|
* The subscriber count of the uploader.
|
||||||
* If the subscriber count is not implemented, or is unavailable, return <code>-1</code>.
|
* If the subscriber count is not implemented, or is unavailable, return <code>-1</code>.
|
||||||
*
|
*
|
||||||
* @return the subscriber count of the uploader or {@value UNKNOWN_SUBSCRIBER_COUNT} if not available
|
* @return the subscriber count of the uploader or {@value UNKNOWN_SUBSCRIBER_COUNT} if not
|
||||||
* @throws ParsingException
|
* available
|
||||||
*/
|
*/
|
||||||
public long getUploaderSubscriberCount() throws ParsingException {
|
public long getUploaderSubscriberCount() throws ParsingException {
|
||||||
return UNKNOWN_SUBSCRIBER_COUNT;
|
return UNKNOWN_SUBSCRIBER_COUNT;
|
||||||
|
@ -219,7 +212,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* If the url is not available you can return an empty String.
|
* If the url is not available you can return an empty String.
|
||||||
*
|
*
|
||||||
* @return The url of the image file of the uploader or an empty String
|
* @return The url of the image file of the uploader or an empty String
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public String getUploaderAvatarUrl() throws ParsingException {
|
public String getUploaderAvatarUrl() throws ParsingException {
|
||||||
|
@ -229,12 +221,10 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
/**
|
/**
|
||||||
* The Url to the page of the sub-channel of the stream. This must not be a homepage,
|
* The Url to the page of the sub-channel of the stream. This must not be a homepage,
|
||||||
* but the page offered by the service the extractor handles. This url will be handled by the
|
* but the page offered by the service the extractor handles. This url will be handled by the
|
||||||
* {@link ChannelExtractor},
|
* {@link ChannelExtractor}, so be sure to implement that one before you return a value here,
|
||||||
* so be sure to implement that one before you return a value here, otherwise NewPipe will crash if one selects
|
* otherwise NewPipe will crash if one selects this url.
|
||||||
* this url.
|
|
||||||
*
|
*
|
||||||
* @return the url to the page of the sub-channel of the stream or an empty String
|
* @return the url to the page of the sub-channel of the stream or an empty String
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public String getSubChannelUrl() throws ParsingException {
|
public String getSubChannelUrl() throws ParsingException {
|
||||||
|
@ -246,7 +236,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* If the name is not available you can simply return an empty string.
|
* If the name is not available you can simply return an empty string.
|
||||||
*
|
*
|
||||||
* @return the name of the sub-channel of the stream or an empty String
|
* @return the name of the sub-channel of the stream or an empty String
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public String getSubChannelName() throws ParsingException {
|
public String getSubChannelName() throws ParsingException {
|
||||||
|
@ -258,7 +247,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* If the url is not available you can return an empty String.
|
* If the url is not available you can return an empty String.
|
||||||
*
|
*
|
||||||
* @return The url of the image file of the sub-channel or an empty String
|
* @return The url of the image file of the sub-channel or an empty String
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public String getSubChannelAvatarUrl() throws ParsingException {
|
public String getSubChannelAvatarUrl() throws ParsingException {
|
||||||
|
@ -278,13 +266,12 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* I am not sure if this is in use, and how this is used. However the frontend is missing support
|
* I am not sure if this is in use, and how this is used. However the frontend is missing
|
||||||
* for HLS streams. Prove me if I am wrong. Please open an
|
* support for HLS streams. Prove me if I am wrong. Please open an
|
||||||
* <a href="https://github.com/teamnewpipe/newpipe/issues">issue</a>,
|
* <a href="https://github.com/teamnewpipe/newpipe/issues">issue</a>,
|
||||||
* or fix this description if you know whats up with this.
|
* or fix this description if you know whats up with this.
|
||||||
*
|
*
|
||||||
* @return The Url to the hls stream or an empty string if not available.
|
* @return The Url to the hls stream or an empty string if not available.
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public String getHlsUrl() throws ParsingException {
|
public String getHlsUrl() throws ParsingException {
|
||||||
|
@ -292,54 +279,42 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This should return a list of available
|
* This should return a list of available {@link AudioStream}s.
|
||||||
* <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/stream/AudioStream.html">AudioStream</a>s
|
|
||||||
* You can also return null or an empty list, however be aware that if you don't return anything
|
* You can also return null or an empty list, however be aware that if you don't return anything
|
||||||
* in getVideoStreams(), getVideoOnlyStreams() and getDashMpdUrl() either the Collector will handle this as
|
* in getVideoStreams(), getVideoOnlyStreams() and getDashMpdUrl() either the Collector will
|
||||||
* a failed extraction procedure.
|
* handle this as a failed extraction procedure.
|
||||||
*
|
*
|
||||||
* @return a list of audio only streams in the format of AudioStream
|
* @return a list of audio only streams in the format of AudioStream
|
||||||
* @throws IOException
|
|
||||||
* @throws ExtractionException
|
|
||||||
*/
|
*/
|
||||||
public abstract List<AudioStream> getAudioStreams() throws IOException, ExtractionException;
|
public abstract List<AudioStream> getAudioStreams() throws IOException, ExtractionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This should return a list of available
|
* This should return a list of available {@link VideoStream}s.
|
||||||
* <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/stream/VideoStream.html">VideoStream</a>s
|
|
||||||
* Be aware this is the list of video streams which do contain an audio stream.
|
* Be aware this is the list of video streams which do contain an audio stream.
|
||||||
* You can also return null or an empty list, however be aware that if you don't return anything
|
* You can also return null or an empty list, however be aware that if you don't return anything
|
||||||
* in getAudioStreams(), getVideoOnlyStreams() and getDashMpdUrl() either the Collector will handle this as
|
* in getAudioStreams(), getVideoOnlyStreams() and getDashMpdUrl() either the Collector will
|
||||||
* a failed extraction procedure.
|
* handle this as a failed extraction procedure.
|
||||||
*
|
*
|
||||||
* @return a list of combined video and streams in the format of AudioStream
|
* @return a list of combined video and streams in the format of AudioStream
|
||||||
* @throws IOException
|
|
||||||
* @throws ExtractionException
|
|
||||||
*/
|
*/
|
||||||
public abstract List<VideoStream> getVideoStreams() throws IOException, ExtractionException;
|
public abstract List<VideoStream> getVideoStreams() throws IOException, ExtractionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This should return a list of available
|
* This should return a list of available {@link VideoStream}s.
|
||||||
* <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/stream/VideoStream.html">VideoStream</a>s.
|
|
||||||
* Be aware this is the list of video streams which do NOT contain an audio stream.
|
* Be aware this is the list of video streams which do NOT contain an audio stream.
|
||||||
* You can also return null or an empty list, however be aware that if you don't return anything
|
* You can also return null or an empty list, however be aware that if you don't return anything
|
||||||
* in getAudioStreams(), getVideoStreams() and getDashMpdUrl() either the Collector will handle this as
|
* in getAudioStreams(), getVideoStreams() and getDashMpdUrl() either the Collector will handle
|
||||||
* a failed extraction procedure.
|
* this as a failed extraction procedure.
|
||||||
*
|
*
|
||||||
* @return a list of video and streams in the format of AudioStream
|
* @return a list of video and streams in the format of AudioStream
|
||||||
* @throws IOException
|
|
||||||
* @throws ExtractionException
|
|
||||||
*/
|
*/
|
||||||
public abstract List<VideoStream> getVideoOnlyStreams() throws IOException, ExtractionException;
|
public abstract List<VideoStream> getVideoOnlyStreams() throws IOException, ExtractionException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will return a list of available
|
* This will return a list of available {@link SubtitlesStream}s.
|
||||||
* <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/stream/Subtitles.html">Subtitles</a>s.
|
|
||||||
* If no subtitles are available an empty list can be returned.
|
* If no subtitles are available an empty list can be returned.
|
||||||
*
|
*
|
||||||
* @return a list of available subtitles or an empty list
|
* @return a list of available subtitles or an empty list
|
||||||
* @throws IOException
|
|
||||||
* @throws ExtractionException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public List<SubtitlesStream> getSubtitlesDefault() throws IOException, ExtractionException {
|
public List<SubtitlesStream> getSubtitlesDefault() throws IOException, ExtractionException {
|
||||||
|
@ -347,26 +322,22 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This will return a list of available
|
* This will return a list of available {@link SubtitlesStream}s given by a specific type.
|
||||||
* <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/org/schabi/newpipe/extractor/stream/Subtitles.html">Subtitles</a>s.
|
|
||||||
* given by a specific type.
|
|
||||||
* If no subtitles in that specific format are available an empty list can be returned.
|
* If no subtitles in that specific format are available an empty list can be returned.
|
||||||
*
|
*
|
||||||
* @param format the media format by which the subtitles should be filtered
|
* @param format the media format by which the subtitles should be filtered
|
||||||
* @return a list of available subtitles or an empty list
|
* @return a list of available subtitles or an empty list
|
||||||
* @throws IOException
|
|
||||||
* @throws ExtractionException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public List<SubtitlesStream> getSubtitles(MediaFormat format) throws IOException, ExtractionException {
|
public List<SubtitlesStream> getSubtitles(final MediaFormat format)
|
||||||
|
throws IOException, ExtractionException {
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the <a href="https://teamnewpipe.github.io/NewPipeExtractor/javadoc/">StreamType</a>.
|
* Get the {@link StreamType}.
|
||||||
*
|
*
|
||||||
* @return the type of the stream
|
* @return the type of the stream
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
public abstract StreamType getStreamType() throws ParsingException;
|
public abstract StreamType getStreamType() throws ParsingException;
|
||||||
|
|
||||||
|
@ -378,8 +349,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* If related streams aren't available simply return {@code null}.
|
* If related streams aren't available simply return {@code null}.
|
||||||
*
|
*
|
||||||
* @return a list of InfoItems showing the related videos/streams
|
* @return a list of InfoItems showing the related videos/streams
|
||||||
* @throws IOException
|
|
||||||
* @throws ExtractionException
|
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public InfoItemsCollector<? extends InfoItem, ? extends InfoItemExtractor>
|
public InfoItemsCollector<? extends InfoItem, ? extends InfoItemExtractor>
|
||||||
|
@ -388,26 +357,26 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @deprecated Use {@link #getRelatedItems()}. May be removed in a future version.
|
|
||||||
* @return The result of {@link #getRelatedItems()} if it is a
|
* @return The result of {@link #getRelatedItems()} if it is a
|
||||||
* StreamInfoItemsCollector, <code>null</code> otherwise
|
* {@link StreamInfoItemsCollector}, <code>null</code> otherwise
|
||||||
* @throws IOException
|
* @deprecated Use {@link #getRelatedItems()}. May be removed in a future version.
|
||||||
* @throws ExtractionException
|
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@Nullable
|
@Nullable
|
||||||
public StreamInfoItemsCollector getRelatedStreams() throws IOException, ExtractionException {
|
public StreamInfoItemsCollector getRelatedStreams() throws IOException, ExtractionException {
|
||||||
InfoItemsCollector<?, ?> collector = getRelatedItems();
|
final InfoItemsCollector<?, ?> collector = getRelatedItems();
|
||||||
if (collector instanceof StreamInfoItemsCollector) {
|
if (collector instanceof StreamInfoItemsCollector) {
|
||||||
return (StreamInfoItemsCollector) collector;
|
return (StreamInfoItemsCollector) collector;
|
||||||
} else return null;
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Should return a list of Frameset object that contains preview of stream frames
|
* Should return a list of Frameset object that contains preview of stream frames
|
||||||
*
|
*
|
||||||
* @return list of preview frames or empty list if frames preview is not supported or not found for specified stream
|
* @return list of preview frames or empty list if frames preview is not supported or not found
|
||||||
* @throws ExtractionException
|
* for specified stream
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public List<Frameset> getFrames() throws ExtractionException {
|
public List<Frameset> getFrames() throws ExtractionException {
|
||||||
|
@ -428,18 +397,16 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
//////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Override this function if the format of time stamp in the url is not the same format as that form youtube.
|
* Override this function if the format of timestamp in the url is not the same format as that
|
||||||
* Honestly I don't even know the time stamp format of YouTube.
|
* from youtube.
|
||||||
*
|
*
|
||||||
* @param regexPattern
|
|
||||||
* @return the time stamp/seek for the video in seconds
|
* @return the time stamp/seek for the video in seconds
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
protected long getTimestampSeconds(String regexPattern) throws ParsingException {
|
protected long getTimestampSeconds(final String regexPattern) throws ParsingException {
|
||||||
String timeStamp;
|
final String timestamp;
|
||||||
try {
|
try {
|
||||||
timeStamp = Parser.matchGroup1(regexPattern, getOriginalUrl());
|
timestamp = Parser.matchGroup1(regexPattern, getOriginalUrl());
|
||||||
} catch (Parser.RegexException e) {
|
} catch (final Parser.RegexException e) {
|
||||||
// catch this instantly since a url does not necessarily have a timestamp
|
// catch this instantly since a url does not necessarily have a timestamp
|
||||||
|
|
||||||
// -2 because the testing system will consequently know that the regex failed
|
// -2 because the testing system will consequently know that the regex failed
|
||||||
|
@ -447,33 +414,29 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!timeStamp.isEmpty()) {
|
if (!timestamp.isEmpty()) {
|
||||||
try {
|
try {
|
||||||
String secondsString = "";
|
String secondsString = "";
|
||||||
String minutesString = "";
|
String minutesString = "";
|
||||||
String hoursString = "";
|
String hoursString = "";
|
||||||
try {
|
try {
|
||||||
secondsString = Parser.matchGroup1("(\\d+)s", timeStamp);
|
secondsString = Parser.matchGroup1("(\\d+)s", timestamp);
|
||||||
minutesString = Parser.matchGroup1("(\\d+)m", timeStamp);
|
minutesString = Parser.matchGroup1("(\\d+)m", timestamp);
|
||||||
hoursString = Parser.matchGroup1("(\\d+)h", timeStamp);
|
hoursString = Parser.matchGroup1("(\\d+)h", timestamp);
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
//it could be that time is given in another method
|
// it could be that time is given in another method
|
||||||
if (secondsString.isEmpty() //if nothing was got,
|
if (secondsString.isEmpty() && minutesString.isEmpty()) {
|
||||||
&& minutesString.isEmpty()//treat as unlabelled seconds
|
// if nothing was obtained, treat as unlabelled seconds
|
||||||
&& hoursString.isEmpty()) {
|
secondsString = Parser.matchGroup1("t=(\\d+)", timestamp);
|
||||||
secondsString = Parser.matchGroup1("t=(\\d+)", timeStamp);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int seconds = secondsString.isEmpty() ? 0 : Integer.parseInt(secondsString);
|
final int seconds = secondsString.isEmpty() ? 0 : Integer.parseInt(secondsString);
|
||||||
int minutes = minutesString.isEmpty() ? 0 : Integer.parseInt(minutesString);
|
final int minutes = minutesString.isEmpty() ? 0 : Integer.parseInt(minutesString);
|
||||||
int hours = hoursString.isEmpty() ? 0 : Integer.parseInt(hoursString);
|
final int hours = hoursString.isEmpty() ? 0 : Integer.parseInt(hoursString);
|
||||||
|
|
||||||
//don't trust BODMAS!
|
return seconds + (60L * minutes) + (3600L * hours);
|
||||||
return seconds + (60 * minutes) + (3600 * hours);
|
} catch (final ParsingException e) {
|
||||||
//Log.d(TAG, "derived timestamp value:"+ret);
|
|
||||||
//the ordering varies internationally
|
|
||||||
} catch (ParsingException e) {
|
|
||||||
throw new ParsingException("Could not get timestamp.", e);
|
throw new ParsingException("Could not get timestamp.", e);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -488,7 +451,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* you can simply return an empty string.
|
* you can simply return an empty string.
|
||||||
*
|
*
|
||||||
* @return the host of the stream or an empty string.
|
* @return the host of the stream or an empty string.
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public String getHost() throws ParsingException {
|
public String getHost() throws ParsingException {
|
||||||
|
@ -499,7 +461,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* The privacy of the stream (Eg. Public, Private, Unlisted…).
|
* The privacy of the stream (Eg. Public, Private, Unlisted…).
|
||||||
*
|
*
|
||||||
* @return the privacy of the stream.
|
* @return the privacy of the stream.
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
public Privacy getPrivacy() throws ParsingException {
|
public Privacy getPrivacy() throws ParsingException {
|
||||||
return Privacy.PUBLIC;
|
return Privacy.PUBLIC;
|
||||||
|
@ -510,7 +471,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* If the category is not available you can simply return an empty string.
|
* If the category is not available you can simply return an empty string.
|
||||||
*
|
*
|
||||||
* @return the category of the stream or an empty string.
|
* @return the category of the stream or an empty string.
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public String getCategory() throws ParsingException {
|
public String getCategory() throws ParsingException {
|
||||||
|
@ -522,7 +482,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* If the licence is not available you can simply return an empty string.
|
* If the licence is not available you can simply return an empty string.
|
||||||
*
|
*
|
||||||
* @return the licence of the stream or an empty String.
|
* @return the licence of the stream or an empty String.
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public String getLicence() throws ParsingException {
|
public String getLicence() throws ParsingException {
|
||||||
|
@ -536,7 +495,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* new Locale(language_code);
|
* new Locale(language_code);
|
||||||
*
|
*
|
||||||
* @return the locale language of the stream or <code>null</code>.
|
* @return the locale language of the stream or <code>null</code>.
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
public Locale getLanguageInfo() throws ParsingException {
|
public Locale getLanguageInfo() throws ParsingException {
|
||||||
|
@ -548,7 +506,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* If the tag list is not available you can simply return an empty list.
|
* If the tag list is not available you can simply return an empty list.
|
||||||
*
|
*
|
||||||
* @return the list of tags of the stream or Collections.emptyList().
|
* @return the list of tags of the stream or Collections.emptyList().
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public List<String> getTags() throws ParsingException {
|
public List<String> getTags() throws ParsingException {
|
||||||
|
@ -563,7 +520,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* you can simply return an empty String.
|
* you can simply return an empty String.
|
||||||
*
|
*
|
||||||
* @return the support information of the stream or an empty string.
|
* @return the support information of the stream or an empty string.
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public String getSupportInfo() throws ParsingException {
|
public String getSupportInfo() throws ParsingException {
|
||||||
|
@ -575,7 +531,6 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
* If the segment list is not available you can simply return an empty list.
|
* If the segment list is not available you can simply return an empty list.
|
||||||
*
|
*
|
||||||
* @return The list of segments of the stream or an empty list.
|
* @return The list of segments of the stream or an empty list.
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public List<StreamSegment> getStreamSegments() throws ParsingException {
|
public List<StreamSegment> getStreamSegments() throws ParsingException {
|
||||||
|
@ -585,14 +540,14 @@ public abstract class StreamExtractor extends Extractor {
|
||||||
/**
|
/**
|
||||||
* Meta information about the stream.
|
* Meta information about the stream.
|
||||||
* <p>
|
* <p>
|
||||||
* This can be information about the stream creator (e.g. if the creator is a public broadcaster)
|
* This can be information about the stream creator (e.g. if the creator is a public
|
||||||
* or further information on the topic (e.g. hints that the video might contain conspiracy theories
|
* broadcaster) or further information on the topic (e.g. hints that the video might contain
|
||||||
* or contains information about a current health situation like the Covid-19 pandemic).
|
* conspiracy theories or contains information about a current health situation like the
|
||||||
|
* Covid-19 pandemic).
|
||||||
* </p>
|
* </p>
|
||||||
* The meta information often contains links to external sources like Wikipedia or the WHO.
|
* The meta information often contains links to external sources like Wikipedia or the WHO.
|
||||||
*
|
*
|
||||||
* @return The meta info of the stream or an empty list if not provided.
|
* @return The meta info of the stream or an empty list if not provided.
|
||||||
* @throws ParsingException
|
|
||||||
*/
|
*/
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public List<MetaInfo> getMetaInfo() throws ParsingException {
|
public List<MetaInfo> getMetaInfo() throws ParsingException {
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
package org.schabi.newpipe.extractor.stream;
|
package org.schabi.newpipe.extractor.stream;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.*;
|
import org.schabi.newpipe.extractor.Info;
|
||||||
|
import org.schabi.newpipe.extractor.InfoItem;
|
||||||
|
import org.schabi.newpipe.extractor.MetaInfo;
|
||||||
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
|
import org.schabi.newpipe.extractor.exceptions.ContentNotSupportedException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
|
||||||
|
@ -44,34 +48,42 @@ import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
|
||||||
public class StreamInfo extends Info {
|
public class StreamInfo extends Info {
|
||||||
|
|
||||||
public static class StreamExtractException extends ExtractionException {
|
public static class StreamExtractException extends ExtractionException {
|
||||||
StreamExtractException(String message) {
|
StreamExtractException(final String message) {
|
||||||
super(message);
|
super(message);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public StreamInfo(int serviceId, String url, String originalUrl, StreamType streamType, String id, String name,
|
public StreamInfo(final int serviceId,
|
||||||
int ageLimit) {
|
final String url,
|
||||||
|
final String originalUrl,
|
||||||
|
final StreamType streamType,
|
||||||
|
final String id,
|
||||||
|
final String name,
|
||||||
|
final int ageLimit) {
|
||||||
super(serviceId, id, url, originalUrl, name);
|
super(serviceId, id, url, originalUrl, name);
|
||||||
this.streamType = streamType;
|
this.streamType = streamType;
|
||||||
this.ageLimit = ageLimit;
|
this.ageLimit = ageLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StreamInfo getInfo(String url) throws IOException, ExtractionException {
|
public static StreamInfo getInfo(final String url) throws IOException, ExtractionException {
|
||||||
return getInfo(NewPipe.getServiceByUrl(url), url);
|
return getInfo(NewPipe.getServiceByUrl(url), url);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StreamInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
|
public static StreamInfo getInfo(final StreamingService service,
|
||||||
|
final String url) throws IOException, ExtractionException {
|
||||||
return getInfo(service.getStreamExtractor(url));
|
return getInfo(service.getStreamExtractor(url));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static StreamInfo getInfo(StreamExtractor extractor) throws ExtractionException, IOException {
|
public static StreamInfo getInfo(final StreamExtractor extractor)
|
||||||
|
throws ExtractionException, IOException {
|
||||||
extractor.fetchPage();
|
extractor.fetchPage();
|
||||||
StreamInfo streamInfo;
|
|
||||||
try {
|
try {
|
||||||
streamInfo = extractImportantData(extractor);
|
final StreamInfo streamInfo = extractImportantData(extractor);
|
||||||
streamInfo = extractStreams(streamInfo, extractor);
|
extractStreams(streamInfo, extractor);
|
||||||
streamInfo = extractOptionalData(streamInfo, extractor);
|
extractOptionalData(streamInfo, extractor);
|
||||||
} catch (ExtractionException e) {
|
return streamInfo;
|
||||||
|
|
||||||
|
} catch (final ExtractionException e) {
|
||||||
// Currently YouTube does not distinguish between age restricted videos and
|
// Currently YouTube does not distinguish between age restricted videos and
|
||||||
// videos blocked
|
// videos blocked
|
||||||
// by country. This means that during the initialisation of the extractor, the
|
// by country. This means that during the initialisation of the extractor, the
|
||||||
|
@ -88,32 +100,32 @@ public class StreamInfo extends Info {
|
||||||
throw new ContentNotAvailableException(errorMessage, e);
|
throw new ContentNotAvailableException(errorMessage, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return streamInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static StreamInfo extractImportantData(StreamExtractor extractor) throws ExtractionException {
|
private static StreamInfo extractImportantData(final StreamExtractor extractor)
|
||||||
|
throws ExtractionException {
|
||||||
/* ---- important data, without the video can't be displayed goes here: ---- */
|
/* ---- important data, without the video can't be displayed goes here: ---- */
|
||||||
// if one of these is not available an exception is meant to be thrown directly
|
// if one of these is not available an exception is meant to be thrown directly
|
||||||
// into the frontend.
|
// into the frontend.
|
||||||
|
|
||||||
int serviceId = extractor.getServiceId();
|
final String url = extractor.getUrl();
|
||||||
String url = extractor.getUrl();
|
final StreamType streamType = extractor.getStreamType();
|
||||||
String originalUrl = extractor.getOriginalUrl();
|
final String id = extractor.getId();
|
||||||
StreamType streamType = extractor.getStreamType();
|
final String name = extractor.getName();
|
||||||
String id = extractor.getId();
|
final int ageLimit = extractor.getAgeLimit();
|
||||||
String name = extractor.getName();
|
|
||||||
int ageLimit = extractor.getAgeLimit();
|
|
||||||
|
|
||||||
if ((streamType == StreamType.NONE) || isNullOrEmpty(url) || (isNullOrEmpty(id))
|
// suppress always-non-null warning as here we double-check it really is not null
|
||||||
|| (name == null /* streamInfo.title can be empty of course */) || (ageLimit == -1)) {
|
//noinspection ConstantConditions
|
||||||
|
if (streamType == StreamType.NONE || isNullOrEmpty(url) || isNullOrEmpty(id)
|
||||||
|
|| name == null /* but it can be empty of course */ || ageLimit == -1) {
|
||||||
throw new ExtractionException("Some important stream information was not given.");
|
throw new ExtractionException("Some important stream information was not given.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return new StreamInfo(serviceId, url, originalUrl, streamType, id, name, ageLimit);
|
return new StreamInfo(extractor.getServiceId(), url, extractor.getOriginalUrl(),
|
||||||
|
streamType, id, name, ageLimit);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static StreamInfo extractStreams(StreamInfo streamInfo, StreamExtractor extractor)
|
private static void extractStreams(final StreamInfo streamInfo, final StreamExtractor extractor)
|
||||||
throws ExtractionException {
|
throws ExtractionException {
|
||||||
/* ---- stream extraction goes here ---- */
|
/* ---- stream extraction goes here ---- */
|
||||||
// At least one type of stream has to be available,
|
// At least one type of stream has to be available,
|
||||||
|
@ -121,56 +133,59 @@ public class StreamInfo extends Info {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
streamInfo.setDashMpdUrl(extractor.getDashMpdUrl());
|
streamInfo.setDashMpdUrl(extractor.getDashMpdUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(new ExtractionException("Couldn't get Dash manifest", e));
|
streamInfo.addError(new ExtractionException("Couldn't get Dash manifest", e));
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
streamInfo.setHlsUrl(extractor.getHlsUrl());
|
streamInfo.setHlsUrl(extractor.getHlsUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(new ExtractionException("Couldn't get HLS manifest", e));
|
streamInfo.addError(new ExtractionException("Couldn't get HLS manifest", e));
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Load and extract audio */
|
/* Load and extract audio */
|
||||||
try {
|
try {
|
||||||
streamInfo.setAudioStreams(extractor.getAudioStreams());
|
streamInfo.setAudioStreams(extractor.getAudioStreams());
|
||||||
} catch (ContentNotSupportedException e) {
|
} catch (final ContentNotSupportedException e) {
|
||||||
throw e;
|
throw e;
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(new ExtractionException("Couldn't get audio streams", e));
|
streamInfo.addError(new ExtractionException("Couldn't get audio streams", e));
|
||||||
}
|
}
|
||||||
/* Extract video stream url */
|
/* Extract video stream url */
|
||||||
try {
|
try {
|
||||||
streamInfo.setVideoStreams(extractor.getVideoStreams());
|
streamInfo.setVideoStreams(extractor.getVideoStreams());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(new ExtractionException("Couldn't get video streams", e));
|
streamInfo.addError(new ExtractionException("Couldn't get video streams", e));
|
||||||
}
|
}
|
||||||
/* Extract video only stream url */
|
/* Extract video only stream url */
|
||||||
try {
|
try {
|
||||||
streamInfo.setVideoOnlyStreams(extractor.getVideoOnlyStreams());
|
streamInfo.setVideoOnlyStreams(extractor.getVideoOnlyStreams());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(new ExtractionException("Couldn't get video only streams", e));
|
streamInfo.addError(new ExtractionException("Couldn't get video only streams", e));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Lists can be null if a exception was thrown during extraction
|
// Lists can be null if a exception was thrown during extraction
|
||||||
if (streamInfo.getVideoStreams() == null)
|
if (streamInfo.getVideoStreams() == null) {
|
||||||
streamInfo.setVideoStreams(Collections.emptyList());
|
streamInfo.setVideoStreams(Collections.emptyList());
|
||||||
if (streamInfo.getVideoOnlyStreams() == null)
|
}
|
||||||
|
if (streamInfo.getVideoOnlyStreams() == null) {
|
||||||
streamInfo.setVideoOnlyStreams(Collections.emptyList());
|
streamInfo.setVideoOnlyStreams(Collections.emptyList());
|
||||||
if (streamInfo.getAudioStreams() == null)
|
}
|
||||||
|
if (streamInfo.getAudioStreams() == null) {
|
||||||
streamInfo.setAudioStreams(Collections.emptyList());
|
streamInfo.setAudioStreams(Collections.emptyList());
|
||||||
|
}
|
||||||
|
|
||||||
Exception dashMpdError = null;
|
Exception dashMpdError = null;
|
||||||
if (!isNullOrEmpty(streamInfo.getDashMpdUrl())) {
|
if (!isNullOrEmpty(streamInfo.getDashMpdUrl())) {
|
||||||
try {
|
try {
|
||||||
DashMpdParser.ParserResult result = DashMpdParser.getStreams(streamInfo);
|
final DashMpdParser.ParserResult result = DashMpdParser.getStreams(streamInfo);
|
||||||
streamInfo.getVideoOnlyStreams().addAll(result.getVideoOnlyStreams());
|
streamInfo.getVideoOnlyStreams().addAll(result.getVideoOnlyStreams());
|
||||||
streamInfo.getAudioStreams().addAll(result.getAudioStreams());
|
streamInfo.getAudioStreams().addAll(result.getAudioStreams());
|
||||||
streamInfo.getVideoStreams().addAll(result.getVideoStreams());
|
streamInfo.getVideoStreams().addAll(result.getVideoStreams());
|
||||||
streamInfo.segmentedVideoOnlyStreams = result.getSegmentedVideoOnlyStreams();
|
streamInfo.segmentedVideoOnlyStreams = result.getSegmentedVideoOnlyStreams();
|
||||||
streamInfo.segmentedAudioStreams = result.getSegmentedAudioStreams();
|
streamInfo.segmentedAudioStreams = result.getSegmentedAudioStreams();
|
||||||
streamInfo.segmentedVideoStreams = result.getSegmentedVideoStreams();
|
streamInfo.segmentedVideoStreams = result.getSegmentedVideoStreams();
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
// Sometimes we receive 403 (forbidden) error when trying to download the
|
// Sometimes we receive 403 (forbidden) error when trying to download the
|
||||||
// manifest (similar to what happens with youtube-dl),
|
// manifest (similar to what happens with youtube-dl),
|
||||||
// just skip the exception (but store it somewhere), as we later check if we
|
// just skip the exception (but store it somewhere), as we later check if we
|
||||||
|
@ -191,13 +206,13 @@ public class StreamInfo extends Info {
|
||||||
streamInfo.addError(dashMpdError);
|
streamInfo.addError(dashMpdError);
|
||||||
}
|
}
|
||||||
|
|
||||||
throw new StreamExtractException("Could not get any stream. See error variable to get further details.");
|
throw new StreamExtractException(
|
||||||
|
"Could not get any stream. See error variable to get further details.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return streamInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static StreamInfo extractOptionalData(StreamInfo streamInfo, StreamExtractor extractor) {
|
private static void extractOptionalData(final StreamInfo streamInfo,
|
||||||
|
final StreamExtractor extractor) {
|
||||||
/* ---- optional data goes here: ---- */
|
/* ---- optional data goes here: ---- */
|
||||||
// If one of these fails, the frontend needs to handle that they are not
|
// If one of these fails, the frontend needs to handle that they are not
|
||||||
// available.
|
// available.
|
||||||
|
@ -207,153 +222,152 @@ public class StreamInfo extends Info {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
streamInfo.setThumbnailUrl(extractor.getThumbnailUrl());
|
streamInfo.setThumbnailUrl(extractor.getThumbnailUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setDuration(extractor.getLength());
|
streamInfo.setDuration(extractor.getLength());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setUploaderName(extractor.getUploaderName());
|
streamInfo.setUploaderName(extractor.getUploaderName());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setUploaderUrl(extractor.getUploaderUrl());
|
streamInfo.setUploaderUrl(extractor.getUploaderUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
|
streamInfo.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setUploaderVerified(extractor.isUploaderVerified());
|
streamInfo.setUploaderVerified(extractor.isUploaderVerified());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setUploaderSubscriberCount(extractor.getUploaderSubscriberCount());
|
streamInfo.setUploaderSubscriberCount(extractor.getUploaderSubscriberCount());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
streamInfo.setSubChannelName(extractor.getSubChannelName());
|
streamInfo.setSubChannelName(extractor.getSubChannelName());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setSubChannelUrl(extractor.getSubChannelUrl());
|
streamInfo.setSubChannelUrl(extractor.getSubChannelUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setSubChannelAvatarUrl(extractor.getSubChannelAvatarUrl());
|
streamInfo.setSubChannelAvatarUrl(extractor.getSubChannelAvatarUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
streamInfo.setDescription(extractor.getDescription());
|
streamInfo.setDescription(extractor.getDescription());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setViewCount(extractor.getViewCount());
|
streamInfo.setViewCount(extractor.getViewCount());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setTextualUploadDate(extractor.getTextualUploadDate());
|
streamInfo.setTextualUploadDate(extractor.getTextualUploadDate());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setUploadDate(extractor.getUploadDate());
|
streamInfo.setUploadDate(extractor.getUploadDate());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setStartPosition(extractor.getTimeStamp());
|
streamInfo.setStartPosition(extractor.getTimeStamp());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setLikeCount(extractor.getLikeCount());
|
streamInfo.setLikeCount(extractor.getLikeCount());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setDislikeCount(extractor.getDislikeCount());
|
streamInfo.setDislikeCount(extractor.getDislikeCount());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setSubtitles(extractor.getSubtitlesDefault());
|
streamInfo.setSubtitles(extractor.getSubtitlesDefault());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
//additional info
|
//additional info
|
||||||
try {
|
try {
|
||||||
streamInfo.setHost(extractor.getHost());
|
streamInfo.setHost(extractor.getHost());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setPrivacy(extractor.getPrivacy());
|
streamInfo.setPrivacy(extractor.getPrivacy());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setCategory(extractor.getCategory());
|
streamInfo.setCategory(extractor.getCategory());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setLicence(extractor.getLicence());
|
streamInfo.setLicence(extractor.getLicence());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setLanguageInfo(extractor.getLanguageInfo());
|
streamInfo.setLanguageInfo(extractor.getLanguageInfo());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setTags(extractor.getTags());
|
streamInfo.setTags(extractor.getTags());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setSupportInfo(extractor.getSupportInfo());
|
streamInfo.setSupportInfo(extractor.getSupportInfo());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setStreamSegments(extractor.getStreamSegments());
|
streamInfo.setStreamSegments(extractor.getStreamSegments());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
streamInfo.setMetaInfo(extractor.getMetaInfo());
|
streamInfo.setMetaInfo(extractor.getMetaInfo());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
streamInfo.setPreviewFrames(extractor.getFrames());
|
streamInfo.setPreviewFrames(extractor.getFrames());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
streamInfo.addError(e);
|
streamInfo.addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
streamInfo.setRelatedItems(ExtractorHelper.getRelatedItemsOrLogError(streamInfo, extractor));
|
streamInfo
|
||||||
|
.setRelatedItems(ExtractorHelper.getRelatedItemsOrLogError(streamInfo, extractor));
|
||||||
return streamInfo;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private StreamType streamType;
|
private StreamType streamType;
|
||||||
|
@ -361,7 +375,7 @@ public class StreamInfo extends Info {
|
||||||
private String textualUploadDate;
|
private String textualUploadDate;
|
||||||
private DateWrapper uploadDate;
|
private DateWrapper uploadDate;
|
||||||
private long duration = -1;
|
private long duration = -1;
|
||||||
private int ageLimit = -1;
|
private int ageLimit;
|
||||||
private Description description;
|
private Description description;
|
||||||
|
|
||||||
private long viewCount = -1;
|
private long viewCount = -1;
|
||||||
|
@ -398,7 +412,7 @@ public class StreamInfo extends Info {
|
||||||
private StreamExtractor.Privacy privacy;
|
private StreamExtractor.Privacy privacy;
|
||||||
private String category = "";
|
private String category = "";
|
||||||
private String licence = "";
|
private String licence = "";
|
||||||
private String support = "";
|
private String supportInfo = "";
|
||||||
private Locale language = null;
|
private Locale language = null;
|
||||||
private List<String> tags = new ArrayList<>();
|
private List<String> tags = new ArrayList<>();
|
||||||
private List<StreamSegment> streamSegments = new ArrayList<>();
|
private List<StreamSegment> streamSegments = new ArrayList<>();
|
||||||
|
@ -418,7 +432,7 @@ public class StreamInfo extends Info {
|
||||||
return streamType;
|
return streamType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStreamType(StreamType streamType) {
|
public void setStreamType(final StreamType streamType) {
|
||||||
this.streamType = streamType;
|
this.streamType = streamType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -431,7 +445,7 @@ public class StreamInfo extends Info {
|
||||||
return thumbnailUrl;
|
return thumbnailUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setThumbnailUrl(String thumbnailUrl) {
|
public void setThumbnailUrl(final String thumbnailUrl) {
|
||||||
this.thumbnailUrl = thumbnailUrl;
|
this.thumbnailUrl = thumbnailUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -439,7 +453,7 @@ public class StreamInfo extends Info {
|
||||||
return textualUploadDate;
|
return textualUploadDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTextualUploadDate(String textualUploadDate) {
|
public void setTextualUploadDate(final String textualUploadDate) {
|
||||||
this.textualUploadDate = textualUploadDate;
|
this.textualUploadDate = textualUploadDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -447,7 +461,7 @@ public class StreamInfo extends Info {
|
||||||
return uploadDate;
|
return uploadDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploadDate(DateWrapper uploadDate) {
|
public void setUploadDate(final DateWrapper uploadDate) {
|
||||||
this.uploadDate = uploadDate;
|
this.uploadDate = uploadDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -460,7 +474,7 @@ public class StreamInfo extends Info {
|
||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDuration(long duration) {
|
public void setDuration(final long duration) {
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -468,7 +482,7 @@ public class StreamInfo extends Info {
|
||||||
return ageLimit;
|
return ageLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAgeLimit(int ageLimit) {
|
public void setAgeLimit(final int ageLimit) {
|
||||||
this.ageLimit = ageLimit;
|
this.ageLimit = ageLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -476,7 +490,7 @@ public class StreamInfo extends Info {
|
||||||
return description;
|
return description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDescription(Description description) {
|
public void setDescription(final Description description) {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -484,7 +498,7 @@ public class StreamInfo extends Info {
|
||||||
return viewCount;
|
return viewCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setViewCount(long viewCount) {
|
public void setViewCount(final long viewCount) {
|
||||||
this.viewCount = viewCount;
|
this.viewCount = viewCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -497,7 +511,7 @@ public class StreamInfo extends Info {
|
||||||
return likeCount;
|
return likeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLikeCount(long likeCount) {
|
public void setLikeCount(final long likeCount) {
|
||||||
this.likeCount = likeCount;
|
this.likeCount = likeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,7 +524,7 @@ public class StreamInfo extends Info {
|
||||||
return dislikeCount;
|
return dislikeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDislikeCount(long dislikeCount) {
|
public void setDislikeCount(final long dislikeCount) {
|
||||||
this.dislikeCount = dislikeCount;
|
this.dislikeCount = dislikeCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -518,7 +532,7 @@ public class StreamInfo extends Info {
|
||||||
return uploaderName;
|
return uploaderName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploaderName(String uploaderName) {
|
public void setUploaderName(final String uploaderName) {
|
||||||
this.uploaderName = uploaderName;
|
this.uploaderName = uploaderName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -526,7 +540,7 @@ public class StreamInfo extends Info {
|
||||||
return uploaderUrl;
|
return uploaderUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploaderUrl(String uploaderUrl) {
|
public void setUploaderUrl(final String uploaderUrl) {
|
||||||
this.uploaderUrl = uploaderUrl;
|
this.uploaderUrl = uploaderUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -534,7 +548,7 @@ public class StreamInfo extends Info {
|
||||||
return uploaderAvatarUrl;
|
return uploaderAvatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploaderAvatarUrl(String uploaderAvatarUrl) {
|
public void setUploaderAvatarUrl(final String uploaderAvatarUrl) {
|
||||||
this.uploaderAvatarUrl = uploaderAvatarUrl;
|
this.uploaderAvatarUrl = uploaderAvatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -550,7 +564,7 @@ public class StreamInfo extends Info {
|
||||||
return uploaderSubscriberCount;
|
return uploaderSubscriberCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploaderSubscriberCount(long uploaderSubscriberCount) {
|
public void setUploaderSubscriberCount(final long uploaderSubscriberCount) {
|
||||||
this.uploaderSubscriberCount = uploaderSubscriberCount;
|
this.uploaderSubscriberCount = uploaderSubscriberCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -558,7 +572,7 @@ public class StreamInfo extends Info {
|
||||||
return subChannelName;
|
return subChannelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubChannelName(String subChannelName) {
|
public void setSubChannelName(final String subChannelName) {
|
||||||
this.subChannelName = subChannelName;
|
this.subChannelName = subChannelName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -566,7 +580,7 @@ public class StreamInfo extends Info {
|
||||||
return subChannelUrl;
|
return subChannelUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubChannelUrl(String subChannelUrl) {
|
public void setSubChannelUrl(final String subChannelUrl) {
|
||||||
this.subChannelUrl = subChannelUrl;
|
this.subChannelUrl = subChannelUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -574,7 +588,7 @@ public class StreamInfo extends Info {
|
||||||
return subChannelAvatarUrl;
|
return subChannelAvatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubChannelAvatarUrl(String subChannelAvatarUrl) {
|
public void setSubChannelAvatarUrl(final String subChannelAvatarUrl) {
|
||||||
this.subChannelAvatarUrl = subChannelAvatarUrl;
|
this.subChannelAvatarUrl = subChannelAvatarUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -582,7 +596,7 @@ public class StreamInfo extends Info {
|
||||||
return videoStreams;
|
return videoStreams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVideoStreams(List<VideoStream> videoStreams) {
|
public void setVideoStreams(final List<VideoStream> videoStreams) {
|
||||||
this.videoStreams = videoStreams;
|
this.videoStreams = videoStreams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -590,7 +604,7 @@ public class StreamInfo extends Info {
|
||||||
return audioStreams;
|
return audioStreams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAudioStreams(List<AudioStream> audioStreams) {
|
public void setAudioStreams(final List<AudioStream> audioStreams) {
|
||||||
this.audioStreams = audioStreams;
|
this.audioStreams = audioStreams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -598,7 +612,7 @@ public class StreamInfo extends Info {
|
||||||
return videoOnlyStreams;
|
return videoOnlyStreams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVideoOnlyStreams(List<VideoStream> videoOnlyStreams) {
|
public void setVideoOnlyStreams(final List<VideoStream> videoOnlyStreams) {
|
||||||
this.videoOnlyStreams = videoOnlyStreams;
|
this.videoOnlyStreams = videoOnlyStreams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -606,7 +620,7 @@ public class StreamInfo extends Info {
|
||||||
return dashMpdUrl;
|
return dashMpdUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDashMpdUrl(String dashMpdUrl) {
|
public void setDashMpdUrl(final String dashMpdUrl) {
|
||||||
this.dashMpdUrl = dashMpdUrl;
|
this.dashMpdUrl = dashMpdUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -614,7 +628,7 @@ public class StreamInfo extends Info {
|
||||||
return segmentedVideoStreams;
|
return segmentedVideoStreams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSegmentedVideoStreams(List<VideoStream> segmentedVideoStreams) {
|
public void setSegmentedVideoStreams(final List<VideoStream> segmentedVideoStreams) {
|
||||||
this.segmentedVideoStreams = segmentedVideoStreams;
|
this.segmentedVideoStreams = segmentedVideoStreams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -622,7 +636,7 @@ public class StreamInfo extends Info {
|
||||||
return segmentedAudioStreams;
|
return segmentedAudioStreams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSegmentedAudioStreams(List<AudioStream> segmentedAudioStreams) {
|
public void setSegmentedAudioStreams(final List<AudioStream> segmentedAudioStreams) {
|
||||||
this.segmentedAudioStreams = segmentedAudioStreams;
|
this.segmentedAudioStreams = segmentedAudioStreams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -630,7 +644,7 @@ public class StreamInfo extends Info {
|
||||||
return segmentedVideoOnlyStreams;
|
return segmentedVideoOnlyStreams;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSegmentedVideoOnlyStreams(List<VideoStream> segmentedVideoOnlyStreams) {
|
public void setSegmentedVideoOnlyStreams(final List<VideoStream> segmentedVideoOnlyStreams) {
|
||||||
this.segmentedVideoOnlyStreams = segmentedVideoOnlyStreams;
|
this.segmentedVideoOnlyStreams = segmentedVideoOnlyStreams;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,7 +652,7 @@ public class StreamInfo extends Info {
|
||||||
return hlsUrl;
|
return hlsUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHlsUrl(String hlsUrl) {
|
public void setHlsUrl(final String hlsUrl) {
|
||||||
this.hlsUrl = hlsUrl;
|
this.hlsUrl = hlsUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -654,7 +668,7 @@ public class StreamInfo extends Info {
|
||||||
return getRelatedItems();
|
return getRelatedItems();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRelatedItems(List<InfoItem> relatedItems) {
|
public void setRelatedItems(final List<InfoItem> relatedItems) {
|
||||||
this.relatedItems = relatedItems;
|
this.relatedItems = relatedItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -662,15 +676,15 @@ public class StreamInfo extends Info {
|
||||||
* @deprecated Use {@link #setRelatedItems(List)}
|
* @deprecated Use {@link #setRelatedItems(List)}
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setRelatedStreams(List<InfoItem> relatedItems) {
|
public void setRelatedStreams(final List<InfoItem> relatedItemsToSet) {
|
||||||
setRelatedItems(relatedItems);
|
setRelatedItems(relatedItemsToSet);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getStartPosition() {
|
public long getStartPosition() {
|
||||||
return startPosition;
|
return startPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStartPosition(long startPosition) {
|
public void setStartPosition(final long startPosition) {
|
||||||
this.startPosition = startPosition;
|
this.startPosition = startPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -678,7 +692,7 @@ public class StreamInfo extends Info {
|
||||||
return subtitles;
|
return subtitles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSubtitles(List<SubtitlesStream> subtitles) {
|
public void setSubtitles(final List<SubtitlesStream> subtitles) {
|
||||||
this.subtitles = subtitles;
|
this.subtitles = subtitles;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -686,63 +700,63 @@ public class StreamInfo extends Info {
|
||||||
return this.host;
|
return this.host;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHost(String str) {
|
public void setHost(final String host) {
|
||||||
this.host = str;
|
this.host = host;
|
||||||
}
|
}
|
||||||
|
|
||||||
public StreamExtractor.Privacy getPrivacy() {
|
public StreamExtractor.Privacy getPrivacy() {
|
||||||
return this.privacy;
|
return this.privacy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPrivacy(StreamExtractor.Privacy str) {
|
public void setPrivacy(final StreamExtractor.Privacy privacy) {
|
||||||
this.privacy = str;
|
this.privacy = privacy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getCategory() {
|
public String getCategory() {
|
||||||
return this.category;
|
return this.category;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCategory(String cat) {
|
public void setCategory(final String category) {
|
||||||
this.category = cat;
|
this.category = category;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getLicence() {
|
public String getLicence() {
|
||||||
return this.licence;
|
return this.licence;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLicence(String str) {
|
public void setLicence(final String licence) {
|
||||||
this.licence = str;
|
this.licence = licence;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Locale getLanguageInfo() {
|
public Locale getLanguageInfo() {
|
||||||
return this.language;
|
return this.language;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLanguageInfo(Locale lang) {
|
public void setLanguageInfo(final Locale locale) {
|
||||||
this.language = lang;
|
this.language = locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getTags() {
|
public List<String> getTags() {
|
||||||
return this.tags;
|
return this.tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTags(List<String> tags) {
|
public void setTags(final List<String> tags) {
|
||||||
this.tags = tags;
|
this.tags = tags;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSupportInfo(String support) {
|
public void setSupportInfo(final String support) {
|
||||||
this.support = support;
|
this.supportInfo = support;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getSupportInfo() {
|
public String getSupportInfo() {
|
||||||
return this.support;
|
return this.supportInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<StreamSegment> getStreamSegments() {
|
public List<StreamSegment> getStreamSegments() {
|
||||||
return streamSegments;
|
return streamSegments;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStreamSegments(List<StreamSegment> streamSegments) {
|
public void setStreamSegments(final List<StreamSegment> streamSegments) {
|
||||||
this.streamSegments = streamSegments;
|
this.streamSegments = streamSegments;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,7 +43,10 @@ public class StreamInfoItem extends InfoItem {
|
||||||
private String uploaderAvatarUrl = null;
|
private String uploaderAvatarUrl = null;
|
||||||
private boolean uploaderVerified = false;
|
private boolean uploaderVerified = false;
|
||||||
|
|
||||||
public StreamInfoItem(int serviceId, String url, String name, StreamType streamType) {
|
public StreamInfoItem(final int serviceId,
|
||||||
|
final String url,
|
||||||
|
final String name,
|
||||||
|
final StreamType streamType) {
|
||||||
super(InfoType.STREAM, serviceId, url, name);
|
super(InfoType.STREAM, serviceId, url, name);
|
||||||
this.streamType = streamType;
|
this.streamType = streamType;
|
||||||
}
|
}
|
||||||
|
@ -56,23 +59,23 @@ public class StreamInfoItem extends InfoItem {
|
||||||
return uploaderName;
|
return uploaderName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploaderName(String uploader_name) {
|
public void setUploaderName(final String uploaderName) {
|
||||||
this.uploaderName = uploader_name;
|
this.uploaderName = uploaderName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getViewCount() {
|
public long getViewCount() {
|
||||||
return viewCount;
|
return viewCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setViewCount(long view_count) {
|
public void setViewCount(final long viewCount) {
|
||||||
this.viewCount = view_count;
|
this.viewCount = viewCount;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getDuration() {
|
public long getDuration() {
|
||||||
return duration;
|
return duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDuration(long duration) {
|
public void setDuration(final long duration) {
|
||||||
this.duration = duration;
|
this.duration = duration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -80,7 +83,7 @@ public class StreamInfoItem extends InfoItem {
|
||||||
return uploaderUrl;
|
return uploaderUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploaderUrl(String uploaderUrl) {
|
public void setUploaderUrl(final String uploaderUrl) {
|
||||||
this.uploaderUrl = uploaderUrl;
|
this.uploaderUrl = uploaderUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -106,8 +109,8 @@ public class StreamInfoItem extends InfoItem {
|
||||||
return textualUploadDate;
|
return textualUploadDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTextualUploadDate(String uploadDate) {
|
public void setTextualUploadDate(final String textualUploadDate) {
|
||||||
this.textualUploadDate = uploadDate;
|
this.textualUploadDate = textualUploadDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -115,7 +118,7 @@ public class StreamInfoItem extends InfoItem {
|
||||||
return uploadDate;
|
return uploadDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploadDate(@Nullable DateWrapper uploadDate) {
|
public void setUploadDate(@Nullable final DateWrapper uploadDate) {
|
||||||
this.uploadDate = uploadDate;
|
this.uploadDate = uploadDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -123,25 +126,25 @@ public class StreamInfoItem extends InfoItem {
|
||||||
return uploaderVerified;
|
return uploaderVerified;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUploaderVerified(boolean uploaderVerified) {
|
public void setUploaderVerified(final boolean uploaderVerified) {
|
||||||
this.uploaderVerified = uploaderVerified;
|
this.uploaderVerified = uploaderVerified;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return "StreamInfoItem{" +
|
return "StreamInfoItem{"
|
||||||
"streamType=" + streamType +
|
+ "streamType=" + streamType
|
||||||
", uploaderName='" + uploaderName + '\'' +
|
+ ", uploaderName='" + uploaderName + '\''
|
||||||
", textualUploadDate='" + textualUploadDate + '\'' +
|
+ ", textualUploadDate='" + textualUploadDate + '\''
|
||||||
", viewCount=" + viewCount +
|
+ ", viewCount=" + viewCount
|
||||||
", duration=" + duration +
|
+ ", duration=" + duration
|
||||||
", uploaderUrl='" + uploaderUrl + '\'' +
|
+ ", uploaderUrl='" + uploaderUrl + '\''
|
||||||
", infoType=" + getInfoType() +
|
+ ", infoType=" + getInfoType()
|
||||||
", serviceId=" + getServiceId() +
|
+ ", serviceId=" + getServiceId()
|
||||||
", url='" + getUrl() + '\'' +
|
+ ", url='" + getUrl() + '\''
|
||||||
", name='" + getName() + '\'' +
|
+ ", name='" + getName() + '\''
|
||||||
", thumbnailUrl='" + getThumbnailUrl() + '\'' +
|
+ ", thumbnailUrl='" + getThumbnailUrl() + '\''
|
||||||
", uploaderVerified='" + isUploaderVerified() + '\'' +
|
+ ", uploaderVerified='" + isUploaderVerified() + '\''
|
||||||
'}';
|
+ '}';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,7 @@ public interface StreamInfoItemExtractor extends InfoItemExtractor {
|
||||||
* @throws ParsingException if there is an error in the extraction
|
* @throws ParsingException if there is an error in the extraction
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
default String getShortDescription() throws ParsingException { return null; }
|
default String getShortDescription() throws ParsingException {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,14 +1,10 @@
|
||||||
package org.schabi.newpipe.extractor.stream;
|
package org.schabi.newpipe.extractor.stream;
|
||||||
|
|
||||||
import org.schabi.newpipe.extractor.InfoItem;
|
|
||||||
import org.schabi.newpipe.extractor.InfoItemsCollector;
|
import org.schabi.newpipe.extractor.InfoItemsCollector;
|
||||||
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
|
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
|
||||||
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Vector;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Created by Christian Schabesberger on 28.02.16.
|
* Created by Christian Schabesberger on 28.02.16.
|
||||||
|
@ -30,80 +26,76 @@ import java.util.Vector;
|
||||||
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
* along with NewPipe. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class StreamInfoItemsCollector extends InfoItemsCollector<StreamInfoItem, StreamInfoItemExtractor> {
|
public class StreamInfoItemsCollector
|
||||||
|
extends InfoItemsCollector<StreamInfoItem, StreamInfoItemExtractor> {
|
||||||
|
|
||||||
public StreamInfoItemsCollector(int serviceId) {
|
public StreamInfoItemsCollector(final int serviceId) {
|
||||||
super(serviceId);
|
super(serviceId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StreamInfoItemsCollector(int serviceId, Comparator<StreamInfoItem> comparator) {
|
public StreamInfoItemsCollector(final int serviceId,
|
||||||
|
final Comparator<StreamInfoItem> comparator) {
|
||||||
super(serviceId, comparator);
|
super(serviceId, comparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StreamInfoItem extract(StreamInfoItemExtractor extractor) throws ParsingException {
|
public StreamInfoItem extract(final StreamInfoItemExtractor extractor) throws ParsingException {
|
||||||
if (extractor.isAd()) {
|
if (extractor.isAd()) {
|
||||||
throw new FoundAdException("Found ad");
|
throw new FoundAdException("Found ad");
|
||||||
}
|
}
|
||||||
|
|
||||||
// important information
|
final StreamInfoItem resultItem = new StreamInfoItem(
|
||||||
int serviceId = getServiceId();
|
getServiceId(), extractor.getUrl(), extractor.getName(), extractor.getStreamType());
|
||||||
String url = extractor.getUrl();
|
|
||||||
String name = extractor.getName();
|
|
||||||
StreamType streamType = extractor.getStreamType();
|
|
||||||
|
|
||||||
StreamInfoItem resultItem = new StreamInfoItem(serviceId, url, name, streamType);
|
|
||||||
|
|
||||||
|
|
||||||
// optional information
|
// optional information
|
||||||
try {
|
try {
|
||||||
resultItem.setDuration(extractor.getDuration());
|
resultItem.setDuration(extractor.getDuration());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setUploaderName(extractor.getUploaderName());
|
resultItem.setUploaderName(extractor.getUploaderName());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setTextualUploadDate(extractor.getTextualUploadDate());
|
resultItem.setTextualUploadDate(extractor.getTextualUploadDate());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setUploadDate(extractor.getUploadDate());
|
resultItem.setUploadDate(extractor.getUploadDate());
|
||||||
} catch (ParsingException e) {
|
} catch (final ParsingException e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setViewCount(extractor.getViewCount());
|
resultItem.setViewCount(extractor.getViewCount());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
|
resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setUploaderUrl(extractor.getUploaderUrl());
|
resultItem.setUploaderUrl(extractor.getUploaderUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
|
resultItem.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setUploaderVerified(extractor.isUploaderVerified());
|
resultItem.setUploaderVerified(extractor.isUploaderVerified());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
resultItem.setShortDescription(extractor.getShortDescription());
|
resultItem.setShortDescription(extractor.getShortDescription());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -111,23 +103,13 @@ public class StreamInfoItemsCollector extends InfoItemsCollector<StreamInfoItem,
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void commit(StreamInfoItemExtractor extractor) {
|
public void commit(final StreamInfoItemExtractor extractor) {
|
||||||
try {
|
try {
|
||||||
addItem(extract(extractor));
|
addItem(extract(extractor));
|
||||||
} catch (FoundAdException ae) {
|
} catch (final FoundAdException ae) {
|
||||||
//System.out.println("AD_WARNING: " + ae.getMessage());
|
//System.out.println("AD_WARNING: " + ae.getMessage());
|
||||||
} catch (Exception e) {
|
} catch (final Exception e) {
|
||||||
addError(e);
|
addError(e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<StreamInfoItem> getStreamInfoItemList() {
|
|
||||||
List<StreamInfoItem> siiList = new ArrayList<>();
|
|
||||||
for (InfoItem ii : super.getItems()) {
|
|
||||||
if (ii instanceof StreamInfoItem) {
|
|
||||||
siiList.add((StreamInfoItem) ii);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return siiList;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -33,7 +33,7 @@ public class StreamSegment implements Serializable {
|
||||||
@Nullable
|
@Nullable
|
||||||
private String previewUrl = null;
|
private String previewUrl = null;
|
||||||
|
|
||||||
public StreamSegment(String title, int startTimeSeconds) {
|
public StreamSegment(final String title, final int startTimeSeconds) {
|
||||||
this.title = title;
|
this.title = title;
|
||||||
this.startTimeSeconds = startTimeSeconds;
|
this.startTimeSeconds = startTimeSeconds;
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,10 @@ public class SubtitlesStream extends Stream implements Serializable {
|
||||||
private final boolean autoGenerated;
|
private final boolean autoGenerated;
|
||||||
private final String code;
|
private final String code;
|
||||||
|
|
||||||
public SubtitlesStream(MediaFormat format, String languageCode, String url, boolean autoGenerated) {
|
public SubtitlesStream(final MediaFormat format,
|
||||||
|
final String languageCode,
|
||||||
|
final String url,
|
||||||
|
final boolean autoGenerated) {
|
||||||
super(url, format);
|
super(url, format);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -25,7 +28,8 @@ public class SubtitlesStream extends Stream implements Serializable {
|
||||||
this.locale = new Locale(splits[0]);
|
this.locale = new Locale(splits[0]);
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
this.locale = new Locale(splits[0], splits[1], splits[2]);// complex variants doesn't work!
|
// complex variants doesn't work!
|
||||||
|
this.locale = new Locale(splits[0], splits[1], splits[2]);
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
this.locale = new Locale(splits[0], splits[1]);
|
this.locale = new Locale(splits[0], splits[1]);
|
||||||
|
@ -45,11 +49,11 @@ public class SubtitlesStream extends Stream implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equalStats(Stream cmp) {
|
public boolean equalStats(final Stream cmp) {
|
||||||
return super.equalStats(cmp) &&
|
return super.equalStats(cmp)
|
||||||
cmp instanceof SubtitlesStream &&
|
&& cmp instanceof SubtitlesStream
|
||||||
code.equals(((SubtitlesStream) cmp).code) &&
|
&& code.equals(((SubtitlesStream) cmp).code)
|
||||||
autoGenerated == ((SubtitlesStream) cmp).autoGenerated;
|
&& autoGenerated == ((SubtitlesStream) cmp).autoGenerated;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDisplayLanguageName() {
|
public String getDisplayLanguageName() {
|
||||||
|
|
|
@ -40,15 +40,18 @@ public class VideoStream extends Stream {
|
||||||
private String quality;
|
private String quality;
|
||||||
private String codec;
|
private String codec;
|
||||||
|
|
||||||
public VideoStream(String url, MediaFormat format, String resolution) {
|
public VideoStream(final String url, final MediaFormat format, final String resolution) {
|
||||||
this(url, format, resolution, false);
|
this(url, format, resolution, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VideoStream(String url, MediaFormat format, String resolution, boolean isVideoOnly) {
|
public VideoStream(final String url,
|
||||||
|
final MediaFormat format,
|
||||||
|
final String resolution,
|
||||||
|
final boolean isVideoOnly) {
|
||||||
this(url, null, format, resolution, isVideoOnly);
|
this(url, null, format, resolution, isVideoOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VideoStream(String url, boolean isVideoOnly, ItagItem itag) {
|
public VideoStream(final String url, final boolean isVideoOnly, final ItagItem itag) {
|
||||||
this(url, itag.getMediaFormat(), itag.resolutionString, isVideoOnly);
|
this(url, itag.getMediaFormat(), itag.resolutionString, isVideoOnly);
|
||||||
this.itag = itag.id;
|
this.itag = itag.id;
|
||||||
this.bitrate = itag.getBitrate();
|
this.bitrate = itag.getBitrate();
|
||||||
|
@ -63,21 +66,28 @@ public class VideoStream extends Stream {
|
||||||
this.fps = itag.fps;
|
this.fps = itag.fps;
|
||||||
}
|
}
|
||||||
|
|
||||||
public VideoStream(String url, String torrentUrl, MediaFormat format, String resolution) {
|
public VideoStream(final String url,
|
||||||
|
final String torrentUrl,
|
||||||
|
final MediaFormat format,
|
||||||
|
final String resolution) {
|
||||||
this(url, torrentUrl, format, resolution, false);
|
this(url, torrentUrl, format, resolution, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public VideoStream(String url, String torrentUrl, MediaFormat format, String resolution, boolean isVideoOnly) {
|
public VideoStream(final String url,
|
||||||
|
final String torrentUrl,
|
||||||
|
final MediaFormat format,
|
||||||
|
final String resolution,
|
||||||
|
final boolean isVideoOnly) {
|
||||||
super(url, torrentUrl, format);
|
super(url, torrentUrl, format);
|
||||||
this.resolution = resolution;
|
this.resolution = resolution;
|
||||||
this.isVideoOnly = isVideoOnly;
|
this.isVideoOnly = isVideoOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equalStats(Stream cmp) {
|
public boolean equalStats(final Stream cmp) {
|
||||||
return super.equalStats(cmp) && cmp instanceof VideoStream &&
|
return super.equalStats(cmp) && cmp instanceof VideoStream
|
||||||
resolution.equals(((VideoStream) cmp).resolution) &&
|
&& resolution.equals(((VideoStream) cmp).resolution)
|
||||||
isVideoOnly == ((VideoStream) cmp).isVideoOnly;
|
&& isVideoOnly == ((VideoStream) cmp).isVideoOnly;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -22,16 +22,17 @@ public abstract class SubscriptionExtractor {
|
||||||
this(null, null);
|
this(null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InvalidSourceException(String detailMessage) {
|
public InvalidSourceException(@Nullable final String detailMessage) {
|
||||||
this(detailMessage, null);
|
this(detailMessage, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InvalidSourceException(Throwable cause) {
|
public InvalidSourceException(final Throwable cause) {
|
||||||
this(null, cause);
|
this(null, cause);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InvalidSourceException(String detailMessage, Throwable cause) {
|
public InvalidSourceException(@Nullable final String detailMessage, final Throwable cause) {
|
||||||
super(detailMessage == null ? "Not a valid source" : "Not a valid source (" + detailMessage + ")", cause);
|
super("Not a valid source" + (detailMessage == null ? "" : " (" + detailMessage + ")"),
|
||||||
|
cause);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,7 +43,8 @@ public abstract class SubscriptionExtractor {
|
||||||
private final List<ContentSource> supportedSources;
|
private final List<ContentSource> supportedSources;
|
||||||
protected final StreamingService service;
|
protected final StreamingService service;
|
||||||
|
|
||||||
public SubscriptionExtractor(StreamingService service, List<ContentSource> supportedSources) {
|
public SubscriptionExtractor(final StreamingService service,
|
||||||
|
final List<ContentSource> supportedSources) {
|
||||||
this.service = service;
|
this.service = service;
|
||||||
this.supportedSources = Collections.unmodifiableList(supportedSources);
|
this.supportedSources = Collections.unmodifiableList(supportedSources);
|
||||||
}
|
}
|
||||||
|
@ -52,7 +54,8 @@ public abstract class SubscriptionExtractor {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns an url that can help/guide the user to the file (or channel url) to extract the subscriptions.
|
* Returns an url that can help/guide the user to the file (or channel url) to extract the
|
||||||
|
* subscriptions.
|
||||||
* <p>For example, in YouTube, the export subscriptions url is a good choice to return here.</p>
|
* <p>For example, in YouTube, the export subscriptions url is a good choice to return here.</p>
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
|
@ -72,7 +75,8 @@ public abstract class SubscriptionExtractor {
|
||||||
/**
|
/**
|
||||||
* Reads and parse a list of {@link SubscriptionItem} from the given InputStream.
|
* Reads and parse a list of {@link SubscriptionItem} from the given InputStream.
|
||||||
*
|
*
|
||||||
* @throws InvalidSourceException when the content read from the InputStream is invalid and can not be parsed
|
* @throws InvalidSourceException when the content read from the InputStream is invalid and can
|
||||||
|
* not be parsed
|
||||||
*/
|
*/
|
||||||
public List<SubscriptionItem> fromInputStream(@Nonnull final InputStream contentInputStream)
|
public List<SubscriptionItem> fromInputStream(@Nonnull final InputStream contentInputStream)
|
||||||
throws ExtractionException {
|
throws ExtractionException {
|
||||||
|
@ -83,7 +87,8 @@ public abstract class SubscriptionExtractor {
|
||||||
/**
|
/**
|
||||||
* Reads and parse a list of {@link SubscriptionItem} from the given InputStream.
|
* Reads and parse a list of {@link SubscriptionItem} from the given InputStream.
|
||||||
*
|
*
|
||||||
* @throws InvalidSourceException when the content read from the InputStream is invalid and can not be parsed
|
* @throws InvalidSourceException when the content read from the InputStream is invalid and can
|
||||||
|
* not be parsed
|
||||||
*/
|
*/
|
||||||
public List<SubscriptionItem> fromInputStream(@Nonnull final InputStream contentInputStream,
|
public List<SubscriptionItem> fromInputStream(@Nonnull final InputStream contentInputStream,
|
||||||
@Nonnull final String contentType)
|
@Nonnull final String contentType)
|
||||||
|
|
|
@ -4,9 +4,10 @@ import java.io.Serializable;
|
||||||
|
|
||||||
public class SubscriptionItem implements Serializable {
|
public class SubscriptionItem implements Serializable {
|
||||||
private final int serviceId;
|
private final int serviceId;
|
||||||
private final String url, name;
|
private final String url;
|
||||||
|
private final String name;
|
||||||
|
|
||||||
public SubscriptionItem(int serviceId, String url, String name) {
|
public SubscriptionItem(final int serviceId, final String url, final String name) {
|
||||||
this.serviceId = serviceId;
|
this.serviceId = serviceId;
|
||||||
this.url = url;
|
this.url = url;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
@ -26,7 +27,7 @@ public class SubscriptionItem implements Serializable {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getClass().getSimpleName() + "@" + Integer.toHexString(hashCode()) +
|
return getClass().getSimpleName() + "@" + Integer.toHexString(hashCode())
|
||||||
"[name=" + name + " > " + serviceId + ":" + url + "]";
|
+ "[name=" + name + " > " + serviceId + ":" + url + "]";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,11 +15,12 @@ public abstract class SuggestionExtractor {
|
||||||
@Nullable private Localization forcedLocalization;
|
@Nullable private Localization forcedLocalization;
|
||||||
@Nullable private ContentCountry forcedContentCountry;
|
@Nullable private ContentCountry forcedContentCountry;
|
||||||
|
|
||||||
public SuggestionExtractor(StreamingService service) {
|
public SuggestionExtractor(final StreamingService service) {
|
||||||
this.service = service;
|
this.service = service;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract List<String> suggestionList(String query) throws IOException, ExtractionException;
|
public abstract List<String> suggestionList(String query)
|
||||||
|
throws IOException, ExtractionException;
|
||||||
|
|
||||||
public int getServiceId() {
|
public int getServiceId() {
|
||||||
return service.getServiceId();
|
return service.getServiceId();
|
||||||
|
@ -31,11 +32,11 @@ public abstract class SuggestionExtractor {
|
||||||
|
|
||||||
// TODO: Create a more general Extractor class
|
// TODO: Create a more general Extractor class
|
||||||
|
|
||||||
public void forceLocalization(@Nullable Localization localization) {
|
public void forceLocalization(@Nullable final Localization localization) {
|
||||||
this.forcedLocalization = localization;
|
this.forcedLocalization = localization;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void forceContentCountry(@Nullable ContentCountry contentCountry) {
|
public void forceContentCountry(@Nullable final ContentCountry contentCountry) {
|
||||||
this.forcedContentCountry = contentCountry;
|
this.forcedContentCountry = contentCountry;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,6 +47,7 @@ public abstract class SuggestionExtractor {
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public ContentCountry getExtractorContentCountry() {
|
public ContentCountry getExtractorContentCountry() {
|
||||||
return forcedContentCountry == null ? getService().getContentCountry() : forcedContentCountry;
|
return forcedContentCountry == null
|
||||||
|
? getService().getContentCountry() : forcedContentCountry;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue