1. add music parser

This commit is contained in:
QAIU
2024-10-21 19:14:29 +08:00
parent 10eec323dd
commit ff569d339c
21 changed files with 689 additions and 62 deletions

View 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();
});
}
}

View 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")));
}
}

View 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));
}
}
}

View 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");
}
}