MD5 校验值:61e58c10a11e4adec8760ee3854e996a
BandcampExtractorHelper.java 文件包含反编译后的源代码,请注意,该内容仅供学习和参考使用,不得用于非法用途。
package org.schabi.newpipe.extractor.services.bandcamp.extractors; import S5.l; import S5.p; import V1.z; import Z5.a; import Z5.b; import a4.c; import a4.d; import a4.e; import android.support.v4.media.session.m; import f0.AbstractC1761a; import java.io.IOException; import java.nio.charset.StandardCharsets; import java.time.DateTimeException; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Objects; import java.util.stream.Collector; import java.util.stream.Collectors; import java.util.stream.Stream; import org.apache.http.HttpStatus; import org.schabi.newpipe.extractor.Image; import org.schabi.newpipe.extractor.NewPipe; import org.schabi.newpipe.extractor.downloader.Downloader; import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ReCaptchaException; import org.schabi.newpipe.extractor.localization.DateWrapper; import org.schabi.newpipe.extractor.utils.ImageSuffix; import org.schabi.newpipe.extractor.utils.Utils; import p4.r; import v0.AbstractC2363a; public final class BandcampExtractorHelper { public static final String BASE_API_URL = "https://bandcamp.com/api"; public static final String BASE_URL = "https://bandcamp.com"; private static final String IMAGES_DOMAIN_AND_PATH = "https://f4.bcbits.com/img/"; private static final String IMAGE_URL_APPENDIX_AND_EXTENSION_REGEX = "_\\d+\\.\\w+"; private static final List<ImageSuffix> IMAGE_URL_SUFFIXES_AND_RESOLUTIONS; static { Image.ResolutionLevel resolutionLevel = Image.ResolutionLevel.HIGH; ImageSuffix imageSuffix = new ImageSuffix("10.jpg", -1, 1200, resolutionLevel); Image.ResolutionLevel resolutionLevel2 = Image.ResolutionLevel.LOW; ImageSuffix imageSuffix2 = new ImageSuffix("101.jpg", 90, -1, resolutionLevel2); Image.ResolutionLevel resolutionLevel3 = Image.ResolutionLevel.MEDIUM; ImageSuffix[] imageSuffixArr = {imageSuffix, imageSuffix2, new ImageSuffix("170.jpg", HttpStatus.SC_UNPROCESSABLE_ENTITY, -1, resolutionLevel3), new ImageSuffix("171.jpg", 646, -1, resolutionLevel3), new ImageSuffix("20.jpg", -1, 1024, resolutionLevel), new ImageSuffix("200.jpg", HttpStatus.SC_METHOD_FAILURE, -1, resolutionLevel3), new ImageSuffix("201.jpg", 280, -1, resolutionLevel3), new ImageSuffix("202.jpg", 140, -1, resolutionLevel2), new ImageSuffix("204.jpg", 360, -1, resolutionLevel3), new ImageSuffix("205.jpg", 240, -1, resolutionLevel3), new ImageSuffix("206.jpg", 180, -1, resolutionLevel3), new ImageSuffix("207.jpg", 120, -1, resolutionLevel2), new ImageSuffix("43.jpg", 100, -1, resolutionLevel2), new ImageSuffix("44.jpg", 200, -1, resolutionLevel3)}; ArrayList arrayList = new ArrayList(14); for (int i5 = 0; i5 < 14; i5++) { ImageSuffix imageSuffix3 = imageSuffixArr[i5]; Objects.requireNonNull(imageSuffix3); arrayList.add(imageSuffix3); } IMAGE_URL_SUFFIXES_AND_RESOLUTIONS = Collections.unmodifiableList(arrayList); } private BandcampExtractorHelper() { } public static String a(p pVar) { return pVar.c("src"); } public static Stream b(p pVar) { return lambda$getImagesFromSearchResult$0(pVar); } public static c getArtistDetails(String str) { try { m h6 = z.h(); Downloader downloader = NewPipe.getDownloader(); Map<String, List<String>> emptyMap = Collections.emptyMap(); e eVar = new e(); eVar.i(); eVar.r("band_id", str); eVar.f(); return (c) h6.H(downloader.postWithContentTypeJson("https://bandcamp.com/api/mobile/22/band_details", emptyMap, eVar.d().getBytes(StandardCharsets.UTF_8)).responseBody()); } catch (d | IOException | ReCaptchaException e) { throw new ParsingException("Could not download band details", e); } } public static String getImageUrl(long j5, boolean z6) { return IMAGES_DOMAIN_AND_PATH + (z6 ? 'a' : "") + j5 + "_10.jpg"; } private static List<Image> getImagesFromImageBaseUrl(String str) { Collector unmodifiableList; Stream<R> map = IMAGE_URL_SUFFIXES_AND_RESOLUTIONS.stream().map(new b(str, 3)); unmodifiableList = Collectors.toUnmodifiableList(); return (List) map.collect(unmodifiableList); } public static List<Image> getImagesFromImageId(long j5, boolean z6) { Object obj; if (j5 == 0) { return Collections.emptyList(); } if (z6) { obj = 'a'; } else { obj = ""; } return getImagesFromImageBaseUrl(IMAGES_DOMAIN_AND_PATH + obj + j5 + "_"); } public static List<Image> getImagesFromImageUrl(String str) { if (Utils.isNullOrEmpty(str)) { return Collections.emptyList(); } return getImagesFromImageBaseUrl(str.replaceFirst(IMAGE_URL_APPENDIX_AND_EXTENSION_REGEX, "_")); } public static List<Image> getImagesFromSearchResult(p pVar) { return getImagesFromImageUrl((String) pVar.J("art").stream().flatMap(new l(19)).map(new l(20)).filter(new a(8)).findFirst().orElse("")); } public static String getStreamUrlFromIds(long j5, long j6, String str) { try { return Utils.replaceHttpWithHttps(((c) z.h().H(NewPipe.getDownloader().get("https://bandcamp.com/api/mobile/22/tralbum_details?band_id=" + j5 + "&tralbum_id=" + j6 + "&tralbum_type=" + str.charAt(0)).responseBody())).h("bandcamp_url", null)); } catch (d | IOException | ReCaptchaException e) { throw new ParsingException("Ids could not be translated to URL", e); } } public static boolean isArtistDomain(String str) { if (str.toLowerCase().matches("https?://.+\\.bandcamp\\.com(/.*)?")) { return true; } if (str.toLowerCase().matches("https?://bandcamp\\.com(/.*)?")) { return false; } try { return ((p) ((p) AbstractC2363a.w(NewPipe.getDownloader().get(Utils.replaceHttpWithHttps(str)).responseBody()).J("cart-wrapper").get(0)).K("a").get(0)).c("href").equals("https://bandcamp.com/cart"); } catch (IOException | ReCaptchaException unused) { throw new ParsingException("Could not determine whether URL is custom domain (not available? network error?)"); } catch (IndexOutOfBoundsException | NullPointerException unused2) { return false; } } public static boolean isRadioUrl(String str) { return str.toLowerCase().matches("https?://bandcamp\\.com/\\?show=\\d+"); } public static Image lambda$getImagesFromImageBaseUrl$3(String str, ImageSuffix imageSuffix) { return new Image(r.h(str, imageSuffix.getSuffix()), imageSuffix.getHeight(), imageSuffix.getWidth(), imageSuffix.getResolutionLevel()); } public static Stream lambda$getImagesFromSearchResult$0(p pVar) { return pVar.K("img").stream(); } public static boolean lambda$getImagesFromSearchResult$2(String str) { return !Utils.isNullOrEmpty(str); } public static DateWrapper parseDate(String str) { try { return new DateWrapper(ZonedDateTime.parse(str, DateTimeFormatter.ofPattern("dd MMM yyyy HH:mm:ss zzz", Locale.ENGLISH)).toOffsetDateTime(), false); } catch (DateTimeException e) { throw new ParsingException(AbstractC1761a.h("Could not parse date '", str, "'"), e); } } }