Skip to content

Commit

Permalink
Rework Bandcamp comments (#613)
Browse files Browse the repository at this point in the history
  • Loading branch information
fynngodau authored Apr 13, 2021
1 parent c14f6db commit 6db4bea
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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() {
Expand Down Expand Up @@ -108,7 +107,7 @@ public InfoItemsPage<StreamInfoItem> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,14 @@ public static JsonObject getArtistDetails(String id) throws ParsingException {
}

/**
* 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 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";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ public List<MetaInfo> getMetaInfo() throws ParsingException {
}

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 InfoItemsSearchCollector collector = new InfoItemsSearchCollector(getServiceId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 6db4bea

Please sign in to comment.