From 6db4bea8ca51ac40a8f831527b274ad50895070e Mon Sep 17 00:00:00 2001 From: fynngodau Date: Tue, 13 Apr 2021 21:10:59 +0200 Subject: [PATCH] Rework Bandcamp comments (#613) --- .../bandcamp/extractors/BandcampChannelExtractor.java | 9 ++++----- .../bandcamp/extractors/BandcampExtractorHelper.java | 10 +++++++--- .../extractors/BandcampRadioInfoItemExtractor.java | 4 ++-- .../extractors/BandcampRadioStreamExtractor.java | 5 ++++- .../bandcamp/extractors/BandcampSearchExtractor.java | 1 - .../bandcamp/extractors/BandcampStreamExtractor.java | 4 +++- .../BandcampStreamInfoItemExtractor.java | 3 +-- 7 files changed, 21 insertions(+), 15 deletions(-) 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 ef2835d26c..3b6adf7b97 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 @@ -38,8 +38,8 @@ public String getAvatarUrl() { @Override public String getBannerUrl() throws ParsingException { /* - * Why does the mobile endpoint not contain the header?? Or at least not the same one? - * Anyway we're back to querying websites + * Mobile API does not return the header or not the correct header. + * Therefore, we need to query the website */ try { final String html = getDownloader() @@ -61,8 +61,7 @@ public String getBannerUrl() throws ParsingException { } /** - * bandcamp stopped providing RSS feeds when appending /feed to any URL - * because too few people used it. + * Bandcamp discontinued their RSS feeds because it hadn't been used enough. */ @Override public String getFeedUrl() { @@ -108,7 +107,7 @@ public InfoItemsPage getInitialPage() throws ParsingException { final JsonArray discography = channelInfo.getArray("discography"); for (int i = 0; i < discography.size(); i++) { - // I define discograph as an item that can appear in a discography + // A discograph is as an item appears in a discography final JsonObject discograph = discography.getObject(i); if (!discograph.getString("item_type").equals("track")) continue; 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 970cddc9ea..69870444e3 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 @@ -71,10 +71,14 @@ public static JsonObject getArtistDetails(String id) throws ParsingException { } /** + * Generate image url from image ID. + *

+ * The appendix "_10" was chosen because it provides images sized 1200x1200. Other integer + * values are possible as well (e.g. 0 is a very large resolution, possibly the original). + * * @param id The image ID - * @param album Whether this is the cover of an album - * @return URL of image with this ID in size 10 which is 1200x1200 (we could also choose size 0 - * but we don't want something as large as 3460x3460 here) + * @param album True if this is the cover of an album or track + * @return URL of image with this ID sized 1200x1200 */ public static String getImageUrl(final long id, final boolean album) { return "https://f4.bcbits.com/img/" + (album ? 'a' : "") + id + "_10.jpg"; 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 2331f258c2..7ecc31844f 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 @@ -24,8 +24,8 @@ public BandcampRadioInfoItemExtractor(final JsonObject radioShow) { @Override public long getDuration() { /* Duration is only present in the more detailed information that has to be queried separately. - * Because the servers would probably not like over 300 queries every time someone opens the kiosk, - * we're just providing 0 here. + * 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 000f884b01..ba24c4a72f 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 @@ -54,7 +54,10 @@ public void onFetchPage(@Nonnull final Downloader downloader) throws IOException @Nonnull @Override public String getName() throws ParsingException { - return showInfo.getString("subtitle"); // "audio_title" is a boring title + /* Select "subtitle" and not "audio_title", as the latter would cause a lot of + * items to show the same title, e.g. "Bandcamp Weekly". + */ + return showInfo.getString("subtitle"); } @Nonnull 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 a0648304cb..12585da39e 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 @@ -48,7 +48,6 @@ public List getMetaInfo() throws ParsingException { } public InfoItemsPage getPage(final Page page) throws IOException, ExtractionException { - // okay apparently this is where we DOWNLOAD the page and then COMMIT its ENTRIES to an INFOITEMPAGE final String html = getDownloader().get(page.getUrl()).responseBody(); final InfoItemsSearchCollector collector = new InfoItemsSearchCollector(getServiceId()); 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 e14a8e917f..e2be2251dd 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 @@ -291,7 +291,9 @@ public String getLicence() { int license = current.getInt("license_type"); - // Tests resulted in this mapping of ints to licence: https://cloud.disroot.org/s/ZTWBxbQ9fKRmRWJ/preview + /* 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) { case 1: diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampStreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampStreamInfoItemExtractor.java index 5f792fdef5..fee96fcd97 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampStreamInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/bandcamp/extractors/streaminfoitem/BandcampStreamInfoItemExtractor.java @@ -8,8 +8,7 @@ import javax.annotation.Nullable; /** - * Implements methods that return a constant value for better readability in - * subclasses. + * Implements methods that return a constant value in subclasses for better readability. */ public abstract class BandcampStreamInfoItemExtractor implements StreamInfoItemExtractor { private final String uploaderUrl;