Fix issue #9 - Convert Twitter media links to Nitter ones.
This commit is contained in:
parent
0230ecc626
commit
cd3f42f47d
|
@ -59,6 +59,7 @@
|
|||
<data android:host="mobile.twitter.com" />
|
||||
<data android:host="www.twitter.com" />
|
||||
<data android:host="twitter.com" />
|
||||
<data android:host="pbs.twimg.com" />
|
||||
|
||||
<!-- YOUTUBE URLs -->
|
||||
<data android:host="www.youtube.com" />
|
||||
|
@ -119,6 +120,7 @@
|
|||
<data android:host="mobile.twitter.com" />
|
||||
<data android:host="www.twitter.com" />
|
||||
<data android:host="twitter.com" />
|
||||
<data android:host="pbs.twimg.com" />
|
||||
|
||||
<!-- YOUTUBE URLs -->
|
||||
<data android:host="www.youtube.com" />
|
||||
|
|
|
@ -69,6 +69,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
"twitter.com",
|
||||
"mobile.twitter.com",
|
||||
"www.twitter.com",
|
||||
"pbs.twimg.com"
|
||||
};
|
||||
public static String[] instagram_domains = {
|
||||
"instagram.com",
|
||||
|
|
|
@ -37,8 +37,10 @@ import android.widget.TextView;
|
|||
import androidx.appcompat.app.AlertDialog;
|
||||
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -471,11 +473,20 @@ public class TransformActivity extends Activity {
|
|||
if (Arrays.asList(twitter_domains).contains(host)) {
|
||||
boolean nitter_enabled = sharedpreferences.getBoolean(SET_NITTER_ENABLED, true);
|
||||
if (nitter_enabled) {
|
||||
Matcher matcher = nitterPattern.matcher(url);
|
||||
while (matcher.find()) {
|
||||
final String nitter_directory = matcher.group(2);
|
||||
String nitterHost = sharedpreferences.getString(MainActivity.SET_NITTER_HOST, MainActivity.DEFAULT_NITTER_HOST).toLowerCase();
|
||||
newUrl = "https://" + nitterHost + nitter_directory;
|
||||
String nitterHost = sharedpreferences.getString(MainActivity.SET_NITTER_HOST, MainActivity.DEFAULT_NITTER_HOST).toLowerCase();
|
||||
assert host != null;
|
||||
if( host.compareTo("pbs.twimg.com") != 0 ) {
|
||||
Matcher matcher = nitterPattern.matcher(url);
|
||||
while (matcher.find()) {
|
||||
final String nitter_directory = matcher.group(2);
|
||||
newUrl = "https://" + nitterHost + nitter_directory;
|
||||
}
|
||||
}else{
|
||||
try {
|
||||
newUrl = "https://" + nitterHost + "/pic/" + URLEncoder.encode(url, "utf-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
newUrl = "https://" + nitterHost + "/pic/" + url;
|
||||
}
|
||||
}
|
||||
return newUrl;
|
||||
} else {
|
||||
|
@ -607,11 +618,21 @@ public class TransformActivity extends Activity {
|
|||
if (Arrays.asList(twitter_domains).contains(host)) {
|
||||
boolean nitter_enabled = sharedpreferences.getBoolean(SET_NITTER_ENABLED, true);
|
||||
if (nitter_enabled) {
|
||||
Matcher matcher = nitterPattern.matcher(url);
|
||||
while (matcher.find()) {
|
||||
final String nitter_directory = matcher.group(2);
|
||||
String nitterHost = sharedpreferences.getString(MainActivity.SET_NITTER_HOST, MainActivity.DEFAULT_NITTER_HOST).toLowerCase();
|
||||
newUrl = "https://" + nitterHost + nitter_directory;
|
||||
|
||||
String nitterHost = sharedpreferences.getString(MainActivity.SET_NITTER_HOST, MainActivity.DEFAULT_NITTER_HOST).toLowerCase();
|
||||
assert host != null;
|
||||
if( host.compareTo("pbs.twimg.com") != 0 ) {
|
||||
Matcher matcher = nitterPattern.matcher(url);
|
||||
while (matcher.find()) {
|
||||
final String nitter_directory = matcher.group(2);
|
||||
newUrl = "https://" + nitterHost + nitter_directory;
|
||||
}
|
||||
}else{
|
||||
try {
|
||||
newUrl = "https://" + nitterHost + "/pic/" + URLEncoder.encode(url, "utf-8");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
newUrl = "https://" + nitterHost + "/pic/" + url;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (Arrays.asList(instagram_domains).contains(host)) {
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
Added:
|
||||
- Allow to redirect Invidious, Nitter and Bibliogram links to the preferred instances
|
||||
- Built-in player that ensures videos are read locally (default disabled)
|
||||
- Built-in player that ensures videos are read locally (default disabled) with download and share buttons
|
||||
- Remove AMP tracking after unshortening URL
|
||||
- Add support for Twitter media to convert them into Nitter links
|
||||
- Unshorten support for buff.ly
|
||||
|
||||
Changed:
|
||||
|
|
Loading…
Reference in New Issue