Code improvements

This commit is contained in:
TobiGr 2021-02-19 13:37:24 +01:00
parent 98268e351c
commit fa61b864f2
4 changed files with 6 additions and 6 deletions

View File

@ -43,7 +43,7 @@ public class BandcampExtractorHelper {
/** /**
* Translate all these parameters together to the URL of the corresponding album or track * Translate all these parameters together to the URL of the corresponding album or track
* using the mobile api * using the mobile API
*/ */
public static String getStreamUrlFromIds(final long bandId, final long itemId, final String itemType) public static String getStreamUrlFromIds(final long bandId, final long itemId, final String itemType)
throws ParsingException { throws ParsingException {
@ -51,7 +51,7 @@ public class BandcampExtractorHelper {
try { try {
final String jsonString = NewPipe.getDownloader().get( final String jsonString = NewPipe.getDownloader().get(
"https://bandcamp.com/api/mobile/22/tralbum_details?band_id=" + bandId "https://bandcamp.com/api/mobile/22/tralbum_details?band_id=" + bandId
+ "&tralbum_id=" + itemId + "&tralbum_type=" + itemType.substring(0, 1)) + "&tralbum_id=" + itemId + "&tralbum_type=" + itemType.charAt(0))
.responseBody(); .responseBody();
return JsonParser.object().from(jsonString).getString("bandcamp_url").replace("http://", "https://"); return JsonParser.object().from(jsonString).getString("bandcamp_url").replace("http://", "https://");
@ -88,7 +88,7 @@ public class BandcampExtractorHelper {
} }
return String.valueOf(result); return result.toString();
} }
/** /**

View File

@ -14,7 +14,7 @@ import static org.schabi.newpipe.extractor.services.bandcamp.extractors.Bandcamp
public class BandcampRadioInfoItemExtractor implements StreamInfoItemExtractor { public class BandcampRadioInfoItemExtractor implements StreamInfoItemExtractor {
private JsonObject show; private final JsonObject show;
public BandcampRadioInfoItemExtractor(final JsonObject radioShow) { public BandcampRadioInfoItemExtractor(final JsonObject radioShow) {
show = radioShow; show = radioShow;

View File

@ -37,7 +37,7 @@ public class BandcampSuggestionExtractor extends SuggestionExtractor {
final JsonArray jsonArray = fuzzyResults.getObject("auto") final JsonArray jsonArray = fuzzyResults.getObject("auto")
.getArray("results"); .getArray("results");
final ArrayList<String> suggestions = new ArrayList<>(); final List<String> suggestions = new ArrayList<>();
for (final Object fuzzyResult : jsonArray) { for (final Object fuzzyResult : jsonArray) {
final String res = ((JsonObject) fuzzyResult).getString("name"); final String res = ((JsonObject) fuzzyResult).getString("name");
@ -52,6 +52,5 @@ public class BandcampSuggestionExtractor extends SuggestionExtractor {
return Collections.emptyList(); return Collections.emptyList();
} }
} }
} }

View File

@ -48,5 +48,6 @@ public class BandcampStreamLinkHandlerFactoryTest {
assertTrue(linkHandler.acceptUrl("http://ZachBenson.Bandcamp.COM/Track/U-I-Tonite/")); assertTrue(linkHandler.acceptUrl("http://ZachBenson.Bandcamp.COM/Track/U-I-Tonite/"));
assertTrue(linkHandler.acceptUrl("https://interovgm.com/track/title")); assertTrue(linkHandler.acceptUrl("https://interovgm.com/track/title"));
assertTrue(linkHandler.acceptUrl("http://bandcamP.com/?show=38")); assertTrue(linkHandler.acceptUrl("http://bandcamP.com/?show=38"));
assertTrue(linkHandler.acceptUrl("https://goodgoodblood-tl.bandcamp.com/track/when-it-all-wakes-up"));
} }
} }