mirror of
https://github.com/qaiu/netdisk-fast-download.git
synced 2025-12-17 21:03:03 +00:00
1. add music parser
This commit is contained in:
44
parser/src/test/java/cn/qaiu/parser/WebClientExample.java
Normal file
44
parser/src/test/java/cn/qaiu/parser/WebClientExample.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package cn.qaiu.parser;
|
||||
|
||||
import io.vertx.core.MultiMap;
|
||||
import io.vertx.core.Vertx;
|
||||
import io.vertx.core.buffer.Buffer;
|
||||
import io.vertx.core.http.HttpHeaders;
|
||||
import io.vertx.core.json.JsonObject;
|
||||
import io.vertx.ext.web.client.HttpResponse;
|
||||
import io.vertx.ext.web.client.WebClient;
|
||||
import io.vertx.ext.web.multipart.MultipartForm;
|
||||
import io.vertx.ext.web.multipart.impl.MultipartFormImpl;
|
||||
|
||||
public class WebClientExample {
|
||||
|
||||
public static void main(String[] args) {
|
||||
Vertx vertx = Vertx.vertx();
|
||||
WebClient client = WebClient.create(vertx);
|
||||
|
||||
MultipartForm form = new MultipartFormImpl()
|
||||
.attribute("email", "")
|
||||
.attribute("password", "");
|
||||
|
||||
client.postAbs("https://cowtransfer.com/api/user/emaillogin")
|
||||
.putHeader(HttpHeaders.CONTENT_TYPE.toString(), "multipart/form-data; boundary=WebAppBoundary")
|
||||
.sendMultipartForm(form, ar -> {
|
||||
if (ar.succeeded()) {
|
||||
HttpResponse<Buffer> response = ar.result();
|
||||
System.out.println("Response status code: " + response.statusCode());
|
||||
|
||||
// Print all response headers
|
||||
MultiMap headers = response.headers();
|
||||
headers.names().forEach(name -> {
|
||||
System.out.println(name + ": " + headers.getAll(name));
|
||||
});
|
||||
|
||||
JsonObject responseBody = response.bodyAsJsonObject();
|
||||
System.out.println("Response body: " + responseBody.encodePrettily());
|
||||
} else {
|
||||
System.out.println("Something went wrong: " + ar.cause().getMessage());
|
||||
}
|
||||
vertx.close();
|
||||
});
|
||||
}
|
||||
}
|
||||
92
parser/src/test/java/cn/qaiu/util/TestAESUtil.java
Normal file
92
parser/src/test/java/cn/qaiu/util/TestAESUtil.java
Normal file
@@ -0,0 +1,92 @@
|
||||
package cn.qaiu.util;
|
||||
|
||||
import cn.qaiu.util.AESUtils;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import javax.crypto.BadPaddingException;
|
||||
import javax.crypto.IllegalBlockSizeException;
|
||||
import javax.crypto.NoSuchPaddingException;
|
||||
import java.security.InvalidKeyException;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.HexFormat;
|
||||
|
||||
public class TestAESUtil {
|
||||
|
||||
// 1686215935703
|
||||
// B4C5B9833113ACA41F16AABADE17349C
|
||||
@Test
|
||||
public void decode() throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException,
|
||||
BadPaddingException, InvalidKeyException {
|
||||
String hex = AESUtils.encryptHexByAES("1686215935703", AESUtils.CIPHER_AES2);
|
||||
Assert.assertEquals("B4C5B9833113ACA41F16AABADE17349C", hex.toUpperCase());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void encode() throws IllegalBlockSizeException, NoSuchPaddingException, BadPaddingException,
|
||||
NoSuchAlgorithmException, InvalidKeyException {
|
||||
String source = AESUtils.decryptByHexAES("B4C5B9833113ACA41F16AABADE17349C", AESUtils.CIPHER_AES2);
|
||||
Assert.assertEquals("1686215935703", source);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void toHex() {
|
||||
byte[] d234EF67A1s = HexFormat.of().parseHex("D234EF67A1");
|
||||
Assert.assertArrayEquals(new byte[]{(byte) 0xd2, (byte) 0x34, (byte) 0xef, (byte) 0x67, (byte) 0xa1},
|
||||
d234EF67A1s);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void base64AES() throws NoSuchAlgorithmException {
|
||||
System.out.println(HexFormat.of().formatHex(AESUtils.createKeyString(AESUtils.KEY_SIZE_128_LENGTH).getEncoded()));
|
||||
System.out.println(HexFormat.of().formatHex(AESUtils.createKeyString(AESUtils.KEY_SIZE_192_LENGTH).getEncoded()));
|
||||
System.out.println(HexFormat.of().formatHex(AESUtils.createKeyString(AESUtils.KEY_SIZE_256_LENGTH).getEncoded()));
|
||||
|
||||
// TODO Base64-AES
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testIdDecode() {
|
||||
Assert.assertEquals(146731, AESUtils.idEncrypt("7jy0zlv"));
|
||||
}
|
||||
|
||||
// 蓝奏优享
|
||||
@Test
|
||||
public void testIzIdDecode() {
|
||||
Assert.assertEquals(26216, AESUtils.idEncryptIz("lGFndCM"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test00() throws IllegalBlockSizeException, NoSuchPaddingException, BadPaddingException,
|
||||
NoSuchAlgorithmException, InvalidKeyException {
|
||||
System.out.println(AESUtils.decryptByBase64AES(AESUtils.CIPHER_AES2, AESUtils.CIPHER_AES));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testTs() {
|
||||
System.out.println(System.currentTimeMillis());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testRandom() {
|
||||
System.out.println(AESUtils.getRandomString());
|
||||
System.out.println(AESUtils.getRandomString());
|
||||
System.out.println(AESUtils.getRandomString());
|
||||
System.out.println(AESUtils.getRandomString());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testKeyAuth(){
|
||||
System.out.println(AESUtils.getAuthKey("/a/api/share/download/info"));
|
||||
System.out.println(AESUtils.getAuthKey("/a/api/share/download/info"));
|
||||
System.out.println(AESUtils.getAuthKey("/b/api/share/get"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAES2() throws NoSuchPaddingException, IllegalBlockSizeException, NoSuchAlgorithmException,
|
||||
BadPaddingException, InvalidKeyException {
|
||||
System.out.println(AESUtils.encryptBase64ByAES("AAAAA", "123123"));
|
||||
System.out.println(AESUtils.encryptBase64ByAES("AAAAA", AESUtils.generateKey("123123")));
|
||||
}
|
||||
}
|
||||
24
parser/src/test/java/cn/qaiu/util/TestRegex.java
Normal file
24
parser/src/test/java/cn/qaiu/util/TestRegex.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package cn.qaiu.util;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class TestRegex {
|
||||
|
||||
@Test
|
||||
public void regexYFC() {
|
||||
String html = """
|
||||
<input type="hidden" id="typed_id" value="file_559003251828">
|
||||
<input type="hidden" id="share_link_token" value="9cbe4b73521ba4d65a8cd38a8c">
|
||||
""";
|
||||
|
||||
Pattern compile = Pattern.compile("id=\"typed_id\"\\s+value=\"file_(\\d+)\"");
|
||||
Matcher matcher = compile.matcher(html);
|
||||
if (matcher.find()) {
|
||||
System.out.println(matcher.group(0));
|
||||
System.out.println(matcher.group(1));
|
||||
}
|
||||
}
|
||||
}
|
||||
19
parser/src/test/java/cn/qaiu/util/URLUtilTest.java
Normal file
19
parser/src/test/java/cn/qaiu/util/URLUtilTest.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package cn.qaiu.util;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
public class URLUtilTest {
|
||||
|
||||
@Test
|
||||
public void getParam() {
|
||||
|
||||
URLUtil util = URLUtil.from("https://i.y.qq.com/v8/playsong.html?ADTAG=cbshare&_wv=1&appshare=android_qq" +
|
||||
"&appsongtype=1&appversion=13100008&channelId=10036163&hosteuin=7iosow-s7enz&openinqqmusic=1&platform" +
|
||||
"=11&songmid=000XjcLg0fbRjv&type=0");
|
||||
Assert.assertEquals(util.getParam("songmid"), "000XjcLg0fbRjv");
|
||||
Assert.assertEquals(util.getParam("type"), "0");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user