capabilities) {
this.serviceId = id;
this.serviceInfo = new ServiceInfo(name, capabilities);
}
@@ -172,22 +178,21 @@ public abstract class StreamingService {
public abstract SubscriptionExtractor getSubscriptionExtractor();
/**
- * This method decides which strategy will be chosen to fetch the feed. In YouTube, for example, a separate feed
- * exists which is lightweight and made specifically to be used like this.
+ * This method decides which strategy will be chosen to fetch the feed. In YouTube, for example,
+ * a separate feed exists which is lightweight and made specifically to be used like this.
*
* In services which there's no other way to retrieve them, null should be returned.
*
* @return a {@link FeedExtractor} instance or null.
*/
@Nullable
- public FeedExtractor getFeedExtractor(String url) throws ExtractionException {
+ public FeedExtractor getFeedExtractor(final String url) throws ExtractionException {
return null;
}
/**
* Must create a new instance of a KioskList implementation.
* @return a new KioskList instance
- * @throws ExtractionException
*/
public abstract KioskList getKioskList() throws ExtractionException;
@@ -195,49 +200,52 @@ public abstract class StreamingService {
* Must create a new instance of a ChannelExtractor implementation.
* @param linkHandler is pointing to the channel which should be handled by this new instance.
* @return a new ChannelExtractor
- * @throws ExtractionException
*/
- public abstract ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler) throws ExtractionException;
+ public abstract ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler)
+ throws ExtractionException;
/**
* Must crete a new instance of a PlaylistExtractor implementation.
* @param linkHandler is pointing to the playlist which should be handled by this new instance.
* @return a new PlaylistExtractor
- * @throws ExtractionException
*/
- public abstract PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler) throws ExtractionException;
+ public abstract PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler)
+ throws ExtractionException;
/**
* Must create a new instance of a StreamExtractor implementation.
* @param linkHandler is pointing to the stream which should be handled by this new instance.
* @return a new StreamExtractor
- * @throws ExtractionException
*/
- public abstract StreamExtractor getStreamExtractor(LinkHandler linkHandler) throws ExtractionException;
+ public abstract StreamExtractor getStreamExtractor(LinkHandler linkHandler)
+ throws ExtractionException;
- public abstract CommentsExtractor getCommentsExtractor(ListLinkHandler linkHandler) throws ExtractionException;
+ public abstract CommentsExtractor getCommentsExtractor(ListLinkHandler linkHandler)
+ throws ExtractionException;
/*//////////////////////////////////////////////////////////////////////////
// Extractors without link handler
//////////////////////////////////////////////////////////////////////////*/
- public SearchExtractor getSearchExtractor(String query,
- List contentFilter,
- String sortFilter) throws ExtractionException {
+ public SearchExtractor getSearchExtractor(final String query,
+ final List contentFilter,
+ final String sortFilter) throws ExtractionException {
return getSearchExtractor(getSearchQHFactory()
.fromQuery(query, contentFilter, sortFilter));
}
- public ChannelExtractor getChannelExtractor(String id,
- List contentFilter,
- String sortFilter) throws ExtractionException {
+ public ChannelExtractor getChannelExtractor(final String id,
+ final List contentFilter,
+ final String sortFilter)
+ throws ExtractionException {
return getChannelExtractor(getChannelLHFactory()
.fromQuery(id, contentFilter, sortFilter));
}
- public PlaylistExtractor getPlaylistExtractor(String id,
- List contentFilter,
- String sortFilter) throws ExtractionException {
+ public PlaylistExtractor getPlaylistExtractor(final String id,
+ final List contentFilter,
+ final String sortFilter)
+ throws ExtractionException {
return getPlaylistExtractor(getPlaylistLHFactory()
.fromQuery(id, contentFilter, sortFilter));
}
@@ -246,28 +254,28 @@ public abstract class StreamingService {
// Short extractors overloads
//////////////////////////////////////////////////////////////////////////*/
- public SearchExtractor getSearchExtractor(String query) throws ExtractionException {
+ public SearchExtractor getSearchExtractor(final String query) throws ExtractionException {
return getSearchExtractor(getSearchQHFactory().fromQuery(query));
}
- public ChannelExtractor getChannelExtractor(String url) throws ExtractionException {
+ public ChannelExtractor getChannelExtractor(final String url) throws ExtractionException {
return getChannelExtractor(getChannelLHFactory().fromUrl(url));
}
- public PlaylistExtractor getPlaylistExtractor(String url) throws ExtractionException {
+ public PlaylistExtractor getPlaylistExtractor(final String url) throws ExtractionException {
return getPlaylistExtractor(getPlaylistLHFactory().fromUrl(url));
}
- public StreamExtractor getStreamExtractor(String url) throws ExtractionException {
+ public StreamExtractor getStreamExtractor(final String url) throws ExtractionException {
return getStreamExtractor(getStreamLHFactory().fromUrl(url));
}
- public CommentsExtractor getCommentsExtractor(String url) throws ExtractionException {
- ListLinkHandlerFactory llhf = getCommentsLHFactory();
- if (llhf == null) {
+ public CommentsExtractor getCommentsExtractor(final String url) throws ExtractionException {
+ final ListLinkHandlerFactory listLinkHandlerFactory = getCommentsLHFactory();
+ if (listLinkHandlerFactory == null) {
return null;
}
- return getCommentsExtractor(llhf.fromUrl(url));
+ return getCommentsExtractor(listLinkHandlerFactory.fromUrl(url));
}
/*//////////////////////////////////////////////////////////////////////////
@@ -320,7 +328,8 @@ public abstract class StreamingService {
* the user prefer (using {@link NewPipe#getPreferredLocalization()}), then it will:
*
* - Check if the exactly localization is supported by this service.
- * - If not, check if a less specific localization is available, using only the language code.
+ * - If not, check if a less specific localization is available, using only the language
+ * code.
* - Fallback to the {@link Localization#DEFAULT default} localization.
*
*/
@@ -333,8 +342,9 @@ public abstract class StreamingService {
}
// Fallback to the first supported language that matches the preferred language
- for (Localization supportedLanguage : getSupportedLocalizations()) {
- if (supportedLanguage.getLanguageCode().equals(preferredLocalization.getLanguageCode())) {
+ for (final Localization supportedLanguage : getSupportedLocalizations()) {
+ if (supportedLanguage.getLanguageCode()
+ .equals(preferredLocalization.getLanguageCode())) {
return supportedLanguage;
}
}
@@ -343,8 +353,8 @@ public abstract class StreamingService {
}
/**
- * Returns the country that should be used to fetch content in this service. It will get which country
- * the user prefer (using {@link NewPipe#getPreferredContentCountry()}), then it will:
+ * Returns the country that should be used to fetch content in this service. It will get which
+ * country the user prefer (using {@link NewPipe#getPreferredContentCountry()}), then it will:
*
* - Check if the country is supported by this service.
* - If not, fallback to the {@link ContentCountry#DEFAULT default} country.
@@ -361,14 +371,15 @@ public abstract class StreamingService {
}
/**
- * Get an instance of the time ago parser using the patterns related to the passed localization.
- *
- * Just like {@link #getLocalization()}, it will also try to fallback to a less specific localization if
- * the exact one is not available/supported.
+ * Get an instance of the time ago parser using the patterns related to the passed localization.
+ *
+ * Just like {@link #getLocalization()}, it will also try to fallback to a less specific
+ * localization if the exact one is not available/supported.
*
- * @throws IllegalArgumentException if the localization is not supported (parsing patterns are not present).
+ * @throws IllegalArgumentException if the localization is not supported (parsing patterns are
+ * not present).
*/
- public TimeAgoParser getTimeAgoParser(Localization localization) {
+ public TimeAgoParser getTimeAgoParser(final Localization localization) {
final TimeAgoParser targetParser = TimeAgoPatternsManager.getTimeAgoParserFor(localization);
if (targetParser != null) {
@@ -376,15 +387,18 @@ public abstract class StreamingService {
}
if (!localization.getCountryCode().isEmpty()) {
- final Localization lessSpecificLocalization = new Localization(localization.getLanguageCode());
- final TimeAgoParser lessSpecificParser = TimeAgoPatternsManager.getTimeAgoParserFor(lessSpecificLocalization);
+ final Localization lessSpecificLocalization
+ = new Localization(localization.getLanguageCode());
+ final TimeAgoParser lessSpecificParser
+ = TimeAgoPatternsManager.getTimeAgoParserFor(lessSpecificLocalization);
if (lessSpecificParser != null) {
return lessSpecificParser;
}
}
- throw new IllegalArgumentException("Localization is not supported (\"" + localization.toString() + "\")");
+ throw new IllegalArgumentException(
+ "Localization is not supported (\"" + localization + "\")");
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java
index 1ec47498a..a04541124 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelExtractor.java
@@ -30,7 +30,7 @@ public abstract class ChannelExtractor extends ListExtractor {
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);
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java
index 00201358a..7e82ba4d7 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfo.java
@@ -34,27 +34,36 @@ import java.io.IOException;
public class ChannelInfo extends ListInfo {
- public ChannelInfo(int serviceId, String id, String url, String originalUrl, String name, ListLinkHandler listLinkHandler) {
- super(serviceId, id, url, originalUrl, name, listLinkHandler.getContentFilters(), listLinkHandler.getSortFilter());
+ public ChannelInfo(final int serviceId,
+ 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);
}
- public static ChannelInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
- ChannelExtractor extractor = service.getChannelExtractor(url);
+ public static ChannelInfo getInfo(final StreamingService service, final String url)
+ throws IOException, ExtractionException {
+ final ChannelExtractor extractor = service.getChannelExtractor(url);
extractor.fetchPage();
return getInfo(extractor);
}
- public static InfoItemsPage getMoreItems(StreamingService service,
- String url,
- Page page) throws IOException, ExtractionException {
+ public static InfoItemsPage getMoreItems(final StreamingService service,
+ final String url,
+ final Page page)
+ throws IOException, ExtractionException {
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 String id = extractor.getId();
@@ -62,60 +71,62 @@ public class ChannelInfo extends ListInfo {
final String originalUrl = extractor.getOriginalUrl();
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 {
info.setAvatarUrl(extractor.getAvatarUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
try {
info.setBannerUrl(extractor.getBannerUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
try {
info.setFeedUrl(extractor.getFeedUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
- final InfoItemsPage itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor);
+ final InfoItemsPage itemsPage =
+ ExtractorHelper.getItemsPageOrLogError(info, extractor);
info.setRelatedItems(itemsPage.getItems());
info.setNextPage(itemsPage.getNextPage());
try {
info.setSubscriberCount(extractor.getSubscriberCount());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
try {
info.setDescription(extractor.getDescription());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
try {
info.setParentChannelName(extractor.getParentChannelName());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
try {
info.setParentChannelUrl(extractor.getParentChannelUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
try {
info.setParentChannelAvatarUrl(extractor.getParentChannelAvatarUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
try {
info.setVerified(extractor.isVerified());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
@@ -137,7 +148,7 @@ public class ChannelInfo extends ListInfo {
return parentChannelName;
}
- public void setParentChannelName(String parentChannelName) {
+ public void setParentChannelName(final String parentChannelName) {
this.parentChannelName = parentChannelName;
}
@@ -145,7 +156,7 @@ public class ChannelInfo extends ListInfo {
return parentChannelUrl;
}
- public void setParentChannelUrl(String parentChannelUrl) {
+ public void setParentChannelUrl(final String parentChannelUrl) {
this.parentChannelUrl = parentChannelUrl;
}
@@ -153,7 +164,7 @@ public class ChannelInfo extends ListInfo {
return parentChannelAvatarUrl;
}
- public void setParentChannelAvatarUrl(String parentChannelAvatarUrl) {
+ public void setParentChannelAvatarUrl(final String parentChannelAvatarUrl) {
this.parentChannelAvatarUrl = parentChannelAvatarUrl;
}
@@ -161,7 +172,7 @@ public class ChannelInfo extends ListInfo {
return avatarUrl;
}
- public void setAvatarUrl(String avatarUrl) {
+ public void setAvatarUrl(final String avatarUrl) {
this.avatarUrl = avatarUrl;
}
@@ -169,7 +180,7 @@ public class ChannelInfo extends ListInfo {
return bannerUrl;
}
- public void setBannerUrl(String bannerUrl) {
+ public void setBannerUrl(final String bannerUrl) {
this.bannerUrl = bannerUrl;
}
@@ -177,7 +188,7 @@ public class ChannelInfo extends ListInfo {
return feedUrl;
}
- public void setFeedUrl(String feedUrl) {
+ public void setFeedUrl(final String feedUrl) {
this.feedUrl = feedUrl;
}
@@ -185,7 +196,7 @@ public class ChannelInfo extends ListInfo {
return subscriberCount;
}
- public void setSubscriberCount(long subscriberCount) {
+ public void setSubscriberCount(final long subscriberCount) {
this.subscriberCount = subscriberCount;
}
@@ -193,7 +204,7 @@ public class ChannelInfo extends ListInfo {
return description;
}
- public void setDescription(String description) {
+ public void setDescription(final String description) {
this.description = description;
}
@@ -201,7 +212,7 @@ public class ChannelInfo extends ListInfo {
return donationLinks;
}
- public void setDonationLinks(String[] donationLinks) {
+ public void setDonationLinks(final String[] donationLinks) {
this.donationLinks = donationLinks;
}
@@ -209,7 +220,7 @@ public class ChannelInfo extends ListInfo {
return verified;
}
- public void setVerified(boolean verified) {
+ public void setVerified(final boolean verified) {
this.verified = verified;
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItem.java b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItem.java
index 51b9619ad..ca29436b3 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItem.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItem.java
@@ -29,7 +29,7 @@ public class ChannelInfoItem extends InfoItem {
private long streamCount = -1;
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);
}
@@ -37,7 +37,7 @@ public class ChannelInfoItem extends InfoItem {
return description;
}
- public void setDescription(String description) {
+ public void setDescription(final String description) {
this.description = description;
}
@@ -45,23 +45,23 @@ public class ChannelInfoItem extends InfoItem {
return subscriberCount;
}
- public void setSubscriberCount(long subscriber_count) {
- this.subscriberCount = subscriber_count;
+ public void setSubscriberCount(final long subscriberCount) {
+ this.subscriberCount = subscriberCount;
}
public long getStreamCount() {
return streamCount;
}
- public void setStreamCount(long stream_count) {
- this.streamCount = stream_count;
+ public void setStreamCount(final long streamCount) {
+ this.streamCount = streamCount;
}
public boolean isVerified() {
return verified;
}
- public void setVerified(boolean verified) {
+ public void setVerified(final boolean verified) {
this.verified = verified;
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.java b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.java
index 454ba30a9..5b085f8b8 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/channel/ChannelInfoItemsCollector.java
@@ -23,45 +23,42 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
* along with NewPipe. If not, see .
*/
-public class ChannelInfoItemsCollector extends InfoItemsCollector {
- public ChannelInfoItemsCollector(int serviceId) {
+public final class ChannelInfoItemsCollector
+ extends InfoItemsCollector {
+ public ChannelInfoItemsCollector(final int serviceId) {
super(serviceId);
}
@Override
- public ChannelInfoItem extract(ChannelInfoItemExtractor extractor) throws ParsingException {
- // important information
- int serviceId = getServiceId();
- String name = extractor.getName();
- String url = extractor.getUrl();
-
- ChannelInfoItem resultItem = new ChannelInfoItem(serviceId, url, name);
-
+ public ChannelInfoItem extract(final ChannelInfoItemExtractor extractor)
+ throws ParsingException {
+ final ChannelInfoItem resultItem = new ChannelInfoItem(
+ getServiceId(), extractor.getUrl(), extractor.getName());
// optional information
try {
resultItem.setSubscriberCount(extractor.getSubscriberCount());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setStreamCount(extractor.getStreamCount());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setDescription(extractor.getDescription());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setVerified(extractor.isVerified());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfo.java
index a280500c8..98ec136e5 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfo.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfo.java
@@ -11,7 +11,7 @@ import org.schabi.newpipe.extractor.utils.ExtractorHelper;
import java.io.IOException;
-public class CommentsInfo extends ListInfo {
+public final class CommentsInfo extends ListInfo {
private CommentsInfo(
final int serviceId,
@@ -56,7 +56,8 @@ public class CommentsInfo extends ListInfo {
public static InfoItemsPage getMoreItems(
final CommentsInfo commentsInfo,
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 getMoreItems(
@@ -86,7 +87,7 @@ public class CommentsInfo extends ListInfo {
/**
* @apiNote Warning: This method is experimental and may get removed in a future release.
- * @return true
if the comments are disabled otherwise false
(default)
+ * @return {@code true} if the comments are disabled otherwise {@code false} (default)
* @see CommentsExtractor#isCommentsDisabled()
*/
public boolean isCommentsDisabled() {
@@ -95,7 +96,7 @@ public class CommentsInfo extends ListInfo {
/**
* @apiNote Warning: This method is experimental and may get removed in a future release.
- * @param commentsDisabled true
if the comments are disabled otherwise false
+ * @param commentsDisabled {@code true} if the comments are disabled otherwise {@code false}
*/
public void setCommentsDisabled(final boolean commentsDisabled) {
this.commentsDisabled = commentsDisabled;
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItem.java b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItem.java
index 5ed6d6888..0f4cbbc24 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItem.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItem.java
@@ -28,7 +28,7 @@ public class CommentsInfoItem extends InfoItem {
public static final int NO_LIKE_COUNT = -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);
}
@@ -36,7 +36,7 @@ public class CommentsInfoItem extends InfoItem {
return commentId;
}
- public void setCommentId(String commentId) {
+ public void setCommentId(final String commentId) {
this.commentId = commentId;
}
@@ -44,7 +44,7 @@ public class CommentsInfoItem extends InfoItem {
return commentText;
}
- public void setCommentText(String commentText) {
+ public void setCommentText(final String commentText) {
this.commentText = commentText;
}
@@ -52,7 +52,7 @@ public class CommentsInfoItem extends InfoItem {
return uploaderName;
}
- public void setUploaderName(String uploaderName) {
+ public void setUploaderName(final String uploaderName) {
this.uploaderName = uploaderName;
}
@@ -60,7 +60,7 @@ public class CommentsInfoItem extends InfoItem {
return uploaderAvatarUrl;
}
- public void setUploaderAvatarUrl(String uploaderAvatarUrl) {
+ public void setUploaderAvatarUrl(final String uploaderAvatarUrl) {
this.uploaderAvatarUrl = uploaderAvatarUrl;
}
@@ -68,7 +68,7 @@ public class CommentsInfoItem extends InfoItem {
return uploaderUrl;
}
- public void setUploaderUrl(String uploaderUrl) {
+ public void setUploaderUrl(final String uploaderUrl) {
this.uploaderUrl = uploaderUrl;
}
@@ -76,7 +76,7 @@ public class CommentsInfoItem extends InfoItem {
return textualUploadDate;
}
- public void setTextualUploadDate(String textualUploadDate) {
+ public void setTextualUploadDate(final String textualUploadDate) {
this.textualUploadDate = textualUploadDate;
}
@@ -85,7 +85,7 @@ public class CommentsInfoItem extends InfoItem {
return uploadDate;
}
- public void setUploadDate(@Nullable DateWrapper uploadDate) {
+ public void setUploadDate(@Nullable final DateWrapper uploadDate) {
this.uploadDate = uploadDate;
}
@@ -97,7 +97,7 @@ public class CommentsInfoItem extends InfoItem {
return likeCount;
}
- public void setLikeCount(int likeCount) {
+ public void setLikeCount(final int likeCount) {
this.likeCount = likeCount;
}
@@ -105,11 +105,11 @@ public class CommentsInfoItem extends InfoItem {
return textualLikeCount;
}
- public void setTextualLikeCount(String textualLikeCount) {
+ public void setTextualLikeCount(final String textualLikeCount) {
this.textualLikeCount = textualLikeCount;
}
- public void setHeartedByUploader(boolean isHeartedByUploader) {
+ public void setHeartedByUploader(final boolean isHeartedByUploader) {
this.heartedByUploader = isHeartedByUploader;
}
@@ -121,11 +121,11 @@ public class CommentsInfoItem extends InfoItem {
return pinned;
}
- public void setPinned(boolean pinned) {
+ public void setPinned(final boolean pinned) {
this.pinned = pinned;
}
- public void setUploaderVerified(boolean uploaderVerified) {
+ public void setUploaderVerified(final boolean uploaderVerified) {
this.uploaderVerified = uploaderVerified;
}
@@ -146,7 +146,12 @@ public class CommentsInfoItem extends InfoItem {
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;
+ }
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.java
index 39c0b48b4..40279eb0d 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemExtractor.java
@@ -18,7 +18,8 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor {
*
*
*
- * 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)
*
* @see StreamExtractor#getLikeCount()
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemsCollector.java b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemsCollector.java
index ea9465809..0a5388d0f 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemsCollector.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/comments/CommentsInfoItemsCollector.java
@@ -1,101 +1,97 @@
package org.schabi.newpipe.extractor.comments;
-import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.InfoItemsCollector;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import java.util.ArrayList;
import java.util.List;
-public class CommentsInfoItemsCollector extends InfoItemsCollector {
+public final class CommentsInfoItemsCollector
+ extends InfoItemsCollector {
- public CommentsInfoItemsCollector(int serviceId) {
+ public CommentsInfoItemsCollector(final int serviceId) {
super(serviceId);
}
@Override
- public CommentsInfoItem extract(CommentsInfoItemExtractor extractor) throws ParsingException {
-
- // important information
- int serviceId = getServiceId();
- String url = extractor.getUrl();
- String name = extractor.getName();
-
- CommentsInfoItem resultItem = new CommentsInfoItem(serviceId, url, name);
+ public CommentsInfoItem extract(final CommentsInfoItemExtractor extractor)
+ throws ParsingException {
+ final CommentsInfoItem resultItem = new CommentsInfoItem(
+ getServiceId(), extractor.getUrl(), extractor.getName());
// optional information
try {
resultItem.setCommentId(extractor.getCommentId());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setCommentText(extractor.getCommentText());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setUploaderName(extractor.getUploaderName());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setUploaderUrl(extractor.getUploaderUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setTextualUploadDate(extractor.getTextualUploadDate());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setUploadDate(extractor.getUploadDate());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setLikeCount(extractor.getLikeCount());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setTextualLikeCount(extractor.getTextualLikeCount());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setHeartedByUploader(extractor.isHeartedByUploader());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setPinned(extractor.isPinned());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setStreamPosition(extractor.getStreamPosition());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setReplies(extractor.getReplies());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
@@ -103,10 +99,10 @@ public class CommentsInfoItemsCollector extends InfoItemsCollector
*
- * This method calls {@link #get(String, Map, Localization)} with the default preferred localization. It should only be
- * used when the resource that will be fetched won't be affected by the localization.
+ * This method calls {@link #get(String, Map, Localization)} with the default preferred
+ * 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
* @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());
}
@@ -38,7 +39,8 @@ public abstract class Downloader {
* @param localization the source of the value of the {@code Accept-Language} header
* @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);
}
@@ -50,7 +52,8 @@ public abstract class Downloader {
* Any default headers should be overridden by these.
* @return the result of the GET request
*/
- public Response get(String url, @Nullable Map> headers) throws IOException, ReCaptchaException {
+ public Response get(final String url, @Nullable final Map> headers)
+ throws IOException, ReCaptchaException {
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
* @return the result of the GET request
*/
- public Response get(String url, @Nullable Map> headers, @Nullable Localization localization)
+ public Response get(final String url,
+ @Nullable final Map> headers,
+ @Nullable final Localization localization)
throws IOException, ReCaptchaException {
return execute(Request.newBuilder()
.get(url)
@@ -80,7 +85,7 @@ public abstract class Downloader {
* @param url the URL that is pointing to the wanted resource
* @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);
}
@@ -92,7 +97,7 @@ public abstract class Downloader {
* Any default headers should be overridden by these.
* @return the result of the HEAD request
*/
- public Response head(String url, @Nullable Map> headers)
+ public Response head(final String url, @Nullable final Map> headers)
throws IOException, ReCaptchaException {
return execute(Request.newBuilder()
.head(url)
@@ -109,7 +114,9 @@ public abstract class Downloader {
* @param dataToSend byte array that will be sent when doing the request.
* @return the result of the GET request
*/
- public Response post(String url, @Nullable Map> headers, @Nullable byte[] dataToSend)
+ public Response post(final String url,
+ @Nullable final Map> headers,
+ @Nullable final byte[] dataToSend)
throws IOException, ReCaptchaException {
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
* @return the result of the GET request
*/
- public Response post(String url, @Nullable Map> headers, @Nullable byte[] dataToSend, @Nullable Localization localization)
+ public Response post(final String url,
+ @Nullable final Map> headers,
+ @Nullable final byte[] dataToSend,
+ @Nullable final Localization localization)
throws IOException, ReCaptchaException {
return execute(Request.newBuilder()
.post(url, dataToSend)
@@ -140,5 +150,6 @@ public abstract class Downloader {
*
* @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;
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/downloader/Request.java b/extractor/src/main/java/org/schabi/newpipe/extractor/downloader/Request.java
index 4bae8fc27..05a992782 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/downloader/Request.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/downloader/Request.java
@@ -2,42 +2,60 @@ package org.schabi.newpipe.extractor.downloader;
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.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 {
private final String httpMethod;
private final String url;
private final Map> headers;
- @Nullable private final byte[] dataToSend;
- @Nullable private final Localization localization;
+ @Nullable
+ private final byte[] dataToSend;
+ @Nullable
+ private final Localization localization;
- public Request(String httpMethod, String url, Map> headers, @Nullable byte[] dataToSend,
- @Nullable Localization localization, boolean automaticLocalizationHeader) {
- if (httpMethod == null) throw new IllegalArgumentException("Request's httpMethod is null");
- if (url == null) throw new IllegalArgumentException("Request's url is null");
+ public Request(final String httpMethod,
+ final String url,
+ @Nullable final Map> headers,
+ @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.url = url;
this.dataToSend = dataToSend;
this.localization = localization;
- Map> headersToSet = null;
- if (headers == null) headers = Collections.emptyMap();
-
+ final Map> actualHeaders = new LinkedHashMap<>();
+ if (headers != null) {
+ actualHeaders.putAll(headers);
+ }
if (automaticLocalizationHeader && localization != null) {
- headersToSet = new LinkedHashMap<>(headersFromLocalization(localization));
- headersToSet.putAll(headers);
+ actualHeaders.putAll(headersFromLocalization(localization));
}
- this.headers = Collections.unmodifiableMap(headersToSet == null ? headers : headersToSet);
+ this.headers = Collections.unmodifiableMap(actualHeaders);
}
- private Request(Builder builder) {
+ private Request(final Builder builder) {
this(builder.httpMethod, builder.url, builder.headers, builder.dataToSend,
builder.localization, builder.automaticLocalizationHeader);
}
@@ -94,7 +112,7 @@ public class Request {
public static final class Builder {
private String httpMethod;
private String url;
- private Map> headers = new LinkedHashMap<>();
+ private final Map> headers = new LinkedHashMap<>();
private byte[] dataToSend;
private Localization localization;
private boolean automaticLocalizationHeader = true;
@@ -105,27 +123,28 @@ public class Request {
/**
* A http method (i.e. {@code GET, POST, HEAD}).
*/
- public Builder httpMethod(String httpMethod) {
- this.httpMethod = httpMethod;
+ public Builder httpMethod(final String httpMethodToSet) {
+ this.httpMethod = httpMethodToSet;
return this;
}
/**
* The URL that is pointing to the wanted resource.
*/
- public Builder url(String url) {
- this.url = url;
+ public Builder url(final String urlToSet) {
+ this.url = urlToSet;
return this;
}
/**
* A list of headers that will be used in the request.
- * Any default headers that the implementation may have, should be overridden by these.
+ * Any default headers that the implementation may have, should be overridden by
+ * these.
*/
- public Builder headers(@Nullable Map> headers) {
+ public Builder headers(@Nullable final Map> headersToSet) {
this.headers.clear();
- if (headers != null) {
- this.headers.putAll(headers);
+ if (headersToSet != null) {
+ this.headers.putAll(headersToSet);
}
return this;
}
@@ -137,8 +156,8 @@ public class Request {
* The implementation should make note of some recommended headers
* (for example, {@code Content-Length} in a post request).
*/
- public Builder dataToSend(byte[] dataToSend) {
- this.dataToSend = dataToSend;
+ public Builder dataToSend(final byte[] dataToSendToSet) {
+ this.dataToSend = dataToSendToSet;
return this;
}
@@ -148,16 +167,16 @@ public class Request {
* Usually the {@code Accept-Language} will be set to this value (a helper
* method to do this easily: {@link Request#headersFromLocalization(Localization)}).
*/
- public Builder localization(Localization localization) {
- this.localization = localization;
+ public Builder localization(final Localization localizationToSet) {
+ this.localization = localizationToSet;
return this;
}
/**
* If localization headers should automatically be included in the request.
*/
- public Builder automaticLocalizationHeader(boolean automaticLocalizationHeader) {
- this.automaticLocalizationHeader = automaticLocalizationHeader;
+ public Builder automaticLocalizationHeader(final boolean automaticLocalizationHeaderToSet) {
+ this.automaticLocalizationHeader = automaticLocalizationHeaderToSet;
return this;
}
@@ -170,22 +189,22 @@ public class Request {
// Http Methods Utils
//////////////////////////////////////////////////////////////////////////*/
- public Builder get(String url) {
+ public Builder get(final String urlToSet) {
this.httpMethod = "GET";
- this.url = url;
+ this.url = urlToSet;
return this;
}
- public Builder head(String url) {
+ public Builder head(final String urlToSet) {
this.httpMethod = "HEAD";
- this.url = url;
+ this.url = urlToSet;
return this;
}
- public Builder post(String url, @Nullable byte[] dataToSend) {
+ public Builder post(final String urlToSet, @Nullable final byte[] dataToSendToSet) {
this.httpMethod = "POST";
- this.url = url;
- this.dataToSend = dataToSend;
+ this.url = urlToSet;
+ this.dataToSend = dataToSendToSet;
return this;
}
@@ -193,13 +212,13 @@ public class Request {
// Additional Headers Utils
//////////////////////////////////////////////////////////////////////////*/
- public Builder setHeaders(String headerName, List headerValueList) {
+ public Builder setHeaders(final String headerName, final List headerValueList) {
this.headers.remove(headerName);
this.headers.put(headerName, headerValueList);
return this;
}
- public Builder addHeaders(String headerName, List headerValueList) {
+ public Builder addHeaders(final String headerName, final List headerValueList) {
@Nullable List currentHeaderValueList = this.headers.get(headerName);
if (currentHeaderValueList == null) {
currentHeaderValueList = new ArrayList<>();
@@ -210,11 +229,11 @@ public class Request {
return this;
}
- public Builder setHeader(String headerName, String headerValue) {
+ public Builder setHeader(final String headerName, final String 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));
}
@@ -226,15 +245,20 @@ public class Request {
@SuppressWarnings("WeakerAccess")
@Nonnull
- public static Map> headersFromLocalization(@Nullable Localization localization) {
- if (localization == null) return Collections.emptyMap();
+ public static Map> headersFromLocalization(
+ @Nullable final Localization localization) {
+ if (localization == null) {
+ return Collections.emptyMap();
+ }
final Map> headers = new LinkedHashMap<>();
if (!localization.getCountryCode().isEmpty()) {
- headers.put("Accept-Language", Collections.singletonList(localization.getLocalizationCode() +
- ", " + localization.getLanguageCode() + ";q=0.9"));
+ headers.put("Accept-Language",
+ Collections.singletonList(localization.getLocalizationCode()
+ + ", " + localization.getLanguageCode() + ";q=0.9"));
} else {
- headers.put("Accept-Language", Collections.singletonList(localization.getLanguageCode()));
+ headers.put("Accept-Language",
+ Collections.singletonList(localization.getLanguageCode()));
}
return headers;
@@ -245,15 +269,19 @@ public class Request {
//////////////////////////////////////////////////////////////////////////*/
@Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (o == null || getClass() != o.getClass()) return false;
- Request request = (Request) o;
- return httpMethod.equals(request.httpMethod) &&
- url.equals(request.url) &&
- headers.equals(request.headers) &&
- Arrays.equals(dataToSend, request.dataToSend) &&
- Objects.equals(localization, request.localization);
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ final Request request = (Request) o;
+ return httpMethod.equals(request.httpMethod)
+ && url.equals(request.url)
+ && headers.equals(request.headers)
+ && Arrays.equals(dataToSend, request.dataToSend)
+ && Objects.equals(localization, request.localization);
}
@Override
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/downloader/Response.java b/extractor/src/main/java/org/schabi/newpipe/extractor/downloader/Response.java
index c986f72d5..ac792dc75 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/downloader/Response.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/downloader/Response.java
@@ -17,11 +17,14 @@ public class Response {
private final String latestUrl;
- public Response(int responseCode, String responseMessage, Map> responseHeaders,
- @Nullable String responseBody, @Nullable String latestUrl) {
+ public Response(final int responseCode,
+ final String responseMessage,
+ @Nullable final Map> responseHeaders,
+ @Nullable final String responseBody,
+ @Nullable final String latestUrl) {
this.responseCode = responseCode;
this.responseMessage = responseMessage;
- this.responseHeaders = responseHeaders != null ? responseHeaders : Collections.>emptyMap();
+ this.responseHeaders = responseHeaders == null ? Collections.emptyMap() : responseHeaders;
this.responseBody = responseBody == null ? "" : responseBody;
this.latestUrl = latestUrl;
@@ -60,14 +63,15 @@ public class Response {
/**
* For easy access to some header value that (usually) don't repeat itself.
- * For getting all the values associated to the header, use {@link #responseHeaders()} (e.g. {@code Set-Cookie}).
+ *
For getting all the values associated to the header, use {@link #responseHeaders()} (e.g.
+ * {@code Set-Cookie}).
*
* @param name the name of the header
* @return the first value assigned to this header
*/
@Nullable
- public String getHeader(String name) {
- for (Map.Entry> headerEntry : responseHeaders.entrySet()) {
+ public String getHeader(final String name) {
+ for (final Map.Entry> headerEntry : responseHeaders.entrySet()) {
final String key = headerEntry.getKey();
if (key != null && key.equalsIgnoreCase(name) && !headerEntry.getValue().isEmpty()) {
return headerEntry.getValue().get(0);
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/feed/FeedExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/feed/FeedExtractor.java
index df3e8915b..42b5a0cbf 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/feed/FeedExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/feed/FeedExtractor.java
@@ -11,7 +11,7 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem;
* YouTube is an example of a service that has this alternative available.
*/
public abstract class FeedExtractor extends ListExtractor {
- public FeedExtractor(StreamingService service, ListLinkHandler listLinkHandler) {
+ public FeedExtractor(final StreamingService service, final ListLinkHandler listLinkHandler) {
super(service, listLinkHandler);
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/feed/FeedInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/feed/FeedInfo.java
index 03fe78f6d..9beb46a23 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/feed/FeedInfo.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/feed/FeedInfo.java
@@ -13,26 +13,35 @@ import java.util.List;
public class FeedInfo extends ListInfo {
- public FeedInfo(int serviceId, String id, String url, String originalUrl, String name, List contentFilter, String sortFilter) {
+ public FeedInfo(final int serviceId,
+ final String id,
+ final String url,
+ final String originalUrl,
+ final String name,
+ final List contentFilter,
+ final String 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);
}
- 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);
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();
return getInfo(extractor);
}
- public static FeedInfo getInfo(FeedExtractor extractor) throws IOException, ExtractionException {
+ public static FeedInfo getInfo(final FeedExtractor extractor)
+ throws IOException, ExtractionException {
extractor.fetchPage();
final int serviceId = extractor.getServiceId();
@@ -43,7 +52,8 @@ public class FeedInfo extends ListInfo {
final FeedInfo info = new FeedInfo(serviceId, id, url, originalUrl, name, null, null);
- final InfoItemsPage itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor);
+ final InfoItemsPage itemsPage
+ = ExtractorHelper.getItemsPageOrLogError(info, extractor);
info.setRelatedItems(itemsPage.getItems());
info.setNextPage(itemsPage.getNextPage());
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskExtractor.java
index 7abefbd94..3bf986a9e 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskExtractor.java
@@ -31,9 +31,9 @@ import javax.annotation.Nonnull;
public abstract class KioskExtractor extends ListExtractor {
private final String id;
- public KioskExtractor(StreamingService streamingService,
- ListLinkHandler linkHandler,
- String kioskId) {
+ public KioskExtractor(final StreamingService streamingService,
+ final ListLinkHandler linkHandler,
+ final String kioskId) {
super(streamingService, linkHandler);
this.id = kioskId;
}
@@ -50,7 +50,6 @@ public abstract class KioskExtractor extends ListExtractor {
- private KioskInfo(int serviceId, ListLinkHandler linkHandler, String name) throws ParsingException {
+public final class KioskInfo extends ListInfo {
+ private KioskInfo(final int serviceId, final ListLinkHandler linkHandler, final String name) {
super(serviceId, linkHandler, name);
}
- public static ListExtractor.InfoItemsPage getMoreItems(StreamingService service,
- String url,
- Page page)
+ public static ListExtractor.InfoItemsPage getMoreItems(
+ final StreamingService service, final String url, final Page page)
throws IOException, ExtractionException {
- KioskList kl = service.getKioskList();
- KioskExtractor extractor = kl.getExtractorByUrl(url, page);
- return extractor.getPage(page);
+ return service.getKioskList().getExtractorByUrl(url, page).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);
}
- public static KioskInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
- KioskList kl = service.getKioskList();
- KioskExtractor extractor = kl.getExtractorByUrl(url, null);
+ public static KioskInfo getInfo(final StreamingService service, final String url)
+ throws IOException, ExtractionException {
+ final KioskExtractor extractor = service.getKioskList().getExtractorByUrl(url, null);
extractor.fetchPage();
return getInfo(extractor);
}
@@ -63,13 +59,14 @@ public class KioskInfo extends ListInfo {
*
* @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(),
extractor.getLinkHandler(),
extractor.getName());
- final ListExtractor.InfoItemsPage itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor);
+ final ListExtractor.InfoItemsPage itemsPage
+ = ExtractorHelper.getItemsPageOrLogError(info, extractor);
info.setRelatedItems(itemsPage.getItems());
info.setNextPage(itemsPage.getNextPage());
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskList.java b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskList.java
index 913cbe26b..cc9df054c 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskList.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/kiosk/KioskList.java
@@ -19,9 +19,9 @@ import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
public class KioskList {
public interface KioskExtractorFactory {
- KioskExtractor createNewKiosk(final StreamingService streamingService,
- final String url,
- final String kioskId)
+ KioskExtractor createNewKiosk(StreamingService streamingService,
+ String url,
+ String kioskId)
throws ExtractionException, IOException;
}
@@ -34,8 +34,8 @@ public class KioskList {
@Nullable
private ContentCountry forcedContentCountry;
- private class KioskEntry {
- public KioskEntry(KioskExtractorFactory ef, ListLinkHandlerFactory h) {
+ private static class KioskEntry {
+ KioskEntry(final KioskExtractorFactory ef, final ListLinkHandlerFactory h) {
extractorFactory = ef;
handlerFactory = h;
}
@@ -44,11 +44,13 @@ public class KioskList {
final ListLinkHandlerFactory handlerFactory;
}
- public KioskList(StreamingService service) {
+ public KioskList(final StreamingService 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 {
if (kioskList.get(id) != null) {
throw new Exception("Kiosk with type " + id + " already exists.");
@@ -56,7 +58,7 @@ public class KioskList {
kioskList.put(id, new KioskEntry(extractorFactory, handlerFactory));
}
- public void setDefaultKiosk(String kioskType) {
+ public void setDefaultKiosk(final String kioskType) {
defaultKiosk = kioskType;
}
@@ -65,19 +67,20 @@ public class KioskList {
return getDefaultKioskExtractor(null);
}
- public KioskExtractor getDefaultKioskExtractor(Page nextPage)
+ public KioskExtractor getDefaultKioskExtractor(final Page nextPage)
throws ExtractionException, IOException {
return getDefaultKioskExtractor(nextPage, NewPipe.getPreferredLocalization());
}
- public KioskExtractor getDefaultKioskExtractor(Page nextPage, Localization localization)
+ public KioskExtractor getDefaultKioskExtractor(final Page nextPage,
+ final Localization localization)
throws ExtractionException, IOException {
if (!isNullOrEmpty(defaultKiosk)) {
return getExtractorById(defaultKiosk, nextPage, localization);
} else {
if (!kioskList.isEmpty()) {
// if not set get any entry
- Object[] keySet = kioskList.keySet().toArray();
+ final Object[] keySet = kioskList.keySet().toArray();
return getExtractorById(keySet[0].toString(), nextPage, localization);
} else {
return null;
@@ -89,22 +92,28 @@ public class KioskList {
return defaultKiosk;
}
- public KioskExtractor getExtractorById(String kioskId, Page nextPage)
+ public KioskExtractor getExtractorById(final String kioskId, final Page nextPage)
throws ExtractionException, IOException {
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 {
- KioskEntry ke = kioskList.get(kioskId);
+ final KioskEntry ke = kioskList.get(kioskId);
if (ke == null) {
throw new ExtractionException("No kiosk found with the type: " + kioskId);
} else {
final KioskExtractor kioskExtractor = ke.extractorFactory.createNewKiosk(service,
ke.handlerFactory.fromId(kioskId).getUrl(), kioskId);
- if (forcedLocalization != null) kioskExtractor.forceLocalization(forcedLocalization);
- if (forcedContentCountry != null) kioskExtractor.forceContentCountry(forcedContentCountry);
+ if (forcedLocalization != null) {
+ kioskExtractor.forceLocalization(forcedLocalization);
+ }
+ if (forcedContentCountry != null) {
+ kioskExtractor.forceContentCountry(forcedContentCountry);
+ }
return kioskExtractor;
}
@@ -114,15 +123,17 @@ public class KioskList {
return kioskList.keySet();
}
- public KioskExtractor getExtractorByUrl(String url, Page nextPage)
+ public KioskExtractor getExtractorByUrl(final String url, final Page nextPage)
throws ExtractionException, IOException {
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 {
- for (Map.Entry e : kioskList.entrySet()) {
- KioskEntry ke = e.getValue();
+ for (final Map.Entry e : kioskList.entrySet()) {
+ final KioskEntry ke = e.getValue();
if (ke.handlerFactory.acceptUrl(url)) {
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);
}
- public ListLinkHandlerFactory getListLinkHandlerFactoryByType(String type) {
+ public ListLinkHandlerFactory getListLinkHandlerFactoryByType(final String type) {
return kioskList.get(type).handlerFactory;
}
- public void forceLocalization(@Nullable Localization localization) {
+ public void forceLocalization(@Nullable final Localization localization) {
this.forcedLocalization = localization;
}
- public void forceContentCountry(@Nullable ContentCountry contentCountry) {
+ public void forceContentCountry(@Nullable final ContentCountry contentCountry) {
this.forcedContentCountry = contentCountry;
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandler.java b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandler.java
index b7439c39d..5bc7a4a11 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandler.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandler.java
@@ -10,13 +10,13 @@ public class LinkHandler implements Serializable {
protected final String url;
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.url = url;
this.id = id;
}
- public LinkHandler(LinkHandler handler) {
+ public LinkHandler(final LinkHandler handler) {
this(handler.originalUrl, handler.url, handler.id);
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandlerFactory.java
index 7d04b87cf..1c6ae2abc 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/LinkHandlerFactory.java
@@ -1,6 +1,5 @@
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.utils.Utils;
@@ -31,10 +30,12 @@ public abstract class LinkHandlerFactory {
///////////////////////////////////
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);
}
@@ -46,6 +47,7 @@ public abstract class LinkHandlerFactory {
* Builds a {@link LinkHandler} from a url.
* Be sure to call {@link Utils#followGoogleRedirectIfNeeded(String)} on the url if overriding
* this function.
+ *
* @param url the url to extract path and id from
* @return a {@link LinkHandler} complete with information
*/
@@ -64,12 +66,15 @@ public abstract class LinkHandlerFactory {
* extracted?).
* So do not call {@link Utils#followGoogleRedirectIfNeeded(String)} on the URL if overriding
* 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
* @return a {@link LinkHandler} complete with information
*/
- public LinkHandler fromUrl(String url, String baseUrl) throws ParsingException {
- if (url == null) throw new IllegalArgumentException("URL cannot be null");
+ public LinkHandler fromUrl(final String url, final String baseUrl) throws ParsingException {
+ if (url == null) {
+ throw new IllegalArgumentException("URL cannot be null");
+ }
if (!acceptUrl(url)) {
throw new ParsingException("URL not accepted: " + url);
}
@@ -78,14 +83,18 @@ public abstract class LinkHandlerFactory {
return new LinkHandler(url, getUrl(id, baseUrl), id);
}
- public LinkHandler fromId(String id) throws ParsingException {
- if (id == null) throw new IllegalArgumentException("id can not be null");
+ public LinkHandler fromId(final String id) throws ParsingException {
+ if (id == null) {
+ throw new IllegalArgumentException("id can not be null");
+ }
final String url = getUrl(id);
return new LinkHandler(url, url, id);
}
- public LinkHandler fromId(String id, String baseUrl) throws ParsingException {
- if (id == null) throw new IllegalArgumentException("id can not be null");
+ public LinkHandler fromId(final String id, final String baseUrl) throws ParsingException {
+ if (id == null) {
+ throw new IllegalArgumentException("id can not be null");
+ }
final String url = getUrl(id, baseUrl);
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.
*/
public boolean acceptUrl(final String url) throws ParsingException {
- try {
- return onAcceptUrl(url);
- } catch (FoundAdException fe) {
- throw fe;
- }
+ return onAcceptUrl(url);
}
-
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandler.java b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandler.java
index 3e85fe1bd..4372c0649 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandler.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandler.java
@@ -1,5 +1,7 @@
package org.schabi.newpipe.extractor.linkhandler;
+import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
+
import java.util.Collections;
import java.util.List;
@@ -7,17 +9,17 @@ public class ListLinkHandler extends LinkHandler {
protected final List contentFilters;
protected final String sortFilter;
- public ListLinkHandler(String originalUrl,
- String url,
- String id,
- List contentFilters,
- String sortFilter) {
+ public ListLinkHandler(final String originalUrl,
+ final String url,
+ final String id,
+ final List contentFilters,
+ final String sortFilter) {
super(originalUrl, url, id);
this.contentFilters = Collections.unmodifiableList(contentFilters);
this.sortFilter = sortFilter;
}
- public ListLinkHandler(ListLinkHandler handler) {
+ public ListLinkHandler(final ListLinkHandler handler) {
this(handler.originalUrl,
handler.url,
handler.id,
@@ -25,14 +27,12 @@ public class ListLinkHandler extends LinkHandler {
handler.sortFilter);
}
- public ListLinkHandler(LinkHandler handler,
- List contentFilters,
- String sortFilter) {
+ public ListLinkHandler(final LinkHandler handler) {
this(handler.originalUrl,
handler.url,
handler.id,
- contentFilters,
- sortFilter);
+ Collections.emptyList(),
+ EMPTY_STRING);
}
public List getContentFilters() {
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandlerFactory.java
index 11b94c7a5..0d67fe6e1 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/ListLinkHandlerFactory.java
@@ -4,7 +4,6 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.utils.Utils;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
public abstract class ListLinkHandlerFactory extends LinkHandlerFactory {
@@ -13,17 +12,13 @@ public abstract class ListLinkHandlerFactory extends LinkHandlerFactory {
// To Override
///////////////////////////////////
- public List getContentFilter(String url) throws ParsingException {
- return Collections.emptyList();
- }
+ public abstract String getUrl(String id, List contentFilter, String sortFilter)
+ throws ParsingException;
- public String getSortFilter(String url) throws ParsingException {
- return "";
- }
-
- public abstract String getUrl(String id, List contentFilter, String sortFilter) throws ParsingException;
-
- public String getUrl(String id, List contentFilter, String sortFilter, String baseUrl) throws ParsingException {
+ public String getUrl(final String id,
+ final List contentFilter,
+ final String sortFilter,
+ final String baseUrl) throws ParsingException {
return getUrl(id, contentFilter, sortFilter);
}
@@ -39,55 +34,58 @@ public abstract class ListLinkHandlerFactory extends LinkHandlerFactory {
}
@Override
- public ListLinkHandler fromUrl(String url, String baseUrl) throws ParsingException {
- if (url == null) throw new IllegalArgumentException("url may not be null");
+ public ListLinkHandler fromUrl(final String url, final String baseUrl) throws ParsingException {
+ 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));
}
@Override
- public ListLinkHandler fromId(String id) throws ParsingException {
- return new ListLinkHandler(super.fromId(id), new ArrayList(0), "");
+ public ListLinkHandler fromId(final String id) throws ParsingException {
+ return new ListLinkHandler(super.fromId(id));
}
@Override
- public ListLinkHandler fromId(String id, String baseUrl) throws ParsingException {
- return new ListLinkHandler(super.fromId(id, baseUrl), new ArrayList(0), "");
+ public ListLinkHandler fromId(final String id, final String baseUrl) throws ParsingException {
+ return new ListLinkHandler(super.fromId(id, baseUrl));
}
- public ListLinkHandler fromQuery(String id,
- List contentFilters,
- String sortFilter) throws ParsingException {
+ public ListLinkHandler fromQuery(final String id,
+ final List contentFilters,
+ final String sortFilter) throws ParsingException {
final String url = getUrl(id, contentFilters, sortFilter);
return new ListLinkHandler(url, url, id, contentFilters, sortFilter);
}
- public ListLinkHandler fromQuery(String id,
- List contentFilters,
- String sortFilter, String baseUrl) throws ParsingException {
+ public ListLinkHandler fromQuery(final String id,
+ final List contentFilters,
+ final String sortFilter,
+ final String baseUrl) throws ParsingException {
final String url = getUrl(id, contentFilters, sortFilter, baseUrl);
return new ListLinkHandler(url, url, id, contentFilters, sortFilter);
}
/**
- * For making ListLinkHandlerFactory compatible with LinkHandlerFactory we need to override this,
- * however it should not be overridden by the actual implementation.
+ * For making ListLinkHandlerFactory compatible with LinkHandlerFactory we need to override
+ * this, however it should not be overridden by the actual implementation.
*
- * @param id
* @return the url corresponding to id without any filters applied
*/
- public String getUrl(String id) throws ParsingException {
- return getUrl(id, new ArrayList(0), "");
+ public String getUrl(final String id) throws ParsingException {
+ return getUrl(id, new ArrayList<>(0), "");
}
@Override
- public String getUrl(String id, String baseUrl) throws ParsingException {
- return getUrl(id, new ArrayList(0), "", baseUrl);
+ public String getUrl(final String id, final String baseUrl) throws ParsingException {
+ 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
*/
@@ -96,7 +94,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
*/
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/SearchQueryHandler.java b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/SearchQueryHandler.java
index 67dd7e49d..010d977d0 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/SearchQueryHandler.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/SearchQueryHandler.java
@@ -4,15 +4,15 @@ import java.util.List;
public class SearchQueryHandler extends ListLinkHandler {
- public SearchQueryHandler(String originalUrl,
- String url,
- String searchString,
- List contentFilters,
- String sortFilter) {
+ public SearchQueryHandler(final String originalUrl,
+ final String url,
+ final String searchString,
+ final List contentFilters,
+ final String sortFilter) {
super(originalUrl, url, searchString, contentFilters, sortFilter);
}
- public SearchQueryHandler(ListLinkHandler handler) {
+ public SearchQueryHandler(final ListLinkHandler handler) {
this(handler.originalUrl,
handler.url,
handler.id,
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/SearchQueryHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/SearchQueryHandlerFactory.java
index 3b891b305..4a27d4a6c 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/SearchQueryHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/linkhandler/SearchQueryHandlerFactory.java
@@ -1,12 +1,12 @@
package org.schabi.newpipe.extractor.linkhandler;
+import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
+
import org.schabi.newpipe.extractor.exceptions.ParsingException;
-import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
-import static org.schabi.newpipe.extractor.utils.Utils.EMPTY_STRING;
-
public abstract class SearchQueryHandlerFactory extends ListLinkHandlerFactory {
///////////////////////////////////
@@ -14,9 +14,11 @@ public abstract class SearchQueryHandlerFactory extends ListLinkHandlerFactory {
///////////////////////////////////
@Override
- public abstract String getUrl(String query, List contentFilter, String sortFilter) throws ParsingException;
+ public abstract String getUrl(String query, List contentFilter, String sortFilter)
+ throws ParsingException;
- public String getSearchString(String url) {
+ @SuppressWarnings("unused")
+ public String getSearchString(final String url) {
return "";
}
@@ -25,28 +27,26 @@ public abstract class SearchQueryHandlerFactory extends ListLinkHandlerFactory {
///////////////////////////////////
@Override
- public String getId(String url) {
+ public String getId(final String url) {
return getSearchString(url);
}
@Override
- public SearchQueryHandler fromQuery(String query,
- List contentFilter,
- String sortFilter) throws ParsingException {
+ public SearchQueryHandler fromQuery(final String query,
+ final List contentFilter,
+ final String sortFilter) throws ParsingException {
return new SearchQueryHandler(super.fromQuery(query, contentFilter, sortFilter));
}
- public SearchQueryHandler fromQuery(String query) throws ParsingException {
- return fromQuery(query, new ArrayList<>(0), EMPTY_STRING);
+ public SearchQueryHandler fromQuery(final String query) throws ParsingException {
+ return fromQuery(query, Collections.emptyList(), EMPTY_STRING);
}
/**
* It's not mandatory for NewPipe to handle the Url
- *
- * @param url
*/
@Override
- public boolean onAcceptUrl(String url) {
+ public boolean onAcceptUrl(final String url) {
return false;
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/localization/ContentCountry.java b/extractor/src/main/java/org/schabi/newpipe/extractor/localization/ContentCountry.java
index 2398d9934..89baf11ea 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/localization/ContentCountry.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/localization/ContentCountry.java
@@ -1,6 +1,7 @@
package org.schabi.newpipe.extractor.localization;
import javax.annotation.Nonnull;
+
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
@@ -9,23 +10,26 @@ import java.util.List;
/**
* Represents a country that should be used when fetching content.
*
- * 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.
*
*/
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 listFrom(String... countryCodeList) {
+ public static List listFrom(final String... countryCodeList) {
final List toReturn = new ArrayList<>();
- for (String countryCode : countryCodeList) {
+ for (final String countryCode : countryCodeList) {
toReturn.add(new ContentCountry(countryCode));
}
return Collections.unmodifiableList(toReturn);
}
- public ContentCountry(@Nonnull String countryCode) {
+ public ContentCountry(@Nonnull final String countryCode) {
this.countryCode = countryCode;
}
@@ -40,11 +44,15 @@ public class ContentCountry implements Serializable {
}
@Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof ContentCountry)) return false;
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof ContentCountry)) {
+ return false;
+ }
- ContentCountry that = (ContentCountry) o;
+ final ContentCountry that = (ContentCountry) o;
return countryCode.equals(that.countryCode);
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/localization/DateWrapper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/localization/DateWrapper.java
index b1424e3b2..ffc29a61c 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/localization/DateWrapper.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/localization/DateWrapper.java
@@ -9,7 +9,8 @@ import java.util.Calendar;
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 {
@Nonnull
@@ -20,7 +21,8 @@ public class DateWrapper implements Serializable {
* @deprecated Use {@link #DateWrapper(OffsetDateTime)} instead.
*/
@Deprecated
- public DateWrapper(@Nonnull Calendar calendar) {
+ public DateWrapper(@Nonnull final Calendar calendar) {
+ //noinspection deprecation
this(calendar, false);
}
@@ -28,15 +30,16 @@ public class DateWrapper implements Serializable {
* @deprecated Use {@link #DateWrapper(OffsetDateTime, boolean)} instead.
*/
@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);
}
- public DateWrapper(@Nonnull OffsetDateTime offsetDateTime) {
+ public DateWrapper(@Nonnull final OffsetDateTime offsetDateTime) {
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.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
- * like 2 weeks ago instead of a precise date).
+ * @return if the date is considered is precise or just an approximation (e.g. service only
+ * returns an approximation like 2 weeks ago instead of a precise date).
*/
public boolean isApproximation() {
return isApproximation;
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/localization/Localization.java b/extractor/src/main/java/org/schabi/newpipe/extractor/localization/Localization.java
index e0f60a86b..0a28d70b8 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/localization/Localization.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/localization/Localization.java
@@ -4,8 +4,15 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
+
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 static final Localization DEFAULT = new Localization("en", "GB");
@@ -16,11 +23,12 @@ public class Localization implements Serializable {
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 listFrom(String... localizationCodeList) {
+ public static List listFrom(final String... localizationCodeList) {
final List toReturn = new ArrayList<>();
- for (String localizationCode : localizationCodeList) {
+ for (final String localizationCode : localizationCodeList) {
toReturn.add(fromLocalizationCode(localizationCode));
}
return Collections.unmodifiableList(toReturn);
@@ -29,10 +37,11 @@ public class Localization implements Serializable {
/**
* @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 String languageCode, countryCode;
+ final String languageCode;
+ final String countryCode;
if (indexSeparator != -1) {
languageCode = localizationCode.substring(0, indexSeparator);
countryCode = localizationCode.substring(indexSeparator + 1);
@@ -44,15 +53,16 @@ public class Localization implements Serializable {
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.countryCode = countryCode;
}
- public Localization(@Nonnull String languageCode) {
+ public Localization(@Nonnull final String languageCode) {
this(languageCode, null);
}
+ @Nonnull
public String getLanguageCode() {
return languageCode;
}
@@ -66,7 +76,7 @@ public class Localization implements Serializable {
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());
}
@@ -84,14 +94,18 @@ public class Localization implements Serializable {
}
@Override
- public boolean equals(Object o) {
- if (this == o) return true;
- if (!(o instanceof Localization)) return false;
+ public boolean equals(final Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof Localization)) {
+ return false;
+ }
- Localization that = (Localization) o;
+ final Localization that = (Localization) o;
- return languageCode.equals(that.languageCode) &&
- Objects.equals(countryCode, that.countryCode);
+ return languageCode.equals(that.languageCode)
+ && Objects.equals(countryCode, that.countryCode);
}
@Override
@@ -108,17 +122,19 @@ public class Localization implements Serializable {
* @param code a three letter language code
* @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 Map localeMap = new HashMap<>(languages.length);
- for (String language : languages) {
+ for (final String language : languages) {
final Locale locale = new Locale(language);
localeMap.put(locale.getISO3Language(), locale);
}
if (localeMap.containsKey(code)) {
return localeMap.get(code);
} 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);
}
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/localization/TimeAgoParser.java b/extractor/src/main/java/org/schabi/newpipe/extractor/localization/TimeAgoParser.java
index dd74f9aae..117b5b12f 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/localization/TimeAgoParser.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/localization/TimeAgoParser.java
@@ -25,16 +25,17 @@ public class TimeAgoParser {
* Instantiate a new {@link TimeAgoParser} every time you extract a new batch of items.
*
*
- * @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;
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
- * {@link DateWrapper} object.
+ * Parses a textual date in the format '2 days ago' into a Calendar representation which is then
+ * wrapped in a {@link DateWrapper} object.
*
* 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)
* @throws ParsingException if the time unit could not be recognized
*/
- public DateWrapper parse(String textualDate) throws ParsingException {
- for (Map.Entry> caseUnitEntry : patternsHolder.specialCases().entrySet()) {
+ public DateWrapper parse(final String textualDate) throws ParsingException {
+ for (final Map.Entry> caseUnitEntry
+ : patternsHolder.specialCases().entrySet()) {
final ChronoUnit chronoUnit = caseUnitEntry.getKey();
- for (Map.Entry caseMapToAmountEntry : caseUnitEntry.getValue().entrySet()) {
+ for (final Map.Entry caseMapToAmountEntry
+ : caseUnitEntry.getValue().entrySet()) {
final String caseText = caseMapToAmountEntry.getKey();
final Integer caseAmount = caseMapToAmountEntry.getValue();
@@ -58,7 +61,7 @@ public class TimeAgoParser {
int timeAgoAmount;
try {
timeAgoAmount = parseTimeAgoAmount(textualDate);
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
// If there is no valid number in the textual date,
// assume it is 1 (as in 'a second ago').
timeAgoAmount = 1;
@@ -68,16 +71,16 @@ public class TimeAgoParser {
return getResultFor(timeAgoAmount, chronoUnit);
}
- private int parseTimeAgoAmount(String textualDate) throws NumberFormatException {
- String timeValueStr = textualDate.replaceAll("\\D+", "");
- return Integer.parseInt(timeValueStr);
+ private int parseTimeAgoAmount(final String textualDate) throws NumberFormatException {
+ return Integer.parseInt(textualDate.replaceAll("\\D+", ""));
}
- private ChronoUnit parseChronoUnit(String textualDate) throws ParsingException {
- for (Map.Entry> entry : patternsHolder.asMap().entrySet()) {
+ private ChronoUnit parseChronoUnit(final String textualDate) throws ParsingException {
+ for (final Map.Entry> entry
+ : patternsHolder.asMap().entrySet()) {
final ChronoUnit chronoUnit = entry.getKey();
- for (String agoPhrase : entry.getValue()) {
+ for (final String agoPhrase : entry.getValue()) {
if (textualDateMatches(textualDate, agoPhrase)) {
return chronoUnit;
}
@@ -87,7 +90,7 @@ public class TimeAgoParser {
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)) {
return true;
}
@@ -98,7 +101,8 @@ public class TimeAgoParser {
final String escapedPhrase = Pattern.quote(agoPhrase.toLowerCase());
final String escapedSeparator;
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]";
} else {
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;
boolean isApproximation = false;
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/localization/TimeAgoPatternsManager.java b/extractor/src/main/java/org/schabi/newpipe/extractor/localization/TimeAgoPatternsManager.java
index 1b41addeb..19b697661 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/localization/TimeAgoPatternsManager.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/localization/TimeAgoPatternsManager.java
@@ -6,14 +6,18 @@ import org.schabi.newpipe.extractor.timeago.PatternsManager;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-public class TimeAgoPatternsManager {
- @Nullable
- private static PatternsHolder getPatternsFor(@Nonnull Localization localization) {
- return PatternsManager.getPatterns(localization.getLanguageCode(), localization.getCountryCode());
+public final class TimeAgoPatternsManager {
+ private TimeAgoPatternsManager() {
}
@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);
if (holder == null) {
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java
index 20627e2a1..aea33304c 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfo.java
@@ -15,7 +15,7 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
-public class PlaylistInfo extends ListInfo {
+public final class PlaylistInfo extends ListInfo {
/**
* Mixes are handled as particular playlists in NewPipeExtractor. {@link PlaylistType#NORMAL} is
@@ -52,23 +52,27 @@ public class PlaylistInfo extends ListInfo {
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);
}
- 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);
}
- public static PlaylistInfo getInfo(StreamingService service, String url) throws IOException, ExtractionException {
- PlaylistExtractor extractor = service.getPlaylistExtractor(url);
+ public static PlaylistInfo getInfo(final StreamingService service, final String url)
+ throws IOException, ExtractionException {
+ final PlaylistExtractor extractor = service.getPlaylistExtractor(url);
extractor.fetchPage();
return getInfo(extractor);
}
- public static InfoItemsPage getMoreItems(StreamingService service,
- String url,
- Page page) throws IOException, ExtractionException {
+ public static InfoItemsPage getMoreItems(final StreamingService service,
+ final String url,
+ final Page page)
+ throws IOException, ExtractionException {
return service.getPlaylistExtractor(url).getPage(page);
}
@@ -77,7 +81,8 @@ public class PlaylistInfo extends ListInfo {
*
* @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(
extractor.getServiceId(),
@@ -85,73 +90,75 @@ public class PlaylistInfo extends ListInfo {
extractor.getName());
// collect uploader extraction failures until we are sure this is not
// just a playlist without an uploader
- List uploaderParsingErrors = new ArrayList(3);
+ final List uploaderParsingErrors = new ArrayList<>();
try {
info.setOriginalUrl(extractor.getOriginalUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
try {
info.setStreamCount(extractor.getStreamCount());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
try {
info.setThumbnailUrl(extractor.getThumbnailUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
try {
info.setUploaderUrl(extractor.getUploaderUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.setUploaderUrl("");
uploaderParsingErrors.add(e);
}
try {
info.setUploaderName(extractor.getUploaderName());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.setUploaderName("");
uploaderParsingErrors.add(e);
}
try {
info.setUploaderAvatarUrl(extractor.getUploaderAvatarUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.setUploaderAvatarUrl("");
uploaderParsingErrors.add(e);
}
try {
info.setSubChannelUrl(extractor.getSubChannelUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
uploaderParsingErrors.add(e);
}
try {
info.setSubChannelName(extractor.getSubChannelName());
- } catch (Exception e) {
+ } catch (final Exception e) {
uploaderParsingErrors.add(e);
}
try {
info.setSubChannelAvatarUrl(extractor.getSubChannelAvatarUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
uploaderParsingErrors.add(e);
}
try {
info.setBannerUrl(extractor.getBannerUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
try {
info.setPlaylistType(extractor.getPlaylistType());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
- // do not fail if everything but the uploader infos could be collected
- if (!uploaderParsingErrors.isEmpty() &&
- (!info.getErrors().isEmpty() || uploaderParsingErrors.size() < 3)) {
+
+ // do not fail if everything but the uploader infos could be collected (TODO better comment)
+ if (!uploaderParsingErrors.isEmpty()
+ && (!info.getErrors().isEmpty() || uploaderParsingErrors.size() < 3)) {
info.addAllErrors(uploaderParsingErrors);
}
- final InfoItemsPage itemsPage = ExtractorHelper.getItemsPageOrLogError(info, extractor);
+ final InfoItemsPage itemsPage
+ = ExtractorHelper.getItemsPageOrLogError(info, extractor);
info.setRelatedItems(itemsPage.getItems());
info.setNextPage(itemsPage.getNextPage());
@@ -173,7 +180,7 @@ public class PlaylistInfo extends ListInfo {
return thumbnailUrl;
}
- public void setThumbnailUrl(String thumbnailUrl) {
+ public void setThumbnailUrl(final String thumbnailUrl) {
this.thumbnailUrl = thumbnailUrl;
}
@@ -181,7 +188,7 @@ public class PlaylistInfo extends ListInfo {
return bannerUrl;
}
- public void setBannerUrl(String bannerUrl) {
+ public void setBannerUrl(final String bannerUrl) {
this.bannerUrl = bannerUrl;
}
@@ -189,7 +196,7 @@ public class PlaylistInfo extends ListInfo {
return uploaderUrl;
}
- public void setUploaderUrl(String uploaderUrl) {
+ public void setUploaderUrl(final String uploaderUrl) {
this.uploaderUrl = uploaderUrl;
}
@@ -197,7 +204,7 @@ public class PlaylistInfo extends ListInfo {
return uploaderName;
}
- public void setUploaderName(String uploaderName) {
+ public void setUploaderName(final String uploaderName) {
this.uploaderName = uploaderName;
}
@@ -205,7 +212,7 @@ public class PlaylistInfo extends ListInfo {
return uploaderAvatarUrl;
}
- public void setUploaderAvatarUrl(String uploaderAvatarUrl) {
+ public void setUploaderAvatarUrl(final String uploaderAvatarUrl) {
this.uploaderAvatarUrl = uploaderAvatarUrl;
}
@@ -213,7 +220,7 @@ public class PlaylistInfo extends ListInfo {
return subChannelUrl;
}
- public void setSubChannelUrl(String subChannelUrl) {
+ public void setSubChannelUrl(final String subChannelUrl) {
this.subChannelUrl = subChannelUrl;
}
@@ -221,7 +228,7 @@ public class PlaylistInfo extends ListInfo {
return subChannelName;
}
- public void setSubChannelName(String subChannelName) {
+ public void setSubChannelName(final String subChannelName) {
this.subChannelName = subChannelName;
}
@@ -229,7 +236,7 @@ public class PlaylistInfo extends ListInfo {
return subChannelAvatarUrl;
}
- public void setSubChannelAvatarUrl(String subChannelAvatarUrl) {
+ public void setSubChannelAvatarUrl(final String subChannelAvatarUrl) {
this.subChannelAvatarUrl = subChannelAvatarUrl;
}
@@ -237,7 +244,7 @@ public class PlaylistInfo extends ListInfo {
return streamCount;
}
- public void setStreamCount(long streamCount) {
+ public void setStreamCount(final long streamCount) {
this.streamCount = streamCount;
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItem.java b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItem.java
index 218beea4a..92ade89b2 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItem.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItem.java
@@ -11,7 +11,7 @@ public class PlaylistInfoItem extends InfoItem {
private long streamCount = 0;
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);
}
@@ -19,16 +19,16 @@ public class PlaylistInfoItem extends InfoItem {
return uploaderName;
}
- public void setUploaderName(String uploader_name) {
- this.uploaderName = uploader_name;
+ public void setUploaderName(final String uploaderName) {
+ this.uploaderName = uploaderName;
}
public long getStreamCount() {
return streamCount;
}
- public void setStreamCount(long stream_count) {
- this.streamCount = stream_count;
+ public void setStreamCount(final long streamCount) {
+ this.streamCount = streamCount;
}
public PlaylistInfo.PlaylistType getPlaylistType() {
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemExtractor.java
index 4cfa47208..be9b10262 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemExtractor.java
@@ -10,14 +10,12 @@ public interface PlaylistInfoItemExtractor extends InfoItemExtractor {
/**
* Get the uploader name
* @return the uploader name
- * @throws ParsingException
*/
String getUploaderName() throws ParsingException;
/**
* Get the number of streams
* @return the number of streams
- * @throws ParsingException
*/
long getStreamCount() throws ParsingException;
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemsCollector.java b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemsCollector.java
index a525f423a..328f12617 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemsCollector.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/playlist/PlaylistInfoItemsCollector.java
@@ -3,39 +3,37 @@ package org.schabi.newpipe.extractor.playlist;
import org.schabi.newpipe.extractor.InfoItemsCollector;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
-public class PlaylistInfoItemsCollector extends InfoItemsCollector {
+public class PlaylistInfoItemsCollector
+ extends InfoItemsCollector {
- public PlaylistInfoItemsCollector(int serviceId) {
+ public PlaylistInfoItemsCollector(final int serviceId) {
super(serviceId);
}
@Override
- public PlaylistInfoItem extract(PlaylistInfoItemExtractor extractor) throws ParsingException {
-
- String name = extractor.getName();
- int serviceId = getServiceId();
- String url = extractor.getUrl();
-
- PlaylistInfoItem resultItem = new PlaylistInfoItem(serviceId, url, name);
+ public PlaylistInfoItem extract(final PlaylistInfoItemExtractor extractor)
+ throws ParsingException {
+ final PlaylistInfoItem resultItem = new PlaylistInfoItem(
+ getServiceId(), extractor.getUrl(), extractor.getName());
try {
resultItem.setUploaderName(extractor.getUploaderName());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setThumbnailUrl(extractor.getThumbnailUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setStreamCount(extractor.getStreamCount());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
try {
resultItem.setPlaylistType(extractor.getPlaylistType());
- } catch (Exception e) {
+ } catch (final Exception e) {
addError(e);
}
return resultItem;
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java
index 3539dc816..601359acf 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchExtractor.java
@@ -14,12 +14,12 @@ import java.util.List;
public abstract class SearchExtractor extends ListExtractor {
public static class NothingFoundException extends ExtractionException {
- public NothingFoundException(String message) {
+ public NothingFoundException(final String message) {
super(message);
}
}
- public SearchExtractor(StreamingService service, SearchQueryHandler linkHandler) {
+ public SearchExtractor(final StreamingService service, final SearchQueryHandler linkHandler) {
super(service, linkHandler);
}
@@ -34,11 +34,11 @@ public abstract class SearchExtractor extends ListExtractor {
* {@link SearchExtractor#isCorrectedSearch()} is true.
*
* @return a suggestion to another query, the corrected query, or an empty String.
- * @throws ParsingException
*/
@Nonnull
public abstract String getSearchSuggestion() throws ParsingException;
+ @Nonnull
@Override
public SearchQueryHandler getLinkHandler() {
return (SearchQueryHandler) super.getLinkHandler();
@@ -66,8 +66,7 @@ public abstract class SearchExtractor extends ListExtractor {
* 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.
* @return additional meta information about the search query
- * @throws ParsingException
*/
- @Nonnull
+ @Nonnull
public abstract List getMetaInfo() throws ParsingException;
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java
index d1eb0b385..ee87446e9 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/search/SearchInfo.java
@@ -1,6 +1,11 @@
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.linkhandler.SearchQueryHandler;
import org.schabi.newpipe.extractor.utils.ExtractorHelper;
@@ -11,26 +16,29 @@ import java.util.List;
import javax.annotation.Nonnull;
public class SearchInfo extends ListInfo {
- private String searchString;
+ private final String searchString;
private String searchSuggestion;
private boolean isCorrectedSearch;
private List metaInfo;
- public SearchInfo(int serviceId,
- SearchQueryHandler qIHandler,
- String searchString) {
+ public SearchInfo(final int serviceId,
+ final SearchQueryHandler qIHandler,
+ final String searchString) {
super(serviceId, qIHandler, "Search");
this.searchString = searchString;
}
- public static SearchInfo getInfo(StreamingService service, SearchQueryHandler searchQuery) throws ExtractionException, IOException {
- SearchExtractor extractor = service.getSearchExtractor(searchQuery);
+ public static SearchInfo getInfo(final StreamingService service,
+ final SearchQueryHandler searchQuery)
+ throws ExtractionException, IOException {
+ final SearchExtractor extractor = service.getSearchExtractor(searchQuery);
extractor.fetchPage();
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(
extractor.getServiceId(),
extractor.getLinkHandler(),
@@ -38,26 +46,27 @@ public class SearchInfo extends ListInfo {
try {
info.setOriginalUrl(extractor.getOriginalUrl());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
try {
info.setSearchSuggestion(extractor.getSearchSuggestion());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
try {
info.setIsCorrectedSearch(extractor.isCorrectedSearch());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
try {
info.setMetaInfo(extractor.getMetaInfo());
- } catch (Exception e) {
+ } catch (final Exception e) {
info.addError(e);
}
- ListExtractor.InfoItemsPage page = ExtractorHelper.getItemsPageOrLogError(info, extractor);
+ final ListExtractor.InfoItemsPage page
+ = ExtractorHelper.getItemsPageOrLogError(info, extractor);
info.setRelatedItems(page.getItems());
info.setNextPage(page.getNextPage());
@@ -65,9 +74,9 @@ public class SearchInfo extends ListInfo {
}
- public static ListExtractor.InfoItemsPage getMoreItems(StreamingService service,
- SearchQueryHandler query,
- Page page)
+ public static ListExtractor.InfoItemsPage getMoreItems(final StreamingService service,
+ final SearchQueryHandler query,
+ final Page page)
throws IOException, ExtractionException {
return service.getSearchExtractor(query).getPage(page);
}
@@ -85,11 +94,11 @@ public class SearchInfo extends ListInfo {
return this.isCorrectedSearch;
}
- public void setIsCorrectedSearch(boolean isCorrectedSearch) {
+ public void setIsCorrectedSearch(final boolean isCorrectedSearch) {
this.isCorrectedSearch = isCorrectedSearch;
}
- public void setSearchSuggestion(String searchSuggestion) {
+ public void setSearchSuggestion(final String searchSuggestion) {
this.searchSuggestion = searchSuggestion;
}
@@ -98,7 +107,7 @@ public class SearchInfo extends ListInfo {
return metaInfo;
}
- public void setMetaInfo(@Nonnull List metaInfo) {
+ public void setMetaInfo(@Nonnull final List metaInfo) {
this.metaInfo = metaInfo;
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampService.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampService.java
index 991a42edf..8b2758796 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampService.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/BandcampService.java
@@ -2,23 +2,6 @@
package org.schabi.newpipe.extractor.services.bandcamp;
-import org.schabi.newpipe.extractor.StreamingService;
-import org.schabi.newpipe.extractor.channel.ChannelExtractor;
-import org.schabi.newpipe.extractor.comments.CommentsExtractor;
-import org.schabi.newpipe.extractor.exceptions.ExtractionException;
-import org.schabi.newpipe.extractor.kiosk.KioskList;
-import org.schabi.newpipe.extractor.linkhandler.*;
-import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
-import org.schabi.newpipe.extractor.search.SearchExtractor;
-import org.schabi.newpipe.extractor.services.bandcamp.extractors.*;
-import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.*;
-import org.schabi.newpipe.extractor.stream.StreamExtractor;
-import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
-import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
-
-import java.util.Arrays;
-import java.util.Collections;
-
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.AUDIO;
import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.COMMENTS;
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.BASE_URL;
@@ -27,6 +10,41 @@ import static org.schabi.newpipe.extractor.services.bandcamp.extractors.Bandcamp
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampRadioExtractor.KIOSK_RADIO;
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampRadioExtractor.RADIO_API_URL;
+import org.schabi.newpipe.extractor.StreamingService;
+import org.schabi.newpipe.extractor.channel.ChannelExtractor;
+import org.schabi.newpipe.extractor.comments.CommentsExtractor;
+import org.schabi.newpipe.extractor.exceptions.ExtractionException;
+import org.schabi.newpipe.extractor.kiosk.KioskList;
+import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
+import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
+import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
+import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
+import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
+import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandlerFactory;
+import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
+import org.schabi.newpipe.extractor.search.SearchExtractor;
+import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampChannelExtractor;
+import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampCommentsExtractor;
+import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper;
+import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampFeaturedExtractor;
+import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampPlaylistExtractor;
+import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampRadioExtractor;
+import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampRadioStreamExtractor;
+import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampSearchExtractor;
+import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampStreamExtractor;
+import org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampSuggestionExtractor;
+import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampChannelLinkHandlerFactory;
+import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampCommentsLinkHandlerFactory;
+import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampFeaturedLinkHandlerFactory;
+import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampPlaylistLinkHandlerFactory;
+import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampSearchQueryHandlerFactory;
+import org.schabi.newpipe.extractor.services.bandcamp.linkHandler.BandcampStreamLinkHandlerFactory;
+import org.schabi.newpipe.extractor.stream.StreamExtractor;
+import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
+import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
+
+import java.util.Arrays;
+
public class BandcampService extends StreamingService {
public BandcampService(final int id) {
@@ -81,19 +99,28 @@ public class BandcampService extends StreamingService {
@Override
public KioskList getKioskList() throws ExtractionException {
- KioskList kioskList = new KioskList(this);
+ final KioskList kioskList = new KioskList(this);
try {
- kioskList.addKioskEntry((streamingService, url, kioskId) ->
- new BandcampFeaturedExtractor(
- BandcampService.this,
- new BandcampFeaturedLinkHandlerFactory().fromUrl(FEATURED_API_URL), kioskId),
- new BandcampFeaturedLinkHandlerFactory(), KIOSK_FEATURED);
+ kioskList.addKioskEntry(
+ (streamingService, url, kioskId) -> new BandcampFeaturedExtractor(
+ BandcampService.this,
+ new BandcampFeaturedLinkHandlerFactory().fromUrl(FEATURED_API_URL),
+ kioskId
+ ),
+ new BandcampFeaturedLinkHandlerFactory(),
+ KIOSK_FEATURED
+ );
- kioskList.addKioskEntry((streamingService, url, kioskId) ->
- new BandcampRadioExtractor(BandcampService.this,
- new BandcampFeaturedLinkHandlerFactory().fromUrl(RADIO_API_URL), kioskId),
- new BandcampFeaturedLinkHandlerFactory(), KIOSK_RADIO);
+ kioskList.addKioskEntry(
+ (streamingService, url, kioskId) -> new BandcampRadioExtractor(
+ BandcampService.this,
+ new BandcampFeaturedLinkHandlerFactory().fromUrl(RADIO_API_URL),
+ kioskId
+ ),
+ new BandcampFeaturedLinkHandlerFactory(),
+ KIOSK_RADIO
+ );
kioskList.setDefaultKiosk(KIOSK_FEATURED);
@@ -116,14 +143,14 @@ public class BandcampService extends StreamingService {
@Override
public StreamExtractor getStreamExtractor(final LinkHandler linkHandler) {
- if (BandcampExtractorHelper.isRadioUrl(linkHandler.getUrl()))
+ if (BandcampExtractorHelper.isRadioUrl(linkHandler.getUrl())) {
return new BandcampRadioStreamExtractor(this, linkHandler);
- else
- return new BandcampStreamExtractor(this, linkHandler);
+ }
+ return new BandcampStreamExtractor(this, linkHandler);
}
@Override
- public CommentsExtractor getCommentsExtractor(ListLinkHandler linkHandler) {
+ public CommentsExtractor getCommentsExtractor(final ListLinkHandler linkHandler) {
return new BandcampCommentsExtractor(this, linkHandler);
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampChannelExtractor.java
index 3b6adf7b9..e4e2c2b57 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampChannelExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampChannelExtractor.java
@@ -4,6 +4,7 @@ package org.schabi.newpipe.extractor.services.bandcamp.extractors;
import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject;
+
import org.jsoup.Jsoup;
import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.StreamingService;
@@ -17,20 +18,24 @@ import org.schabi.newpipe.extractor.services.bandcamp.extractors.streaminfoitem.
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
-import javax.annotation.Nonnull;
import java.io.IOException;
+import javax.annotation.Nonnull;
+
public class BandcampChannelExtractor extends ChannelExtractor {
private JsonObject channelInfo;
- public BandcampChannelExtractor(final StreamingService service, final ListLinkHandler linkHandler) {
+ public BandcampChannelExtractor(final StreamingService service,
+ final ListLinkHandler linkHandler) {
super(service, linkHandler);
}
@Override
public String getAvatarUrl() {
- if (channelInfo.getLong("bio_image_id") == 0) return "";
+ if (channelInfo.getLong("bio_image_id") == 0) {
+ return "";
+ }
return BandcampExtractorHelper.getImageUrl(channelInfo.getLong("bio_image_id"), false);
}
@@ -43,7 +48,8 @@ public class BandcampChannelExtractor extends ChannelExtractor {
*/
try {
final String html = getDownloader()
- .get(channelInfo.getString("bandcamp_url").replace("http://", "https://"))
+ .get(channelInfo.getString("bandcamp_url")
+ .replace("http://", "https://"))
.responseBody();
return Jsoup.parse(html)
@@ -110,7 +116,9 @@ public class BandcampChannelExtractor extends ChannelExtractor {
// A discograph is as an item appears in a discography
final JsonObject discograph = discography.getObject(i);
- if (!discograph.getString("item_type").equals("track")) continue;
+ if (!discograph.getString("item_type").equals("track")) {
+ continue;
+ }
collector.commit(new BandcampDiscographStreamInfoItemExtractor(discograph, getUrl()));
}
@@ -119,12 +127,13 @@ public class BandcampChannelExtractor extends ChannelExtractor {
}
@Override
- public InfoItemsPage getPage(Page page) {
+ public InfoItemsPage getPage(final Page page) {
return null;
}
@Override
- public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
+ public void onFetchPage(@Nonnull final Downloader downloader)
+ throws IOException, ExtractionException {
channelInfo = BandcampExtractorHelper.getArtistDetails(getId());
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampChannelInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampChannelInfoItemExtractor.java
index d25c82656..405824af7 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampChannelInfoItemExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampChannelInfoItemExtractor.java
@@ -8,7 +8,8 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
public class BandcampChannelInfoItemExtractor implements ChannelInfoItemExtractor {
- private final Element resultInfo, searchResult;
+ private final Element resultInfo;
+ private final Element searchResult;
public BandcampChannelInfoItemExtractor(final Element searchResult) {
this.searchResult = searchResult;
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampCommentsExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampCommentsExtractor.java
index 85c754907..4cebedd96 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampCommentsExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampCommentsExtractor.java
@@ -21,25 +21,27 @@ public class BandcampCommentsExtractor extends CommentsExtractor {
private Document document;
- public BandcampCommentsExtractor(StreamingService service, ListLinkHandler linkHandler) {
+ public BandcampCommentsExtractor(final StreamingService service,
+ final ListLinkHandler linkHandler) {
super(service, linkHandler);
}
@Override
- public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
- String html = downloader.get(getLinkHandler().getUrl()).responseBody();
- document = Jsoup.parse(html);
+ public void onFetchPage(@Nonnull final Downloader downloader)
+ throws IOException, ExtractionException {
+ document = Jsoup.parse(downloader.get(getLinkHandler().getUrl()).responseBody());
}
@Nonnull
@Override
- public InfoItemsPage getInitialPage() throws IOException, ExtractionException {
+ public InfoItemsPage getInitialPage()
+ throws IOException, ExtractionException {
- CommentsInfoItemsCollector collector = new CommentsInfoItemsCollector(getServiceId());
+ final CommentsInfoItemsCollector collector = new CommentsInfoItemsCollector(getServiceId());
- Elements writings = document.getElementsByClass("writing");
+ final Elements writings = document.getElementsByClass("writing");
- for (Element writing : writings) {
+ for (final Element writing : writings) {
collector.commit(new BandcampCommentsInfoItemExtractor(writing, getUrl()));
}
@@ -47,7 +49,8 @@ public class BandcampCommentsExtractor extends CommentsExtractor {
}
@Override
- public InfoItemsPage getPage(Page page) throws IOException, ExtractionException {
+ public InfoItemsPage getPage(final Page page)
+ throws IOException, ExtractionException {
return null;
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampCommentsInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampCommentsInfoItemExtractor.java
index 4c077f74c..a3ca0d7df 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampCommentsInfoItemExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampCommentsInfoItemExtractor.java
@@ -9,7 +9,7 @@ public class BandcampCommentsInfoItemExtractor implements CommentsInfoItemExtrac
private final Element writing;
private final String url;
- public BandcampCommentsInfoItemExtractor(Element writing, String url) {
+ public BandcampCommentsInfoItemExtractor(final Element writing, final String url) {
this.writing = writing;
this.url = url;
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampExtractorHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampExtractorHelper.java
index 69870444e..0d222d7b6 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampExtractorHelper.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampExtractorHelper.java
@@ -6,6 +6,7 @@ import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException;
import com.grack.nanojson.JsonWriter;
+
import org.jsoup.Jsoup;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
@@ -18,18 +19,21 @@ import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;
-public class BandcampExtractorHelper {
+public final class BandcampExtractorHelper {
public static final String BASE_URL = "https://bandcamp.com";
public static final String BASE_API_URL = BASE_URL + "/api";
+ private BandcampExtractorHelper() {
+ }
+
/**
* Translate all these parameters together to the URL of the corresponding album or track
* using the mobile API
*/
- public static String getStreamUrlFromIds(final long bandId, final long itemId, final String itemType)
- throws ParsingException {
-
+ public static String getStreamUrlFromIds(final long bandId,
+ final long itemId,
+ final String itemType) throws ParsingException {
try {
final String jsonString = NewPipe.getDownloader().get(
BASE_API_URL + "/mobile/22/tralbum_details?band_id=" + bandId
@@ -50,7 +54,7 @@ public class BandcampExtractorHelper {
*
* More technical info.
*/
- public static JsonObject getArtistDetails(String id) throws ParsingException {
+ public static JsonObject getArtistDetails(final String id) throws ParsingException {
try {
return
JsonParser.object().from(
@@ -91,24 +95,24 @@ public class BandcampExtractorHelper {
public static boolean isSupportedDomain(final String url) throws ParsingException {
// Accept all bandcamp.com URLs
- if (url.toLowerCase().matches("https?://.+\\.bandcamp\\.com(/.*)?")) return true;
+ if (url.toLowerCase().matches("https?://.+\\.bandcamp\\.com(/.*)?")) {
+ return true;
+ }
try {
// Test other URLs for whether they contain a footer that links to bandcamp
- return Jsoup.parse(
- NewPipe.getDownloader().get(url).responseBody()
- )
+ return Jsoup.parse(NewPipe.getDownloader().get(url).responseBody())
.getElementById("pgFt")
.getElementById("pgFt-inner")
.getElementById("footer-logo-wrapper")
.getElementById("footer-logo")
.getElementsByClass("hiddenAccess")
.text().equals("Bandcamp");
- } catch (NullPointerException e) {
+ } catch (final NullPointerException e) {
return false;
- } catch (IOException | ReCaptchaException e) {
- throw new ParsingException("Could not determine whether URL is custom domain " +
- "(not available? network error?)");
+ } catch (final IOException | ReCaptchaException e) {
+ throw new ParsingException("Could not determine whether URL is custom domain "
+ + "(not available? network error?)");
}
}
@@ -121,10 +125,10 @@ public class BandcampExtractorHelper {
return url.toLowerCase().matches("https?://bandcamp\\.com/\\?show=\\d+");
}
- static DateWrapper parseDate(final String textDate) throws ParsingException {
+ public static DateWrapper parseDate(final String textDate) throws ParsingException {
try {
- final ZonedDateTime zonedDateTime = ZonedDateTime.parse(
- textDate, DateTimeFormatter.ofPattern("dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH));
+ final ZonedDateTime zonedDateTime = ZonedDateTime.parse(textDate,
+ DateTimeFormatter.ofPattern("dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH));
return new DateWrapper(zonedDateTime.toOffsetDateTime(), false);
} catch (final DateTimeException e) {
throw new ParsingException("Could not parse date '" + textDate + "'", e);
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampFeaturedExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampFeaturedExtractor.java
index 69f081391..3667f3da6 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampFeaturedExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampFeaturedExtractor.java
@@ -25,17 +25,20 @@ public class BandcampFeaturedExtractor extends KioskExtractor
public static final String KIOSK_FEATURED = "Featured";
public static final String FEATURED_API_URL = BASE_API_URL + "/mobile/24/bootstrap_data";
- public static final String MORE_FEATURED_API_URL = BASE_API_URL + "/mobile/24/feed_older_logged_out";
+ public static final String MORE_FEATURED_API_URL
+ = BASE_API_URL + "/mobile/24/feed_older_logged_out";
private JsonObject json;
- public BandcampFeaturedExtractor(final StreamingService streamingService, final ListLinkHandler listLinkHandler,
+ public BandcampFeaturedExtractor(final StreamingService streamingService,
+ final ListLinkHandler listLinkHandler,
final String kioskId) {
super(streamingService, listLinkHandler, kioskId);
}
@Override
- public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
+ public void onFetchPage(@Nonnull final Downloader downloader)
+ throws IOException, ExtractionException {
try {
json = JsonParser.object().from(
getDownloader().post(
@@ -55,9 +58,8 @@ public class BandcampFeaturedExtractor extends KioskExtractor
@Nonnull
@Override
- public InfoItemsPage getInitialPage() throws IOException, ExtractionException {
-
-
+ public InfoItemsPage getInitialPage()
+ throws IOException, ExtractionException {
final JsonArray featuredStories = json.getObject("feed_content")
.getObject("stories")
.getArray("featured");
@@ -65,8 +67,7 @@ public class BandcampFeaturedExtractor extends KioskExtractor
return extractItems(featuredStories);
}
- private InfoItemsPage extractItems(JsonArray featuredStories) {
-
+ private InfoItemsPage extractItems(final JsonArray featuredStories) {
final PlaylistInfoItemsCollector c = new PlaylistInfoItemsCollector(getServiceId());
for (int i = 0; i < featuredStories.size(); i++) {
@@ -81,14 +82,13 @@ public class BandcampFeaturedExtractor extends KioskExtractor
}
final JsonObject lastFeaturedStory = featuredStories.getObject(featuredStories.size() - 1);
-
return new InfoItemsPage<>(c, getNextPageFrom(lastFeaturedStory));
}
/**
* Next Page can be generated from metadata of last featured story
*/
- private Page getNextPageFrom(JsonObject lastFeaturedStory) {
+ private Page getNextPageFrom(final JsonObject lastFeaturedStory) {
final long lastStoryDate = lastFeaturedStory.getLong("story_date");
final long lastStoryId = lastFeaturedStory.getLong("ntid");
final String lastStoryType = lastFeaturedStory.getString("story_type");
@@ -99,9 +99,10 @@ public class BandcampFeaturedExtractor extends KioskExtractor
}
@Override
- public InfoItemsPage getPage(Page page) throws IOException, ExtractionException {
+ public InfoItemsPage getPage(final Page page)
+ throws IOException, ExtractionException {
- JsonObject response;
+ final JsonObject response;
try {
response = JsonParser.object().from(
getDownloader().get(page.getUrl()).responseBody()
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistExtractor.java
index 7bd98b863..8f2477766 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistExtractor.java
@@ -30,9 +30,9 @@ import static org.schabi.newpipe.extractor.utils.Utils.HTTPS;
public class BandcampPlaylistExtractor extends PlaylistExtractor {
/**
- * An arbitrarily chosen number above which cover arts won't be fetched individually for each track;
- * instead, it will be assumed that every track has the same cover art as the album, which is not
- * always the case.
+ * An arbitrarily chosen number above which cover arts won't be fetched individually for each
+ * track; instead, it will be assumed that every track has the same cover art as the album,
+ * which is not always the case.
*/
private static final int MAXIMUM_INDIVIDUAL_COVER_ARTS = 10;
@@ -41,12 +41,14 @@ public class BandcampPlaylistExtractor extends PlaylistExtractor {
private JsonArray trackInfo;
private String name;
- public BandcampPlaylistExtractor(final StreamingService service, final ListLinkHandler linkHandler) {
+ public BandcampPlaylistExtractor(final StreamingService service,
+ final ListLinkHandler linkHandler) {
super(service, linkHandler);
}
@Override
- public void onFetchPage(@Nonnull final Downloader downloader) throws IOException, ExtractionException {
+ public void onFetchPage(@Nonnull final Downloader downloader)
+ throws IOException, ExtractionException {
final String html = downloader.get(getLinkHandler().getUrl()).responseBody();
document = Jsoup.parse(html);
albumJson = getAlbumInfoJson(html);
@@ -115,7 +117,7 @@ public class BandcampPlaylistExtractor extends PlaylistExtractor {
final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
for (int i = 0; i < trackInfo.size(); i++) {
- JsonObject track = trackInfo.getObject(i);
+ final JsonObject track = trackInfo.getObject(i);
if (trackInfo.size() < MAXIMUM_INDIVIDUAL_COVER_ARTS) {
// Load cover art of every track individually
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistInfoItemExtractor.java
index f6b393bfb..504eb350a 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistInfoItemExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampPlaylistInfoItemExtractor.java
@@ -6,9 +6,10 @@ import org.schabi.newpipe.extractor.playlist.PlaylistInfoItemExtractor;
import javax.annotation.Nonnull;
public class BandcampPlaylistInfoItemExtractor implements PlaylistInfoItemExtractor {
- private final Element searchResult, resultInfo;
+ private final Element searchResult;
+ private final Element resultInfo;
- public BandcampPlaylistInfoItemExtractor(@Nonnull Element searchResult) {
+ public BandcampPlaylistInfoItemExtractor(@Nonnull final Element searchResult) {
this.searchResult = searchResult;
resultInfo = searchResult.getElementsByClass("result-info").first();
}
@@ -41,6 +42,8 @@ public class BandcampPlaylistInfoItemExtractor implements PlaylistInfoItemExtrac
.getElementsByTag("img").first();
if (img != null) {
return img.attr("src");
- } else return null;
+ } else {
+ return null;
+ }
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioExtractor.java
index da062ab04..a90eb3cc4 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioExtractor.java
@@ -28,13 +28,15 @@ public class BandcampRadioExtractor extends KioskExtractor {
private JsonObject json = null;
- public BandcampRadioExtractor(final StreamingService streamingService, final ListLinkHandler linkHandler,
+ public BandcampRadioExtractor(final StreamingService streamingService,
+ final ListLinkHandler linkHandler,
final String kioskId) {
super(streamingService, linkHandler, kioskId);
}
@Override
- public void onFetchPage(@Nonnull final Downloader downloader) throws IOException, ExtractionException {
+ public void onFetchPage(@Nonnull final Downloader downloader)
+ throws IOException, ExtractionException {
try {
json = JsonParser.object().from(
getDownloader().get(RADIO_API_URL).responseBody());
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioInfoItemExtractor.java
index cca802e95..be6ba0b7a 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioInfoItemExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioInfoItemExtractor.java
@@ -23,10 +23,9 @@ public class BandcampRadioInfoItemExtractor implements StreamInfoItemExtractor {
@Override
public long getDuration() {
- /* Duration is only present in the more detailed information that has to be queried separately.
- * Therefore, over 300 queries would be needed every time the kiosk is opened if we were to
- * display the real value.
- */
+ /* Duration is only present in the more detailed information that has to be queried
+ separately. Therefore, over 300 queries would be needed every time the kiosk is opened if we
+ were to display the real value. */
//return query(show.getInt("id")).getLong("audio_duration");
return 0;
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioStreamExtractor.java
index edd7c33f4..9e6e5acf3 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioStreamExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRadioStreamExtractor.java
@@ -26,28 +26,31 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.*;
+import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.BASE_API_URL;
+import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.BASE_URL;
+import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImageUrl;
public class BandcampRadioStreamExtractor extends BandcampStreamExtractor {
private JsonObject showInfo;
- public BandcampRadioStreamExtractor(final StreamingService service, final LinkHandler linkHandler) {
+ public BandcampRadioStreamExtractor(final StreamingService service,
+ final LinkHandler linkHandler) {
super(service, linkHandler);
}
static JsonObject query(final int id) throws ParsingException {
try {
- return JsonParser.object().from(
- NewPipe.getDownloader().get(BASE_API_URL + "/bcweekly/1/get?id=" + id).responseBody()
- );
+ return JsonParser.object().from(NewPipe.getDownloader()
+ .get(BASE_API_URL + "/bcweekly/1/get?id=" + id).responseBody());
} catch (final IOException | ReCaptchaException | JsonParserException e) {
throw new ParsingException("could not get show data", e);
}
}
@Override
- public void onFetchPage(@Nonnull final Downloader downloader) throws IOException, ExtractionException {
+ public void onFetchPage(@Nonnull final Downloader downloader)
+ throws IOException, ExtractionException {
showInfo = query(Integer.parseInt(getId()));
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRelatedPlaylistInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRelatedPlaylistInfoItemExtractor.java
index 7d639131e..74e4997b5 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRelatedPlaylistInfoItemExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampRelatedPlaylistInfoItemExtractor.java
@@ -14,7 +14,7 @@ import javax.annotation.Nonnull;
public class BandcampRelatedPlaylistInfoItemExtractor implements PlaylistInfoItemExtractor {
private final Element relatedAlbum;
- public BandcampRelatedPlaylistInfoItemExtractor(@Nonnull Element relatedAlbum) {
+ public BandcampRelatedPlaylistInfoItemExtractor(@Nonnull final Element relatedAlbum) {
this.relatedAlbum = relatedAlbum;
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampSearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampSearchExtractor.java
index cd0643951..e5a80f87d 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampSearchExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampSearchExtractor.java
@@ -26,7 +26,8 @@ import java.util.List;
public class BandcampSearchExtractor extends SearchExtractor {
- public BandcampSearchExtractor(StreamingService service, SearchQueryHandler linkHandler) {
+ public BandcampSearchExtractor(final StreamingService service,
+ final SearchQueryHandler linkHandler) {
super(service, linkHandler);
}
@@ -47,7 +48,8 @@ public class BandcampSearchExtractor extends SearchExtractor {
return Collections.emptyList();
}
- public InfoItemsPage getPage(final Page page) throws IOException, ExtractionException {
+ public InfoItemsPage getPage(final Page page)
+ throws IOException, ExtractionException {
final String html = getDownloader().get(page.getUrl()).responseBody();
final MultiInfoItemsCollector collector = new MultiInfoItemsCollector(getServiceId());
@@ -86,8 +88,9 @@ public class BandcampSearchExtractor extends SearchExtractor {
// Count pages
final Elements pageLists = d.getElementsByClass("pagelist");
- if (pageLists.isEmpty())
+ if (pageLists.isEmpty()) {
return new InfoItemsPage<>(collector, null);
+ }
final Elements pages = pageLists.first().getElementsByTag("li");
@@ -120,7 +123,7 @@ public class BandcampSearchExtractor extends SearchExtractor {
}
@Override
- public void onFetchPage(@Nonnull final Downloader downloader) throws IOException, ExtractionException {
-
+ public void onFetchPage(@Nonnull final Downloader downloader)
+ throws IOException, ExtractionException {
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampStreamExtractor.java
index 530c182b7..e082bd716 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampStreamExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampStreamExtractor.java
@@ -2,14 +2,16 @@
package org.schabi.newpipe.extractor.services.bandcamp.extractors;
+import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImageUrl;
+
import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParserException;
+
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
import org.schabi.newpipe.extractor.MediaFormat;
-import org.schabi.newpipe.extractor.MetaInfo;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.downloader.Downloader;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
@@ -17,19 +19,21 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
import org.schabi.newpipe.extractor.localization.DateWrapper;
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItemsCollector;
-import org.schabi.newpipe.extractor.stream.*;
+import org.schabi.newpipe.extractor.stream.AudioStream;
+import org.schabi.newpipe.extractor.stream.Description;
+import org.schabi.newpipe.extractor.stream.StreamExtractor;
+import org.schabi.newpipe.extractor.stream.StreamType;
+import org.schabi.newpipe.extractor.stream.VideoStream;
import org.schabi.newpipe.extractor.utils.JsonUtils;
import org.schabi.newpipe.extractor.utils.Utils;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import java.util.Locale;
-import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImageUrl;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
public class BandcampStreamExtractor extends StreamExtractor {
@@ -43,7 +47,8 @@ public class BandcampStreamExtractor extends StreamExtractor {
@Override
- public void onFetchPage(@Nonnull final Downloader downloader) throws IOException, ExtractionException {
+ public void onFetchPage(@Nonnull final Downloader downloader)
+ throws IOException, ExtractionException {
final String html = downloader.get(getLinkHandler().getUrl()).responseBody();
document = Jsoup.parse(html);
albumJson = getAlbumInfoJson(html);
@@ -94,7 +99,7 @@ public class BandcampStreamExtractor extends StreamExtractor {
@Nonnull
@Override
- public String getUploaderName() {
+ public String getUploaderName() throws ParsingException {
return albumJson.getString("artist");
}
@@ -113,8 +118,11 @@ public class BandcampStreamExtractor extends StreamExtractor {
@Nonnull
@Override
public String getThumbnailUrl() throws ParsingException {
- if (albumJson.isNull("art_id")) return "";
- else return getImageUrl(albumJson.getLong("art_id"), true);
+ if (albumJson.isNull("art_id")) {
+ return "";
+ } else {
+ return getImageUrl(albumJson.getLong("art_id"), true);
+ }
}
@Nonnull
@@ -170,15 +178,12 @@ public class BandcampStreamExtractor extends StreamExtractor {
@Override
public PlaylistInfoItemsCollector getRelatedItems() {
+ final PlaylistInfoItemsCollector collector = new PlaylistInfoItemsCollector(getServiceId());
+ final Elements recommendedAlbums = document.getElementsByClass("recommended-album");
- PlaylistInfoItemsCollector collector = new PlaylistInfoItemsCollector(getServiceId());
-
- Elements recommendedAlbums = document.getElementsByClass("recommended-album");
-
- for (Element album : recommendedAlbums) {
+ for (final Element album : recommendedAlbums) {
collector.commit(new BandcampRelatedPlaylistInfoItemExtractor(album));
}
-
return collector;
}
@@ -186,22 +191,21 @@ public class BandcampStreamExtractor extends StreamExtractor {
@Override
public String getCategory() {
// Get first tag from html, which is the artist's Genre
- return document
- .getElementsByClass("tralbum-tags").first()
- .getElementsByClass("tag").first().text();
+ return document.getElementsByClass("tralbum-tags").stream()
+ .flatMap(element -> element.getElementsByClass("tag").stream())
+ .map(Element::text)
+ .findFirst()
+ .orElse("");
}
@Nonnull
@Override
public String getLicence() {
+ /* Tests resulted in this mapping of ints to licence:
+ https://cloud.disroot.org/s/ZTWBxbQ9fKRmRWJ/preview (screenshot from a Bandcamp artist's
+ account) */
- int license = current.getInt("license_type");
-
- /* Tests resulted in this mapping of ints to licence: https://cloud.disroot.org/s/ZTWBxbQ9fKRmRWJ/preview
- * (screenshot from a Bandcamp artist's account)
- */
-
- switch (license) {
+ switch (current.getInt("license_type")) {
case 1:
return "All rights reserved ©";
case 2:
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampSuggestionExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampSuggestionExtractor.java
index 46283345b..67516b4fc 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampSuggestionExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/BandcampSuggestionExtractor.java
@@ -2,10 +2,13 @@
package org.schabi.newpipe.extractor.services.bandcamp.extractors;
+import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.BASE_API_URL;
+
import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException;
+
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.downloader.Downloader;
@@ -18,8 +21,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
-import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.BASE_API_URL;
-
public class BandcampSuggestionExtractor extends SuggestionExtractor {
private static final String AUTOCOMPLETE_URL = BASE_API_URL + "/fuzzysearch/1/autocomplete?q=";
@@ -32,9 +33,8 @@ public class BandcampSuggestionExtractor extends SuggestionExtractor {
final Downloader downloader = NewPipe.getDownloader();
try {
- final JsonObject fuzzyResults = JsonParser.object().from(
- downloader.get(AUTOCOMPLETE_URL + URLEncoder.encode(query, "UTF-8")).responseBody()
- );
+ final JsonObject fuzzyResults = JsonParser.object().from(downloader
+ .get(AUTOCOMPLETE_URL + URLEncoder.encode(query, "UTF-8")).responseBody());
final JsonArray jsonArray = fuzzyResults.getObject("auto")
.getArray("results");
@@ -44,7 +44,9 @@ public class BandcampSuggestionExtractor extends SuggestionExtractor {
for (final Object fuzzyResult : jsonArray) {
final String res = ((JsonObject) fuzzyResult).getString("name");
- if (!suggestions.contains(res)) suggestions.add(res);
+ if (!suggestions.contains(res)) {
+ suggestions.add(res);
+ }
}
return suggestions;
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampDiscographStreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampDiscographStreamInfoItemExtractor.java
index 6a2549989..42b3170b3 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampDiscographStreamInfoItemExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampDiscographStreamInfoItemExtractor.java
@@ -9,9 +9,9 @@ import javax.annotation.Nullable;
public class BandcampDiscographStreamInfoItemExtractor extends BandcampStreamInfoItemExtractor {
private final JsonObject discograph;
- public BandcampDiscographStreamInfoItemExtractor(final JsonObject discograph, final String uploaderUrl) {
+ public BandcampDiscographStreamInfoItemExtractor(final JsonObject discograph,
+ final String uploaderUrl) {
super(uploaderUrl);
-
this.discograph = discograph;
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampPlaylistStreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampPlaylistStreamInfoItemExtractor.java
index c28c24ba2..1b2e7e886 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampPlaylistStreamInfoItemExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampPlaylistStreamInfoItemExtractor.java
@@ -18,14 +18,16 @@ public class BandcampPlaylistStreamInfoItemExtractor extends BandcampStreamInfoI
private String substituteCoverUrl;
private final StreamingService service;
- public BandcampPlaylistStreamInfoItemExtractor(final JsonObject track, final String uploaderUrl,
+ public BandcampPlaylistStreamInfoItemExtractor(final JsonObject track,
+ final String uploaderUrl,
final StreamingService service) {
super(uploaderUrl);
this.track = track;
this.service = service;
}
- public BandcampPlaylistStreamInfoItemExtractor(final JsonObject track, final String uploaderUrl,
+ public BandcampPlaylistStreamInfoItemExtractor(final JsonObject track,
+ final String uploaderUrl,
final String substituteCoverUrl) {
this(track, uploaderUrl, (StreamingService) null);
this.substituteCoverUrl = substituteCoverUrl;
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampSearchStreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampSearchStreamInfoItemExtractor.java
index 87ba69d11..0fdf58a9c 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampSearchStreamInfoItemExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampSearchStreamInfoItemExtractor.java
@@ -7,9 +7,11 @@ import javax.annotation.Nullable;
public class BandcampSearchStreamInfoItemExtractor extends BandcampStreamInfoItemExtractor {
- private final Element resultInfo, searchResult;
+ private final Element resultInfo;
+ private final Element searchResult;
- public BandcampSearchStreamInfoItemExtractor(final Element searchResult, final String uploaderUrl) {
+ public BandcampSearchStreamInfoItemExtractor(final Element searchResult,
+ final String uploaderUrl) {
super(uploaderUrl);
this.searchResult = searchResult;
resultInfo = searchResult.getElementsByClass("result-info").first();
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampChannelLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampChannelLinkHandlerFactory.java
index 05caf1141..3f51ed174 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampChannelLinkHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampChannelLinkHandlerFactory.java
@@ -30,7 +30,8 @@ public class BandcampChannelLinkHandlerFactory extends ListLinkHandlerFactory {
return String.valueOf(bandData.getLong("id"));
- } catch (final IOException | ReCaptchaException | ArrayIndexOutOfBoundsException | JsonParserException e) {
+ } catch (final IOException | ReCaptchaException | ArrayIndexOutOfBoundsException
+ | JsonParserException e) {
throw new ParsingException("Download failed", e);
}
}
@@ -46,7 +47,8 @@ public class BandcampChannelLinkHandlerFactory extends ListLinkHandlerFactory {
.getString("bandcamp_url")
.replace("http://", "https://");
} catch (final NullPointerException e) {
- throw new ParsingException("JSON does not contain URL (invalid id?) or is otherwise invalid", e);
+ throw new ParsingException(
+ "JSON does not contain URL (invalid id?) or is otherwise invalid", e);
}
}
@@ -55,16 +57,18 @@ public class BandcampChannelLinkHandlerFactory extends ListLinkHandlerFactory {
* Accepts only pages that lead to the root of an artist profile. Supports external pages.
*/
@Override
- public boolean onAcceptUrl(String url) throws ParsingException {
+ public boolean onAcceptUrl(final String url) throws ParsingException {
- url = url.toLowerCase();
+ final String lowercaseUrl = url.toLowerCase();
// https: | | artist.bandcamp.com | releases
// 0 1 2 3
- String[] splitUrl = url.split("/");
+ final String[] splitUrl = lowercaseUrl.split("/");
// URL is too short
- if (splitUrl.length < 3) return false;
+ if (splitUrl.length < 3) {
+ return false;
+ }
// Must have "releases" or "music" as segment after url or none at all
if (splitUrl.length > 3 && !(
@@ -80,7 +84,7 @@ public class BandcampChannelLinkHandlerFactory extends ListLinkHandlerFactory {
}
// Test whether domain is supported
- return BandcampExtractorHelper.isSupportedDomain(url);
+ return BandcampExtractorHelper.isSupportedDomain(lowercaseUrl);
}
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampCommentsLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampCommentsLinkHandlerFactory.java
index 84e97279b..31e93ccc0 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampCommentsLinkHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampCommentsLinkHandlerFactory.java
@@ -13,21 +13,25 @@ import java.util.List;
public class BandcampCommentsLinkHandlerFactory extends ListLinkHandlerFactory {
@Override
- public String getId(String url) throws ParsingException {
+ public String getId(final String url) throws ParsingException {
return url;
}
@Override
- public boolean onAcceptUrl(String url) throws ParsingException {
+ public boolean onAcceptUrl(final String url) throws ParsingException {
// Don't accept URLs that don't point to a track
- if (!url.toLowerCase().matches("https?://.+\\..+/(track|album)/.+")) return false;
+ if (!url.toLowerCase().matches("https?://.+\\..+/(track|album)/.+")) {
+ return false;
+ }
// Test whether domain is supported
return BandcampExtractorHelper.isSupportedDomain(url);
}
@Override
- public String getUrl(String id, List contentFilter, String sortFilter) throws ParsingException {
+ public String getUrl(final String id,
+ final List contentFilter,
+ final String sortFilter) throws ParsingException {
return id;
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampFeaturedLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampFeaturedLinkHandlerFactory.java
index ea6254979..fd6933738 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampFeaturedLinkHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampFeaturedLinkHandlerFactory.java
@@ -16,7 +16,9 @@ import static org.schabi.newpipe.extractor.services.bandcamp.extractors.Bandcamp
public class BandcampFeaturedLinkHandlerFactory extends ListLinkHandlerFactory {
@Override
- public String getUrl(final String id, final List contentFilter, final String sortFilter) {
+ public String getUrl(final String id,
+ final List contentFilter,
+ final String sortFilter) {
if (id.equals(KIOSK_FEATURED)) {
return FEATURED_API_URL; // doesn't have a website
} else if (id.equals(KIOSK_RADIO)) {
@@ -27,11 +29,11 @@ public class BandcampFeaturedLinkHandlerFactory extends ListLinkHandlerFactory {
}
@Override
- public String getId(String url) {
- url = Utils.replaceHttpWithHttps(url);
- if (BandcampExtractorHelper.isRadioUrl(url) || url.equals(RADIO_API_URL)) {
+ public String getId(final String url) {
+ final String fixedUrl = Utils.replaceHttpWithHttps(url);
+ if (BandcampExtractorHelper.isRadioUrl(fixedUrl) || fixedUrl.equals(RADIO_API_URL)) {
return KIOSK_RADIO;
- } else if (url.equals(FEATURED_API_URL)) {
+ } else if (fixedUrl.equals(FEATURED_API_URL)) {
return KIOSK_FEATURED;
} else {
return null;
@@ -39,8 +41,10 @@ public class BandcampFeaturedLinkHandlerFactory extends ListLinkHandlerFactory {
}
@Override
- public boolean onAcceptUrl(String url) {
- url = Utils.replaceHttpWithHttps(url);
- return url.equals(FEATURED_API_URL) || (url.equals(RADIO_API_URL) || BandcampExtractorHelper.isRadioUrl(url));
+ public boolean onAcceptUrl(final String url) {
+ final String fixedUrl = Utils.replaceHttpWithHttps(url);
+ return fixedUrl.equals(FEATURED_API_URL)
+ || fixedUrl.equals(RADIO_API_URL)
+ || BandcampExtractorHelper.isRadioUrl(fixedUrl);
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampPlaylistLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampPlaylistLinkHandlerFactory.java
index b0fd2d50a..a88453339 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampPlaylistLinkHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampPlaylistLinkHandlerFactory.java
@@ -18,8 +18,9 @@ public class BandcampPlaylistLinkHandlerFactory extends ListLinkHandlerFactory {
}
@Override
- public String getUrl(final String url, final List contentFilter, final String sortFilter)
- throws ParsingException {
+ public String getUrl(final String url,
+ final List contentFilter,
+ final String sortFilter) throws ParsingException {
return url;
}
@@ -30,7 +31,9 @@ public class BandcampPlaylistLinkHandlerFactory extends ListLinkHandlerFactory {
public boolean onAcceptUrl(final String url) throws ParsingException {
// Exclude URLs which do not lead to an album
- if (!url.toLowerCase().matches("https?://.+\\..+/album/.+")) return false;
+ if (!url.toLowerCase().matches("https?://.+\\..+/album/.+")) {
+ return false;
+ }
// Test whether domain is supported
return BandcampExtractorHelper.isSupportedDomain(url);
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampSearchQueryHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampSearchQueryHandlerFactory.java
index 9e295d5de..15cf36706 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampSearchQueryHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampSearchQueryHandlerFactory.java
@@ -15,14 +15,11 @@ public class BandcampSearchQueryHandlerFactory extends SearchQueryHandlerFactory
@Override
- public String getUrl(final String query, final List contentFilter, final String sortFilter)
- throws ParsingException {
+ public String getUrl(final String query,
+ final List contentFilter,
+ final String sortFilter) throws ParsingException {
try {
-
- return BASE_URL + "/search?q=" +
- URLEncoder.encode(query, "UTF-8")
- + "&page=1";
-
+ return BASE_URL + "/search?q=" + URLEncoder.encode(query, "UTF-8") + "&page=1";
} catch (final UnsupportedEncodingException e) {
throw new ParsingException("query \"" + query + "\" could not be encoded", e);
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampStreamLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampStreamLinkHandlerFactory.java
index 96b9f9d8e..0ef30cbec 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampStreamLinkHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/linkHandler/BandcampStreamLinkHandlerFactory.java
@@ -50,10 +50,14 @@ public class BandcampStreamLinkHandlerFactory extends LinkHandlerFactory {
public boolean onAcceptUrl(final String url) throws ParsingException {
// Accept Bandcamp radio
- if (BandcampExtractorHelper.isRadioUrl(url)) return true;
+ if (BandcampExtractorHelper.isRadioUrl(url)) {
+ return true;
+ }
// Don't accept URLs that don't point to a track
- if (!url.toLowerCase().matches("https?://.+\\..+/track/.+")) return false;
+ if (!url.toLowerCase().matches("https?://.+\\..+/track/.+")) {
+ return false;
+ }
// Test whether domain is supported
return BandcampExtractorHelper.isSupportedDomain(url);
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCService.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCService.java
index 02820c03a..54bfb9530 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCService.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCService.java
@@ -1,10 +1,13 @@
package org.schabi.newpipe.extractor.services.media_ccc;
+import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.AUDIO;
+import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.VIDEO;
+import static java.util.Arrays.asList;
+
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.comments.CommentsExtractor;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
-import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
import org.schabi.newpipe.extractor.kiosk.KioskList;
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
@@ -14,16 +17,24 @@ import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandlerFactory;
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.search.SearchExtractor;
-import org.schabi.newpipe.extractor.services.media_ccc.extractors.*;
-import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.*;
+import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCConferenceExtractor;
+import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCConferenceKiosk;
+import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCLiveStreamExtractor;
+import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCLiveStreamKiosk;
+import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCParsingHelper;
+import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCRecentKiosk;
+import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCSearchExtractor;
+import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor;
+import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCConferenceLinkHandlerFactory;
+import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCConferencesListLinkHandlerFactory;
+import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCLiveListLinkHandlerFactory;
+import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCRecentListLinkHandlerFactory;
+import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory;
+import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCStreamLinkHandlerFactory;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
-import static java.util.Arrays.asList;
-import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.AUDIO;
-import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.VIDEO;
-
public class MediaCCCService extends StreamingService {
public MediaCCCService(final int id) {
super(id, "media.ccc.de", asList(AUDIO, VIDEO));
@@ -79,42 +90,42 @@ public class MediaCCCService extends StreamingService {
@Override
public KioskList getKioskList() throws ExtractionException {
- KioskList list = new KioskList(this);
+ final KioskList list = new KioskList(this);
// add kiosks here e.g.:
try {
- list.addKioskEntry(new KioskList.KioskExtractorFactory() {
- @Override
- public KioskExtractor createNewKiosk(final StreamingService streamingService,
- final String url, final String kioskId)
- throws ExtractionException {
- return new MediaCCCConferenceKiosk(MediaCCCService.this,
- new MediaCCCConferencesListLinkHandlerFactory().fromUrl(url), kioskId);
- }
- }, new MediaCCCConferencesListLinkHandlerFactory(), "conferences");
+ list.addKioskEntry(
+ (streamingService, url, kioskId) -> new MediaCCCConferenceKiosk(
+ MediaCCCService.this,
+ new MediaCCCConferencesListLinkHandlerFactory().fromUrl(url),
+ kioskId
+ ),
+ new MediaCCCConferencesListLinkHandlerFactory(),
+ "conferences"
+ );
- list.addKioskEntry(new KioskList.KioskExtractorFactory() {
- @Override
- public KioskExtractor createNewKiosk(final StreamingService streamingService,
- final String url, final String kioskId)
- throws ExtractionException {
- return new MediaCCCRecentKiosk(MediaCCCService.this,
- new MediaCCCRecentListLinkHandlerFactory().fromUrl(url), kioskId);
- }
- }, new MediaCCCRecentListLinkHandlerFactory(), "recent");
+ list.addKioskEntry(
+ (streamingService, url, kioskId) -> new MediaCCCRecentKiosk(
+ MediaCCCService.this,
+ new MediaCCCRecentListLinkHandlerFactory().fromUrl(url),
+ kioskId
+ ),
+ new MediaCCCRecentListLinkHandlerFactory(),
+ "recent"
+ );
- list.addKioskEntry(new KioskList.KioskExtractorFactory() {
- @Override
- public KioskExtractor createNewKiosk(final StreamingService streamingService,
- final String url, final String kioskId)
- throws ExtractionException {
- return new MediaCCCLiveStreamKiosk(MediaCCCService.this,
- new MediaCCCLiveListLinkHandlerFactory().fromUrl(url), kioskId);
- }
- }, new MediaCCCLiveListLinkHandlerFactory(), "live");
+ list.addKioskEntry(
+ (streamingService, url, kioskId) -> new MediaCCCLiveStreamKiosk(
+ MediaCCCService.this,
+ new MediaCCCLiveListLinkHandlerFactory().fromUrl(url),
+ kioskId
+ ),
+ new MediaCCCLiveListLinkHandlerFactory(),
+ "live"
+ );
list.setDefaultKiosk("recent");
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new ExtractionException(e);
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceExtractor.java
index 22571b895..98aa2c257 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceExtractor.java
@@ -53,22 +53,22 @@ public class MediaCCCConferenceExtractor extends ChannelExtractor {
}
@Override
- public String getParentChannelName() throws ParsingException {
+ public String getParentChannelName() {
return "";
}
@Override
- public String getParentChannelUrl() throws ParsingException {
+ public String getParentChannelUrl() {
return "";
}
@Override
- public String getParentChannelAvatarUrl() throws ParsingException {
+ public String getParentChannelAvatarUrl() {
return "";
}
@Override
- public boolean isVerified() throws ParsingException {
+ public boolean isVerified() {
return false;
}
@@ -91,10 +91,11 @@ public class MediaCCCConferenceExtractor extends ChannelExtractor {
@Override
public void onFetchPage(@Nonnull final Downloader downloader)
throws IOException, ExtractionException {
- final String conferenceUrl = MediaCCCConferenceLinkHandlerFactory.CONFERENCE_API_ENDPOINT + getId();
+ final String conferenceUrl
+ = MediaCCCConferenceLinkHandlerFactory.CONFERENCE_API_ENDPOINT + getId();
try {
conferenceData = JsonParser.object().from(downloader.get(conferenceUrl).responseBody());
- } catch (JsonParserException jpe) {
+ } catch (final JsonParserException jpe) {
throw new ExtractionException("Could not parse json returnd by url: " + conferenceUrl);
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceKiosk.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceKiosk.java
index 8ca272924..85aa48999 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceKiosk.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCConferenceKiosk.java
@@ -32,8 +32,8 @@ public class MediaCCCConferenceKiosk extends KioskExtractor {
@Nonnull
@Override
public InfoItemsPage getInitialPage() {
- JsonArray conferences = doc.getArray("conferences");
- ChannelInfoItemsCollector collector = new ChannelInfoItemsCollector(getServiceId());
+ final JsonArray conferences = doc.getArray("conferences");
+ final ChannelInfoItemsCollector collector = new ChannelInfoItemsCollector(getServiceId());
for (int i = 0; i < conferences.size(); i++) {
collector.commit(new MediaCCCConferenceInfoItemExtractor(conferences.getObject(i)));
}
@@ -54,7 +54,7 @@ public class MediaCCCConferenceKiosk extends KioskExtractor {
.responseBody();
try {
doc = JsonParser.object().from(site);
- } catch (JsonParserException jpe) {
+ } catch (final JsonParserException jpe) {
throw new ExtractionException("Could not parse json.", jpe);
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCLiveStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCLiveStreamExtractor.java
index bd02d6483..2a4eb45ed 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCLiveStreamExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCLiveStreamExtractor.java
@@ -2,50 +2,51 @@ package org.schabi.newpipe.extractor.services.media_ccc.extractors;
import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject;
+
import org.schabi.newpipe.extractor.MediaFormat;
-import org.schabi.newpipe.extractor.MetaInfo;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.downloader.Downloader;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
-import org.schabi.newpipe.extractor.localization.DateWrapper;
-import org.schabi.newpipe.extractor.stream.*;
+import org.schabi.newpipe.extractor.stream.AudioStream;
+import org.schabi.newpipe.extractor.stream.Description;
+import org.schabi.newpipe.extractor.stream.StreamExtractor;
+import org.schabi.newpipe.extractor.stream.StreamType;
+import org.schabi.newpipe.extractor.stream.VideoStream;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Collections;
import java.util.List;
-import java.util.Locale;
+
+import javax.annotation.Nonnull;
public class MediaCCCLiveStreamExtractor extends StreamExtractor {
- private JsonArray doc = null;
private JsonObject conference = null;
private String group = "";
private JsonObject room = null;
- public MediaCCCLiveStreamExtractor(StreamingService service, LinkHandler linkHandler) {
+ public MediaCCCLiveStreamExtractor(final StreamingService service,
+ final LinkHandler linkHandler) {
super(service, linkHandler);
}
@Override
- public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
- doc = MediaCCCParsingHelper.getLiveStreams(downloader, getExtractorLocalization());
+ public void onFetchPage(@Nonnull final Downloader downloader)
+ throws IOException, ExtractionException {
+ final JsonArray doc =
+ MediaCCCParsingHelper.getLiveStreams(downloader, getExtractorLocalization());
// find correct room
for (int c = 0; c < doc.size(); c++) {
- final JsonObject conference = doc.getObject(c);
+ conference = doc.getObject(c);
final JsonArray groups = conference.getArray("groups");
for (int g = 0; g < groups.size(); g++) {
- final String group = groups.getObject(g).getString("group");
+ group = groups.getObject(g).getString("group");
final JsonArray rooms = groups.getObject(g).getArray("rooms");
for (int r = 0; r < rooms.size(); r++) {
- final JsonObject room = rooms.getObject(r);
- if (getId().equals(conference.getString("slug") + "/" + room.getString("slug"))) {
- this.conference = conference;
- this.group = group;
- this.room = room;
+ room = rooms.getObject(r);
+ if (getId().equals(
+ conference.getString("slug") + "/" + room.getString("slug"))) {
return;
}
}
@@ -69,7 +70,8 @@ public class MediaCCCLiveStreamExtractor extends StreamExtractor {
@Nonnull
@Override
public Description getDescription() throws ParsingException {
- return new Description(conference.getString("description") + " - " + group, Description.PLAIN_TEXT);
+ return new Description(conference.getString("description")
+ + " - " + group, Description.PLAIN_TEXT);
}
@Override
@@ -93,12 +95,11 @@ public class MediaCCCLiveStreamExtractor extends StreamExtractor {
@Override
public String getHlsUrl() {
// TODO: There are multiple HLS streams.
- // Make getHlsUrl() and getDashMpdUrl() return lists of VideoStreams, so the user can choose a resolution.
+ // Make getHlsUrl() and getDashMpdUrl() return lists of VideoStreams,
+ // so the user can choose a resolution.
for (int s = 0; s < room.getArray("streams").size(); s++) {
final JsonObject stream = room.getArray("streams").getObject(s);
if (stream.getString("type").equals("video")) {
- final String resolution = stream.getArray("videoSize").getInt(0) + "x"
- + stream.getArray("videoSize").getInt(1);
if (stream.has("hls")) {
return stream.getObject("urls").getObject("hls").getString("url");
}
@@ -115,7 +116,8 @@ public class MediaCCCLiveStreamExtractor extends StreamExtractor {
if (stream.getString("type").equals("audio")) {
for (final String type : stream.getObject("urls").keySet()) {
final JsonObject url = stream.getObject("urls").getObject(type);
- audioStreams.add(new AudioStream(url.getString("url"), MediaFormat.getFromSuffix(type), -1));
+ audioStreams.add(new AudioStream(url.getString("url"),
+ MediaFormat.getFromSuffix(type), -1));
}
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCLiveStreamKiosk.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCLiveStreamKiosk.java
index 260b04f36..769ba19ee 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCLiveStreamKiosk.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCLiveStreamKiosk.java
@@ -18,19 +18,22 @@ import java.io.IOException;
public class MediaCCCLiveStreamKiosk extends KioskExtractor {
private JsonArray doc;
- public MediaCCCLiveStreamKiosk(StreamingService streamingService, ListLinkHandler linkHandler, String kioskId) {
+ public MediaCCCLiveStreamKiosk(final StreamingService streamingService,
+ final ListLinkHandler linkHandler,
+ final String kioskId) {
super(streamingService, linkHandler, kioskId);
}
@Override
- public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
+ public void onFetchPage(@Nonnull final Downloader downloader)
+ throws IOException, ExtractionException {
doc = MediaCCCParsingHelper.getLiveStreams(downloader, getExtractorLocalization());
}
@Nonnull
@Override
public InfoItemsPage getInitialPage() throws IOException, ExtractionException {
- StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
+ final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
for (int c = 0; c < doc.size(); c++) {
final JsonObject conference = doc.getObject(c);
final JsonArray groups = conference.getArray("groups");
@@ -48,7 +51,8 @@ public class MediaCCCLiveStreamKiosk extends KioskExtractor {
}
@Override
- public InfoItemsPage getPage(Page page) throws IOException, ExtractionException {
+ public InfoItemsPage getPage(final Page page)
+ throws IOException, ExtractionException {
return InfoItemsPage.emptyPage();
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCLiveStreamKioskExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCLiveStreamKioskExtractor.java
index e04be76f9..2b311fb35 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCLiveStreamKioskExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCLiveStreamKioskExtractor.java
@@ -14,7 +14,8 @@ public class MediaCCCLiveStreamKioskExtractor implements StreamInfoItemExtractor
private final String group;
private final JsonObject roomInfo;
- public MediaCCCLiveStreamKioskExtractor(final JsonObject conferenceInfo, final String group,
+ public MediaCCCLiveStreamKioskExtractor(final JsonObject conferenceInfo,
+ final String group,
final JsonObject roomInfo) {
this.conferenceInfo = conferenceInfo;
this.group = group;
@@ -39,7 +40,7 @@ public class MediaCCCLiveStreamKioskExtractor implements StreamInfoItemExtractor
@Override
public StreamType getStreamType() throws ParsingException {
boolean isVideo = false;
- for (Object stream : roomInfo.getArray("streams")) {
+ for (final Object stream : roomInfo.getArray("streams")) {
if ("video".equals(((JsonObject) stream).getString("type"))) {
isVideo = true;
break;
@@ -65,7 +66,8 @@ public class MediaCCCLiveStreamKioskExtractor implements StreamInfoItemExtractor
@Override
public String getUploaderName() throws ParsingException {
- return conferenceInfo.getString("conference") + " - " + group + " - " + roomInfo.getString("display");
+ return conferenceInfo.getString("conference") + " - " + group
+ + " - " + roomInfo.getString("display");
}
@Override
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCParsingHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCParsingHelper.java
index 1cb9d9757..ad07c4720 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCParsingHelper.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCParsingHelper.java
@@ -15,15 +15,17 @@ import java.time.format.DateTimeParseException;
import java.util.regex.Pattern;
public final class MediaCCCParsingHelper {
- private static final Pattern LIVE_STREAM_ID_PATTERN = Pattern.compile("\\w+/\\w+"); // {conference_slug}/{room_slug}
+ // {conference_slug}/{room_slug}
+ private static final Pattern LIVE_STREAM_ID_PATTERN = Pattern.compile("\\w+/\\w+");
private static JsonArray liveStreams = null;
private MediaCCCParsingHelper() { }
- public static OffsetDateTime parseDateFrom(final String textualUploadDate) throws ParsingException {
+ public static OffsetDateTime parseDateFrom(final String textualUploadDate)
+ throws ParsingException {
try {
return OffsetDateTime.parse(textualUploadDate);
- } catch (DateTimeParseException e) {
+ } catch (final DateTimeParseException e) {
throw new ParsingException("Could not parse date: \"" + textualUploadDate + "\"", e);
}
}
@@ -31,8 +33,8 @@ public final class MediaCCCParsingHelper {
/**
* Check whether an id is a live stream id
* @param id the {@code id} to check
- * @return returns {@code true} if the {@code id} is formatted like {@code {conference_slug}/{room_slug}};
- * {@code false} otherwise
+ * @return returns {@code true} if the {@code id} is formatted like
+ * {@code {conference_slug}/{room_slug}}; {@code false} otherwise
*/
public static boolean isLiveStreamId(final String id) {
return LIVE_STREAM_ID_PATTERN.matcher(id).find();
@@ -40,24 +42,28 @@ public final class MediaCCCParsingHelper {
/**
* Get currently available live streams from
- * https://streaming.media.ccc.de/streams/v2.json.
+ *
+ * https://streaming.media.ccc.de/streams/v2.json.
* Use this method to cache requests, because they can get quite big.
* TODO: implement better caching policy (max-age: 3 min)
* @param downloader The downloader to use for making the request
* @param localization The localization to be used. Will most likely be ignored.
- * @return {@link JsonArray} containing current conferences and info about their rooms and streams.
- * @throws ExtractionException if the data could not be fetched or the retrieved data could not be parsed to a {@link JsonArray}
+ * @return {@link JsonArray} containing current conferences and info about their rooms and
+ * streams.
+ * @throws ExtractionException if the data could not be fetched or the retrieved data could not
+ * be parsed to a {@link JsonArray}
*/
- public static JsonArray getLiveStreams(final Downloader downloader, final Localization localization)
+ public static JsonArray getLiveStreams(final Downloader downloader,
+ final Localization localization)
throws ExtractionException {
if (liveStreams == null) {
try {
final String site = downloader.get("https://streaming.media.ccc.de/streams/v2.json",
localization).responseBody();
liveStreams = JsonParser.array().from(site);
- } catch (IOException | ReCaptchaException e) {
+ } catch (final IOException | ReCaptchaException e) {
throw new ExtractionException("Could not get live stream JSON.", e);
- } catch (JsonParserException e) {
+ } catch (final JsonParserException e) {
throw new ExtractionException("Could not parse JSON.", e);
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCRecentKiosk.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCRecentKiosk.java
index 6f95aa62f..1e6bd774f 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCRecentKiosk.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCRecentKiosk.java
@@ -22,17 +22,20 @@ public class MediaCCCRecentKiosk extends KioskExtractor {
private JsonObject doc;
- public MediaCCCRecentKiosk(StreamingService streamingService, ListLinkHandler linkHandler, String kioskId) {
+ public MediaCCCRecentKiosk(final StreamingService streamingService,
+ final ListLinkHandler linkHandler,
+ final String kioskId) {
super(streamingService, linkHandler, kioskId);
}
@Override
- public void onFetchPage(@Nonnull Downloader downloader) throws IOException, ExtractionException {
+ public void onFetchPage(@Nonnull final Downloader downloader)
+ throws IOException, ExtractionException {
final String site = downloader.get("https://api.media.ccc.de/public/events/recent",
getExtractorLocalization()).responseBody();
try {
doc = JsonParser.object().from(site);
- } catch (JsonParserException jpe) {
+ } catch (final JsonParserException jpe) {
throw new ExtractionException("Could not parse json.", jpe);
}
}
@@ -48,7 +51,8 @@ public class MediaCCCRecentKiosk extends KioskExtractor {
streamInfoItem -> streamInfoItem.getUploadDate().offsetDateTime());
comparator = comparator.reversed();
- StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId(), comparator);
+ final StreamInfoItemsCollector collector
+ = new StreamInfoItemsCollector(getServiceId(), comparator);
for (int i = 0; i < events.size(); i++) {
collector.commit(new MediaCCCRecentKioskExtractor(events.getObject(i)));
}
@@ -56,7 +60,8 @@ public class MediaCCCRecentKiosk extends KioskExtractor {
}
@Override
- public InfoItemsPage getPage(Page page) throws IOException, ExtractionException {
+ public InfoItemsPage getPage(final Page page)
+ throws IOException, ExtractionException {
return InfoItemsPage.emptyPage();
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCRecentKioskExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCRecentKioskExtractor.java
index 4f272898c..dd2aced2e 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCRecentKioskExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCRecentKioskExtractor.java
@@ -46,8 +46,8 @@ public class MediaCCCRecentKioskExtractor implements StreamInfoItemExtractor {
@Override
public long getDuration() throws ParsingException {
- // duration and length have the same value
- // see https://github.com/voc/voctoweb/blob/master/app/views/public/shared/_event.json.jbuilder
+ // duration and length have the same value, see
+ // https://github.com/voc/voctoweb/blob/master/app/views/public/shared/_event.json.jbuilder
return event.getInt("duration");
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCSearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCSearchExtractor.java
index f4d48e557..e9c300b8a 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCSearchExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCSearchExtractor.java
@@ -1,5 +1,9 @@
package org.schabi.newpipe.extractor.services.media_ccc.extractors;
+import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory.ALL;
+import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory.CONFERENCES;
+import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory.EVENTS;
+
import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser;
@@ -13,7 +17,6 @@ import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
import org.schabi.newpipe.extractor.channel.ChannelInfoItemExtractor;
import org.schabi.newpipe.extractor.downloader.Downloader;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
-import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
import org.schabi.newpipe.extractor.MultiInfoItemsCollector;
import org.schabi.newpipe.extractor.search.SearchExtractor;
@@ -26,10 +29,6 @@ import java.util.List;
import javax.annotation.Nonnull;
-import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory.ALL;
-import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory.CONFERENCES;
-import static org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCSearchQueryHandlerFactory.EVENTS;
-
public class MediaCCCSearchExtractor extends SearchExtractor {
private JsonObject doc;
private MediaCCCConferenceKiosk conferenceKiosk;
@@ -41,7 +40,7 @@ public class MediaCCCSearchExtractor extends SearchExtractor {
conferenceKiosk = new MediaCCCConferenceKiosk(service,
new MediaCCCConferencesListLinkHandlerFactory().fromId("conferences"),
"conferences");
- } catch (Exception e) {
+ } catch (final Exception e) {
e.printStackTrace();
}
}
@@ -79,7 +78,7 @@ public class MediaCCCSearchExtractor extends SearchExtractor {
if (getLinkHandler().getContentFilters().contains(EVENTS)
|| getLinkHandler().getContentFilters().contains(ALL)
|| getLinkHandler().getContentFilters().isEmpty()) {
- JsonArray events = doc.getArray("events");
+ final JsonArray events = doc.getArray("events");
for (int i = 0; i < events.size(); i++) {
// Ensure only uploaded talks are shown in the search results.
// If the release date is null, the talk has not been held or uploaded yet
@@ -109,7 +108,7 @@ public class MediaCCCSearchExtractor extends SearchExtractor {
site = downloader.get(url, getExtractorLocalization()).responseBody();
try {
doc = JsonParser.object().from(site);
- } catch (JsonParserException jpe) {
+ } catch (final JsonParserException jpe) {
throw new ExtractionException("Could not parse JSON.", jpe);
}
}
@@ -143,7 +142,7 @@ public class MediaCCCSearchExtractor extends SearchExtractor {
}
@Override
- public boolean isVerified() throws ParsingException {
+ public boolean isVerified() {
return false;
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCStreamExtractor.java
index a1b09f88d..64a268971 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCStreamExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCStreamExtractor.java
@@ -4,8 +4,8 @@ import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException;
+
import org.schabi.newpipe.extractor.MediaFormat;
-import org.schabi.newpipe.extractor.MetaInfo;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.downloader.Downloader;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
@@ -15,17 +15,21 @@ import org.schabi.newpipe.extractor.localization.DateWrapper;
import org.schabi.newpipe.extractor.localization.Localization;
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCConferenceLinkHandlerFactory;
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCStreamLinkHandlerFactory;
-import org.schabi.newpipe.extractor.stream.*;
+import org.schabi.newpipe.extractor.stream.AudioStream;
+import org.schabi.newpipe.extractor.stream.Description;
+import org.schabi.newpipe.extractor.stream.StreamExtractor;
+import org.schabi.newpipe.extractor.stream.StreamType;
+import org.schabi.newpipe.extractor.stream.VideoStream;
import org.schabi.newpipe.extractor.utils.JsonUtils;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
+import javax.annotation.Nonnull;
+
public class MediaCCCStreamExtractor extends StreamExtractor {
private JsonObject data;
private JsonObject conferenceData;
@@ -158,7 +162,7 @@ public class MediaCCCStreamExtractor extends StreamExtractor {
data = JsonParser.object().from(downloader.get(videoUrl).responseBody());
conferenceData = JsonParser.object()
.from(downloader.get(data.getString("conference_url")).responseBody());
- } catch (JsonParserException jpe) {
+ } catch (final JsonParserException jpe) {
throw new ExtractionException("Could not parse json returned by url: " + videoUrl, jpe);
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/infoItems/MediaCCCStreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/infoItems/MediaCCCStreamInfoItemExtractor.java
index 0f03788a4..92f0894b9 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/infoItems/MediaCCCStreamInfoItemExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/infoItems/MediaCCCStreamInfoItemExtractor.java
@@ -10,7 +10,7 @@ import org.schabi.newpipe.extractor.stream.StreamType;
import javax.annotation.Nullable;
public class MediaCCCStreamInfoItemExtractor implements StreamInfoItemExtractor {
- private JsonObject event;
+ private final JsonObject event;
public MediaCCCStreamInfoItemExtractor(final JsonObject event) {
this.event = event;
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCConferenceLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCConferenceLinkHandlerFactory.java
index e5e9b158f..ddbd2e8e6 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCConferenceLinkHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCConferenceLinkHandlerFactory.java
@@ -7,9 +7,12 @@ import org.schabi.newpipe.extractor.utils.Parser;
import java.util.List;
public class MediaCCCConferenceLinkHandlerFactory extends ListLinkHandlerFactory {
- public static final String CONFERENCE_API_ENDPOINT = "https://api.media.ccc.de/public/conferences/";
+ public static final String CONFERENCE_API_ENDPOINT
+ = "https://api.media.ccc.de/public/conferences/";
public static final String CONFERENCE_PATH = "https://media.ccc.de/c/";
- private static final String ID_PATTERN = "(?:(?:(?:api\\.)?media\\.ccc\\.de/public/conferences/)|(?:media\\.ccc\\.de/[bc]/))([^/?]*)";
+ private static final String ID_PATTERN
+ = "(?:(?:(?:api\\.)?media\\.ccc\\.de/public/conferences/)"
+ + "|(?:media\\.ccc\\.de/[bc]/))([^/?]*)";
@Override
public String getUrl(final String id,
@@ -27,7 +30,7 @@ public class MediaCCCConferenceLinkHandlerFactory extends ListLinkHandlerFactory
public boolean onAcceptUrl(final String url) {
try {
return getId(url) != null;
- } catch (ParsingException e) {
+ } catch (final ParsingException e) {
return false;
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCLiveListLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCLiveListLinkHandlerFactory.java
index 84009c2bf..f66e5c808 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCLiveListLinkHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCLiveListLinkHandlerFactory.java
@@ -7,20 +7,22 @@ import java.util.List;
import java.util.regex.Pattern;
public class MediaCCCLiveListLinkHandlerFactory extends ListLinkHandlerFactory {
- private static final String streamPattern = "^(?:https?://)?media\\.ccc\\.de/live$";
+ private static final String STREAM_PATTERN = "^(?:https?://)?media\\.ccc\\.de/live$";
@Override
- public String getId(String url) throws ParsingException {
+ public String getId(final String url) throws ParsingException {
return "live";
}
@Override
- public boolean onAcceptUrl(String url) throws ParsingException {
- return Pattern.matches(streamPattern, url);
+ public boolean onAcceptUrl(final String url) throws ParsingException {
+ return Pattern.matches(STREAM_PATTERN, url);
}
@Override
- public String getUrl(String id, List contentFilter, String sortFilter) throws ParsingException {
+ public String getUrl(final String id,
+ final List contentFilter,
+ final String sortFilter) throws ParsingException {
// FIXME: wrong URL; should be https://streaming.media.ccc.de/{conference_slug}/{room_slug}
return "https://media.ccc.de/live";
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCLiveStreamLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCLiveStreamLinkHandlerFactory.java
index 9c88e026f..f7b0c1f18 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCLiveStreamLinkHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCLiveStreamLinkHandlerFactory.java
@@ -7,7 +7,9 @@ import org.schabi.newpipe.extractor.utils.Parser;
public class MediaCCCLiveStreamLinkHandlerFactory extends LinkHandlerFactory {
public static final String VIDEO_API_ENDPOINT = "https://api.media.ccc.de/public/events/";
private static final String VIDEO_PATH = "https://streaming.media.ccc.de/v/";
- private static final String ID_PATTERN = "(?:(?:(?:api\\.)?media\\.ccc\\.de/public/events/)|(?:media\\.ccc\\.de/v/))([^/?]*)";
+ private static final String ID_PATTERN
+ = "(?:(?:(?:api\\.)?media\\.ccc\\.de/public/events/)"
+ + "|(?:media\\.ccc\\.de/v/))([^/?]*)";
@Override
public String getId(final String url) throws ParsingException {
@@ -23,7 +25,7 @@ public class MediaCCCLiveStreamLinkHandlerFactory extends LinkHandlerFactory {
public boolean onAcceptUrl(final String url) {
try {
return getId(url) != null;
- } catch (ParsingException e) {
+ } catch (final ParsingException e) {
return false;
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCRecentListLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCRecentListLinkHandlerFactory.java
index 8b22577b8..be2b10044 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCRecentListLinkHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCRecentListLinkHandlerFactory.java
@@ -6,20 +6,22 @@ import java.util.List;
import java.util.regex.Pattern;
public class MediaCCCRecentListLinkHandlerFactory extends ListLinkHandlerFactory {
- private static final String pattern = "^(https?://)?media\\.ccc\\.de/recent/?$";
+ private static final String PATTERN = "^(https?://)?media\\.ccc\\.de/recent/?$";
@Override
- public String getId(String url) {
+ public String getId(final String url) {
return "recent";
}
@Override
- public boolean onAcceptUrl(String url) {
- return Pattern.matches(pattern, url);
+ public boolean onAcceptUrl(final String url) {
+ return Pattern.matches(PATTERN, url);
}
@Override
- public String getUrl(String id, List contentFilter, String sortFilter) {
+ public String getUrl(final String id,
+ final List contentFilter,
+ final String sortFilter) {
return "https://media.ccc.de/recent";
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCSearchQueryHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCSearchQueryHandlerFactory.java
index 264dcccf1..83930d1e0 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCSearchQueryHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCSearchQueryHandlerFactory.java
@@ -34,7 +34,7 @@ public class MediaCCCSearchQueryHandlerFactory extends SearchQueryHandlerFactory
try {
return "https://media.ccc.de/public/events/search?q="
+ URLEncoder.encode(query, UTF_8);
- } catch (UnsupportedEncodingException e) {
+ } catch (final UnsupportedEncodingException e) {
throw new ParsingException("Could not create search string with query: " + query, e);
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCStreamLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCStreamLinkHandlerFactory.java
index cb2f72fc9..3ae9c37d1 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCStreamLinkHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/linkHandler/MediaCCCStreamLinkHandlerFactory.java
@@ -8,19 +8,21 @@ import org.schabi.newpipe.extractor.utils.Parser;
public class MediaCCCStreamLinkHandlerFactory extends LinkHandlerFactory {
public static final String VIDEO_API_ENDPOINT = "https://api.media.ccc.de/public/events/";
private static final String VIDEO_PATH = "https://media.ccc.de/v/";
- private static final String RECORDING_ID_PATTERN = "(?:(?:(?:api\\.)?media\\.ccc\\.de/public/events/)|(?:media\\.ccc\\.de/v/))([^/?]*)";
- private static final String LIVE_STREAM_API_ENDPOINT = "https://streaming.media.ccc.de/streams/v2.json";
+ private static final String RECORDING_ID_PATTERN
+ = "(?:(?:(?:api\\.)?media\\.ccc\\.de/public/events/)"
+ + "|(?:media\\.ccc\\.de/v/))([^/?]*)";
private static final String LIVE_STREAM_PATH = "https://streaming.media.ccc.de/";
- private static final String LIVE_STREAM_ID_PATTERN = "streaming\\.media\\.ccc\\.de\\/(\\w+\\/\\w+)";
+ private static final String LIVE_STREAM_ID_PATTERN
+ = "streaming\\.media\\.ccc\\.de\\/(\\w+\\/\\w+)";
@Override
public String getId(final String url) throws ParsingException {
String streamId = null;
try {
streamId = Parser.matchGroup1(LIVE_STREAM_ID_PATTERN, url);
- } catch (Parser.RegexException ignored) {
-
+ } catch (final Parser.RegexException ignored) {
}
+
if (streamId == null) {
return Parser.matchGroup1(RECORDING_ID_PATTERN, url);
}
@@ -39,7 +41,7 @@ public class MediaCCCStreamLinkHandlerFactory extends LinkHandlerFactory {
public boolean onAcceptUrl(final String url) {
try {
return getId(url) != null;
- } catch (ParsingException e) {
+ } catch (final ParsingException e) {
return false;
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeInstance.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeInstance.java
index a29a592e0..5b6d64d6f 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeInstance.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeInstance.java
@@ -5,7 +5,6 @@ import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException;
import org.schabi.newpipe.extractor.NewPipe;
-import org.schabi.newpipe.extractor.downloader.Downloader;
import org.schabi.newpipe.extractor.downloader.Response;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.exceptions.ReCaptchaException;
@@ -18,14 +17,15 @@ public class PeertubeInstance {
private final String url;
private String name;
- public static final PeertubeInstance defaultInstance = new PeertubeInstance("https://framatube.org", "FramaTube");
+ public static final PeertubeInstance DEFAULT_INSTANCE
+ = new PeertubeInstance("https://framatube.org", "FramaTube");
- public PeertubeInstance(String url) {
+ public PeertubeInstance(final String url) {
this.url = url;
this.name = "PeerTube";
}
- public PeertubeInstance(String url, String name) {
+ public PeertubeInstance(final String url, final String name) {
this.url = url;
this.name = name;
}
@@ -35,11 +35,9 @@ public class PeertubeInstance {
}
public void fetchInstanceMetaData() throws Exception {
- Downloader downloader = NewPipe.getDownloader();
- Response response = null;
-
+ final Response response;
try {
- response = downloader.get(url + "/api/v1/config");
+ response = NewPipe.getDownloader().get(url + "/api/v1/config");
} catch (ReCaptchaException | IOException e) {
throw new Exception("unable to configure instance " + url, e);
}
@@ -49,7 +47,7 @@ public class PeertubeInstance {
}
try {
- JsonObject json = JsonParser.object().from(response.responseBody());
+ final JsonObject json = JsonParser.object().from(response.responseBody());
this.name = JsonUtils.getString(json, "instance.name");
} catch (JsonParserException | ParsingException e) {
throw new Exception("unable to parse instance config", e);
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeParsingHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeParsingHelper.java
index b324cb1af..afe491869 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeParsingHelper.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeParsingHelper.java
@@ -17,7 +17,7 @@ import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import java.time.format.DateTimeParseException;
-public class PeertubeParsingHelper {
+public final class PeertubeParsingHelper {
public static final String START_KEY = "start";
public static final String COUNT_KEY = "count";
public static final int ITEMS_PER_PAGE = 12;
@@ -33,10 +33,11 @@ public class PeertubeParsingHelper {
}
}
- public static OffsetDateTime parseDateFrom(final String textualUploadDate) throws ParsingException {
+ public static OffsetDateTime parseDateFrom(final String textualUploadDate)
+ throws ParsingException {
try {
return OffsetDateTime.ofInstant(Instant.parse(textualUploadDate), ZoneOffset.UTC);
- } catch (DateTimeParseException e) {
+ } catch (final DateTimeParseException e) {
throw new ParsingException("Could not parse date: \"" + textualUploadDate + "\"", e);
}
}
@@ -45,25 +46,31 @@ public class PeertubeParsingHelper {
final String prevStart;
try {
prevStart = Parser.matchGroup1(START_PATTERN, prevPageUrl);
- } catch (Parser.RegexException e) {
+ } catch (final Parser.RegexException e) {
return null;
}
- if (Utils.isBlank(prevStart)) return null;
+ if (Utils.isBlank(prevStart)) {
+ return null;
+ }
+
final long nextStart;
try {
nextStart = Long.parseLong(prevStart) + ITEMS_PER_PAGE;
- } catch (NumberFormatException e) {
+ } catch (final NumberFormatException e) {
return null;
}
if (nextStart >= total) {
return null;
} else {
- return new Page(prevPageUrl.replace(START_KEY + "=" + prevStart, START_KEY + "=" + nextStart));
+ return new Page(prevPageUrl.replace(
+ START_KEY + "=" + prevStart, START_KEY + "=" + nextStart));
}
}
- public static void collectStreamsFrom(final InfoItemsCollector collector, final JsonObject json, final String baseUrl) throws ParsingException {
+ public static void collectStreamsFrom(final InfoItemsCollector collector,
+ final JsonObject json,
+ final String baseUrl) throws ParsingException {
collectStreamsFrom(collector, json, baseUrl, false);
}
@@ -74,13 +81,15 @@ public class PeertubeParsingHelper {
* @param json the file to retrieve data from
* @param baseUrl the base Url of the instance
* @param sepia if we should use PeertubeSepiaStreamInfoItemExtractor
- * @throws ParsingException
*/
- public static void collectStreamsFrom(final InfoItemsCollector collector, final JsonObject json, final String baseUrl, boolean sepia) throws ParsingException {
+ public static void collectStreamsFrom(final InfoItemsCollector collector,
+ final JsonObject json,
+ final String baseUrl,
+ final boolean sepia) throws ParsingException {
final JsonArray contents;
try {
contents = (JsonArray) JsonUtils.getValue(json, "data");
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new ParsingException("Unable to extract list info", e);
}
@@ -93,7 +102,7 @@ public class PeertubeParsingHelper {
item = item.getObject("video");
}
- PeertubeStreamInfoItemExtractor extractor;
+ final PeertubeStreamInfoItemExtractor extractor;
if (sepia) {
extractor = new PeertubeSepiaStreamInfoItemExtractor(item, baseUrl);
} else {
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeService.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeService.java
index 9d86ca992..de25e2799 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeService.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/PeertubeService.java
@@ -1,35 +1,51 @@
package org.schabi.newpipe.extractor.services.peertube;
+import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.COMMENTS;
+import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.VIDEO;
+import static java.util.Arrays.asList;
+
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
import org.schabi.newpipe.extractor.comments.CommentsExtractor;
import org.schabi.newpipe.extractor.exceptions.ExtractionException;
-import org.schabi.newpipe.extractor.kiosk.KioskExtractor;
import org.schabi.newpipe.extractor.kiosk.KioskList;
-import org.schabi.newpipe.extractor.linkhandler.*;
+import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
+import org.schabi.newpipe.extractor.linkhandler.LinkHandlerFactory;
+import org.schabi.newpipe.extractor.linkhandler.ListLinkHandler;
+import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
+import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandler;
+import org.schabi.newpipe.extractor.linkhandler.SearchQueryHandlerFactory;
import org.schabi.newpipe.extractor.playlist.PlaylistExtractor;
import org.schabi.newpipe.extractor.search.SearchExtractor;
-import org.schabi.newpipe.extractor.services.peertube.extractors.*;
-import org.schabi.newpipe.extractor.services.peertube.linkHandler.*;
+import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeAccountExtractor;
+import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeChannelExtractor;
+import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeCommentsExtractor;
+import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubePlaylistExtractor;
+import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeSearchExtractor;
+import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeStreamExtractor;
+import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeSuggestionExtractor;
+import org.schabi.newpipe.extractor.services.peertube.extractors.PeertubeTrendingExtractor;
+import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeChannelLinkHandlerFactory;
+import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeCommentsLinkHandlerFactory;
+import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubePlaylistLinkHandlerFactory;
+import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeSearchQueryHandlerFactory;
+import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeStreamLinkHandlerFactory;
+import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeTrendingLinkHandlerFactory;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.subscription.SubscriptionExtractor;
import org.schabi.newpipe.extractor.suggestion.SuggestionExtractor;
import java.util.List;
-import static java.util.Arrays.asList;
-import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.COMMENTS;
-import static org.schabi.newpipe.extractor.StreamingService.ServiceInfo.MediaCapability.VIDEO;
-
public class PeertubeService extends StreamingService {
private PeertubeInstance instance;
- public PeertubeService(int id) {
- this(id, PeertubeInstance.defaultInstance);
+ public PeertubeService(final int id) {
+ this(id, PeertubeInstance.DEFAULT_INSTANCE);
}
- public PeertubeService(int id, PeertubeInstance instance) {
+ public PeertubeService(final int id, final PeertubeInstance instance) {
super(id, "PeerTube", asList(VIDEO, COMMENTS));
this.instance = instance;
}
@@ -60,13 +76,10 @@ public class PeertubeService extends StreamingService {
}
@Override
- public SearchExtractor getSearchExtractor(SearchQueryHandler queryHandler) {
+ public SearchExtractor getSearchExtractor(final SearchQueryHandler queryHandler) {
final List contentFilters = queryHandler.getContentFilters();
- boolean external = false;
- if (!contentFilters.isEmpty() && contentFilters.get(0).startsWith("sepia_")) {
- external = true;
- }
- return new PeertubeSearchExtractor(this, queryHandler, external);
+ return new PeertubeSearchExtractor(this, queryHandler,
+ !contentFilters.isEmpty() && contentFilters.get(0).startsWith("sepia_"));
}
@Override
@@ -80,7 +93,7 @@ public class PeertubeService extends StreamingService {
}
@Override
- public ChannelExtractor getChannelExtractor(ListLinkHandler linkHandler)
+ public ChannelExtractor getChannelExtractor(final ListLinkHandler linkHandler)
throws ExtractionException {
if (linkHandler.getUrl().contains("/video-channels/")) {
@@ -91,19 +104,19 @@ public class PeertubeService extends StreamingService {
}
@Override
- public PlaylistExtractor getPlaylistExtractor(ListLinkHandler linkHandler)
+ public PlaylistExtractor getPlaylistExtractor(final ListLinkHandler linkHandler)
throws ExtractionException {
return new PeertubePlaylistExtractor(this, linkHandler);
}
@Override
- public StreamExtractor getStreamExtractor(LinkHandler linkHandler)
+ public StreamExtractor getStreamExtractor(final LinkHandler linkHandler)
throws ExtractionException {
return new PeertubeStreamExtractor(this, linkHandler);
}
@Override
- public CommentsExtractor getCommentsExtractor(ListLinkHandler linkHandler)
+ public CommentsExtractor getCommentsExtractor(final ListLinkHandler linkHandler)
throws ExtractionException {
return new PeertubeCommentsExtractor(this, linkHandler);
}
@@ -117,34 +130,31 @@ public class PeertubeService extends StreamingService {
return this.instance;
}
- public void setInstance(PeertubeInstance instance) {
+ public void setInstance(final PeertubeInstance instance) {
this.instance = instance;
}
@Override
public KioskList getKioskList() throws ExtractionException {
- KioskList.KioskExtractorFactory kioskFactory = new KioskList.KioskExtractorFactory() {
- @Override
- public KioskExtractor createNewKiosk(StreamingService streamingService,
- String url,
- String id)
- throws ExtractionException {
- return new PeertubeTrendingExtractor(PeertubeService.this,
- new PeertubeTrendingLinkHandlerFactory().fromId(id), id);
- }
- };
+ final KioskList.KioskExtractorFactory kioskFactory = (streamingService, url, id) ->
+ new PeertubeTrendingExtractor(
+ PeertubeService.this,
+ new PeertubeTrendingLinkHandlerFactory().fromId(id),
+ id
+ );
- KioskList list = new KioskList(this);
+ final KioskList list = new KioskList(this);
// add kiosks here e.g.:
final PeertubeTrendingLinkHandlerFactory h = new PeertubeTrendingLinkHandlerFactory();
try {
list.addKioskEntry(kioskFactory, h, PeertubeTrendingLinkHandlerFactory.KIOSK_TRENDING);
- list.addKioskEntry(kioskFactory, h, PeertubeTrendingLinkHandlerFactory.KIOSK_MOST_LIKED);
+ list.addKioskEntry(kioskFactory, h,
+ PeertubeTrendingLinkHandlerFactory.KIOSK_MOST_LIKED);
list.addKioskEntry(kioskFactory, h, PeertubeTrendingLinkHandlerFactory.KIOSK_RECENT);
list.addKioskEntry(kioskFactory, h, PeertubeTrendingLinkHandlerFactory.KIOSK_LOCAL);
list.setDefaultKiosk(PeertubeTrendingLinkHandlerFactory.KIOSK_TRENDING);
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new ExtractionException(e);
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeAccountExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeAccountExtractor.java
index 65f88b213..f63eca52f 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeAccountExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeAccountExtractor.java
@@ -23,7 +23,10 @@ import org.schabi.newpipe.extractor.utils.Utils;
import javax.annotation.Nonnull;
import java.io.IOException;
-import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.*;
+import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.COUNT_KEY;
+import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.ITEMS_PER_PAGE;
+import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.START_KEY;
+import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.collectStreamsFrom;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
public class PeertubeAccountExtractor extends ChannelExtractor {
@@ -31,7 +34,8 @@ public class PeertubeAccountExtractor extends ChannelExtractor {
private final String baseUrl;
private static final String ACCOUNTS = "accounts/";
- public PeertubeAccountExtractor(final StreamingService service, final ListLinkHandler linkHandler) throws ParsingException {
+ public PeertubeAccountExtractor(final StreamingService service,
+ final ListLinkHandler linkHandler) throws ParsingException {
super(service, linkHandler);
this.baseUrl = getBaseUrl();
}
@@ -41,7 +45,7 @@ public class PeertubeAccountExtractor extends ChannelExtractor {
String value;
try {
value = JsonUtils.getString(json, "avatar.path");
- } catch (Exception e) {
+ } catch (final Exception e) {
value = "/client/assets/images/default-avatar.png";
}
return baseUrl + value;
@@ -80,7 +84,8 @@ public class PeertubeAccountExtractor extends ChannelExtractor {
subscribersCount += videoChannelJsonObject.getInt("followersCount");
}
} catch (final IOException | JsonParserException | ReCaptchaException ignored) {
- // something went wrong during video channels extraction, only return subscribers of ownerAccount
+ // something went wrong during video channels extraction,
+ // only return subscribers of ownerAccount
}
return subscribersCount;
}
@@ -89,7 +94,7 @@ public class PeertubeAccountExtractor extends ChannelExtractor {
public String getDescription() {
try {
return JsonUtils.getString(json, "description");
- } catch (ParsingException e) {
+ } catch (final ParsingException e) {
return "No description";
}
}
@@ -117,8 +122,8 @@ public class PeertubeAccountExtractor extends ChannelExtractor {
@Nonnull
@Override
public InfoItemsPage getInitialPage() throws IOException, ExtractionException {
- return getPage(new Page(
- baseUrl + "/api/v1/" + getId() + "/videos?" + START_KEY + "=0&" + COUNT_KEY + "=" + ITEMS_PER_PAGE));
+ return getPage(new Page(baseUrl + "/api/v1/" + getId() + "/videos?" + START_KEY + "=0&"
+ + COUNT_KEY + "=" + ITEMS_PER_PAGE));
}
@Override
@@ -130,23 +135,24 @@ public class PeertubeAccountExtractor extends ChannelExtractor {
final Response response = getDownloader().get(page.getUrl());
- JsonObject json = null;
+ JsonObject pageJson = null;
if (response != null && !Utils.isBlank(response.responseBody())) {
try {
- json = JsonParser.object().from(response.responseBody());
- } catch (Exception e) {
+ pageJson = JsonParser.object().from(response.responseBody());
+ } catch (final Exception e) {
throw new ParsingException("Could not parse json data for account info", e);
}
}
- if (json != null) {
- PeertubeParsingHelper.validate(json);
- final long total = json.getLong("total");
+ if (pageJson != null) {
+ PeertubeParsingHelper.validate(pageJson);
+ final long total = pageJson.getLong("total");
final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
- collectStreamsFrom(collector, json, getBaseUrl());
+ collectStreamsFrom(collector, pageJson, getBaseUrl());
- return new InfoItemsPage<>(collector, PeertubeParsingHelper.getNextPage(page.getUrl(), total));
+ return new InfoItemsPage<>(collector,
+ PeertubeParsingHelper.getNextPage(page.getUrl(), total));
} else {
throw new ExtractionException("Unable to get PeerTube account info");
}
@@ -173,10 +179,12 @@ public class PeertubeAccountExtractor extends ChannelExtractor {
private void setInitialData(final String responseBody) throws ExtractionException {
try {
json = JsonParser.object().from(responseBody);
- } catch (JsonParserException e) {
+ } catch (final JsonParserException e) {
throw new ExtractionException("Unable to extract PeerTube account data", e);
}
- if (json == null) throw new ExtractionException("Unable to extract PeerTube account data");
+ if (json == null) {
+ throw new ExtractionException("Unable to extract PeerTube account data");
+ }
}
@Nonnull
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java
index bcfa7d284..940f0fa5c 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeChannelExtractor.java
@@ -21,15 +21,18 @@ import org.schabi.newpipe.extractor.utils.Utils;
import javax.annotation.Nonnull;
import java.io.IOException;
-import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.*;
+import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.COUNT_KEY;
+import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.ITEMS_PER_PAGE;
+import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.START_KEY;
+import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.collectStreamsFrom;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
-
public class PeertubeChannelExtractor extends ChannelExtractor {
private JsonObject json;
private final String baseUrl;
- public PeertubeChannelExtractor(final StreamingService service, final ListLinkHandler linkHandler) throws ParsingException {
+ public PeertubeChannelExtractor(final StreamingService service,
+ final ListLinkHandler linkHandler) throws ParsingException {
super(service, linkHandler);
this.baseUrl = getBaseUrl();
}
@@ -39,7 +42,7 @@ public class PeertubeChannelExtractor extends ChannelExtractor {
String value;
try {
value = JsonUtils.getString(json, "avatar.path");
- } catch (Exception e) {
+ } catch (final Exception e) {
value = "/client/assets/images/default-avatar.png";
}
return baseUrl + value;
@@ -64,7 +67,7 @@ public class PeertubeChannelExtractor extends ChannelExtractor {
public String getDescription() {
try {
return JsonUtils.getString(json, "description");
- } catch (ParsingException e) {
+ } catch (final ParsingException e) {
return "No description";
}
}
@@ -84,7 +87,7 @@ public class PeertubeChannelExtractor extends ChannelExtractor {
String value;
try {
value = JsonUtils.getString(json, "ownerAccount.avatar.path");
- } catch (Exception e) {
+ } catch (final Exception e) {
value = "/client/assets/images/default-avatar.png";
}
return baseUrl + value;
@@ -98,45 +101,48 @@ public class PeertubeChannelExtractor extends ChannelExtractor {
@Nonnull
@Override
public InfoItemsPage getInitialPage() throws IOException, ExtractionException {
- return getPage(new Page(
- baseUrl + "/api/v1/" + getId() + "/videos?" + START_KEY + "=0&" + COUNT_KEY + "=" + ITEMS_PER_PAGE));
+ return getPage(new Page(baseUrl + "/api/v1/" + getId() + "/videos?" + START_KEY + "=0&"
+ + COUNT_KEY + "=" + ITEMS_PER_PAGE));
}
@Override
- public InfoItemsPage getPage(final Page page) throws IOException, ExtractionException {
+ public InfoItemsPage getPage(final Page page)
+ throws IOException, ExtractionException {
if (page == null || isNullOrEmpty(page.getUrl())) {
throw new IllegalArgumentException("Page doesn't contain an URL");
}
final Response response = getDownloader().get(page.getUrl());
- JsonObject json = null;
+ JsonObject pageJson = null;
if (response != null && !Utils.isBlank(response.responseBody())) {
try {
- json = JsonParser.object().from(response.responseBody());
- } catch (Exception e) {
+ pageJson = JsonParser.object().from(response.responseBody());
+ } catch (final Exception e) {
throw new ParsingException("Could not parse json data for channel info", e);
}
}
- if (json != null) {
- PeertubeParsingHelper.validate(json);
- final long total = json.getLong("total");
+ if (pageJson != null) {
+ PeertubeParsingHelper.validate(pageJson);
+ final long total = pageJson.getLong("total");
final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
- collectStreamsFrom(collector, json, getBaseUrl());
+ collectStreamsFrom(collector, pageJson, getBaseUrl());
- return new InfoItemsPage<>(collector, PeertubeParsingHelper.getNextPage(page.getUrl(), total));
+ return new InfoItemsPage<>(collector,
+ PeertubeParsingHelper.getNextPage(page.getUrl(), total));
} else {
throw new ExtractionException("Unable to get PeerTube channel info");
}
}
@Override
- public void onFetchPage(final Downloader downloader) throws IOException, ExtractionException {
+ public void onFetchPage(final Downloader downloader)
+ throws IOException, ExtractionException {
final Response response = downloader.get(
baseUrl + PeertubeChannelLinkHandlerFactory.API_ENDPOINT + getId());
- if (response != null ) {
+ if (response != null) {
setInitialData(response.responseBody());
} else {
throw new ExtractionException("Unable to extract PeerTube channel data");
@@ -146,10 +152,12 @@ public class PeertubeChannelExtractor extends ChannelExtractor {
private void setInitialData(final String responseBody) throws ExtractionException {
try {
json = JsonParser.object().from(responseBody);
- } catch (JsonParserException e) {
+ } catch (final JsonParserException e) {
throw new ExtractionException("Unable to extract PeerTube channel data", e);
}
- if (json == null) throw new ExtractionException("Unable to extract PeerTube channel data");
+ if (json == null) {
+ throw new ExtractionException("Unable to extract PeerTube channel data");
+ }
}
@Nonnull
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsExtractor.java
index 5ba80134d..dd4a4e7b3 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsExtractor.java
@@ -18,36 +18,41 @@ import org.schabi.newpipe.extractor.utils.Utils;
import java.io.IOException;
-import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.*;
+import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.COUNT_KEY;
+import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.ITEMS_PER_PAGE;
+import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.START_KEY;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
public class PeertubeCommentsExtractor extends CommentsExtractor {
- public PeertubeCommentsExtractor(final StreamingService service, final ListLinkHandler uiHandler) {
+ public PeertubeCommentsExtractor(final StreamingService service,
+ final ListLinkHandler uiHandler) {
super(service, uiHandler);
}
@Override
- public InfoItemsPage getInitialPage() throws IOException, ExtractionException {
- final String pageUrl = getUrl() + "?" + START_KEY + "=0&" + COUNT_KEY + "=" + ITEMS_PER_PAGE;
- return getPage(new Page(pageUrl));
+ public InfoItemsPage getInitialPage()
+ throws IOException, ExtractionException {
+ return getPage(new Page(getUrl() + "?" + START_KEY + "=0&"
+ + COUNT_KEY + "=" + ITEMS_PER_PAGE));
}
- private void collectCommentsFrom(final CommentsInfoItemsCollector collector, final JsonObject json) throws ParsingException {
+ private void collectCommentsFrom(final CommentsInfoItemsCollector collector,
+ final JsonObject json) throws ParsingException {
final JsonArray contents = json.getArray("data");
for (final Object c : contents) {
if (c instanceof JsonObject) {
final JsonObject item = (JsonObject) c;
if (!item.getBoolean("isDeleted")) {
- final PeertubeCommentsInfoItemExtractor extractor = new PeertubeCommentsInfoItemExtractor(item, this);
- collector.commit(extractor);
+ collector.commit(new PeertubeCommentsInfoItemExtractor(item, this));
}
}
}
}
@Override
- public InfoItemsPage getPage(final Page page) throws IOException, ExtractionException {
+ public InfoItemsPage getPage(final Page page)
+ throws IOException, ExtractionException {
if (page == null || isNullOrEmpty(page.getUrl())) {
throw new IllegalArgumentException("Page doesn't contain an URL");
}
@@ -58,7 +63,7 @@ public class PeertubeCommentsExtractor extends CommentsExtractor {
if (response != null && !Utils.isBlank(response.responseBody())) {
try {
json = JsonParser.object().from(response.responseBody());
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new ParsingException("Could not parse json data for comments info", e);
}
}
@@ -67,15 +72,18 @@ public class PeertubeCommentsExtractor extends CommentsExtractor {
PeertubeParsingHelper.validate(json);
final long total = json.getLong("total");
- final CommentsInfoItemsCollector collector = new CommentsInfoItemsCollector(getServiceId());
+ final CommentsInfoItemsCollector collector
+ = new CommentsInfoItemsCollector(getServiceId());
collectCommentsFrom(collector, json);
- return new InfoItemsPage<>(collector, PeertubeParsingHelper.getNextPage(page.getUrl(), total));
+ return new InfoItemsPage<>(collector,
+ PeertubeParsingHelper.getNextPage(page.getUrl(), total));
} else {
throw new ExtractionException("Unable to get PeerTube kiosk info");
}
}
@Override
- public void onFetchPage(Downloader downloader) { }
+ public void onFetchPage(final Downloader downloader) {
+ }
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsInfoItemExtractor.java
index a1de79340..db374dbc5 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsInfoItemExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeCommentsInfoItemExtractor.java
@@ -19,7 +19,9 @@ public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtrac
private final String url;
private final String baseUrl;
- public PeertubeCommentsInfoItemExtractor(final JsonObject item, final PeertubeCommentsExtractor extractor) throws ParsingException {
+ public PeertubeCommentsInfoItemExtractor(final JsonObject item,
+ final PeertubeCommentsExtractor extractor)
+ throws ParsingException {
this.item = item;
this.url = extractor.getUrl();
this.baseUrl = extractor.getBaseUrl();
@@ -35,7 +37,7 @@ public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtrac
String value;
try {
value = JsonUtils.getString(item, "account.avatar.path");
- } catch (Exception e) {
+ } catch (final Exception e) {
value = "/client/assets/images/default-avatar.png";
}
return baseUrl + value;
@@ -63,7 +65,7 @@ public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtrac
try {
final Document doc = Jsoup.parse(htmlText);
return doc.body().text();
- } catch (Exception e) {
+ } catch (final Exception e) {
return htmlText.replaceAll("(?s)<[^>]*>(\\s*<[^>]*>)*", EMPTY_STRING);
}
}
@@ -78,7 +80,7 @@ public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtrac
String value;
try {
value = JsonUtils.getString(item, "account.avatar.path");
- } catch (Exception e) {
+ } catch (final Exception e) {
value = "/client/assets/images/default-avatar.png";
}
return baseUrl + value;
@@ -86,13 +88,15 @@ public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtrac
@Override
public String getUploaderName() throws ParsingException {
- return JsonUtils.getString(item, "account.name") + "@" + JsonUtils.getString(item, "account.host");
+ return JsonUtils.getString(item, "account.name") + "@"
+ + JsonUtils.getString(item, "account.host");
}
@Override
public String getUploaderUrl() throws ParsingException {
final String name = JsonUtils.getString(item, "account.name");
final String host = JsonUtils.getString(item, "account.host");
- return ServiceList.PeerTube.getChannelLHFactory().fromId("accounts/" + name + "@" + host, baseUrl).getUrl();
+ return ServiceList.PeerTube.getChannelLHFactory()
+ .fromId("accounts/" + name + "@" + host, baseUrl).getUrl();
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubePlaylistExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubePlaylistExtractor.java
index f8fd38b1d..71648b1ec 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubePlaylistExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubePlaylistExtractor.java
@@ -19,13 +19,17 @@ import org.schabi.newpipe.extractor.utils.Utils;
import javax.annotation.Nonnull;
import java.io.IOException;
-import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.*;
+import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.COUNT_KEY;
+import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.ITEMS_PER_PAGE;
+import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.START_KEY;
+import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.collectStreamsFrom;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
public class PeertubePlaylistExtractor extends PlaylistExtractor {
private JsonObject playlistInfo;
- public PeertubePlaylistExtractor(final StreamingService service, final ListLinkHandler linkHandler) {
+ public PeertubePlaylistExtractor(final StreamingService service,
+ final ListLinkHandler linkHandler) {
super(service, linkHandler);
}
@@ -47,7 +51,8 @@ public class PeertubePlaylistExtractor extends PlaylistExtractor {
@Override
public String getUploaderAvatarUrl() throws ParsingException {
- return getBaseUrl() + playlistInfo.getObject("ownerAccount").getObject("avatar").getString("path");
+ return getBaseUrl()
+ + playlistInfo.getObject("ownerAccount").getObject("avatar").getString("path");
}
@Override
@@ -75,17 +80,20 @@ public class PeertubePlaylistExtractor extends PlaylistExtractor {
@Nonnull
@Override
public String getSubChannelAvatarUrl() throws ParsingException {
- return getBaseUrl() + playlistInfo.getObject("videoChannel").getObject("avatar").getString("path");
+ return getBaseUrl()
+ + playlistInfo.getObject("videoChannel").getObject("avatar").getString("path");
}
@Nonnull
@Override
public InfoItemsPage getInitialPage() throws IOException, ExtractionException {
- return getPage(new Page(getUrl() + "/videos?" + START_KEY + "=0&" + COUNT_KEY + "=" + ITEMS_PER_PAGE));
+ return getPage(new Page(getUrl() + "/videos?" + START_KEY + "=0&"
+ + COUNT_KEY + "=" + ITEMS_PER_PAGE));
}
@Override
- public InfoItemsPage getPage(final Page page) throws IOException, ExtractionException {
+ public InfoItemsPage getPage(final Page page)
+ throws IOException, ExtractionException {
if (page == null || isNullOrEmpty(page.getUrl())) {
throw new IllegalArgumentException("Page doesn't contain an URL");
}
@@ -96,7 +104,7 @@ public class PeertubePlaylistExtractor extends PlaylistExtractor {
if (response != null && !Utils.isBlank(response.responseBody())) {
try {
json = JsonParser.object().from(response.responseBody());
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new ParsingException("Could not parse json data for playlist info", e);
}
}
@@ -108,18 +116,20 @@ public class PeertubePlaylistExtractor extends PlaylistExtractor {
final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
collectStreamsFrom(collector, json, getBaseUrl());
- return new InfoItemsPage<>(collector, PeertubeParsingHelper.getNextPage(page.getUrl(), total));
+ return new InfoItemsPage<>(collector,
+ PeertubeParsingHelper.getNextPage(page.getUrl(), total));
} else {
throw new ExtractionException("Unable to get PeerTube playlist info");
}
}
@Override
- public void onFetchPage(@Nonnull final Downloader downloader) throws IOException, ExtractionException {
+ public void onFetchPage(@Nonnull final Downloader downloader)
+ throws IOException, ExtractionException {
final Response response = downloader.get(getUrl());
try {
playlistInfo = JsonParser.object().from(response.responseBody());
- } catch (JsonParserException jpe) {
+ } catch (final JsonParserException jpe) {
throw new ExtractionException("Could not parse json", jpe);
}
PeertubeParsingHelper.validate(playlistInfo);
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeSearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeSearchExtractor.java
index 854ace99b..79da72165 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeSearchExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeSearchExtractor.java
@@ -32,13 +32,16 @@ import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
public class PeertubeSearchExtractor extends SearchExtractor {
// if we should use PeertubeSepiaStreamInfoItemExtractor
- private boolean sepia;
+ private final boolean sepia;
- public PeertubeSearchExtractor(StreamingService service, SearchQueryHandler linkHandler) {
+ public PeertubeSearchExtractor(final StreamingService service,
+ final SearchQueryHandler linkHandler) {
this(service, linkHandler, false);
}
- public PeertubeSearchExtractor(StreamingService service, SearchQueryHandler linkHandler, boolean sepia) {
+ public PeertubeSearchExtractor(final StreamingService service,
+ final SearchQueryHandler linkHandler,
+ final boolean sepia) {
super(service, linkHandler);
this.sepia = sepia;
}
@@ -62,12 +65,13 @@ public class PeertubeSearchExtractor extends SearchExtractor {
@Override
public InfoItemsPage getInitialPage() throws IOException, ExtractionException {
- final String pageUrl = getUrl() + "&" + START_KEY + "=0&" + COUNT_KEY + "=" + ITEMS_PER_PAGE;
- return getPage(new Page(pageUrl));
+ return getPage(new Page(getUrl() + "&" + START_KEY + "=0&"
+ + COUNT_KEY + "=" + ITEMS_PER_PAGE));
}
@Override
- public InfoItemsPage getPage(final Page page) throws IOException, ExtractionException {
+ public InfoItemsPage getPage(final Page page)
+ throws IOException, ExtractionException {
if (page == null || isNullOrEmpty(page.getUrl())) {
throw new IllegalArgumentException("Page doesn't contain an URL");
}
@@ -78,7 +82,7 @@ public class PeertubeSearchExtractor extends SearchExtractor {
if (response != null && !Utils.isBlank(response.responseBody())) {
try {
json = JsonParser.object().from(response.responseBody());
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new ParsingException("Could not parse json data for search info", e);
}
}
@@ -90,12 +94,15 @@ public class PeertubeSearchExtractor extends SearchExtractor {
final MultiInfoItemsCollector collector = new MultiInfoItemsCollector(getServiceId());
collectStreamsFrom(collector, json, getBaseUrl(), sepia);
- return new InfoItemsPage<>(collector, PeertubeParsingHelper.getNextPage(page.getUrl(), total));
+ return new InfoItemsPage<>(collector,
+ PeertubeParsingHelper.getNextPage(page.getUrl(), total));
} else {
throw new ExtractionException("Unable to get PeerTube search info");
}
}
@Override
- public void onFetchPage(@Nonnull final Downloader downloader) throws IOException, ExtractionException { }
+ public void onFetchPage(@Nonnull final Downloader downloader)
+ throws IOException, ExtractionException {
+ }
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeSepiaStreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeSepiaStreamInfoItemExtractor.java
index 925aa9f0b..a58894be6 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeSepiaStreamInfoItemExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeSepiaStreamInfoItemExtractor.java
@@ -7,7 +7,7 @@ import com.grack.nanojson.JsonObject;
*/
public class PeertubeSepiaStreamInfoItemExtractor extends PeertubeStreamInfoItemExtractor {
- public PeertubeSepiaStreamInfoItemExtractor(JsonObject item, String baseUrl) {
+ public PeertubeSepiaStreamInfoItemExtractor(final JsonObject item, final String baseUrl) {
super(item, baseUrl);
final String embedUrl = super.item.getString("embedUrl");
final String embedPath = super.item.getString("embedPath");
@@ -15,8 +15,8 @@ public class PeertubeSepiaStreamInfoItemExtractor extends PeertubeStreamInfoItem
setBaseUrl(itemBaseUrl);
// Usually, all videos, pictures and other content are hosted on the instance,
- // or can be accessed by the same URL path if the instance with baseUrl federates the one where the video is actually uploaded
- // But it can't be accessed with Sepiasearch, so we use the item's instance as base URL
+ // or can be accessed by the same URL path if the instance with baseUrl federates the one
+ // where the video is actually uploaded. But it can't be accessed with Sepiasearch, so we
+ // use the item's instance as base URL.
}
-
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java
index 4902bff30..eb33bf18b 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeStreamExtractor.java
@@ -1,11 +1,14 @@
package org.schabi.newpipe.extractor.services.peertube.extractors;
+import static org.schabi.newpipe.extractor.utils.Utils.UTF_8;
+import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
+
import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException;
+
import org.schabi.newpipe.extractor.MediaFormat;
-import org.schabi.newpipe.extractor.MetaInfo;
import org.schabi.newpipe.extractor.NewPipe;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.downloader.Downloader;
@@ -18,12 +21,17 @@ import org.schabi.newpipe.extractor.localization.DateWrapper;
import org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper;
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeSearchQueryHandlerFactory;
import org.schabi.newpipe.extractor.services.peertube.linkHandler.PeertubeStreamLinkHandlerFactory;
-import org.schabi.newpipe.extractor.stream.*;
+import org.schabi.newpipe.extractor.stream.AudioStream;
+import org.schabi.newpipe.extractor.stream.Description;
+import org.schabi.newpipe.extractor.stream.Stream;
+import org.schabi.newpipe.extractor.stream.StreamExtractor;
+import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
+import org.schabi.newpipe.extractor.stream.StreamType;
+import org.schabi.newpipe.extractor.stream.SubtitlesStream;
+import org.schabi.newpipe.extractor.stream.VideoStream;
import org.schabi.newpipe.extractor.utils.JsonUtils;
import org.schabi.newpipe.extractor.utils.Utils;
-import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
@@ -32,15 +40,16 @@ import java.util.Collections;
import java.util.List;
import java.util.Locale;
-import static org.schabi.newpipe.extractor.utils.Utils.UTF_8;
-import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
+import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
public class PeertubeStreamExtractor extends StreamExtractor {
private final String baseUrl;
private JsonObject json;
private final List subtitles = new ArrayList<>();
- public PeertubeStreamExtractor(final StreamingService service, final LinkHandler linkHandler) throws ParsingException {
+ public PeertubeStreamExtractor(final StreamingService service, final LinkHandler linkHandler)
+ throws ParsingException {
super(service, linkHandler);
this.baseUrl = getBaseUrl();
}
@@ -73,9 +82,10 @@ public class PeertubeStreamExtractor extends StreamExtractor {
String text;
try {
text = JsonUtils.getString(json, "description");
- } catch (ParsingException e) {
- return Description.emptyDescription;
+ } catch (final ParsingException e) {
+ return Description.EMPTY_DESCRIPTION;
}
+
if (text.length() == 250 && text.substring(247).equals("...")) {
//if description is shortened, get full description
final Downloader dl = NewPipe.getDownloader();
@@ -140,7 +150,8 @@ public class PeertubeStreamExtractor extends StreamExtractor {
public String getUploaderUrl() throws ParsingException {
final String name = JsonUtils.getString(json, "account.name");
final String host = JsonUtils.getString(json, "account.host");
- return getService().getChannelLHFactory().fromId("accounts/" + name + "@" + host, baseUrl).getUrl();
+ return getService().getChannelLHFactory()
+ .fromId("accounts/" + name + "@" + host, baseUrl).getUrl();
}
@Nonnull
@@ -155,7 +166,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
String value;
try {
value = JsonUtils.getString(json, "account.avatar.path");
- } catch (Exception e) {
+ } catch (final Exception e) {
value = "/client/assets/images/default-avatar.png";
}
return baseUrl + value;
@@ -179,7 +190,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
String value;
try {
value = JsonUtils.getString(json, "channel.avatar.path");
- } catch (Exception e) {
+ } catch (final Exception e) {
value = "/client/assets/images/default-avatar.png";
}
return baseUrl + value;
@@ -200,35 +211,41 @@ public class PeertubeStreamExtractor extends StreamExtractor {
public List getVideoStreams() throws ExtractionException {
assertPageFetched();
final List videoStreams = new ArrayList<>();
+
// mp4
try {
videoStreams.addAll(getVideoStreamsFromArray(json.getArray("files")));
- } catch (Exception ignored) { }
+ } catch (final Exception ignored) { }
+
// HLS
try {
final JsonArray streamingPlaylists = json.getArray("streamingPlaylists");
for (final Object p : streamingPlaylists) {
- if (!(p instanceof JsonObject)) continue;
+ if (!(p instanceof JsonObject)) {
+ continue;
+ }
final JsonObject playlist = (JsonObject) p;
videoStreams.addAll(getVideoStreamsFromArray(playlist.getArray("files")));
}
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new ParsingException("Could not get video streams", e);
}
if (getStreamType() == StreamType.LIVE_STREAM) {
- final String url = getHlsUrl();
- videoStreams.add(new VideoStream(url, MediaFormat.MPEG_4, "720p"));
+ videoStreams.add(new VideoStream(getHlsUrl(), MediaFormat.MPEG_4, "720p"));
}
return videoStreams;
}
- private List getVideoStreamsFromArray(final JsonArray streams) throws ParsingException {
+ private List getVideoStreamsFromArray(final JsonArray streams)
+ throws ParsingException {
try {
final List videoStreams = new ArrayList<>();
for (final Object s : streams) {
- if (!(s instanceof JsonObject)) continue;
+ if (!(s instanceof JsonObject)) {
+ continue;
+ }
final JsonObject stream = (JsonObject) s;
final String url;
if (stream.has("fileDownloadUrl")) {
@@ -240,13 +257,14 @@ public class PeertubeStreamExtractor extends StreamExtractor {
final String resolution = JsonUtils.getString(stream, "resolution.label");
final String extension = url.substring(url.lastIndexOf(".") + 1);
final MediaFormat format = MediaFormat.getFromSuffix(extension);
- final VideoStream videoStream = new VideoStream(url, torrentUrl, format, resolution);
+ final VideoStream videoStream
+ = new VideoStream(url, torrentUrl, format, resolution);
if (!Stream.containSimilarStream(videoStream, videoStreams)) {
videoStreams.add(videoStream);
}
}
return videoStreams;
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new ParsingException("Could not get video streams from array");
}
@@ -287,8 +305,8 @@ public class PeertubeStreamExtractor extends StreamExtractor {
final String apiUrl;
if (tags.isEmpty()) {
apiUrl = baseUrl + "/api/v1/accounts/" + JsonUtils.getString(json, "account.name")
- + "@" + JsonUtils.getString(json, "account.host") +
- "/videos?start=0&count=8";
+ + "@" + JsonUtils.getString(json, "account.host")
+ + "/videos?start=0&count=8";
} else {
apiUrl = getRelatedItemsUrl(tags);
}
@@ -313,7 +331,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
public String getSupportInfo() {
try {
return JsonUtils.getString(json, "support");
- } catch (ParsingException e) {
+ } catch (final ParsingException e) {
return "";
}
}
@@ -326,16 +344,17 @@ public class PeertubeStreamExtractor extends StreamExtractor {
params.append("&tagsOneOf=");
params.append(URLEncoder.encode(tag, UTF_8));
}
- return url + "?" + params.toString();
+ return url + "?" + params;
}
- private void getStreamsFromApi(final StreamInfoItemsCollector collector, final String apiUrl) throws ReCaptchaException, IOException, ParsingException {
+ private void getStreamsFromApi(final StreamInfoItemsCollector collector, final String apiUrl)
+ throws ReCaptchaException, IOException, ParsingException {
final Response response = getDownloader().get(apiUrl);
JsonObject relatedVideosJson = null;
if (response != null && !Utils.isBlank(response.responseBody())) {
try {
relatedVideosJson = JsonParser.object().from(response.responseBody());
- } catch (JsonParserException e) {
+ } catch (final JsonParserException e) {
throw new ParsingException("Could not parse json data for related videos", e);
}
}
@@ -345,27 +364,33 @@ public class PeertubeStreamExtractor extends StreamExtractor {
}
}
- private void collectStreamsFrom(final StreamInfoItemsCollector collector, final JsonObject json) throws ParsingException {
+ private void collectStreamsFrom(final StreamInfoItemsCollector collector,
+ final JsonObject jsonObject)
+ throws ParsingException {
final JsonArray contents;
try {
- contents = (JsonArray) JsonUtils.getValue(json, "data");
- } catch (Exception e) {
+ contents = (JsonArray) JsonUtils.getValue(jsonObject, "data");
+ } catch (final Exception e) {
throw new ParsingException("unable to extract related videos", e);
}
for (final Object c : contents) {
if (c instanceof JsonObject) {
final JsonObject item = (JsonObject) c;
- final PeertubeStreamInfoItemExtractor extractor = new PeertubeStreamInfoItemExtractor(item, baseUrl);
+ final PeertubeStreamInfoItemExtractor extractor
+ = new PeertubeStreamInfoItemExtractor(item, baseUrl);
//do not add the same stream in related streams
- if (!extractor.getUrl().equals(getUrl())) collector.commit(extractor);
+ if (!extractor.getUrl().equals(getUrl())) {
+ collector.commit(extractor);
+ }
}
}
}
@Override
public void onFetchPage(final Downloader downloader) throws IOException, ExtractionException {
- final Response response = downloader.get(baseUrl + PeertubeStreamLinkHandlerFactory.VIDEO_API_ENDPOINT + getId());
+ final Response response = downloader.get(
+ baseUrl + PeertubeStreamLinkHandlerFactory.VIDEO_API_ENDPOINT + getId());
if (response != null) {
setInitialData(response.responseBody());
} else {
@@ -378,7 +403,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
private void setInitialData(final String responseBody) throws ExtractionException {
try {
json = JsonParser.object().from(responseBody);
- } catch (JsonParserException e) {
+ } catch (final JsonParserException e) {
throw new ExtractionException("Unable to extract PeerTube stream data", e);
}
if (json == null) {
@@ -402,11 +427,12 @@ public class PeertubeStreamExtractor extends StreamExtractor {
final String languageCode = JsonUtils.getString(caption, "language.id");
final String ext = url.substring(url.lastIndexOf(".") + 1);
final MediaFormat fmt = MediaFormat.getFromSuffix(ext);
- if (fmt != null && !isNullOrEmpty(languageCode))
+ if (fmt != null && !isNullOrEmpty(languageCode)) {
subtitles.add(new SubtitlesStream(fmt, languageCode, url, false));
+ }
}
}
- } catch (Exception e) {
+ } catch (final Exception e) {
// ignore all exceptions
}
}
@@ -457,7 +483,7 @@ public class PeertubeStreamExtractor extends StreamExtractor {
public Locale getLanguageInfo() {
try {
return new Locale(JsonUtils.getString(json, "language.id"));
- } catch (ParsingException e) {
+ } catch (final ParsingException e) {
return null;
}
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeTrendingExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeTrendingExtractor.java
index fdc32aa19..676fdfb22 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeTrendingExtractor.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/extractors/PeertubeTrendingExtractor.java
@@ -27,7 +27,9 @@ import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelp
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;
public class PeertubeTrendingExtractor extends KioskExtractor {
- public PeertubeTrendingExtractor(final StreamingService streamingService, final ListLinkHandler linkHandler, final String kioskId) {
+ public PeertubeTrendingExtractor(final StreamingService streamingService,
+ final ListLinkHandler linkHandler,
+ final String kioskId) {
super(streamingService, linkHandler, kioskId);
}
@@ -38,12 +40,13 @@ public class PeertubeTrendingExtractor extends KioskExtractor {
@Override
public InfoItemsPage getInitialPage() throws IOException, ExtractionException {
- final String pageUrl = getUrl() + "&" + START_KEY + "=0&" + COUNT_KEY + "=" + ITEMS_PER_PAGE;
- return getPage(new Page(pageUrl));
+ return getPage(new Page(getUrl() + "&" + START_KEY + "=0&"
+ + COUNT_KEY + "=" + ITEMS_PER_PAGE));
}
@Override
- public InfoItemsPage getPage(final Page page) throws IOException, ExtractionException {
+ public InfoItemsPage getPage(final Page page)
+ throws IOException, ExtractionException {
if (page == null || isNullOrEmpty(page.getUrl())) {
throw new IllegalArgumentException("Page doesn't contain an URL");
}
@@ -54,7 +57,7 @@ public class PeertubeTrendingExtractor extends KioskExtractor {
if (response != null && !Utils.isBlank(response.responseBody())) {
try {
json = JsonParser.object().from(response.responseBody());
- } catch (Exception e) {
+ } catch (final Exception e) {
throw new ParsingException("Could not parse json data for kiosk info", e);
}
}
@@ -66,12 +69,15 @@ public class PeertubeTrendingExtractor extends KioskExtractor {
final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
collectStreamsFrom(collector, json, getBaseUrl());
- return new InfoItemsPage<>(collector, PeertubeParsingHelper.getNextPage(page.getUrl(), total));
+ return new InfoItemsPage<>(collector,
+ PeertubeParsingHelper.getNextPage(page.getUrl(), total));
} else {
throw new ExtractionException("Unable to get PeerTube kiosk info");
}
}
@Override
- public void onFetchPage(@Nonnull final Downloader downloader) throws IOException, ExtractionException { }
+ public void onFetchPage(@Nonnull final Downloader downloader)
+ throws IOException, ExtractionException {
+ }
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubeChannelLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubeChannelLinkHandlerFactory.java
index 950514b0e..57a15d16d 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubeChannelLinkHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubeChannelLinkHandlerFactory.java
@@ -7,39 +7,49 @@ import org.schabi.newpipe.extractor.utils.Parser;
import java.util.List;
-public class PeertubeChannelLinkHandlerFactory extends ListLinkHandlerFactory {
+public final class PeertubeChannelLinkHandlerFactory extends ListLinkHandlerFactory {
- private static final PeertubeChannelLinkHandlerFactory instance = new PeertubeChannelLinkHandlerFactory();
+ private static final PeertubeChannelLinkHandlerFactory INSTANCE
+ = new PeertubeChannelLinkHandlerFactory();
private static final String ID_PATTERN = "((accounts|a)|(video-channels|c))/([^/?]*)";
public static final String API_ENDPOINT = "/api/v1/";
+ private PeertubeChannelLinkHandlerFactory() {
+ }
+
public static PeertubeChannelLinkHandlerFactory getInstance() {
- return instance;
+ return INSTANCE;
}
@Override
- public String getId(String url) throws ParsingException {
+ public String getId(final String url) throws ParsingException {
return fixId(Parser.matchGroup(ID_PATTERN, url, 0));
}
@Override
- public String getUrl(String id, List contentFilters, String searchFilter) throws ParsingException {
+ public String getUrl(final String id,
+ final List contentFilters,
+ final String searchFilter) throws ParsingException {
return getUrl(id, contentFilters, searchFilter, ServiceList.PeerTube.getBaseUrl());
}
@Override
- public String getUrl(String id, List contentFilter, String sortFilter, String baseUrl)
+ public String getUrl(final String id,
+ final List contentFilter,
+ final String sortFilter,
+ final String baseUrl)
throws ParsingException {
if (id.matches(ID_PATTERN)) {
return baseUrl + "/" + fixId(id);
} else {
- // This is needed for compatibility with older versions were we didn't support video channels yet
+ // This is needed for compatibility with older versions were we didn't support
+ // video channels yet
return baseUrl + "/accounts/" + id;
}
}
@Override
- public boolean onAcceptUrl(String url) {
+ public boolean onAcceptUrl(final String url) {
return url.contains("/accounts/") || url.contains("/a/")
|| url.contains("/video-channels/") || url.contains("/c/");
}
@@ -56,11 +66,11 @@ public class PeertubeChannelLinkHandlerFactory extends ListLinkHandlerFactory {
* @param id the id to fix
* @return the fixed id
*/
- private String fixId(String id) {
+ private String fixId(final String id) {
if (id.startsWith("a/")) {
- id = "accounts" + id.substring(1);
+ return "accounts" + id.substring(1);
} else if (id.startsWith("c/")) {
- id = "video-channels" + id.substring(1);
+ return "video-channels" + id.substring(1);
}
return id;
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubeCommentsLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubeCommentsLinkHandlerFactory.java
index 3bf531a8d..366b0a159 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubeCommentsLinkHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubeCommentsLinkHandlerFactory.java
@@ -4,21 +4,24 @@ import org.schabi.newpipe.extractor.ServiceList;
import org.schabi.newpipe.extractor.exceptions.FoundAdException;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.ListLinkHandlerFactory;
-import org.schabi.newpipe.extractor.utils.Parser;
import java.util.List;
-public class PeertubeCommentsLinkHandlerFactory extends ListLinkHandlerFactory {
+public final class PeertubeCommentsLinkHandlerFactory extends ListLinkHandlerFactory {
- private static final PeertubeCommentsLinkHandlerFactory instance = new PeertubeCommentsLinkHandlerFactory();
+ private static final PeertubeCommentsLinkHandlerFactory INSTANCE
+ = new PeertubeCommentsLinkHandlerFactory();
private static final String COMMENTS_ENDPOINT = "/api/v1/videos/%s/comment-threads";
+ private PeertubeCommentsLinkHandlerFactory() {
+ }
+
public static PeertubeCommentsLinkHandlerFactory getInstance() {
- return instance;
+ return INSTANCE;
}
@Override
- public String getId(String url) throws ParsingException, IllegalArgumentException {
+ public String getId(final String url) throws ParsingException, IllegalArgumentException {
return PeertubeStreamLinkHandlerFactory.getInstance().getId(url); // the same id is needed
}
@@ -28,13 +31,17 @@ public class PeertubeCommentsLinkHandlerFactory extends ListLinkHandlerFactory {
}
@Override
- public String getUrl(String id, List contentFilter, String sortFilter) throws ParsingException {
- String baseUrl = ServiceList.PeerTube.getBaseUrl();
- return getUrl(id, contentFilter, sortFilter, baseUrl);
+ public String getUrl(final String id,
+ final List contentFilter,
+ final String sortFilter) throws ParsingException {
+ return getUrl(id, contentFilter, sortFilter, ServiceList.PeerTube.getBaseUrl());
}
@Override
- public String getUrl(String id, List contentFilter, String sortFilter, String baseUrl) throws ParsingException {
+ public String getUrl(final String id,
+ final List contentFilter,
+ final String sortFilter,
+ final String baseUrl) throws ParsingException {
return baseUrl + String.format(COMMENTS_ENDPOINT, id);
}
diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubePlaylistLinkHandlerFactory.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubePlaylistLinkHandlerFactory.java
index f27e55eb1..fa48fe32c 100644
--- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubePlaylistLinkHandlerFactory.java
+++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/peertube/linkHandler/PeertubePlaylistLinkHandlerFactory.java
@@ -8,28 +8,36 @@ import org.schabi.newpipe.extractor.utils.Parser;
import java.util.List;
-public class PeertubePlaylistLinkHandlerFactory extends ListLinkHandlerFactory {
+public final class PeertubePlaylistLinkHandlerFactory extends ListLinkHandlerFactory {
- private static final PeertubePlaylistLinkHandlerFactory instance = new PeertubePlaylistLinkHandlerFactory();
+ private static final PeertubePlaylistLinkHandlerFactory INSTANCE
+ = new PeertubePlaylistLinkHandlerFactory();
private static final String ID_PATTERN = "(/videos/watch/playlist/|/w/p/)([^/?]*)";
+ private PeertubePlaylistLinkHandlerFactory() {
+ }
+
public static PeertubePlaylistLinkHandlerFactory getInstance() {
- return instance;
+ return INSTANCE;
}
@Override
- public String getUrl(String id, List contentFilters, String sortFilter) {
- String baseUrl = ServiceList.PeerTube.getBaseUrl();
- return getUrl(id, contentFilters, sortFilter, baseUrl);
+ public String getUrl(final String id,
+ final List contentFilters,
+ final String sortFilter) {
+ return getUrl(id, contentFilters, sortFilter, ServiceList.PeerTube.getBaseUrl());
}
@Override
- public String getUrl(String id, List contentFilters, String sortFilter, String baseUrl) {
+ public String getUrl(final String id,
+ final List