mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2025-04-26 23:10:34 +05:30
fix donation link parsing
This commit is contained in:
parent
94d1eb6f32
commit
0501a2f543
@ -15,9 +15,8 @@ public class DonationLinkHelper {
|
|||||||
AMAZON,
|
AMAZON,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static DonationService getDonatoinServiceByLink(String link) throws MalformedURLException {
|
public static DonationService getDonatoinServiceByLink(String link) throws MalformedURLException {
|
||||||
URL url = new URL(link);
|
URL url = new URL(fixLink(link));
|
||||||
switch (url.getHost()) {
|
switch (url.getHost()) {
|
||||||
case "www.patreon.com":
|
case "www.patreon.com":
|
||||||
return DonationService.PATREON;
|
return DonationService.PATREON;
|
||||||
@ -33,11 +32,17 @@ public class DonationLinkHelper {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static AffiliateService getAffiliateServiceByLink(String link) throws MalformedURLException {
|
public static AffiliateService getAffiliateServiceByLink(String link) throws MalformedURLException {
|
||||||
URL url = new URL(link);
|
URL url = new URL(fixLink(link));
|
||||||
switch (url.getHost()) {
|
switch (url.getHost()) {
|
||||||
case "amzn.to": return AffiliateService.AMAZON;
|
case "amzn.to": return AffiliateService.AMAZON;
|
||||||
default: return AffiliateService.NO_AFILIATE;
|
default: return AffiliateService.NO_AFILIATE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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