mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2025-04-27 23:40:36 +05:30
Fix checkstyle issues & more in DonationLinkHelper
Also add comment about the class being unused and replace the fixLink function with Utils.stringToUrl()
This commit is contained in:
parent
bd7b362040
commit
87d2834986
@ -1,9 +1,11 @@
|
|||||||
package org.schabi.newpipe.extractor.utils;
|
package org.schabi.newpipe.extractor.utils;
|
||||||
|
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
|
||||||
|
|
||||||
public class DonationLinkHelper {
|
/**
|
||||||
|
* Note: this class seems unused? Should it be removed?
|
||||||
|
*/
|
||||||
|
public final class DonationLinkHelper {
|
||||||
public enum DonationService {
|
public enum DonationService {
|
||||||
NO_DONATION,
|
NO_DONATION,
|
||||||
PATREON,
|
PATREON,
|
||||||
@ -15,9 +17,12 @@ public class DonationLinkHelper {
|
|||||||
AMAZON,
|
AMAZON,
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DonationService getDonationServiceByLink(String link) throws MalformedURLException {
|
private DonationLinkHelper() {
|
||||||
URL url = new URL(fixLink(link));
|
}
|
||||||
switch (url.getHost()) {
|
|
||||||
|
public static DonationService getDonationServiceByLink(final String link)
|
||||||
|
throws MalformedURLException {
|
||||||
|
switch (Utils.stringToURL(link).getHost()) {
|
||||||
case "www.patreon.com":
|
case "www.patreon.com":
|
||||||
case "patreon.com":
|
case "patreon.com":
|
||||||
return DonationService.PATREON;
|
return DonationService.PATREON;
|
||||||
@ -29,18 +34,11 @@ public class DonationLinkHelper {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static AffiliateService getAffiliateServiceByLink(String link) throws MalformedURLException {
|
public static AffiliateService getAffiliateServiceByLink(final String link)
|
||||||
URL url = new URL(fixLink(link));
|
throws MalformedURLException {
|
||||||
switch (url.getHost()) {
|
if ("amzn.to".equals(Utils.stringToURL(link).getHost())) {
|
||||||
case "amzn.to": return AffiliateService.AMAZON;
|
return AffiliateService.AMAZON;
|
||||||
default: return AffiliateService.NO_AFFILIATE;
|
|
||||||
}
|
}
|
||||||
|
return AffiliateService.NO_AFFILIATE;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String fixLink(String link) {
|
|
||||||
return (link.startsWith("https://") || link.startsWith("http://"))
|
|
||||||
? link
|
|
||||||
: "https://" + link;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user