diff --git a/README.md b/README.md index 94695d144cc7ff612449339ea112f95ff0cbb3ad..fa88fbfb8e2f33680c7cf63899d9474b9bffbe90 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ 1. xxxx 2. xxxx 3. xxxx + mvn clean install org.apache.maven.plugins:maven-deploy-plugin:2.8:deploy -DskipTests #### 使用说明 diff --git a/pom.xml b/pom.xml index 91445a591de4a7df20e2fd3d576b7a054a93f438..5fdb31762b9072ae7072a3f0fe9195187061f8db 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.qiwenshare qiwenshare - 1.2.1 + 1.2.2 com.qiwenshare @@ -51,9 +51,10 @@ tomcat-embed-core + - commons-fileupload - commons-fileupload + commons-io + commons-io @@ -81,6 +82,7 @@ net.sourceforge.htmlunit htmlunit + 2.62.0 org.bytedeco @@ -101,6 +103,14 @@ ${spring-security.version} compile + + com.github.stuxuhai + jpinyin + + + cn.hutool + hutool-core + \ No newline at end of file diff --git a/src/main/java/com/qiwenshare/common/operation/CrawHtmlOperation.java b/src/main/java/com/qiwenshare/common/operation/CrawHtmlOperation.java index fd9a43753f575cab7f8470e96d614d196ec52735..56fea817751cc4fb89bbc0f3ee2a765f363573d5 100644 --- a/src/main/java/com/qiwenshare/common/operation/CrawHtmlOperation.java +++ b/src/main/java/com/qiwenshare/common/operation/CrawHtmlOperation.java @@ -35,4 +35,8 @@ public class CrawHtmlOperation { pageXml = StringUtil.replaceBlank(pageXml); return pageXml; } + + public static void main(String[] args) { + System.out.println(crawHtmlByUrl("https://www.baidu.com/")); + } } diff --git a/src/main/java/com/qiwenshare/common/operation/FileOperation.java b/src/main/java/com/qiwenshare/common/operation/FileOperation.java index 95186f31d67a11590e15e2de0696daf91582316e..04d1faff806ceb36291b736a0a8f148fd30986b3 100644 --- a/src/main/java/com/qiwenshare/common/operation/FileOperation.java +++ b/src/main/java/com/qiwenshare/common/operation/FileOperation.java @@ -224,7 +224,7 @@ public class FileOperation { } archive.extract(in, false, new ExtractCallback(archive,destDirPath)); File destFile = new File(destDirPath); - Collection files = FileUtils.listFilesAndDirs(destFile, new IOFileFilter() { + Collection files = FileUtils.listFiles(destFile, new IOFileFilter() { @Override public boolean accept(File file) { return true; diff --git a/src/main/java/com/qiwenshare/common/util/MusicUtils.java b/src/main/java/com/qiwenshare/common/util/MusicUtils.java new file mode 100644 index 0000000000000000000000000000000000000000..c29aefbbfd5b48f963e97ad118f521ef9dd2bd90 --- /dev/null +++ b/src/main/java/com/qiwenshare/common/util/MusicUtils.java @@ -0,0 +1,138 @@ +package com.qiwenshare.common.util; + +import com.alibaba.fastjson2.JSON; +import com.github.stuxuhai.jpinyin.PinyinException; +import com.github.stuxuhai.jpinyin.PinyinFormat; +import com.github.stuxuhai.jpinyin.PinyinHelper; +import org.apache.commons.lang3.StringUtils; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class MusicUtils { + + + public static String getLyc(String singerName, String mp3Name, String albumName) { + Map headMap = new HashMap<>(); + headMap.put("Referer", "https://y.qq.com/"); + String singer = ""; + String id = ""; + String mid = ""; + boolean isMatch = false; + if (StringUtils.isNotEmpty(albumName)) { + String s = HttpsUtils.doGetString("https://c.y.qq.com/splcloud/fcgi-bin/smartbox_new.fcg?_=1655481018175&cv=4747474&ct=24&format=json&inCharset=utf-8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=1&uin=0&g_tk_new_20200303=5381&g_tk=5381&hostUin=0&is_xml=0&key=" + albumName, headMap); + Map map = JSON.parseObject(s, Map.class); + Map data = (Map) map.get("data"); + Map album = (Map) data.get("album"); + List albumlist = (List) album.get("itemlist"); + for (Map item : albumlist) { + String albumItem = (String) item.get("name"); + singer = (String) item.get("singer"); + if (albumName.equals(albumItem) && singerName.equals(singer)) { + mid = (String) item.get("mid"); + } + } + if (StringUtils.isNotEmpty(mid)) { + s = HttpsUtils.doGetString("https://c.y.qq.com/v8/fcg-bin/musicmall.fcg?_=1655481477830&cv=4747474&ct=24&format=json&inCharset=utf-8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=1&uin=0&g_tk_new_20200303=5381&g_tk=5381&cmd=get_album_buy_page&albummid=" + mid + "&albumid=0", headMap); + map = JSON.parseObject(s, Map.class); + data = (Map) map.get("data"); + List songlist = (List) data.get("songlist"); + for (Map item : songlist) { + String songname = (String) item.get("songname"); + String songorig = (String) item.get("songorig"); + + if (mp3Name.equals(songname) || mp3Name.equals(songorig)) { + mid = (String) item.get("songmid"); + id = String.valueOf(item.get("songid")); + isMatch = true; + } + } + } + + } + if (!isMatch) { + String s = HttpsUtils.doGetString("https://c.y.qq.com/splcloud/fcgi-bin/smartbox_new.fcg?_=1651992748984&cv=4747474&ct=24&format=json&inCharset=utf-8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=1&uin=0&g_tk_new_20200303=5381&g_tk=5381&hostUin=0&is_xml=0&key=" + mp3Name.replaceAll(" ", ""), headMap); + Map map = JSON.parseObject(s, Map.class); + Map data = (Map) map.get("data"); + Map song = (Map) data.get("song"); + List list = (List) song.get("itemlist"); + + for (Map item : list) { + singer = (String) item.get("singer"); + id = (String) item.get("id"); + mid = (String) item.get("mid"); + try { + String singer1 = PinyinHelper.convertToPinyinString(singerName.replaceAll(" ", ""), ",", PinyinFormat.WITHOUT_TONE); + String singer2 = PinyinHelper.convertToPinyinString(singer.replaceAll(" ", ""), ",", PinyinFormat.WITHOUT_TONE); + if (singer1.contains(singer2) || singer2.contains(singer1)) { + isMatch = true; + break; + } + } catch (PinyinException e) { + e.printStackTrace(); + } + + } + + if (!isMatch) { + for (Map item : list) { + singer = (String) item.get("singer"); + id = String.valueOf(item.get("id")); + mid = String.valueOf(item.get("mid")); + try { + String singer2 = PinyinHelper.convertToPinyinString(singer.replaceAll(" ", ""), ",", PinyinFormat.WITHOUT_TONE); + String singer3 = PinyinHelper.convertToPinyinString(mp3Name.replaceAll(" ", ""), ",", PinyinFormat.WITHOUT_TONE); + if (singer3.contains(singer2) || singer2.contains(singer3)) { + isMatch = true; + break; + } + } catch (PinyinException e) { + e.printStackTrace(); + } + + } + } + + if (!isMatch) { + Map album = (Map) data.get("album"); + List albumlist = (List) album.get("itemlist"); + for (Map item : albumlist) { + String mp3name = (String) item.get("name"); + singer = (String) item.get("singer"); + id = (String) item.get("id"); + mid = (String) item.get("mid"); + if (singer.equals(singerName) && mp3Name.equals(mp3name)) { + String res = HttpsUtils.doGetString("https://c.y.qq.com/v8/fcg-bin/musicmall.fcg?_=1652026128283&cv=4747474&ct=24&format=json&inCharset=utf-8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=1&uin=0&g_tk_new_20200303=5381&g_tk=5381&cmd=get_album_buy_page&albummid=" + mid + "&albumid=0", headMap); + Map map1 = JSON.parseObject(res, Map.class); + Map data1 = (Map) map1.get("data"); + List list1 = (List) data1.get("songlist"); + for (Map item1 : list1) { + if (mp3Name.equals((String) item1.get("songname"))) { + id = String.valueOf(item1.get("songid")); + mid = String.valueOf(item1.get("songmid")); + isMatch = true; + break; + } + } + if (isMatch) { + break; + } + + } + } + } + } + String s1 = HttpsUtils.doGetString("https://c.y.qq.com/lyric/fcgi-bin/fcg_query_lyric_new.fcg?_=1651993218842&cv=4747474&ct=24&format=json&inCharset=utf-8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=1&uin=0&g_tk_new_20200303=5381&g_tk=5381&loginUin=0&" + + "songmid=" + mid + "&" + + "musicid=" + id, headMap); + Map map1 = JSON.parseObject(s1, Map.class); + return (String) map1.get("lyric"); + } + +// public static void main(String[] args) { +// String lyc = getLyc("周杰伦", "以父之名", "周杰伦地表最强世界巡回演唱会"); +// String decodeStr = Base64.decodeStr(lyc); +// System.out.println(decodeStr); +// } +} diff --git a/src/main/java/com/qiwenshare/common/util/math/ArithHelper.java b/src/main/java/com/qiwenshare/common/util/math/ArithHelper.java index c04fe43e4584401e33d3fe193e4319877de24bdb..938d427840792814cd849c28888c0c7ce5520d18 100644 --- a/src/main/java/com/qiwenshare/common/util/math/ArithHelper.java +++ b/src/main/java/com/qiwenshare/common/util/math/ArithHelper.java @@ -1,5 +1,7 @@ package com.qiwenshare.common.util.math; +import java.math.RoundingMode; + public class ArithHelper { // 默认除法运算精度 @@ -88,7 +90,7 @@ public class ArithHelper { public static double div(String v1, String v2) { java.math.BigDecimal b1 = new java.math.BigDecimal(v1); java.math.BigDecimal b2 = new java.math.BigDecimal(v2); - return b1.divide(b2, DEF_DIV_SCALE, java.math.BigDecimal.ROUND_HALF_UP).doubleValue(); + return b1.divide(b2, DEF_DIV_SCALE, RoundingMode.HALF_UP).doubleValue(); } /** @@ -106,7 +108,7 @@ public class ArithHelper { } java.math.BigDecimal b1 = new java.math.BigDecimal(Double.toString(v1)); java.math.BigDecimal b2 = new java.math.BigDecimal(Double.toString(v2)); - return b1.divide(b2, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue(); + return b1.divide(b2, scale, RoundingMode.HALF_UP).doubleValue(); } /** @@ -123,7 +125,7 @@ public class ArithHelper { } java.math.BigDecimal b = new java.math.BigDecimal(Double.toString(v)); java.math.BigDecimal one = new java.math.BigDecimal("1"); - return b.divide(one, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue(); + return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue(); } public static double round(String v, int scale) { @@ -132,6 +134,6 @@ public class ArithHelper { } java.math.BigDecimal b = new java.math.BigDecimal(v); java.math.BigDecimal one = new java.math.BigDecimal("1"); - return b.divide(one, scale, java.math.BigDecimal.ROUND_HALF_UP).doubleValue(); + return b.divide(one, scale, RoundingMode.HALF_UP).doubleValue(); } } \ No newline at end of file