added vk video opening externally

This commit is contained in:
Vologhat
2022-07-13 13:21:40 +03:00
parent 5b38ea3b3f
commit f5cac67d38
3 changed files with 35 additions and 23 deletions
@@ -51,23 +51,15 @@ public class GCMFix{
public static String requestToken(){
String xappide;
try {
String[] aidarr = {"3974055026275073921", "4418584909973341826", "4585634953328772978"};
int r = new Random().nextInt(aidarr.length - 1);
String aid = "AidLogin " + aidarr[r] + ":" + new String[] {"1932960345884890854", "6594645578425092292", "1792344590975444730"}[r];
String aid = getRandomAid();
String pub2 = genNewKey();
String sig = getSig(pub2);
String xappide2 = null;
byte[] bytes = pair.getPublic().getEncoded();
try {
bytes = MessageDigest.getInstance("SHA1").digest(bytes);
} catch (NoSuchAlgorithmException e) {
xappide2 = "";
}
if (xappide2 == null) {
byte[] bytes = MessageDigest.getInstance("SHA1").digest(pair.getPublic().getEncoded());
bytes[0] = (byte) (((bytes[0] & 15) + 112) & 255);
xappide = Base64.encodeToString(bytes, 2).substring(0, 11);
} else {
xappide = xappide2;
} catch (NoSuchAlgorithmException e) {
xappide = "";
}
AtomicBoolean wait = new AtomicBoolean(false);
StringBuilder sb = new StringBuilder();
@@ -176,6 +168,13 @@ public class GCMFix{
con.getInputStream().close();
}
private static String getRandomAid() {
var arr1 = new String[]{ "3974055026275073921", "4418584909973341826", "4585634953328772978" };
var arr2 = new String[]{ "1932960345884890854", "6594645578425092292", "1792344590975444730" };
int r = new Random().nextInt(2);
return "AidLogin " + arr1[r] + ":" + arr2[r];
}
private static String genNewKey(){
try {
KeyPairGenerator gen = KeyPairGenerator.getInstance("RSA");
@@ -2,6 +2,7 @@ package ru.vtosters.lite.downloaders;
import static ru.vtosters.lite.net.Request.makeRequest;
import static ru.vtosters.lite.utils.Globals.getContext;
import static ru.vtosters.lite.utils.Globals.getIdentifier;
import static ru.vtosters.lite.utils.Globals.getString;
import static ru.vtosters.lite.utils.Globals.getUserToken;
@@ -25,29 +26,37 @@ import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import com.vtosters.lite.R;
import ru.vtosters.lite.utils.ExternalLinkHandler;
import ru.vtosters.lite.utils.Preferences;
public class VideoDownloader{
private static final int action_id = 1488;
private static final int DOWNLOAD_ID = 0;
private static final int OPEN_EXTERNAL_LINK_ID = 1;
public static boolean onClick(int id, VideoFile video, Context ctx){
if (id == action_id) {
if (id == DOWNLOAD_ID) {
downloadVideo(video, ctx);
return true;
} else if (id == OPEN_EXTERNAL_LINK_ID) {
ExternalLinkHandler.parseVideoFile(video, ctx);
}
return false;
}
public static void injectAction(ArrayList<MenuBottomSheetAction> list, VideoFile video){
if (!video.U && !video.I1()) {
MenuBottomSheetAction downloadAction = new MenuBottomSheetAction(
action_id,
com.vtosters.lite.R.drawable.ic_download_outline_24,
com.vtosters.lite.R.string.download,
9
);
list.add(downloadAction);
addAction(list, DOWNLOAD_ID, R.drawable.ic_download_outline_24, R.string.download, 9);
if (Preferences.isEnableExternalOpening())
addAction(list, OPEN_EXTERNAL_LINK_ID, R.drawable.ic_link_outline_28, getIdentifier("interfacevideoext", "string"), 9);
}
}
private static void addAction(List<MenuBottomSheetAction> actions, int... ints) {
actions.add(new MenuBottomSheetAction(ints[0], ints[1], ints[2], ints[3]));
}
public static void downloadVideo(VideoFile videoFile, Context context){
final List<String> list = new ArrayList<>();
final List<String> urls = new ArrayList<>();
@@ -1,6 +1,7 @@
package ru.vtosters.lite.utils;
import static ru.vtosters.lite.utils.Globals.getContext;
import static ru.vtosters.lite.utils.Globals.getCurrentActivity;
import static ru.vtosters.lite.utils.Globals.isEmpty;
import static ru.vtosters.lite.utils.Preferences.isEnableExternalOpening;
@@ -29,8 +30,11 @@ public class ExternalLinkHandler{
);
private static final Map<String, String> qualities = new HashMap<>();
public static boolean parseVideoFile(VideoFile file){
var context = getContext();
public static boolean parseVideoFile(VideoFile file) {
return parseVideoFile(file, getContext());
}
public static boolean parseVideoFile(VideoFile file, Context context) {
if (checkYoutubeLink(file)) {
try {
Intent intent = new Intent(Intent.ACTION_VIEW);