Detects Twitter URLs (test1) + improve invidous detection with residual parameters
This commit is contained in:
parent
ad5d00b4d8
commit
16568d9444
|
@ -629,13 +629,24 @@ public class Status implements Parcelable {
|
||||||
boolean invidious = sharedpreferences.getBoolean(Helper.SET_INVIDIOUS, false);
|
boolean invidious = sharedpreferences.getBoolean(Helper.SET_INVIDIOUS, false);
|
||||||
if (invidious) {
|
if (invidious) {
|
||||||
while (matcher.find()) {
|
while (matcher.find()) {
|
||||||
final String youtubeId = matcher.group(3);
|
final String youtubeId = matcher.group(4);
|
||||||
String invidiousHost = sharedpreferences.getString(Helper.SET_INVIDIOUS_HOST, Helper.DEFAULT_INVIDIOUS_HOST).toLowerCase();
|
String invidiousHost = sharedpreferences.getString(Helper.SET_INVIDIOUS_HOST, Helper.DEFAULT_INVIDIOUS_HOST).toLowerCase();
|
||||||
content = content.replaceAll("https://"+Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://"+invidiousHost + "/watch?v=" + youtubeId+"&local=true"));
|
content = content.replaceAll("https://"+Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://"+invidiousHost + "/watch?v=" + youtubeId+"&local=true"));
|
||||||
content = content.replaceAll(">"+Pattern.quote(matcher.group()), Matcher.quoteReplacement(">"+invidiousHost + "/watch?v=" + youtubeId+"&local=true"));
|
content = content.replaceAll(">"+Pattern.quote(matcher.group()), Matcher.quoteReplacement(">"+invidiousHost + "/watch?v=" + youtubeId+"&local=true"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
matcher = Helper.nitterPattern.matcher(content);
|
||||||
|
boolean nitter = sharedpreferences.getBoolean(Helper.SET_NITTER, false);
|
||||||
|
if (nitter) {
|
||||||
|
while (matcher.find()) {
|
||||||
|
final String nitter_directory = matcher.group(2);
|
||||||
|
String nitterHost = sharedpreferences.getString(Helper.SET_NITTER_HOST, Helper.DEFAULT_NITTER_HOST).toLowerCase();
|
||||||
|
content = content.replaceAll("https://"+Pattern.quote(matcher.group()), Matcher.quoteReplacement("https://"+nitterHost + nitter_directory));
|
||||||
|
content = content.replaceAll(">"+Pattern.quote(matcher.group()), Matcher.quoteReplacement(">"+nitterHost + nitter_directory));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Pattern aLink = Pattern.compile("<a((?!href).)*href=\"([^\"]*)\"[^>]*(((?!<\\/a).)*)<\\/a>");
|
Pattern aLink = Pattern.compile("<a((?!href).)*href=\"([^\"]*)\"[^>]*(((?!<\\/a).)*)<\\/a>");
|
||||||
Matcher matcherALink = aLink.matcher(content);
|
Matcher matcherALink = aLink.matcher(content);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
|
|
|
@ -437,9 +437,12 @@ public class Helper {
|
||||||
|
|
||||||
public static final String SET_INVIDIOUS = "set_invidious";
|
public static final String SET_INVIDIOUS = "set_invidious";
|
||||||
public static final String SET_INVIDIOUS_HOST = "set_invidious_host";
|
public static final String SET_INVIDIOUS_HOST = "set_invidious_host";
|
||||||
|
public static final String DEFAULT_INVIDIOUS_HOST = "invidio.us";
|
||||||
|
|
||||||
public static final String SET_NITTER = "set_nitter";
|
public static final String SET_NITTER = "set_nitter";
|
||||||
public static final String SET_NITTER_HOST = "set_nitter_host";
|
public static final String SET_NITTER_HOST = "set_nitter_host";
|
||||||
public static final String DEFAULT_INVIDIOUS_HOST = "invidio.us";
|
public static final String DEFAULT_NITTER_HOST = "nitter.net";
|
||||||
|
|
||||||
public static final String SET_NOTIF_VALIDATION = "set_share_validation";
|
public static final String SET_NOTIF_VALIDATION = "set_share_validation";
|
||||||
public static final String SET_NOTIF_VALIDATION_FAV = "set_share_validation_fav";
|
public static final String SET_NOTIF_VALIDATION_FAV = "set_share_validation_fav";
|
||||||
public static final String SET_WIFI_ONLY = "set_wifi_only";
|
public static final String SET_WIFI_ONLY = "set_wifi_only";
|
||||||
|
@ -525,7 +528,8 @@ public class Helper {
|
||||||
public static final Pattern hashtagPattern = Pattern.compile("(#[\\w_A-zÀ-ÿ]+)");
|
public static final Pattern hashtagPattern = Pattern.compile("(#[\\w_A-zÀ-ÿ]+)");
|
||||||
public static final Pattern groupPattern = Pattern.compile("(\\![\\w_]+(\\s|$))");
|
public static final Pattern groupPattern = Pattern.compile("(\\![\\w_]+(\\s|$))");
|
||||||
public static final Pattern twitterPattern = Pattern.compile("((@[\\w]+)@twitter\\.com)");
|
public static final Pattern twitterPattern = Pattern.compile("((@[\\w]+)@twitter\\.com)");
|
||||||
public static final Pattern youtubePattern = Pattern.compile("(m\\.|www\\.)?youtu(\\.be/|be\\.com/watch\\?v=)([\\w-]+)");
|
public static final Pattern youtubePattern = Pattern.compile("(m\\.|www\\.)?youtu(\\.be/|be\\.com/watch\\?((?!v=).)*v=)([\\w-]+)");
|
||||||
|
public static final Pattern nitterPattern = Pattern.compile("(mobile\\.|www\\.)?twitter.com([\\w-/]+)");
|
||||||
public static final Pattern youtubeOembedPattern = Pattern.compile("(www\\.)?youtube\\.com\\/embed\\/(\\w+)\\?feature=oembed");
|
public static final Pattern youtubeOembedPattern = Pattern.compile("(www\\.)?youtube\\.com\\/embed\\/(\\w+)\\?feature=oembed");
|
||||||
private static final Pattern mentionPattern = Pattern.compile("(@[\\w_]+(\\s|$))");
|
private static final Pattern mentionPattern = Pattern.compile("(@[\\w_]+(\\s|$))");
|
||||||
private static final Pattern mentionLongPattern = Pattern.compile("(@[\\w_-]+@[a-z0-9.\\-]+[.][a-z]{2,10})");
|
private static final Pattern mentionLongPattern = Pattern.compile("(@[\\w_-]+@[a-z0-9.\\-]+[.][a-z]{2,10})");
|
||||||
|
|
Loading…
Reference in New Issue