Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public boolean equals(final Object o) {
return false;
}

final Localization that = (Localization) o;
final var that = (Localization) o;

return languageCode.equals(that.languageCode)
&& Objects.equals(countryCode, that.countryCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public boolean isVerified() throws ParsingException {
@Override
public List<ListLinkHandler> getTabs() throws ParsingException {
final JsonArray discography = channelInfo.getArray("discography");
final TabExtractorBuilder builder = new TabExtractorBuilder(discography);
final var builder = new TabExtractorBuilder(discography);

final List<ListLinkHandler> tabs = new ArrayList<>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ public BandcampChannelTabExtractor(final StreamingService service,
public static BandcampChannelTabExtractor fromDiscography(final StreamingService service,
final ListLinkHandler linkHandler,
final JsonArray discography) {
final BandcampChannelTabExtractor tabExtractor =
new BandcampChannelTabExtractor(service, linkHandler);
final var tabExtractor = new BandcampChannelTabExtractor(service, linkHandler);
tabExtractor.discography = discography;
return tabExtractor;
}
Expand All @@ -58,7 +57,7 @@ public void onFetchPage(@Nonnull final Downloader downloader) throws ParsingExce
@Nonnull
@Override
public InfoItemsPage<InfoItem> getInitialPage() throws IOException, ExtractionException {
final MultiInfoItemsCollector collector = new MultiInfoItemsCollector(getServiceId());
final var collector = new MultiInfoItemsCollector(getServiceId());

for (final Object discograph : discography) {
// A discograph is as an item appears in a discography
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void onFetchPage(@Nonnull final Downloader downloader)
public InfoItemsPage<CommentsInfoItem> getInitialPage()
throws IOException, ExtractionException {

final CommentsInfoItemsCollector collector = new CommentsInfoItemsCollector(getServiceId());
final var collector = new CommentsInfoItemsCollector(getServiceId());

final JsonObject collectorsData = JsonUtils.toJsonObject(
document.getElementById("collectors-data").attr("data-blob"));
Expand All @@ -74,7 +74,7 @@ public InfoItemsPage<CommentsInfoItem> getInitialPage()
public InfoItemsPage<CommentsInfoItem> getPage(final Page page)
throws IOException, ExtractionException {

final CommentsInfoItemsCollector collector = new CommentsInfoItemsCollector(getServiceId());
final var collector = new CommentsInfoItemsCollector(getServiceId());

final List<String> pageIds = page.getIds();
final String trackId = pageIds.get(0);
Expand Down Expand Up @@ -114,9 +114,7 @@ private JsonObject fetchReviewsData(final String trackId, final String token)
}

private String getNextPageToken(final JsonArray reviews) throws ParsingException {
return reviews.stream()
.filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast)
return reviews.streamAsJsonObjects()
.map(review -> review.getString("token"))
.reduce((a, b) -> b) // keep only the last element
.orElseThrow(() -> new ParsingException("Could not get token"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public InfoItemsPage<PlaylistInfoItem> getInitialPage()
}

private InfoItemsPage<PlaylistInfoItem> extractItems(final JsonArray featuredStories) {
final PlaylistInfoItemsCollector c = new PlaylistInfoItemsCollector(getServiceId());
final var c = new PlaylistInfoItemsCollector(getServiceId());

for (int i = 0; i < featuredStories.size(); i++) {
final JsonObject featuredStory = featuredStories.getObject(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public Description getDescription() throws ParsingException {
if (about.isEmpty() && credits.isEmpty() && license == null) {
return Description.EMPTY_DESCRIPTION;
}
final StringBuilder sb = new StringBuilder();
final var sb = new StringBuilder();
if (!about.isEmpty()) {
sb.append(Objects.requireNonNull(about.first()).html());
}
Expand All @@ -147,7 +147,7 @@ public Description getDescription() throws ParsingException {
@Override
public InfoItemsPage<StreamInfoItem> getInitialPage() throws ExtractionException {

final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
final var collector = new StreamInfoItemsCollector(getServiceId());

for (int i = 0; i < trackInfo.size(); i++) {
final JsonObject track = trackInfo.getObject(i);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public String getName() throws ParsingException {
@Nonnull
@Override
public InfoItemsPage<StreamInfoItem> getInitialPage() {
final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
final var collector = new StreamInfoItemsCollector(getServiceId());

final JsonArray radioShows = json.getArray("results");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ public List<StreamSegment> getStreamSegments() throws ParsingException {
final List<StreamSegment> segments = new ArrayList<>(tracks.size());
for (final Object t : tracks) {
final JsonObject track = (JsonObject) t;
final StreamSegment segment = new StreamSegment(
final var segment = new StreamSegment(
track.getString("title"), track.getInt("timecode"));
// "track art" is the track's album cover
segment.setPreviewUrl(getImageUrl(track.getLong("track_art_id"), true));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public List<MetaInfo> getMetaInfo() throws ParsingException {
@Override
public InfoItemsPage<InfoItem> getPage(final Page page)
throws IOException, ExtractionException {
final MultiInfoItemsCollector collector = new MultiInfoItemsCollector(getServiceId());
final var collector = new MultiInfoItemsCollector(getServiceId());
final Document d = Jsoup.parse(getDownloader().get(page.getUrl()).responseBody());

for (final Element searchResult : d.getElementsByClass("searchresult")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public StreamType getStreamType() {

@Override
public PlaylistInfoItemsCollector getRelatedItems() {
final PlaylistInfoItemsCollector collector = new PlaylistInfoItemsCollector(getServiceId());
final var collector = new PlaylistInfoItemsCollector(getServiceId());
document.getElementsByClass("recommended-album")
.stream()
.map(BandcampRelatedPlaylistInfoItemExtractor::new)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,7 @@ public List<String> suggestionList(final String query) throws IOException, Extra
.done()
.getBytes(StandardCharsets.UTF_8)).responseBody());

return fuzzyResults.getObject("auto").getArray("results").stream()
.filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast)
return fuzzyResults.getObject("auto").getArray("results").streamAsJsonObjects()
.map(jsonObject -> jsonObject.getString("name"))
.distinct()
.collect(Collectors.toList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public SuggestionExtractor getSuggestionExtractor() {

@Override
public KioskList getKioskList() throws ExtractionException {
final KioskList list = new KioskList(this);
final var list = new KioskList(this);
final ListLinkHandlerFactory h = MediaCCCConferencesListLinkHandlerFactory.getInstance();

// add kiosks here e.g.:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,10 @@ public void onFetchPage(@Nonnull final Downloader downloader)
@Nonnull
@Override
public ListExtractor.InfoItemsPage<InfoItem> getInitialPage() {
final MultiInfoItemsCollector collector =
new MultiInfoItemsCollector(getServiceId());
final var collector = new MultiInfoItemsCollector(getServiceId());
Objects.requireNonNull(conferenceData) // will surely be != null after onFetchPage
.getArray("events")
.stream()
.filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast)
.streamAsJsonObjects()
.forEach(event -> collector.commit(new MediaCCCStreamInfoItemExtractor(event)));
return new ListExtractor.InfoItemsPage<>(collector, null);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public MediaCCCConferenceKiosk(final StreamingService streamingService,
@Override
public InfoItemsPage<ChannelInfoItem> getInitialPage() {
final JsonArray conferences = doc.getArray("conferences");
final ChannelInfoItemsCollector collector = new ChannelInfoItemsCollector(getServiceId());
final var collector = new ChannelInfoItemsCollector(getServiceId());
for (int i = 0; i < conferences.size(); i++) {
collector.commit(new MediaCCCConferenceInfoItemExtractor(conferences.getObject(i)));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,7 @@ public String getHlsUrl() {

@Nonnull
private String getManifestOfDeliveryMethodWanted(@Nonnull final String deliveryMethod) {
return room.getArray(STREAMS).stream()
.filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast)
return room.getArray(STREAMS).streamAsJsonObjects()
.map(streamObject -> streamObject.getObject(URLS))
.filter(urls -> urls.has(deliveryMethod))
.map(urls -> urls.getObject(deliveryMethod).getString(URL, ""))
Expand Down Expand Up @@ -228,11 +226,7 @@ private static final class MediaCCCLiveStreamMapperDTO {
private <T extends Stream> List<T> getStreams(
@Nonnull final String streamType,
@Nonnull final Function<MediaCCCLiveStreamMapperDTO, T> converter) {
return room.getArray(STREAMS).stream()
// Ensure that we use only process JsonObjects
.filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast)
// Only process streams of requested type
return room.getArray(STREAMS).streamAsJsonObjects()
.filter(streamJsonObj -> streamType.equals(streamJsonObj.getString("type")))
// Flatmap Urls and ensure that we use only process JsonObjects
.flatMap(streamJsonObj -> streamJsonObj.getObject(URLS).entrySet().stream()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void onFetchPage(@Nonnull final Downloader downloader)
@Nonnull
@Override
public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, ExtractionException {
final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
final var collector = new StreamInfoItemsCollector(getServiceId());
for (int c = 0; c < doc.size(); c++) {
final JsonObject conference = doc.getObject(c);
if (conference.getBoolean("isCurrentlyStreaming")) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,7 @@ public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, Extrac
.reversed();
final var collector = new StreamInfoItemsCollector(getServiceId(), comparator);

events.stream()
.filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast)
events.streamAsJsonObjects()
.map(MediaCCCRecentKioskExtractor::new)
// #813 / voc/voctoweb#609 -> returns faulty data -> filter it out
.filter(extractor -> extractor.getDuration() > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public List<MetaInfo> getMetaInfo() {
@Nonnull
@Override
public InfoItemsPage<InfoItem> getInitialPage() {
final MultiInfoItemsCollector searchItems = new MultiInfoItemsCollector(getServiceId());
final var searchItems = new MultiInfoItemsCollector(getServiceId());

if (getLinkHandler().getContentFilters().contains(CONFERENCES)
|| getLinkHandler().getContentFilters().contains(ALL)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -293,9 +293,7 @@ private static List<Image> getImagesFromAvatarsOrBanners(
private static List<Image> getImagesFromAvatarOrBannerArray(
@Nonnull final String baseUrl,
@Nonnull final JsonArray avatarsOrBannersArray) {
return avatarsOrBannersArray.stream()
.filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast)
return avatarsOrBannersArray.streamAsJsonObjects()
.filter(image -> !isNullOrEmpty(image.getString("path")))
.map(image -> new Image(baseUrl + image.getString("path"), HEIGHT_UNKNOWN,
image.getInt("width", WIDTH_UNKNOWN), ResolutionLevel.UNKNOWN))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public InfoItemsPage<InfoItem> getPage(final Page page)
}
PeertubeParsingHelper.validate(pageJson);

final MultiInfoItemsCollector collector = new MultiInfoItemsCollector(getServiceId());
final var collector = new MultiInfoItemsCollector(getServiceId());
collectItemsFrom(collector, pageJson, getBaseUrl());

return new InfoItemsPage<>(collector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public InfoItemsPage<CommentsInfoItem> getPage(final Page page)
}

JsonObject json = null;
final CommentsInfoItemsCollector collector = new CommentsInfoItemsCollector(getServiceId());
final var collector = new CommentsInfoItemsCollector(getServiceId());
final long total;
if (page.getBody() == null) {
final Response response = getDownloader().get(page.getUrl());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public InfoItemsPage<StreamInfoItem> getPage(final Page page)
PeertubeParsingHelper.validate(json);
final long total = json.getLong("total");

final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
final var collector = new StreamInfoItemsCollector(getServiceId());
collectItemsFrom(collector, json, getBaseUrl());

return new InfoItemsPage<>(collector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public InfoItemsPage<InfoItem> getPage(final Page page)
PeertubeParsingHelper.validate(json);
final long total = json.getLong("total");

final MultiInfoItemsCollector collector = new MultiInfoItemsCollector(getServiceId());
final var collector = new MultiInfoItemsCollector(getServiceId());
collectItemsFrom(collector, json, getBaseUrl(), sepia);

return new InfoItemsPage<>(collector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -288,8 +288,7 @@ public StreamInfoItemsCollector getRelatedItems() throws IOException, Extraction
if (Utils.isBlank(apiUrl)) {
return null;
} else {
final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(
getServiceId());
final var collector = new StreamInfoItemsCollector(getServiceId());
getStreamsFromApi(collector, apiUrl);
return collector;
}
Expand Down Expand Up @@ -374,7 +373,7 @@ public List<Frameset> getFrames() throws ExtractionException {
@Nonnull
private String getRelatedItemsUrl(@Nonnull final List<String> tags) {
final String url = baseUrl + PeertubeSearchQueryHandlerFactory.SEARCH_ENDPOINT_VIDEOS;
final StringBuilder params = new StringBuilder();
final var params = new StringBuilder();
params.append("start=0&count=8&sort=-createdAt");
for (final String tag : tags) {
params.append("&tagsOneOf=").append(Utils.encodeUrlUtf8(tag));
Expand Down Expand Up @@ -481,9 +480,7 @@ private void loadSubtitles() {
private void extractLiveVideoStreams() throws ParsingException {
try {
final JsonArray streamingPlaylists = json.getArray(STREAMING_PLAYLISTS);
streamingPlaylists.stream()
.filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast)
streamingPlaylists.streamAsJsonObjects()
.map(stream -> new VideoStream.Builder()
.setId(String.valueOf(stream.getInt("id", -1)))
.setContent(stream.getString(PLAYLIST_URL, ""), true)
Expand All @@ -507,9 +504,8 @@ private void getStreams() throws ParsingException {

// HLS streams
try {
for (final JsonObject playlist : json.getArray(STREAMING_PLAYLISTS).stream()
.filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast)
for (final JsonObject playlist : json.getArray(STREAMING_PLAYLISTS)
.streamAsJsonObjects()
.collect(Collectors.toList())) {
getStreamsFromArray(playlist.getArray(FILES), playlist.getString(PLAYLIST_URL));
}
Expand All @@ -531,9 +527,7 @@ private void getStreamsFromArray(@Nonnull final JsonArray streams,
final boolean isInstanceUsingRandomUuidsForHlsStreams = !isNullOrEmpty(playlistUrl)
&& playlistUrl.endsWith("-master.m3u8");

for (final JsonObject stream : streams.stream()
.filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast)
for (final JsonObject stream : streams.streamAsJsonObjects()
.collect(Collectors.toList())) {

// Extract stream version of streams first
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public InfoItemsPage<StreamInfoItem> getPage(final Page page)
PeertubeParsingHelper.validate(json);
final long total = json.getLong("total");

final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
final var collector = new StreamInfoItemsCollector(getServiceId());
collectItemsFrom(collector, json, getBaseUrl());

return new InfoItemsPage<>(collector,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,7 @@ public static String getInfoItemsFromApi(final MultiInfoItemsCollector collector
}

responseObject.getArray("collection")
.stream()
.filter(JsonObject.class::isInstance)
.map(JsonObject.class::cast)
.streamAsJsonObjects()
.forEach(searchResult -> {
final String kind = searchResult.getString("kind", "");
switch (kind) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public InfoItemsPage<InfoItem> getPage(final Page page)
throw new IllegalArgumentException("Page doesn't contain an URL");
}

final MultiInfoItemsCollector collector = new MultiInfoItemsCollector(getServiceId());
final var collector = new MultiInfoItemsCollector(getServiceId());
final Set<String> visitedPages = new HashSet<>();

String currentPageUrl = page.getUrl();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public InfoItemsPage<StreamInfoItem> getPage(final Page page) throws IOException
throw new IllegalArgumentException("Page doesn't contain an URL");
}

final StreamInfoItemsCollector collector = new StreamInfoItemsCollector(getServiceId());
final var collector = new StreamInfoItemsCollector(getServiceId());
final String nextPageUrl = SoundcloudParsingHelper.getStreamsFromApi(collector,
page.getUrl(), true);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ private InfoItemsPage<CommentsInfoItem> getPage(@Nonnull final String url)
throw new ParsingException("Could not parse json", e);
}

final CommentsInfoItemsCollector collector = new CommentsInfoItemsCollector(
getServiceId());
final var collector = new CommentsInfoItemsCollector(getServiceId());

collectStreamsFrom(collector, json.getArray("collection"));
return new InfoItemsPage<>(collector, new Page(json.getString("next_href", null)));
Expand Down
Loading