Rework Bandcamp comments (#613)

This commit is contained in:
fynngodau 2021-04-13 21:10:59 +02:00 committed by GitHub
parent c14f6db14a
commit 6db4bea8ca
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 21 additions and 15 deletions

View File

@ -38,8 +38,8 @@ public class BandcampChannelExtractor extends ChannelExtractor {
@Override @Override
public String getBannerUrl() throws ParsingException { public String getBannerUrl() throws ParsingException {
/* /*
* Why does the mobile endpoint not contain the header?? Or at least not the same one? * Mobile API does not return the header or not the correct header.
* Anyway we're back to querying websites * Therefore, we need to query the website
*/ */
try { try {
final String html = getDownloader() final String html = getDownloader()
@ -61,8 +61,7 @@ public class BandcampChannelExtractor extends ChannelExtractor {
} }
/** /**
* bandcamp stopped providing RSS feeds when appending /feed to any URL * Bandcamp discontinued their RSS feeds because it hadn't been used enough.
* because too few people used it.
*/ */
@Override @Override
public String getFeedUrl() { public String getFeedUrl() {
@ -108,7 +107,7 @@ public class BandcampChannelExtractor extends ChannelExtractor {
final JsonArray discography = channelInfo.getArray("discography"); final JsonArray discography = channelInfo.getArray("discography");
for (int i = 0; i < discography.size(); i++) { 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); final JsonObject discograph = discography.getObject(i);
if (!discograph.getString("item_type").equals("track")) continue; if (!discograph.getString("item_type").equals("track")) continue;

View File

@ -71,10 +71,14 @@ public class BandcampExtractorHelper {
} }
/** /**
* Generate image url from image ID.
* <p>
* 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 id The image ID
* @param album Whether this is the cover of an album * @param album True if this is the cover of an album or track
* @return URL of image with this ID in size 10 which is 1200x1200 (we could also choose size 0 * @return URL of image with this ID sized 1200x1200
* but we don't want something as large as 3460x3460 here)
*/ */
public static String getImageUrl(final long id, final boolean album) { public static String getImageUrl(final long id, final boolean album) {
return "https://f4.bcbits.com/img/" + (album ? 'a' : "") + id + "_10.jpg"; return "https://f4.bcbits.com/img/" + (album ? 'a' : "") + id + "_10.jpg";

View File

@ -24,8 +24,8 @@ public class BandcampRadioInfoItemExtractor implements StreamInfoItemExtractor {
@Override @Override
public long getDuration() { public long getDuration() {
/* Duration is only present in the more detailed information that has to be queried separately. /* 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, * Therefore, over 300 queries would be needed every time the kiosk is opened if we were to
* we're just providing 0 here. * display the real value.
*/ */
//return query(show.getInt("id")).getLong("audio_duration"); //return query(show.getInt("id")).getLong("audio_duration");
return 0; return 0;

View File

@ -54,7 +54,10 @@ public class BandcampRadioStreamExtractor extends BandcampStreamExtractor {
@Nonnull @Nonnull
@Override @Override
public String getName() throws ParsingException { 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 @Nonnull

View File

@ -48,7 +48,6 @@ public class BandcampSearchExtractor extends SearchExtractor {
} }
public InfoItemsPage<InfoItem> getPage(final Page page) throws IOException, ExtractionException { public InfoItemsPage<InfoItem> 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 String html = getDownloader().get(page.getUrl()).responseBody();
final InfoItemsSearchCollector collector = new InfoItemsSearchCollector(getServiceId()); final InfoItemsSearchCollector collector = new InfoItemsSearchCollector(getServiceId());

View File

@ -291,7 +291,9 @@ public class BandcampStreamExtractor extends StreamExtractor {
int license = current.getInt("license_type"); 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) { switch (license) {
case 1: case 1:

View File

@ -8,8 +8,7 @@ import org.schabi.newpipe.extractor.stream.StreamType;
import javax.annotation.Nullable; import javax.annotation.Nullable;
/** /**
* Implements methods that return a constant value for better readability in * Implements methods that return a constant value in subclasses for better readability.
* subclasses.
*/ */
public abstract class BandcampStreamInfoItemExtractor implements StreamInfoItemExtractor { public abstract class BandcampStreamInfoItemExtractor implements StreamInfoItemExtractor {
private final String uploaderUrl; private final String uploaderUrl;