mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2025-01-06 01:20:32 +05:30
[Bandcamp] Apply changes in Extractors
This commit is contained in:
parent
7e01eaac33
commit
71cda03c4c
@ -2,12 +2,18 @@
|
|||||||
|
|
||||||
package org.schabi.newpipe.extractor.services.bandcamp.extractors;
|
package org.schabi.newpipe.extractor.services.bandcamp.extractors;
|
||||||
|
|
||||||
|
import static org.schabi.newpipe.extractor.Image.HEIGHT_UNKNOWN;
|
||||||
|
import static org.schabi.newpipe.extractor.Image.WIDTH_UNKNOWN;
|
||||||
|
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getArtistDetails;
|
||||||
|
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImagesFromImageId;
|
||||||
import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps;
|
import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps;
|
||||||
|
|
||||||
import com.grack.nanojson.JsonArray;
|
import com.grack.nanojson.JsonArray;
|
||||||
import com.grack.nanojson.JsonObject;
|
import com.grack.nanojson.JsonObject;
|
||||||
|
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
|
import org.schabi.newpipe.extractor.Image;
|
||||||
|
import org.schabi.newpipe.extractor.Image.ResolutionLevel;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
|
||||||
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor;
|
import org.schabi.newpipe.extractor.channel.tabs.ChannelTabExtractor;
|
||||||
@ -25,6 +31,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
@ -38,17 +45,15 @@ public class BandcampChannelExtractor extends ChannelExtractor {
|
|||||||
super(service, linkHandler);
|
super(service, linkHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getAvatarUrl() {
|
public List<Image> getAvatars() {
|
||||||
if (channelInfo.getLong("bio_image_id") == 0) {
|
return getImagesFromImageId(channelInfo.getLong("bio_image_id"), false);
|
||||||
return "";
|
|
||||||
}
|
|
||||||
|
|
||||||
return BandcampExtractorHelper.getImageUrl(channelInfo.getLong("bio_image_id"), false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getBannerUrl() throws ParsingException {
|
public List<Image> getBanners() throws ParsingException {
|
||||||
/*
|
/*
|
||||||
* Mobile API does not return the header or not the correct header.
|
* Mobile API does not return the header or not the correct header.
|
||||||
* Therefore, we need to query the website
|
* Therefore, we need to query the website
|
||||||
@ -62,8 +67,11 @@ public class BandcampChannelExtractor extends ChannelExtractor {
|
|||||||
.filter(Objects::nonNull)
|
.filter(Objects::nonNull)
|
||||||
.flatMap(element -> element.getElementsByTag("img").stream())
|
.flatMap(element -> element.getElementsByTag("img").stream())
|
||||||
.map(element -> element.attr("src"))
|
.map(element -> element.attr("src"))
|
||||||
.findFirst()
|
.filter(url -> !url.isEmpty())
|
||||||
.orElse(""); // no banner available
|
.map(url -> new Image(
|
||||||
|
replaceHttpWithHttps(url), HEIGHT_UNKNOWN, WIDTH_UNKNOWN,
|
||||||
|
ResolutionLevel.UNKNOWN))
|
||||||
|
.collect(Collectors.toUnmodifiableList());
|
||||||
|
|
||||||
} catch (final IOException | ReCaptchaException e) {
|
} catch (final IOException | ReCaptchaException e) {
|
||||||
throw new ParsingException("Could not download artist web site", e);
|
throw new ParsingException("Could not download artist web site", e);
|
||||||
@ -98,9 +106,10 @@ public class BandcampChannelExtractor extends ChannelExtractor {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getParentChannelAvatarUrl() {
|
public List<Image> getParentChannelAvatars() {
|
||||||
return null;
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -156,7 +165,7 @@ public class BandcampChannelExtractor extends ChannelExtractor {
|
|||||||
@Override
|
@Override
|
||||||
public void onFetchPage(@Nonnull final Downloader downloader)
|
public void onFetchPage(@Nonnull final Downloader downloader)
|
||||||
throws IOException, ExtractionException {
|
throws IOException, ExtractionException {
|
||||||
channelInfo = BandcampExtractorHelper.getArtistDetails(getId());
|
channelInfo = getArtistDetails(getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package org.schabi.newpipe.extractor.services.bandcamp.extractors;
|
package org.schabi.newpipe.extractor.services.bandcamp.extractors;
|
||||||
|
|
||||||
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImageUrl;
|
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImagesFromImageId;
|
||||||
|
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImagesFromImageUrl;
|
||||||
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampStreamExtractor.getAlbumInfoJson;
|
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampStreamExtractor.getAlbumInfoJson;
|
||||||
import static org.schabi.newpipe.extractor.utils.JsonUtils.getJsonData;
|
import static org.schabi.newpipe.extractor.utils.JsonUtils.getJsonData;
|
||||||
import static org.schabi.newpipe.extractor.utils.Utils.HTTPS;
|
import static org.schabi.newpipe.extractor.utils.Utils.HTTPS;
|
||||||
@ -13,6 +14,7 @@ import org.jsoup.Jsoup;
|
|||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
import org.jsoup.select.Elements;
|
import org.jsoup.select.Elements;
|
||||||
|
import org.schabi.newpipe.extractor.Image;
|
||||||
import org.schabi.newpipe.extractor.Page;
|
import org.schabi.newpipe.extractor.Page;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.downloader.Downloader;
|
import org.schabi.newpipe.extractor.downloader.Downloader;
|
||||||
@ -28,6 +30,7 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
|
|||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
import javax.annotation.Nonnull;
|
import javax.annotation.Nonnull;
|
||||||
|
|
||||||
@ -74,11 +77,11 @@ public class BandcampPlaylistExtractor extends PlaylistExtractor {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getThumbnailUrl() throws ParsingException {
|
public List<Image> getThumbnails() throws ParsingException {
|
||||||
if (albumJson.isNull("art_id")) {
|
if (albumJson.isNull("art_id")) {
|
||||||
return "";
|
return List.of();
|
||||||
} else {
|
} else {
|
||||||
return getImageUrl(albumJson.getLong("art_id"), true);
|
return getImagesFromImageId(albumJson.getLong("art_id"), true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,12 +97,14 @@ public class BandcampPlaylistExtractor extends PlaylistExtractor {
|
|||||||
return albumJson.getString("artist");
|
return albumJson.getString("artist");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getUploaderAvatarUrl() {
|
public List<Image> getUploaderAvatars() {
|
||||||
return document.getElementsByClass("band-photo").stream()
|
return getImagesFromImageUrl(document.getElementsByClass("band-photo")
|
||||||
|
.stream()
|
||||||
.map(element -> element.attr("src"))
|
.map(element -> element.attr("src"))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse("");
|
.orElse(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -154,7 +159,7 @@ public class BandcampPlaylistExtractor extends PlaylistExtractor {
|
|||||||
} else {
|
} else {
|
||||||
// Pretend every track has the same cover art as the album
|
// Pretend every track has the same cover art as the album
|
||||||
collector.commit(new BandcampPlaylistStreamInfoItemExtractor(
|
collector.commit(new BandcampPlaylistStreamInfoItemExtractor(
|
||||||
track, getUploaderUrl(), getThumbnailUrl()));
|
track, getUploaderUrl(), getThumbnails()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@ package org.schabi.newpipe.extractor.services.bandcamp.extractors;
|
|||||||
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.BASE_API_URL;
|
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.BASE_URL;
|
||||||
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImageUrl;
|
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImageUrl;
|
||||||
|
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImagesFromImageId;
|
||||||
|
|
||||||
import com.grack.nanojson.JsonArray;
|
import com.grack.nanojson.JsonArray;
|
||||||
import com.grack.nanojson.JsonObject;
|
import com.grack.nanojson.JsonObject;
|
||||||
@ -11,6 +12,8 @@ import com.grack.nanojson.JsonParserException;
|
|||||||
|
|
||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
|
import org.schabi.newpipe.extractor.Image;
|
||||||
|
import org.schabi.newpipe.extractor.Image.ResolutionLevel;
|
||||||
import org.schabi.newpipe.extractor.MediaFormat;
|
import org.schabi.newpipe.extractor.MediaFormat;
|
||||||
import org.schabi.newpipe.extractor.NewPipe;
|
import org.schabi.newpipe.extractor.NewPipe;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
@ -97,14 +100,16 @@ public class BandcampRadioStreamExtractor extends BandcampStreamExtractor {
|
|||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getThumbnailUrl() throws ParsingException {
|
public List<Image> getThumbnails() throws ParsingException {
|
||||||
return getImageUrl(showInfo.getLong("show_image_id"), false);
|
return getImagesFromImageId(showInfo.getLong("show_image_id"), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getUploaderAvatarUrl() {
|
public List<Image> getUploaderAvatars() {
|
||||||
return BASE_URL + "/img/buttons/bandcamp-button-circle-whitecolor-512.png";
|
return Collections.singletonList(
|
||||||
|
new Image(BASE_URL + "/img/buttons/bandcamp-button-circle-whitecolor-512.png",
|
||||||
|
512, 512, ResolutionLevel.MEDIUM));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
@ -2,8 +2,11 @@
|
|||||||
|
|
||||||
package org.schabi.newpipe.extractor.services.bandcamp.extractors;
|
package org.schabi.newpipe.extractor.services.bandcamp.extractors;
|
||||||
|
|
||||||
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImageUrl;
|
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImagesFromImageId;
|
||||||
|
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.getImagesFromImageUrl;
|
||||||
|
import static org.schabi.newpipe.extractor.services.bandcamp.extractors.BandcampExtractorHelper.parseDate;
|
||||||
import static org.schabi.newpipe.extractor.utils.Utils.HTTPS;
|
import static org.schabi.newpipe.extractor.utils.Utils.HTTPS;
|
||||||
|
import static org.schabi.newpipe.extractor.utils.Utils.replaceHttpWithHttps;
|
||||||
|
|
||||||
import com.grack.nanojson.JsonObject;
|
import com.grack.nanojson.JsonObject;
|
||||||
import com.grack.nanojson.JsonParserException;
|
import com.grack.nanojson.JsonParserException;
|
||||||
@ -11,6 +14,7 @@ import com.grack.nanojson.JsonParserException;
|
|||||||
import org.jsoup.Jsoup;
|
import org.jsoup.Jsoup;
|
||||||
import org.jsoup.nodes.Document;
|
import org.jsoup.nodes.Document;
|
||||||
import org.jsoup.nodes.Element;
|
import org.jsoup.nodes.Element;
|
||||||
|
import org.schabi.newpipe.extractor.Image;
|
||||||
import org.schabi.newpipe.extractor.MediaFormat;
|
import org.schabi.newpipe.extractor.MediaFormat;
|
||||||
import org.schabi.newpipe.extractor.StreamingService;
|
import org.schabi.newpipe.extractor.StreamingService;
|
||||||
import org.schabi.newpipe.extractor.downloader.Downloader;
|
import org.schabi.newpipe.extractor.downloader.Downloader;
|
||||||
@ -98,7 +102,7 @@ public class BandcampStreamExtractor extends StreamExtractor {
|
|||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getUrl() throws ParsingException {
|
public String getUrl() throws ParsingException {
|
||||||
return albumJson.getString("url").replace("http://", "https://");
|
return replaceHttpWithHttps(albumJson.getString("url"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@ -116,26 +120,27 @@ public class BandcampStreamExtractor extends StreamExtractor {
|
|||||||
@Nullable
|
@Nullable
|
||||||
@Override
|
@Override
|
||||||
public DateWrapper getUploadDate() throws ParsingException {
|
public DateWrapper getUploadDate() throws ParsingException {
|
||||||
return BandcampExtractorHelper.parseDate(getTextualUploadDate());
|
return parseDate(getTextualUploadDate());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getThumbnailUrl() throws ParsingException {
|
public List<Image> getThumbnails() throws ParsingException {
|
||||||
if (albumJson.isNull("art_id")) {
|
if (albumJson.isNull("art_id")) {
|
||||||
return "";
|
return List.of();
|
||||||
}
|
}
|
||||||
|
|
||||||
return getImageUrl(albumJson.getLong("art_id"), true);
|
return getImagesFromImageId(albumJson.getLong("art_id"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
@Override
|
@Override
|
||||||
public String getUploaderAvatarUrl() {
|
public List<Image> getUploaderAvatars() {
|
||||||
return document.getElementsByClass("band-photo").stream()
|
return getImagesFromImageUrl(document.getElementsByClass("band-photo")
|
||||||
|
.stream()
|
||||||
.map(element -> element.attr("src"))
|
.map(element -> element.attr("src"))
|
||||||
.findFirst()
|
.findFirst()
|
||||||
.orElse("");
|
.orElse(""));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
|
Loading…
Reference in New Issue
Block a user