Merge remote-tracking branch 'origin/master'

This commit is contained in:
Yutousama 2022-08-19 20:51:48 +08:00
commit dfd1c9b35b
39 changed files with 1371 additions and 268 deletions

26
pom.xml
View File

@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.4.RELEASE</version>
<version>2.7.1</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.yutou</groupId>
@ -47,20 +47,20 @@
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
<version>RELEASE</version>
<version>2.7.1</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.6.3</version>
<version>4.2.3</version>
</dependency>
<dependency>
<!-- <dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-redis</artifactId>
<version>2.2.5.RELEASE</version>
</dependency>
<version>2.7.1</version>
</dependency>-->
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
@ -69,20 +69,20 @@
<dependency>
<groupId>org.mybatis.spring.boot</groupId>
<artifactId>mybatis-spring-boot-starter</artifactId>
<version>2.2.0</version>
<version>2.2.2</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.22</version>
<version>1.18.24</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.alibaba/fastjson -->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.79</version>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.8</version>
</dependency>
<!-- https://mvnrepository.com/artifact/com.jcraft/jsch -->
<dependency>
@ -93,13 +93,13 @@
<dependency>
<groupId>com.aliyun.oss</groupId>
<artifactId>aliyun-sdk-oss</artifactId>
<version>3.13.2</version>
<version>3.15.0</version>
</dependency>
<dependency>
<groupId>org.xerial</groupId>
<artifactId>sqlite-jdbc</artifactId>
<version>3.36.0.2</version>
<version>3.36.0.3</version>
</dependency>
<dependency>

View File

@ -1,6 +1,6 @@
package com.yutou.tools.AuthConfig;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.mybatis.dao.PermissionDao;
import com.yutou.tools.mybatis.dao.UKeyDao;
import org.springframework.context.annotation.Configuration;

View File

@ -1,6 +1,6 @@
package com.yutou.tools.AuthConfig;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson2.JSONArray;
import com.yutou.tools.mybatis.dao.PermissionDao;
import com.yutou.tools.mybatis.dao.UKeyDao;
import com.yutou.tools.mybatis.model.Permission;
@ -46,6 +46,7 @@ public class RoleAccessDecisionManager implements AccessDecisionManager {
return;
}
if("dev".equals(ConfigTools.load(ConfigTools.CONFIG, "model"))) {
authentication.setAuthenticated(true);
return;
}
if(url.endsWith(".ts")||url.endsWith(".m3u8")){
@ -79,14 +80,14 @@ public class RoleAccessDecisionManager implements AccessDecisionManager {
}
UKey key = list.get(0);
JSONArray powers = JSONArray.parseArray(key.getPower());
if(powers.toJavaList(String.class).contains("-1")){
if(powers.toList(String.class).contains("-1")){
return;
}
PermissionExample pExample = new PermissionExample();
pExample.createCriteria().andUrlEqualTo(url);
List<Permission> permissions = permissionDao.selectByExample(pExample);
if (!permissions.isEmpty()) {
if (!powers.toJavaList(String.class).contains(permissions.get(0).getId()+"")) {
if (!powers.toList(String.class).contains(permissions.get(0).getId()+"")) {
System.out.println("111111");
error();
}else{

View File

@ -1,7 +1,8 @@
package com.yutou.tools.BiliBili;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.mybatis.dao.BilibiliLiveDao;
import com.yutou.tools.mybatis.model.BilibiliLive;
import com.yutou.tools.mybatis.model.BilibiliLiveExample;
@ -54,7 +55,7 @@ public class Live {
JSONObject json=new JSONObject();
json.put("code",0);
json.put("msg","ok");
json.put("data",JSONArray.toJSON(list));
json.put("data", JSON.toJSON(list));
return json.toJSONString();
}
@ResponseBody

View File

@ -1,8 +1,8 @@
package com.yutou.tools.Tools;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.mybatis.dao.PermissionDao;
import com.yutou.tools.mybatis.dao.UKeyDao;
import com.yutou.tools.mybatis.model.Permission;
@ -66,7 +66,7 @@ public class AuthManagerController {
admin.put("disabled", "");
admin.put("checked", "");
allPermission.add(admin);
List<String> list = powers.toJavaList(String.class);
List<String> list = powers.toList(String.class);
if (list.contains("-1")) {
userPermission.add("-1");
}

View File

@ -1,7 +1,8 @@
package com.yutou.tools.Tools;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.mybatis.dao.ToolsPasswordDao;
import com.yutou.tools.mybatis.dao.ToolsPasswordTypeDao;
import com.yutou.tools.mybatis.model.ToolsPassword;
@ -45,7 +46,7 @@ public class PasswordManager {
}
json.put("code",0);
json.put("msg","ok");
json.put("data", JSONArray.toJSON(passwords));
json.put("data", JSON.toJSON(passwords));
return json.toJSONString();
}
@ResponseBody
@ -100,7 +101,7 @@ public class PasswordManager {
List<ToolsPasswordType> toolsPasswordTypes=passwordTypeDao.selectByExample(example);
json.put("code",0);
json.put("msg","ok");
json.put("data", JSONArray.toJSON(toolsPasswordTypes));
json.put("data", JSON.toJSON(toolsPasswordTypes));
return json.toJSONString();
}
@ResponseBody

View File

@ -6,7 +6,7 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ToolsApplication {
public static final String version="1.4.5";
public static final String version="1.4.7";
public static void main(String[] args) {
System.out.println("当前版本号:" + version);

View File

@ -1,7 +1,7 @@
package com.yutou.tools.bangumi;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.nas.UpdateIp;
import com.yutou.tools.utils.HttpTools;
import org.springframework.stereotype.Controller;

View File

@ -1,13 +1,15 @@
package com.yutou.tools.bangumi;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yutou.tools.mybatis.dao.BangumiItemDao;
import com.yutou.tools.mybatis.dao.BangumiListDao;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.mybatis.model.BangumiItem;
import com.yutou.tools.mybatis.model.BangumiItemExample;
import com.yutou.tools.mybatis.model.BangumiList;
import com.yutou.tools.mybatis.model.BangumiListExample;
import com.yutou.tools.nas.UpdateIp;
import com.yutou.tools.services.interfaces.BangumiService;
import com.yutou.tools.utils.BangumiTools;
import com.yutou.tools.utils.HttpTools;
import com.yutou.tools.utils.RedisTools;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
@ -15,36 +17,32 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.annotation.Resource;
import java.nio.charset.StandardCharsets;
import java.util.List;
import java.util.Objects;
@Controller
public class AnimationController {
@Resource
BangumiListDao listDao;
@Resource
BangumiItemDao itemDao;
BangumiService bangumiService;
@ResponseBody
@RequestMapping(value = "/anim/rss/data.do", method = RequestMethod.GET)
public String getAnimList(String key,String type,String team, int page) {
public String getAnimList(String key, String type, String team, int page) {
boolean isNull = key.length() == 0;
if(!StringUtils.isEmpty(type)&&type.length()>2) {
type=type.substring(2);
if (!StringUtils.isEmpty(type) && type.length() > 2) {
type = type.substring(2);
}
if(!StringUtils.isEmpty(team)&&team.length()>2) {
team=team.substring(2);
if (!StringUtils.isEmpty(team) && team.length() > 2) {
team = team.substring(2);
}
String[] keys = key.split(" ");
JSONArray items = null;
if (!isNull) {
items = new AnimationData().bangumiList(page,type,team, keys);
items = new AnimationData().bangumiList(page, type, team, keys);
}
JSONObject json = new JSONObject();
if (items != null) {
json.put("data", items);
} else {
json.put("data", new JSONArray());
}
json.put("data", Objects.requireNonNullElseGet(items, JSONArray::new));
json.put("count", 999);
json.put("code", 0);
json.put("msg", "ok");
@ -57,7 +55,7 @@ public class AnimationController {
BangumiList bangumiList = new BangumiList();
bangumiList.setTitle(title);
bangumiList.setStatus(1);
int i = listDao.insert(bangumiList);
int i = bangumiService.addBangumiList(bangumiList);
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("msg", i == 0 ? "添加失败" : "添加成功");
@ -70,17 +68,15 @@ public class AnimationController {
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("msg", "ok");
json.put("data", JSONArray.toJSON(listDao.selectByExample(new BangumiListExample())));
json.put("data", JSON.toJSON(bangumiService.getAllBangumiList()));
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "/anim/type/del.do", method = RequestMethod.POST)
public String delType(int id){
BangumiItemExample example=new BangumiItemExample();
example.createCriteria().andBidEqualTo(id+"");
itemDao.deleteByExample(example);
int i=listDao.deleteByPrimaryKey(id);
JSONObject json=new JSONObject();
public String delType(int id) {
int i = bangumiService.removeBangumiType(id);
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("msg", i == 0 ? "删除失败" : "删除成功");
return json.toJSONString();
@ -88,80 +84,152 @@ public class AnimationController {
@ResponseBody
@RequestMapping(value = "/anim/rss/add.do", method = RequestMethod.POST)
public String addAnimationRss(String title, String author, String categories, String titleKey, String bid) {
public JSONObject addAnimationRss(String bgmId, String title, String author, String categories, String titleKey, String bid) {
int i = 0;
JSONObject json = new JSONObject();
json.put("code", 0);
if ("-1".equals(bid)) {
BangumiItem item = new BangumiItem();
item.setId(-1);
item.setTitle(title);
item.setTitlekey(titleKey);
i = bangumiService.addBangumiItem(item);
json.put("msg", i == 0 ? "添加失败" : "添加成功");
return json;
}
int id = 0;
if (!StringUtils.isEmpty(bgmId)) {
try {
id = Integer.parseInt(bgmId.trim());
} catch (Exception ignored) {
}
}
BangumiItem item = new BangumiItem();
item.setBgmid(id);
item.setTitle(title);
item.setAuthor(author);
item.setCategories(categories);
item.setTitlekey(titleKey);
item.setBid(bid);
item.setEnable(1);
int i = itemDao.insert(item);
JSONObject json = new JSONObject();
json.put("code", 0);
i = bangumiService.addBangumiItem(item);
json.put("msg", i == 0 ? "添加失败" : "添加成功");
return json.toJSONString();
return json;
}
@ResponseBody
@RequestMapping(value = "/anim/rss/list.do", method = RequestMethod.GET)
public String getAnimationRssList(String type) {
JSONObject json = new JSONObject();
BangumiItemExample example=new BangumiItemExample();
example.createCriteria().andBidEqualTo(type);
json.put("code", 0);
json.put("msg", "ok");
json.put("data", JSONArray.toJSON(itemDao.selectByExample(example)));
json.put("data", JSON.toJSON(bangumiService.getBangumiItemList(type)));
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "/anim/rss/del.do", method = RequestMethod.POST)
public String delAnimation(int id){
int i=itemDao.deleteByPrimaryKey(id);
JSONObject json=new JSONObject();
public JSONObject delAnimation(String id) {
JSONObject json = new JSONObject();
json.put("code", 0);
json.put("msg", i == 0 ? "删除失败" : "删除成功");
return json.toJSONString();
}
@ResponseBody
@RequestMapping(value = "/anim/rss/edit.do",method = RequestMethod.POST)
public JSONObject editAnimation(int id,String title, String author, String categories, String titleKey,String enable){
JSONObject json=new JSONObject();
BangumiItem item =itemDao.selectByPrimaryKey(id);
if(!StringUtils.isEmpty(title)){
item.setTitle(title);
}
if(!StringUtils.isEmpty(author)){
item.setAuthor(author);
}
if(!StringUtils.isEmpty(categories)){
item.setCategories(categories);
}
if(!StringUtils.isEmpty(titleKey)){
item.setTitlekey(titleKey);
}
if(!StringUtils.isEmpty(enable)){
item.setEnable(Integer.parseInt(enable));
}
int i=itemDao.updateByPrimaryKey(item);
if(i>0){
json.put("msg","操作成功");
}else{
json.put("msg","操作失败");
}
json.put("code",1);
if (id.startsWith("{")) {
boolean tmpRss = RedisTools.list_remove("anim_tmp_rss", id);
json.put("msg", tmpRss ? "删除成功" : "删除失败");
return json;
}
int i = bangumiService.removeBangumiItem(Integer.parseInt(id));
json.put("msg", i == 0 ? "删除失败" : "删除成功");
return json;
}
@ResponseBody
@RequestMapping(value = "/anim/rss/edit.do", method = RequestMethod.POST)
public JSONObject editAnimation(int id, String bgmId, String title, String author, String categories, String titleKey, String enable) {
JSONObject json = new JSONObject();
BangumiItem item = bangumiService.getBangumiItem(id);
if (!StringUtils.isEmpty(bgmId)) {
try {
item.setBgmid(Integer.parseInt(bgmId));
} catch (Exception ignored) {
}
}
if (!StringUtils.isEmpty(title)) {
item.setTitle(title);
}
if (!StringUtils.isEmpty(author)) {
item.setAuthor(author);
}
if (!StringUtils.isEmpty(categories)) {
item.setCategories(categories);
}
if (!StringUtils.isEmpty(titleKey)) {
item.setTitlekey(titleKey);
}
if (!StringUtils.isEmpty(enable)) {
item.setEnable(Integer.parseInt(enable));
}
int i = bangumiService.updateBangumiItem(item);
if (i > 0) {
json.put("msg", "操作成功");
} else {
json.put("msg", "操作失败");
}
json.put("code", 1);
return json;
}
@ResponseBody
@RequestMapping(value = "/anim/client/get.do", method = RequestMethod.GET)
public String clientApi(){
AnimationData animationData=new AnimationData();
List<BangumiItem> list=itemDao.selectByExample(new BangumiItemExample());
public String clientApi() {
AnimationData animationData = new AnimationData();
List<BangumiItem> list = bangumiService.getAllBangumiItemList();
for (BangumiItem item : list) {
item.setCategories(animationData.nameToValue(item.getCategories(),false)+"");
item.setAuthor(animationData.nameToValue(item.getAuthor(),true)+"");
item.setCategories(animationData.nameToValue(item.getCategories(), false) + "");
item.setAuthor(animationData.nameToValue(item.getAuthor(), true) + "");
}
JSONArray array= (JSONArray) JSONArray.toJSON(list);
JSONArray array = (JSONArray) JSON.toJSON(list);
return array.toJSONString();
}
@ResponseBody
@RequestMapping(value = "/anim/getToDay.do", method = RequestMethod.GET)
public JSONObject getToDayAnim() {
return BangumiTools.getBangumi(0);
}
@ResponseBody
@RequestMapping(value = "/anim/setDownload.do", method = RequestMethod.POST)
public JSONObject setDownload(int id, String url) {
String serverUrl = "http://" + UpdateIp.nas_ip + ":8000/bt/download.do";
JSONObject json = new JSONObject();
json.put("id", id);
json.put("url", url);
String post = HttpTools.post(serverUrl, HttpTools.toUrlParams(json).getBytes(StandardCharsets.UTF_8));
json.clear();
json.put("code", 0);
json.put("msg", post);
return json;
}
@ResponseBody
@RequestMapping(value = "/anim/rssdata.do", method = RequestMethod.POST)
public JSONObject getRssData(int id) {
JSONObject json = new JSONObject();
BangumiItem item = bangumiService.getBangumiItem(id);
if (item != null) {
String key = item.getTitle().split("/")[0];
AnimationData animationData = new AnimationData();
JSONArray array = animationData.bangumiList(1, "0", "0", ","+key.replace(" ","+"));
json.put("code",0);
json.put("data", array);
json.put("msg","ok");
}else{
json.put("code",-1);
json.put("msg","id错误");
}
return json;
}
}

View File

@ -1,7 +1,7 @@
package com.yutou.tools.bangumi;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.utils.HttpTools;
import java.net.URLEncoder;
@ -10,7 +10,7 @@ public class AnimationData {
private String rss2jsonApi_1="wtfm5pebya13pnl8rtu51wfgfpte0mb9sap1foll";
private String rss2jsonApi_2="z2s7zyzxvrsjz9vh5alvq3lxdypzykly2nnvqpdx";
private String rss2jsonUrl = "https://api.rss2json.com/v1/api.json?rss_url=";
private String animUrl = "http://share.dmhy.org/topics/rss/page/%s/rss.xml?keyword=%s&sort_id=%s&order=date-desc";
private String animUrl = "https://share.dmhy.org/topics/rss/page/%s/rss.xml?keyword=%s&sort_id=%s&order=date-desc";
private String team="[{\"0\":\"全部\"},{\"117\":\"動漫花園\"},{\"669\":\"喵萌奶茶屋\"},{\"648\":\"魔星字幕团\"},{\"185\":\"极影字幕社\"},{\"619\":\"桜都字幕组\"},{\"604\":\"lleeopen\"},{\"241\":\"幻樱字幕组\"},{\"151\":\"悠哈C9字幕社\"},{\"657\":\"LoliHouse\"},{\"283\":\"千夏字幕组\"},{\"755\":\"GMTeam\"},{\"390\":\"天使动漫\"},{\"731\":\"星空字幕组\"},{\"303\":\"动漫国字幕组\"},{\"563\":\"花園壓制組\"},{\"37\":\"雪飄工作室(FLsnow)\"},{\"47\":\"爱恋字幕社\"},{\"710\":\"咪梦动漫组\"},{\"88\":\"动音漫影\"},{\"574\":\"梦蓝字幕组\"},{\"504\":\"LoveEcho!\"},{\"765\":\"爱咕字幕组\"},{\"520\":\"豌豆字幕组\"},{\"650\":\"SweetSub\"},{\"430\":\"幻之字幕组\"},{\"407\":\"DHR動研字幕組\"},{\"321\":\"轻之国度\"},{\"581\":\"VCB-Studio\"},{\"703\":\"届恋字幕组\"},{\"576\":\"银色子弹字幕组\"},{\"454\":\"风车字幕组\"},{\"485\":\"天空树双语字幕组\"},{\"134\":\"漫游字幕组\"},{\"434\":\"风之圣殿\"},{\"630\":\"枫叶字幕组\"},{\"228\":\"KRL字幕组\"},{\"526\":\"东京不够热\"},{\"592\":\"未央阁联盟\"},{\"288\":\"诸神kamigami字幕组\"},{\"767\":\"天月動漫&發佈組\"},{\"768\":\"千歲字幕組\"},{\"423\":\"漫貓字幕組\"},{\"562\":\"129.3字幕組\"},{\"447\":\"夢幻戀櫻\"},{\"680\":\"Little字幕组\"},{\"641\":\"冷番补完字幕组\"},{\"31\":\"卡通空間\"},{\"649\":\"云光字幕组\"},{\"701\":\"狐狸小宮\"},{\"459\":\"紫音動漫&發佈組\"},{\"699\":\"小花花同盟戰線\"},{\"626\":\"驯兽师联盟\"},{\"58\":\"澄空学园\"},{\"769\":\"动漫萌\"},{\"734\":\"TD-RAWS\"},{\"225\":\"鈴風字幕組\"},{\"673\":\"VRAINSTORM\"},{\"741\":\"銀月字幕組\"},{\"675\":\"AikatsuFans\"},{\"759\":\"红鸟窝字幕组\"},{\"764\":\"MCE汉化组\"},{\"391\":\"ZERO字幕组\"},{\"561\":\"钉铛字幕组\"},{\"727\":\"2B4B\"},{\"104\":\"动漫先锋\"},{\"567\":\"雪梦字幕组\"},{\"573\":\"Centaurea-Raws\"},{\"652\":\"SFEO-Raws\"},{\"666\":\"中肯字幕組\"},{\"754\":\"BYYM发布组\"},{\"613\":\"AI-Raws\"},{\"706\":\"K&W-RAWS\"},{\"732\":\"肥猫压制\"},{\"424\":\"TSDM字幕組\"},{\"739\":\"Clarita 压制组\"},{\"432\":\"自由字幕组\"},{\"217\":\"AQUA工作室\"},{\"753\":\"柠檬水字幕组\"},{\"763\":\"光之家族字幕组\"},{\"332\":\"CureSub\"},{\"537\":\"NEO·QSW\"},{\"632\":\"歐克勒亞\"},{\"548\":\"Cornflower Studio\"},{\"638\":\"LittleBakas!\"}]";
private String type="[{\"0\":\"全部\"},{\"2\":\"動畫\"},{\"31\":\"季度全集\"},{\"3\":\"漫畫\"},{\"41\":\"港台原版\"},{\"42\":\"日文原版\"},{\"4\":\"音樂\"},{\"43\":\"動漫音樂\"},{\"44\":\"同人音樂\"},{\"15\":\"流行音樂\"},{\"6\":\"日劇\"},{\"7\":\"\"},{\"9\":\"遊戲\"},{\"17\":\"電腦遊戲\"},{\"18\":\"電視遊戲\"},{\"19\":\"掌機遊戲\"},{\"20\":\"網絡遊戲\"},{\"21\":\"遊戲周邊\"},{\"12\":\"特攝\"},{\"1\":\"其他\"}]";

View File

@ -11,6 +11,8 @@ import lombok.Data;
public class BangumiItem implements Serializable {
private Integer id;
private Integer bgmid;
private String bid;
private String categories;
@ -19,6 +21,8 @@ public class BangumiItem implements Serializable {
private String title;
private String updateDay ;
/**
* 标题过滤词
*/

View File

@ -164,6 +164,66 @@ public class BangumiItemExample {
return (Criteria) this;
}
public Criteria andBgmidIsNull() {
addCriterion("bgmId is null");
return (Criteria) this;
}
public Criteria andBgmidIsNotNull() {
addCriterion("bgmId is not null");
return (Criteria) this;
}
public Criteria andBgmidEqualTo(Integer value) {
addCriterion("bgmId =", value, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidNotEqualTo(Integer value) {
addCriterion("bgmId <>", value, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidGreaterThan(Integer value) {
addCriterion("bgmId >", value, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidGreaterThanOrEqualTo(Integer value) {
addCriterion("bgmId >=", value, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidLessThan(Integer value) {
addCriterion("bgmId <", value, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidLessThanOrEqualTo(Integer value) {
addCriterion("bgmId <=", value, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidIn(List<Integer> values) {
addCriterion("bgmId in", values, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidNotIn(List<Integer> values) {
addCriterion("bgmId not in", values, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidBetween(Integer value1, Integer value2) {
addCriterion("bgmId between", value1, value2, "bgmid");
return (Criteria) this;
}
public Criteria andBgmidNotBetween(Integer value1, Integer value2) {
addCriterion("bgmId not between", value1, value2, "bgmid");
return (Criteria) this;
}
public Criteria andBidIsNull() {
addCriterion("bid is null");
return (Criteria) this;

View File

@ -1,7 +1,8 @@
package com.yutou.tools.nas;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.mybatis.dao.NasAdminAddressDao;
import com.yutou.tools.mybatis.model.NasAdminAddress;
import com.yutou.tools.mybatis.model.NasAdminAddressExample;
@ -66,7 +67,7 @@ public class NasManager {
if (list.size() == 0) {
json.put("data", new JSONArray());
} else {
json.put("data", JSONArray.toJSON(list));
json.put("data", JSON.toJSON(list));
}
} catch (Exception e) {
e.printStackTrace();
@ -302,7 +303,7 @@ public class NasManager {
e.printStackTrace();
}
}
@RequestMapping("/nas/door/{*.ts}")
@RequestMapping("/nas/door/*.ts")
public void getDoorCCTVOfTs(HttpServletResponse response, HttpServletRequest request, @PathVariable("*.ts") String name){
try {
if(!name.endsWith(".ts")){

View File

@ -1,6 +1,6 @@
package com.yutou.tools.nas;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.utils.ConfigTools;
import com.yutou.tools.utils.RedisTools;
import com.yutou.tools.utils.Tools;

View File

@ -1,7 +1,7 @@
package com.yutou.tools.other;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.ToolsApplication;
import com.yutou.tools.mybatis.dao.UKeyDao;
import com.yutou.tools.mybatis.model.UKey;

View File

@ -0,0 +1,145 @@
package com.yutou.tools.services;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.mybatis.dao.BangumiItemDao;
import com.yutou.tools.mybatis.dao.BangumiListDao;
import com.yutou.tools.mybatis.model.BangumiItem;
import com.yutou.tools.mybatis.model.BangumiItemExample;
import com.yutou.tools.mybatis.model.BangumiList;
import com.yutou.tools.mybatis.model.BangumiListExample;
import com.yutou.tools.services.interfaces.BangumiService;
import com.yutou.tools.utils.BangumiTools;
import com.yutou.tools.utils.RedisTools;
import com.yutou.tools.utils.Tools;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.Set;
@Service("BangumiService")
public class BangumiServiceImpl implements BangumiService {
@Resource
BangumiListDao listDao;
@Resource
BangumiItemDao itemDao;
@Override
public int addBangumiList(BangumiList... list) {
for (BangumiList bangumiList : list) {
if (listDao.insert(bangumiList) <= 0) {
return 0;
}
}
return 1;
}
@Override
public int addBangumiItem(BangumiItem... list) {
for (BangumiItem item : list) {
if (item.getId().equals(-1)) {
RedisTools.list_add("anim_tmp_rss", JSON.toJSON(item).toString());
} else if (itemDao.insert(item) <= 0) {
return 0;
}
}
return 1;
}
@Override
public int updateBangumiItem(BangumiItem item) {
return itemDao.updateByPrimaryKey(item);
}
@Override
public int removeBangumiItem(int id) {
return itemDao.deleteByPrimaryKey(id);
}
@Override
public int removeBangumiType(int id) {
BangumiItemExample example = new BangumiItemExample();
example.createCriteria().andBidEqualTo(id + "");
itemDao.deleteByExample(example);
return listDao.deleteByPrimaryKey(id);
}
@Override
public BangumiItem getBangumiItem(int id) {
return itemDao.selectByPrimaryKey(id);
}
@Override
public List<BangumiItem> getBangumiItemList(String type) {
List<BangumiItem> items;
if ("-1".equals(type)) {
Set<String> strings = RedisTools.list_get("anim_tmp_rss");
items=new ArrayList<>();
for (String string : strings) {
BangumiItem item=JSON.parseObject(string, BangumiItem.class);
items.add(item);
}
return items;
}
BangumiItemExample example = new BangumiItemExample();
example.createCriteria().andBidEqualTo(type);
items = itemDao.selectByExample(example);
for (BangumiItem item : items) {
if (item.getEnable() == 0 || item.getBgmid() == 0) {
continue;
}
String tmp = RedisTools.get(item.getBgmid() + "", 1);
JSONObject bangumi = tmp == null ? BangumiTools.getBangumiInfoSmall(item.getBgmid()) : JSONObject.parseObject(tmp);
RedisTools.set(1, 2592000, item.getBgmid() + "", bangumi.toJSONString());
if (bangumi.containsKey("code") && bangumi.getInteger("code") == 404) {
continue;
}
int day = Tools.getWeekDay();
if (day == 0) {
day = 7;
}
if (bangumi.getInteger("air_weekday") == day) {
item.setUpdateDay("今天更新");
} else {
item.setUpdateDay("" + getDay(bangumi.getInteger("air_weekday")) + "更新");
}
}
return items;
}
private String getDay(int day) {
switch (day) {
case 1:
return "";
case 2:
return "";
case 3:
return "";
case 4:
return "";
case 5:
return "";
case 6:
return "";
default:
return "";
}
}
@Override
public List<BangumiItem> getAllBangumiItemList() {
return itemDao.selectByExample(new BangumiItemExample());
}
@Override
public List<BangumiList> getAllBangumiList() {
List<BangumiList> list = listDao.selectByExample(new BangumiListExample());
BangumiList bangumi = new BangumiList();
bangumi.setTitle("临时RSS");
bangumi.setId(-1);
list.add(bangumi);
return list;
}
}

View File

@ -0,0 +1,20 @@
package com.yutou.tools.services.interfaces;
import com.yutou.tools.mybatis.model.BangumiItem;
import com.yutou.tools.mybatis.model.BangumiList;
import org.springframework.stereotype.Service;
import java.util.List;
public interface BangumiService {
int addBangumiList(BangumiList... list);
int addBangumiItem(BangumiItem... list);
int updateBangumiItem(BangumiItem item);
int removeBangumiItem(int id);
int removeBangumiType(int id);
BangumiItem getBangumiItem(int id);
List<BangumiItem> getBangumiItemList(String type);
List<BangumiItem> getAllBangumiItemList();
List<BangumiList> getAllBangumiList();
}

View File

@ -1,7 +1,7 @@
package com.yutou.tools.sqlite;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import java.sql.ResultSet;
import java.sql.SQLException;

View File

@ -1,7 +1,7 @@
package com.yutou.tools.sqlite;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.utils.ConfigTools;
import java.io.File;

View File

@ -1,6 +1,6 @@
package com.yutou.tools.utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson2.JSONArray;
import com.yutou.tools.mybatis.dao.PermissionDao;
import com.yutou.tools.mybatis.dao.UKeyDao;
import com.yutou.tools.mybatis.model.Permission;
@ -62,14 +62,14 @@ public class APIFilter implements Filter {
UKey key = list.get(0);
JSONArray powers = JSONArray.parseArray(key.getPower());
if(powers.toJavaList(String.class).contains("-1")){
if(powers.toList(String.class).contains("-1")){
isToken=true;
}else {
PermissionExample pExample = new PermissionExample();
pExample.createCriteria().andUrlEqualTo(url);
List<Permission> permissions = permissionDao.selectByExample(pExample);
if (permissions != null && permissions.size() > 0) {
if (powers.toJavaList(String.class).contains(permissions.get(0).getId()+"")) {
if (powers.toList(String.class).contains(permissions.get(0).getId()+"")) {
isToken = true;
}
}

View File

@ -0,0 +1,359 @@
package com.yutou.tools.utils;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.aliyuncs.utils.StringUtils;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
public class BangumiTools {
private static final String url = "https://api.bgm.tv/";
private static final String toDayBangumi = url + "calendar";
private static final String BangumiInfo = url + "subject/%s?responseGroup=large";
private static final String BangumiInfoSmall = url + "subject/%s?responseGroup=small";
private static final String SearchBangumi = url + "search/subject/%s?responseGroup=large&type=2";
/**
* 获取番剧列表
*
* @param day 周几-1为全部,非1~7范围则为当天
* @return 当日数据
*/
public static JSONObject getBangumi(int day) {
String str = HttpTools.get(toDayBangumi);
JSONArray main = JSON.parseArray(str);
if (day == -1) {
JSONObject json = new JSONObject();
json.put("bangumi", main);
return json;
}
if (day < 1 || day > 7) {
day=Tools.getWeekDay();
if (day == 0) {
day = 7;
}
}
if (main != null) {
for (Object o : main) {
JSONObject json = (JSONObject) o;
if (json.getJSONObject("weekday").getInteger("id") == day) {
return json;
}
}
}
return null;
}
/**
* 获取番剧详细信息
*
* @param id 剧集id
* @return 详细信息
*/
public static JSONObject getBangumiInfo(int id) {
String str = HttpTools.get(String.format(BangumiInfo, id + ""));
return JSON.parseObject(str);
}
/**
* 获取番剧简略信息
*
* @param id 剧集id
* @return 详细信息
*/
public static JSONObject getBangumiInfoSmall(int id) {
String str = HttpTools.get(String.format(BangumiInfoSmall, id + ""));
return JSON.parseObject(str);
}
public static JSONArray getPeople(int id) {
/**
* Actor 演员
* Composer 作曲家
* Director 导演
* GuestStar 特邀明星
* Producer 制片人
* Writer 编剧
*/
JSONArray people = new JSONArray();
JSONObject bangumi = getBangumiInfo(id);
JSONArray crt = bangumi.getJSONArray("crt");
if(crt!=null) {
for (Object o : crt) {
JSONObject item = (JSONObject) o;
JSONObject pel = new JSONObject();
pel.put("Name", item.getString("name_cn"));
pel.put("Role", item.getString("role_name"));
pel.put("Type", "Actor");
people.add(pel);
}
}
crt = bangumi.getJSONArray("staff");
if(crt!=null) {
for (Object o : crt) {
JSONObject item = (JSONObject) o;
JSONObject pel = new JSONObject();
pel.put("Name", item.getString("name_cn"));
String jobsName="";
for (Object _jobs : item.getJSONArray("jobs")) {
jobsName+=_jobs+"";
}
jobsName=jobsName.substring(0,jobsName.length()-1);
pel.put("Role", jobsName);
pel.put("Type", "");
if (jobsName.contains("导演")) {
pel.put("Type", "Director");
} else if (jobsName.contains("脚本")) {
pel.put("Type", "DirectorDirector");
}
people.add(pel);
}
}
return people;
}
/**
* 搜索番剧
*
* @param key 关键词
* @return 详细信息
*/
public static JSONObject search(String key) {
String str = HttpTools.get(String.format(SearchBangumi, URLEncoder.encode(key, StandardCharsets.UTF_8)));
return JSON.parseObject(str);
}
/**
* 获取下一集播放日期
*
* @param id 番剧id
* @return 日期
*/
public static String getPlayNextTime(int id) {
JSONObject info = getBangumiInfo(id);
JSONArray eps = info.getJSONArray("eps");
String toDayTime = Tools.getToDayTime();
for (Object o : eps) {
JSONObject ep = (JSONObject) o;
String time = ep.getString("airdate");
try {
if (new SimpleDateFormat("yyyy-MM-dd").parse(time).getTime() >=
new SimpleDateFormat("yyyy-MM-dd").parse(toDayTime).getTime()) {
return time;
}
} catch (ParseException e) {
e.printStackTrace();
}
}
return null;
}
/**
* 格式化字符串输出番剧详细信息
*
* @param id 番剧id
* @return 详细内容
*/
public static List<String> reportBangumiInfo(int id) {
List<String> bangumiList = new ArrayList<>();
JSONObject json = getBangumiInfo(id);
if (json.containsKey("code")) {
bangumiList.add("error = " + json.toJSONString());
return bangumiList;
}
JSONArray eps = json.getJSONArray("eps");
JSONArray crts = json.getJSONArray("crt");
JSONArray staffs = json.getJSONArray("staff");
StringBuilder builder = new StringBuilder();
builder.append("<img ").append(json.getJSONObject("images").getString("large")).append(" /img>").append("\n");
builder.append("标题:").append(json.getString("name_cn")).append("\n");
builder.append("日文标题:").append(json.getString("name")).append("\n");
builder.append("首播时间:").append(json.getString("air_date")).append("\n");
builder.append("每周").append(json.getInteger("air_weekday")).append("放送").append("\n");
builder.append("Bangumi地址:").append(json.getString("url")).append("\n");
builder.append("Bangumi评分:").append(json.getJSONObject("rating").getFloat("score")).append("\n");
builder.append("预计放送集数:").append(json.getInteger("eps_count")).append("\n");
if (eps != null) {
builder.append("已放送集:").append("\n");
for (Object o : eps) {
JSONObject ep = (JSONObject) o;
if (ep.getString("status").equals("Air")) {
builder.append("· 第").append(ep.getInteger("sort")).append("话:");
builder.append(ep.getString("name"));
builder.append("[").append(ep.getString("name_cn")).append("]").append("\n");
builder.append("播放日期:").append(ep.getString("airdate")).append(";\n");
builder.append("播放时长:").append(ep.getString("duration")).append(";\n");
builder.append("单集介绍:").append(ep.getString("desc"));
builder.append("\n\n");
} else {
builder.append("下一话:");
builder.append("").append(ep.getInteger("sort")).append("话:");
builder.append("播放日期:").append(ep.getString("airdate")).append("\n\n");
break;
}
}
}
if (crts != null) {
builder.append("角色介绍:").append("\n");
for (Object o : crts) {
JSONObject crt = (JSONObject) o;
JSONObject info = crt.getJSONObject("info");
builder.append(crt.getString("role_name")).append(":");
builder.append(crt.getString("name"));
builder.append("(").append(crt.getString("name_cn")).append(")").append(" ");
builder.append("CV:").append(crt.getJSONArray("actors").getJSONObject(0).getString("name"));
builder.append("(").append(info.getString("gender")).append(")");
builder.append("\n");
}
}
Map<String, List<JSONObject>> map = new HashMap<>();
for (Object o : staffs) {
JSONObject staff = (JSONObject) o;
for (Object jobs : staff.getJSONArray("jobs")) {
String job = (String) jobs;
List<JSONObject> list;
if (!map.containsKey(job)) {
list = new ArrayList<>();
} else {
list = map.get(job);
}
list.add(staff);
map.put(job, list);
}
}
if (!map.isEmpty()) {
builder.append("staff:").append("\n");
for (String key : map.keySet()) {
builder.append(key).append(":");
for (JSONObject staff : map.get(key)) {
builder.append(staff.getString("name_cn"));
builder.append("(").append(staff.getString("name")).append(")");
builder.append("");
}
builder.append("\n");
}
}
bangumiList.add(builder.toString());
return bangumiList;
}
/**
* 格式化输出新番列表
*
* @return 新番信息
*/
public static String reportBangumiList() {
try {
JSONObject json = getBangumi(-1);
StringBuilder builder = new StringBuilder();
assert json != null;
JSONArray array = json.getJSONArray("bangumi");
for (Object o : array) {
JSONObject data = (JSONObject) o;
JSONObject weekday = data.getJSONObject("weekday");
JSONArray items = data.getJSONArray("items");
builder.append(weekday.getString("cn")).append("(").append(weekday.getString("ja")).append(")");
builder.append(":").append("\n");
reportBangumi(builder, items, false);
builder.append("\n");
}
return builder.toString();
} catch (Exception e) {
e.printStackTrace();
return e.getMessage();
}
}
private static void reportBangumi(StringBuilder builder, JSONArray items, boolean reportEp) {
int epIndex = 0;
String epName = "N/A";
for (Object oj : items) {
JSONObject item = (JSONObject) oj;
builder.append("[").append(item.getInteger("id")).append("]");
builder.append(StringUtils.isEmpty(item.getString("name_cn"))
? item.getString("name") : item.getString("name_cn"));
if (!reportEp) {
builder.append("\n");
continue;
}
JSONObject info = getBangumiInfo(item.getInteger("id"));
if (info.get("eps") == null) {
continue;
}
JSONArray eps = info.getJSONArray("eps");
for (Object oe : eps) {
JSONObject ep = (JSONObject) oe;
if (ep.getString("status").equals("Air")) {
epIndex = ep.getInteger("sort");
epName = ep.getString("name");
} else {
break;
}
}
builder.append("").append(epIndex).append("话:");
builder.append(epName);
builder.append("\n");
}
}
/**
* 格式化字符串输出今日播放番剧列表
*
* @return 番剧列表
*/
public static String reportToDayBangumi() {
String toDayTime = Tools.getToDayTime();
if (!toDayTime.equals(RedisTools.get("reportToDayBangumi"))) {
RedisTools.set("reportToDayBangumi", toDayTime);
StringBuilder builder = new StringBuilder();
JSONObject toDay = getBangumi(0);
if (toDay == null) {
builder.append("今天没有任何番剧放送~");
} else {
JSONObject weekday = toDay.getJSONObject("weekday");
JSONArray items = toDay.getJSONArray("items");
builder.append("今日 ").append(weekday.get("cn")).append("(").append(weekday.get("ja")).append(")");
builder.append(" 放送列表:").append("\n");
reportBangumi(builder, items, true);
}
RedisTools.set("toDayBangumi", builder.toString());
return builder.toString();
} else {
System.out.println("error ");
return RedisTools.get("toDayBangumi");
}
}
/**
* 格式化字符串输出搜索动画
*
* @param key 关键词
* @return 详细内容
*/
public static List<String> reportSearchBangumi(String key) {
List<String> bangumiList = new ArrayList<>();
JSONObject main = search(key);
if (main.getInteger("results") > 0) {
JSONArray list = main.getJSONArray("list");
Collections.reverse(list);
for (Object _items : list) {
JSONObject items= (JSONObject) _items;
bangumiList.addAll(reportBangumiInfo(items.getInteger("id")));
}
return bangumiList;
} else {
bangumiList.add("搜索不到任何内容:" + key);
return bangumiList;
}
}
public static void main(String[] args) {
JSONObject toDay = getBangumiInfoSmall(371396);
System.out.println(toDay);
}
}

View File

@ -1,7 +1,7 @@
package com.yutou.tools.utils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import javax.net.ssl.HttpsURLConnection;
import java.io.BufferedReader;

View File

@ -1,6 +1,6 @@
package com.yutou.tools.utils;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONObject;
import java.io.*;

View File

@ -11,7 +11,7 @@ public class CorsConfig implements WebMvcConfigurer {
//设置允许跨域的路径
registry.addMapping("/**")
//设置允许跨域请求的域名
.allowedOrigins("*")
.allowedOrigins("Access-Control-Allow-Origin")
//是否允许证书 不再默认开启
.allowCredentials(true)
//设置允许的方法

View File

@ -1,6 +1,6 @@
package com.yutou.tools.utils;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.interfaces.DownloadInterface;
import org.springframework.util.StringUtils;

View File

@ -1,7 +1,8 @@
package com.yutou.tools.utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@ -26,7 +27,7 @@ public class NasDepotManager {
json.put("code",1);
json.put("msg","添加成功");
}
json.put("data", JSONArray.toJSON(RedisTools.list_get(DEPOT_NAME)));
json.put("data", JSON.toJSON(RedisTools.list_get(DEPOT_NAME)));
return json;
}
@ -36,7 +37,7 @@ public class NasDepotManager {
JSONObject json=new JSONObject();
json.put("code",1);
json.put("msg","ok");
json.put("data", JSONArray.toJSON(RedisTools.list_get(DEPOT_NAME)));
json.put("data", JSON.toJSON(RedisTools.list_get(DEPOT_NAME)));
return json;
}
@ResponseBody

View File

@ -8,7 +8,7 @@ import java.util.HashSet;
import java.util.Properties;
import java.util.Set;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONObject;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.JedisPoolConfig;
@ -34,15 +34,19 @@ public class RedisTools {
port = 6379;
}
public static boolean set(int dbIndex, String key, String value) {
public static boolean set(int dbIndex, int timeout, String key, String value) {
try {
if (isNotInstallRedis) {
return false;
}
Jedis jedis = getRedis();
jedis.select(dbIndex);
String ret = jedis.set(key, value);
System.out.println("Redis set =" + ret);
if (timeout == -1) {
jedis.set(key, value);
} else {
jedis.setex(key, timeout, value);
}
jedis.close();
} catch (Exception e) {
// TODO: handle exception
@ -52,6 +56,10 @@ public class RedisTools {
return true;
}
public static boolean set(int dbIndex, String key, String value) {
return set(dbIndex, -1, key, value);
}
public static boolean set(String key, String value) {
return set(0, key, value);
}
@ -77,9 +85,9 @@ public class RedisTools {
}
public static String get(String key, int dbIndex) {
String value = "-999";
String value = null;
if (isNotInstallRedis) {
return value;
return null;
}
try (Jedis jedis = getRedis()) {
jedis.select(dbIndex);
@ -97,7 +105,7 @@ public class RedisTools {
}
public static boolean remove(String key) {
return remove(key,0);
return remove(key, 0);
}
public static void removeLoginState(String uid) {
@ -148,32 +156,36 @@ public class RedisTools {
}
public static long list_add(String listName, String... value) {
Jedis jedis=getRedis();
long index=jedis.sadd(listName,value);
Jedis jedis = getRedis();
long index = jedis.sadd(listName, value);
jedis.close();
return index;
}
public static Set<String> list_get(String listName){
Jedis jedis=getRedis();
Set<String> set=jedis.smembers(listName);
public static Set<String> list_get(String listName) {
Jedis jedis = getRedis();
Set<String> set = jedis.smembers(listName);
jedis.close();
if(set==null){
set=new HashSet<>();
if (set == null) {
set = new HashSet<>();
}
return set;
}
public static boolean list_remove(String listName,String... value){
Jedis jedis=getRedis();
long index=jedis.srem(listName,value);
public static boolean list_remove(String listName, String... value) {
Jedis jedis = getRedis();
long index = jedis.srem(listName, value);
jedis.close();
return index != 0;
}
public static boolean list_isExist(String listName,String value){
Jedis jedis=getRedis();
boolean flag=jedis.sismember(listName,value);
public static boolean list_isExist(String listName, String value) {
Jedis jedis = getRedis();
boolean flag = jedis.sismember(listName, value);
jedis.close();
return flag;
}
private static class PropertyUtil {
// 加载property文件到io流里面
@ -256,7 +268,7 @@ public class RedisTools {
system("cmd", message);
break;
case "msg":
Tools.sendServer("来自服务姬的通知~",message);
Tools.sendServer("来自服务姬的通知~", message);
break;
}
}
@ -293,7 +305,6 @@ public class RedisTools {
}
public static void bot(String value) {
switch (value) {
case "getip":
@ -303,6 +314,7 @@ public class RedisTools {
}
}
}
public static void processOut(InputStream inputStream) {
String tmp;
@ -320,6 +332,7 @@ public class RedisTools {
System.out.println("cmd > " + str);
System.out.println("线程结束");
}
public static void main(String[] args) {
RedisTools.pullMsg("msg", "abc");
}

View File

@ -1,7 +1,7 @@
package com.yutou.tools.utils;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.interfaces.DownloadInterface;
import com.yutou.tools.nas.UpdateIp;
import org.apache.commons.codec.digest.DigestUtils;
@ -434,6 +434,9 @@ public class Tools {
}
public static String getLoginUser() {
if("dev".equals(ConfigTools.load(ConfigTools.CONFIG, "model"))) {
return "admin";
}
Object user = SecurityContextHolder.getContext().getAuthentication().getPrincipal();
if (user instanceof String) {
return (String) user;
@ -463,4 +466,11 @@ public class Tools {
return "";
}
public static int getWeekDay() {
Calendar calendar = Calendar.getInstance();
calendar.setTimeZone(TimeZone.getTimeZone("GMT+8:00"));
calendar.setFirstDayOfWeek(Calendar.MONDAY);
calendar.setTime(new Date());
return calendar.get(Calendar.DAY_OF_WEEK) - 1;
}
}

View File

@ -1,7 +1,7 @@
package com.yutou.tools.web;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.Tools.GoogleAccount;
import com.yutou.tools.utils.ConfigTools;
import com.yutou.tools.utils.RedisTools;

View File

@ -3,6 +3,7 @@
<mapper namespace="com.yutou.tools.mybatis.dao.BangumiItemDao">
<resultMap id="BaseResultMap" type="com.yutou.tools.mybatis.model.BangumiItem">
<id column="id" jdbcType="INTEGER" property="id" />
<result column="bgmId" jdbcType="INTEGER" property="bgmid" />
<result column="bid" jdbcType="VARCHAR" property="bid" />
<result column="categories" jdbcType="VARCHAR" property="categories" />
<result column="author" jdbcType="VARCHAR" property="author" />
@ -69,7 +70,7 @@
</where>
</sql>
<sql id="Base_Column_List">
id, bid, categories, author, title, titleKey, `enable`
id, bgmId, bid, categories, author, title, titleKey, `enable`
</sql>
<select id="selectByExample" parameterType="com.yutou.tools.mybatis.model.BangumiItemExample" resultMap="BaseResultMap">
select
@ -102,16 +103,19 @@
</if>
</delete>
<insert id="insert" keyColumn="id" keyProperty="id" parameterType="com.yutou.tools.mybatis.model.BangumiItem" useGeneratedKeys="true">
insert into bangumi_item (bid, categories, author,
title, titleKey, `enable`
)
values (#{bid,jdbcType=VARCHAR}, #{categories,jdbcType=VARCHAR}, #{author,jdbcType=VARCHAR},
#{title,jdbcType=VARCHAR}, #{titlekey,jdbcType=VARCHAR}, #{enable,jdbcType=INTEGER}
)
insert into bangumi_item (bgmId, bid, categories,
author, title, titleKey,
`enable`)
values (#{bgmid,jdbcType=INTEGER}, #{bid,jdbcType=VARCHAR}, #{categories,jdbcType=VARCHAR},
#{author,jdbcType=VARCHAR}, #{title,jdbcType=VARCHAR}, #{titlekey,jdbcType=VARCHAR},
#{enable,jdbcType=INTEGER})
</insert>
<insert id="insertSelective" keyColumn="id" keyProperty="id" parameterType="com.yutou.tools.mybatis.model.BangumiItem" useGeneratedKeys="true">
insert into bangumi_item
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="bgmid != null">
bgmId,
</if>
<if test="bid != null">
bid,
</if>
@ -132,6 +136,9 @@
</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="bgmid != null">
#{bgmid,jdbcType=INTEGER},
</if>
<if test="bid != null">
#{bid,jdbcType=VARCHAR},
</if>
@ -164,6 +171,9 @@
<if test="record.id != null">
id = #{record.id,jdbcType=INTEGER},
</if>
<if test="record.bgmid != null">
bgmId = #{record.bgmid,jdbcType=INTEGER},
</if>
<if test="record.bid != null">
bid = #{record.bid,jdbcType=VARCHAR},
</if>
@ -190,6 +200,7 @@
<update id="updateByExample" parameterType="map">
update bangumi_item
set id = #{record.id,jdbcType=INTEGER},
bgmId = #{record.bgmid,jdbcType=INTEGER},
bid = #{record.bid,jdbcType=VARCHAR},
categories = #{record.categories,jdbcType=VARCHAR},
author = #{record.author,jdbcType=VARCHAR},
@ -203,6 +214,9 @@
<update id="updateByPrimaryKeySelective" parameterType="com.yutou.tools.mybatis.model.BangumiItem">
update bangumi_item
<set>
<if test="bgmid != null">
bgmId = #{bgmid,jdbcType=INTEGER},
</if>
<if test="bid != null">
bid = #{bid,jdbcType=VARCHAR},
</if>
@ -226,7 +240,8 @@
</update>
<update id="updateByPrimaryKey" parameterType="com.yutou.tools.mybatis.model.BangumiItem">
update bangumi_item
set bid = #{bid,jdbcType=VARCHAR},
set bgmId = #{bgmid,jdbcType=INTEGER},
bid = #{bid,jdbcType=VARCHAR},
categories = #{categories,jdbcType=VARCHAR},
author = #{author,jdbcType=VARCHAR},
title = #{title,jdbcType=VARCHAR},

View File

@ -1,6 +1,6 @@
package com.yutou.tools;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONObject;
import com.yutou.tools.Tools.AuthManagerController;
import com.yutou.tools.utils.Tools;
import org.junit.jupiter.api.Test;

27
web/css/lyricer.min.css vendored Normal file
View File

@ -0,0 +1,27 @@
#lyricer {
font-size: 100%;
font-family: "Microsoft YaHei","Hiragino Sans GB W3",Tahoma,Arial;
text-shadow: 0 0 1px #EEEEEE;
color: #666666;
overflow: hidden;
}
#lyricer ul {
list-style-type: none;
padding: 5px;
margin-left: 50px;
}
#lyricer ul li {
overflow: auto;
}
#lyricer ul li:hover {
color: #428bca;
}
#lyricer .lyricer-current-line {
color: #fff;
text-shadow: 0 0 1px #fff, 0 0 2px #fff, 0 0 3px #fff, 0 0 4px #ff2d95, 0 0 6px #ff2d95, 0 0 8px #ff2d95, 0 0 10px #ff2d95, 0 0 12px #ff2d95;
padding:10px
}

View File

@ -24,16 +24,16 @@
$('#header').load("/html/header.html");
$('#footer').load("/html/footer.html");
var loadId = layer.load();
let loadId = layer.load();
$.get('/anim/meta/get.do', function (json) {
layer.close(loadId)
layui.use('tree', function () {
var tree = layui.tree;
let tree = layui.tree;
tree.render({
elem: '#animmeta',
data: json,
click: function (obj) {
var url="https://bgm.tv/subject_search/"+encodeURIComponent(obj.data.title)+"?cat=2"
let url="https://bgm.tv/subject_search/"+encodeURIComponent(obj.data.title)+"?cat=2"
layer.prompt({
title: "设置元数据:"+'<a href='+url+' target="_blank">查询</a>',
value: ''

View File

@ -1,5 +1,5 @@
<!DOCTYPE html>
<html>
<html lang="zh">
<head>
<meta charset="utf-8">
@ -13,12 +13,10 @@
<div class="layui-layout layui-layout-admin">
<div id="header"></div>
<div class="layui-body body2">
<div id="side"></div>
<blockquote class="layui-elem-quote"><span id="ip">番剧订阅器</span></blockquote>
<blockquote class="layui-elem-quote"><span>番剧订阅器</span></blockquote>
<button type="button" id="addType" class="layui-btn layui-btn-normal">新增分类</button>
<div class="layui-tab" lay-filter="animType" lay-allowclose="true">
<ul class="layui-tab-title">
@ -28,7 +26,7 @@
</div>
</div>
<blockquote class="layui-elem-quote"><span id="ip">动漫花园RSS</span></blockquote>
<blockquote class="layui-elem-quote"><span>动漫花园RSS</span></blockquote>
<form class="layui-form" action="" lay-filter="formTest">
<div class="layui-form-item">
<label class="layui-form-label"><a type="text" id="search"
@ -171,9 +169,16 @@
</script>
<script type="text/html" id="listTools">
<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="src">原地址</a>
<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="bgm_src">番剧计划</a>
<a class="layui-btn layui-btn-xs" lay-event="show">查看</a>
<a class="layui-btn layui-btn-xs layui-btn-normal" lay-event="down">手动下载</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
</script>
<script type="text/html" id="RsslistTools">
<a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="mikan">MiKan</a>
<a class="layui-btn layui-btn-xs" lay-event="tmp_rss_show">查看</a>
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="tmp_rss_del">删除</a>
</script>
<script type="text/html" id="animState">
{{# if(d.enable==1){}}
<div><input type="checkbox" name="state" lay-text="启用|关闭" lay-filter="stateCheckbox" lay-skin="switch"
@ -183,6 +188,15 @@
value="{{d.id}}"></div>
{{# }}}
</script>
<script type="text/html" id="animUpdateState">
{{# if(d.updateDay=='今天更新'){}}
<div><input type="checkbox" name="update" lay-text="今天更新|不更新" lay-filter="stateCheckbox" lay-skin="switch"
value="{{d.id}}" checked disabled></div>
{{# } else { }}
<div><input type="checkbox" name="update" lay-text="{{d.updateDay}}|{{d.updateDay}}" lay-filter="stateCheckbox" lay-skin="switch"
value="{{d.id}}" disabled></div>
{{# }}}
</script>
<script>
$('#header').load("/html/header.html");
$('#footer').load("/html/footer.html");
@ -194,38 +208,106 @@
window.location.href = "/"
}
})
function addTmpRss(def) {
let option = '';
for (let i = 0; i < 20; i++) {
if (i === 1) {
option += '<option selected>' + i + '</option>'
} else {
option += '<option>' + i + '</option>'
}
}
let html = '<form class="layui-form">标题:<div class="layui-form-item"><input type="text" id="anim_rss_title" required lay-verify="required" placeholder="请输入标题" autocomplete="off" class="layui-input">URL:<textarea class="layui-textarea" id="rss_value""></textarea> 季度:<select lay-search lay-verify="required" id="rss_select">' + option + '</select> </div></form>'
layer.open({
type: 0,
area: ['500px', '600px'],
title: '请输入RSS地址',
content: html,
success: function () {
layui.use(['form'], function () {
layui.form.render('select');
})
},
cancel :function (index){
layer.close(index)
},
yes: function (index, elem) {
let url = $('#rss_value')[0].value
let title = $('#anim_rss_title')[0].value+ '/Season ' + $('#rss_select')[0].value
layui.use(['layer', 'form', 'element', 'table'], function () {
$.post("/anim/rss/add.do", {
title: url
, titleKey: title
, bid: -1
}, function (json) {
layer.msg(json.msg)
layer.close(index)
})
}
})
}
layui.use(['layer', 'form', 'element', 'table', 'util'], function () {
let layer = layui.layer
, util = layui.util
, form = layui.form
, table = layui.table
, element = layui.element;
util.fixbar({
bar1: '&#xe637;',
bgcolor: '#393D49',
css: {right: 100, bottom: 100},
click: function(type){
console.log(type);
if(type === 'bar1'){
showToDayAnim()
}
}
});
$.get("/anim/type/list.do", function (data) {
let json = JSON.parse(data);
if (json.code === 0) {
for (let index = 0; index < json.data.length; index++) {
const ret = json.data[index];
let ret = json.data[index];
let content;
if(ret.id===-1){
content='<button type="button" class="layui-btn layui-btn-xs" onclick="addTmpRss(this)">添加临时订阅地址</button>'
}else{
content=''
}
element.tabAdd('animType', {
title: ret.title
, content: '<table id="passwordlist' + ret.id + '" lay-filter="adminTable"></table>'
, content: content+'<table id="passwordlist' + ret.id + '" lay-filter="adminTable"></table>'
, id: ret.id
})
}
element.on('tab(animType)', function (data) {
tabid = $(this).attr('lay-id')
let cols;
if(tabid==='-1'){
cols=[[
{field: 'title', title: '地址'}
,{field: "right", toolbar: '#RsslistTools'}
]]
}else{
cols=[[
{field: "id", title: "id", width: 60, sort: true, fixed: 'left'}
, {field: 'bgmid', title: 'bgmId', width: 80, edit: 'text'}
, {field: 'title', title: '标题', edit: 'text'}
, {field: 'categories', title: '类型', width: 80}
, {field: 'author', title: '字幕组', width: 100}
, {field: 'titlekey', title: '搜索关键词', width: 200, edit: 'text'}
, {field: 'enable', title: '状态', width: 80, templet: '#animState'}
, {field: 'update', title: '更新', width: 110, templet: '#animUpdateState'}
, {field: "right", toolbar: '#listTools'}
]]
}
table.render({
elem: "#passwordlist" + tabid
, url: '/anim/rss/list.do?type=' + tabid
, page: true
, cols: [[
{field: "id", title: "id", width: 80, sort: true, fixed: 'left'}
, {field: 'title', title: '标题', edit: 'text'}
, {field: 'categories', title: '类型',width: 80}
, {field: 'author', title: '字幕组',width:100}
, {field: 'titlekey', title: '搜索关键词', edit: 'text'}
, {field: 'enable', title: '状态',width:80, templet: '#animState'}
, {field: "right", toolbar: '#listTools'}
]]
, cols: cols
});
})
table.on('edit(adminTable)', function (obj) {
@ -236,6 +318,8 @@
let data = {}
if (type === 'title') {
data = {id: id, title: value}
} else if (type === 'bgmid') {
data = {id: id, bgmId: value}
} else {
data = {id: id, titleKey: value}
}
@ -282,8 +366,7 @@
, content: "删除操作无法回滚,是否确认删除:" + obj.data.title
, btn: ['确认', '取消']
, yes: function (index) {
$.post('/anim/rss/del.do', {id: obj.data.id}, function (data) {
let json = JSON.parse(data);
$.post('/anim/rss/del.do', {id: obj.data.id}, function (json) {
layer.msg(json.msg)
layer.close(index)
})
@ -293,38 +376,92 @@
layer.close(index);
}
})
}else if(obj.event === 'src'){
window.open("https://share.dmhy.org/topics/list?keyword="+encodeURI(obj.data.titlekey))
} else if (obj.event === 'src') {
window.open("https://share.dmhy.org/topics/list?keyword=" + encodeURI(obj.data.titlekey))
} else if (obj.event === 'bgm_src') {
window.open("https://bgm.tv/subject/" + obj.data.bgmid)
} else if (obj.event==='mikan'){
console.log(getParamToUrl('bangumiId',obj.data.title))
window.open('https://mikanani.me/Home/Bangumi/'+getParamToUrl('bangumiId',obj.data.title)+'#'+getParamToUrl('subgroupid',obj.data.title))
} else if (obj.event==='tmp_rss_show'){
window.open(obj.data.title)
} else if (obj.event === 'tmp_rss_del'){
$.post('/anim/rss/del.do', {id: JSON.stringify(obj.data)}, function (json) {
layer.msg(json.msg)
})
} else if(obj.event === 'down'){
let index=layer.load()
$.post('/anim/rssdata.do',{id:obj.data.id},function (json) {
layer.close(index)
if(json.code!==0){
layer.msg(json.msg)
return;
}
let html = '<table class="layui-table"> <colgroup> <col width="150" /> <col width="200" /> <col /> </colgroup> <thead> <tr> <th width="200">标题</th> <th>更新时间</th> <th>图片</th> <th>地址</th> </tr> </thead> <tbody> </tbody>'
json.data.forEach((item) => {
let name = item.title
let img='#'
if(item.thumbnail!=null){
img=item.thumbnail
}
html += '<tr><td>' + name + '</td><td>' + item.pubDate + '</td><td><img src="' + img + '"></td><td><a href="javascript:sendDownload('+obj.data.id+',\''+item.enclosure.link+'\')">下载这个</a></td></tr>'
})
html += "</table>"
layer.open({
title: '手动下载',
area: ['800px', '600px'],
content: html,
shade: 0
});
})
}
})
table.on('tool(rssTools)', function (obj) {
let data = obj.data;
if (obj.event === 'addRss') {
layer.prompt({
formType: 2,
let option = '';
for (let i = 0; i < 20; i++) {
if (i === 1) {
option += '<option selected>' + i + '</option>'
} else {
option += '<option>' + i + '</option>'
}
}
let html = '<form class="layui-form">名字:<div class="layui-form-item"><textarea class="layui-textarea" id="rss_value" onblur="setTitle(this)">' + data.title + '</textarea> 季度:<select lay-search lay-verify="required" id="rss_select">' + option + '</select> <a id="bgmUrl" href="javascript:;" target="_blank">bgmId:</a><input class="layui-input" id="bgmId"/></div></form>'
layer.open({
type: 0,
area: ['500px', '600px'],
title: '订阅这个RSS结果,并加入到第' + tabid + '个分类中',
value: data.title
}, function (value, index, elem) {
content: html,
success: function () {
form.render('select');
},
yes: function (index, elem) {
let value = $('#rss_value')[0].value + '/Season ' + $('#rss_select')[0].value
let bgmId = $('#bgmId')[0].value
$.post("/anim/rss/add.do", {
title: value
, bgmId: bgmId
, author: data.author
, categories: data.categories[0]
, titleKey: $('#title').val()
, bid: tabid
}, function (data) {
let json = JSON.parse(data);
}, function (json) {
layer.msg(json.msg)
layer.close(index)
})
}
})
}else if(obj.event === "rss_src"){
} else if (obj.event === "rss_src") {
window.open(obj.data.link)
}
})
form.on('switch(stateCheckbox)', function (data) {
let flag = data.elem.checked ? 1 : 0;
let id = data.value;
$.post('/anim/rss/edit.do',{id:id,enable:flag},function (json) {
$.post('/anim/rss/edit.do', {id: id, enable: flag}, function (json) {
layer.msg(json.msg)
})
})
@ -339,8 +476,8 @@
page: true,
cols: [[
{field: "title", title: "标题", sort: true, fixed: 'left'}
, {field: 'author', title: '字幕组',width:100}
, {field: 'categories', title: '类型',width:80, templet: '<div><label>{{d.categories[0]}}</label><div>'}
, {field: 'author', title: '字幕组', width: 100}
, {field: 'categories', title: '类型', width: 80, templet: '<div><label>{{d.categories[0]}}</label><div>'}
, {field: 'pubDate', title: '发布时间',}
, {field: 'thumbnail', title: '封面', templet: '<div><img src="{{d.thumbnail}}"/><div>'}
, {field: 'title', title: 'magnet', templet: '<div><label >{{d.enclosure.link}}</label ></div>'}
@ -363,6 +500,10 @@
$('#search').click(function () {
searchClick()
})
$('#searchBgmId').click(function () {
let url = "https://bgm.tv/subject_search/" + encodeURIComponent($('#title')[0].value) + "?cat=2"
window.open(url)
})
function searchClick() {
rssList.reload({
@ -374,9 +515,47 @@
})
}
function showToDayAnim() {
$.get("/anim/getToDay.do", function (json) {
let items = json.items;
let html = '<table class="layui-table"> <colgroup> <col width="150" /> <col width="200" /> <col /> </colgroup> <thead> <tr> <th>标题</th> <th>首更时间</th> <th>图片</th> <th>地址</th> </tr> </thead> <tbody> </tbody>'
items.forEach((item) => {
let name = item.name_cn
if (name === '') {
name = item.name;
}
let img='#'
if(item.images!=null){
img=item.images.small
}
html += '<tr><td>' + name + '</td><td>' + item.air_date + '</td><td><img src="' + img + '"></td><td><a href="' + item.url + '" target="_blank">前往番剧计划</a></td></tr>'
})
html += "</table>"
layer.open({
title: '今日新番列表',
area: ['700px', '300px'],
content: html,
shade: 0,
offset: 'rb'
});
})
}
});
//let js="" ; $('#team option').each(function() { let value=$(this).val(); let text=$(this).text(); js+='{"'+value+'":"'+text+'"},'})
function setTitle(_this) {
let url = "https://bgm.tv/subject_search/" + encodeURIComponent(_this.value) + "?cat=2"
$('#bgmUrl')[0].href = url;
}
function sendDownload(id, url) {
console.log("id = "+id +" url = "+url);
$.post("/anim/setDownload.do",{id:id,url:url},function (json) {
layer.msg(json.msg)
})
}
</script>
</body>
<style>

View File

@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>来点Music~</title>
<link rel="stylesheet" href="/layui/css/layui.css">
<link rel="stylesheet" href="/css/lyricer.min.css">
</head>
<body>
<div class="layui-layout layui-layout-admin">
@ -16,9 +17,9 @@
<div style="margin-left: 2%; margin-top: 2%;">
<div>
<img src="/assets/defaultPlayImg.jpg" id="img" style="height: 200px; width: 200px"/>
<img src="/assets/defaultPlayImg.jpg" id="img" style="height: 300px; width: 300px"/>
<div style="display:inline-block;">
<div style="top: 800px;display:inline-block;">
<div id="musicSize">歌单总数:</div>
<div id="playerNowList">播放列表:</div>
<div id="title">标题:</div>
@ -28,6 +29,7 @@
<a class="layui-btn layui-btn-normal" id="download">下载</a>
<a class="layui-btn layui-btn-normal" id="next">下一首</a>
<a class="layui-btn layui-btn-normal" id="play_share">分享</a>
<a class="layui-btn layui-btn-normal" id="showLrc">显示歌词</a>
</div>
<div id="audioWrap"></div>
@ -44,6 +46,7 @@
<script src="/layui/layui.js"></script>
<script src="/js/jquery-3.2.1.js"></script>
<script src="/js/myjs.js"></script>
<script src="/js/lyricer.min.js"></script>
<link rel="stylesheet" href="/css/AudioPlayer.css">
<script src="/js/AudioPlayer.js"></script>
<script id="listTemplet">
@ -64,23 +67,24 @@
let isRandom = true;
let playIndex = 0;
let playNow = ""
let share=getParam('share');
if(share!=null){
let share = getParam('share');
if (share != null) {
//$('#playlist').remove()
$('#reload').remove()
$('#next').remove()
$('#play_share').remove()
}
$.get("/nas/music/getlocalhost.do",{share:share}, function (obj) {
$.get("/nas/music/getlocalhost.do", {share: share}, function (obj) {
try {
let json = JSON.parse(obj);
if(json.code===403){
if (json.code === 403) {
layer.msg('您没有权限访问')
return;
}
localhost = json.data ;
localhost = json.data;
if (localhost === 'http://null:8000' || localhost === ":8000") {
localhost = "https://"+window.location.host;
localhost = "https://" + window.location.host;
}
} catch (e) {
localhost = ""
@ -90,11 +94,11 @@
let table = layui.table;
let element = layui.element;
let listTable = undefined;
$.post("/public/nas/music/playlist.do",{share:share},function (json) {
if(json.code!==0){
$.post("/public/nas/music/playlist.do", {share: share}, function (json) {
if (json.code !== 0) {
return;
}
listTable=table.render({
listTable = table.render({
elem: '#playlist'
, url: json.data //数据接口
, method: 'post'
@ -115,19 +119,19 @@
, done: function (res, curr, count) {
musicLib = res.data
$('#musicSize').html("歌单总数:" + res.size)
},error:function (e,data){
}, error: function (e, data) {
}
})
table.on('rowDouble(music)', function (obj) {
//obj 同上
if (obj.data.isdir === 1) {
let path=obj.data.md5;
if(path===undefined){
path=obj.data.file;
let path = obj.data.md5;
if (path === undefined) {
path = obj.data.file;
}
listTable.reload({
where: {
path:path
path: path
}
, page: {
curr: 1
@ -149,49 +153,49 @@
window.open(localhost + "/nas/music/play.do?token=&random=false&filePath=" + data.md5)
}
} else if (obj.event === 'play') {
if(data.md5!==undefined){
if (data.md5 !== undefined) {
play(data)
return;
}
$.ajax({
type: "POST",
url:localhost + "/nas/music/list.do",
url: localhost + "/nas/music/list.do",
contentType: "application/json; charset=utf-8",
data:JSON.stringify({type: true, path: data.file}),
data: JSON.stringify({type: true, path: data.file}),
dataType: "json",
success:function (json){
success: function (json) {
try {
if (json.code === 0) {
playIndex = 0;
musicLib=[]
musicLib = []
for (let datum of json.data) {
if(datum.isdir===0){
if (datum.isdir === 0) {
musicLib.push(datum)
}
}
isRandom = false;
playNext()
}
}catch (e){
} catch (e) {
}
}
})
}else if(obj.event==='share'){
let isDir=false;
let file=data.md5;
if(data.isdir===1){
isDir=true;
file=data.file;
} else if (obj.event === 'share') {
let isDir = false;
let file = data.md5;
if (data.isdir === 1) {
isDir = true;
file = data.file;
}
$.post('/nas/music/share.do',{file:file,isDir:isDir},function (json){
if(json.code===0){
var url="http://"+window.location.host+"/html/body/nas/music.html?share="+json.data.token
$.post('/nas/music/share.do', {file: file, isDir: isDir}, function (json) {
if (json.code === 0) {
var url = "http://" + window.location.host + "/html/body/nas/music.html?share=" + json.data.token
layer.prompt({
title:"分享链接",
value:url
},function (value,index,elem){
title: "分享链接",
value: url
}, function (value, index, elem) {
$('.layui-layer-input')[0].select()
document.execCommand("Copy")
layer.close(index);
@ -203,17 +207,19 @@
element.on('nav(menus)', function (elem) {
});
})
function playShare(){
$.get('/nas/music/playShare.do?share='+share,function (json) {
function playShare() {
$.get('/nas/music/playShare.do?share=' + share, function (json) {
isRandom = false;
playIndex =0;
playIndex = 0;
json.data.forEach(function (item) {
musicLib.push(item)
})
play(json.data[0])
})
}
if(share!==null){
if (share !== null) {
playShare()
}
});
@ -221,6 +227,8 @@
});
let player = $.AudioPlayer;
let showLrc = false;
let lrc = new Lyricer();
player.init({
container: '#audioWrap'
, source: ''
@ -237,6 +245,10 @@
}, canplayCallback: function () {
console.log("点击播放")
}, timeupdateCallback: function (time) {
if (showLrc) {
lrc.move(time)
}
}
});
$.ajax({cache: false})
@ -244,7 +256,7 @@
$('#footer').load("/html/footer.html");
$('#img').click(function () {
if(share!==null){
if (share !== null) {
return;
}
isRandom = true;
@ -256,14 +268,14 @@
$('#next').click(function () {
playNext()
});
$('#play_share').click(function (){
$.post('/nas/music/share.do',{file:playNow},function (json){
if(json.code===0){
var url="http://"+window.location.host+"/html/body/nas/music.html?share="+json.data.token
$('#play_share').click(function () {
$.post('/nas/music/share.do', {file: playNow}, function (json) {
if (json.code === 0) {
let url = "http://" + window.location.host + "/html/body/nas/music.html?share=" + json.data.token
layer.prompt({
title:"分享链接",
value:url
},function(value,index,elem){
title: "分享链接",
value: url
}, function (value, index, elem) {
$('.layui-layer-input')[0].select()
document.execCommand("Copy")
layer.close(index);
@ -271,12 +283,45 @@
}
})
})
$('#showLrc').click(function () {
let html = '<div id="lyricer"></div>';
$.get(localhost + '/nas/music/lrc.do?filePath=' + playNow, function (file) {
layer.open({
title: '歌词列表',
area: ['400px', '600px'],
content: html,
shade: 0,
offset: 'rb',
success: function () {
showLrc = true
if(file===''){
file='[00:00.00]---暂无歌词---'
}
lrc.setLrc(file)
},
end: function () {
showLrc = false;
}
});
})
})
$('#reload').click(function () {
$.post(localhost + "/nas/music/reload.do", function (obj) {
layer.msg("提交刷新请求成功,几分钟后生效")
})
});
function updateLrc() {
if (showLrc) {
$.get(localhost + '/nas/music/lrc.do?filePath=' + playNow, function (file) {
if(file===''){
file='[00:00.00]---暂无歌词---'
}
lrc.setLrc(file)
lrc.move(0)
})
}
}
function playNext() {
if (isRandom) {
@ -313,8 +358,8 @@
}
function play(_json) {
let md5=''
md5=_json.md5
let md5 = ''
md5 = _json.md5
playNow = _json.md5
player.updateSource({
source: localhost + "/nas/music/play.do?random=false&filePath=" + md5
@ -344,9 +389,9 @@
title: json.data.title,
artist: json.data.artist,
album: json.data.album,
artwork:[
artwork: [
{
src: localhost+'/nas/music/web/image.do?fileName='+fileName,
src: localhost + '/nas/music/web/image.do?fileName=' + fileName,
type: 'image/png',
sizes: '128x128'
}
@ -358,7 +403,8 @@
});
}
})
$('#img').attr("src",localhost+'/nas/music/web/image.do?fileName='+fileName);
$('#img').attr("src", localhost + '/nas/music/web/image.do?fileName=' + fileName);
updateLrc()
}

View File

@ -66,7 +66,6 @@
$.get("/login/check.do",{share:getParam("share")}, function (data) {
try {
let json = JSON.parse(data);
console.log(data)
if (json.code === 0) {
$('#login_text').text('已登录')
loginStatus = true;

View File

@ -414,6 +414,7 @@
_this.elements.totalTime.html(_this.formatTime(duration));
}
_this.elements.playProgress.width((_this.elements.audioDom.currentTime / _this.elements.audioDom.duration) * $('.progress_bg').width());
_this.options.timeupdateCallback(currTime)
}
// Formatting a timestamp / 格式化时间戳相关
,formatTime: function(secs, format) {

148
web/js/lyricer.min.js vendored Normal file
View File

@ -0,0 +1,148 @@
(function () {
// The constrcutor can be empty or passed in the lrc string
var Lyricer = function (options) {
this.divID = "lyricer"; // the default html container id
this.currentcss = "lyricer-current-line"; // this css for the line current playing
this.lineidPrefix = "lyricer-line"; // the id prefix for each line
this.showLines = 8; //lines showing before and after;
this.clickable = true;
this.clickEventName = "lyricerclick";
if( options ) {
for( var prop in options ) {
if ( typeof this[prop] != "undefined" && options.hasOwnProperty(prop)) {
this[prop] = options[prop];
}
}
}
};
Lyricer.prototype.setLrc = function(rawLrc) {
this.tags = {};
this.lrc = [];
this.rangeLrc = [];
var tagRegex = /\[([a-z]+):(.*)\].*/;
var lrcAllRegex = /(\[[0-9.:\[\]]*\])+(.*)/;
var timeRegex = /\[([0-9]+):([0-9.]+)\]/;
var timeRegexGim = /\[([0-9]+):([0-9.]+)\]/g;
var rawLrcArray = rawLrc.split(/[\r\n]/);
for (var i = 0; i < rawLrcArray.length; i++) {
// handle tags first
var tag = tagRegex.exec(rawLrcArray[i]);
if ( tag && tag[0] ) {
this.tags[tag[1]] = tag[2];
continue;
}
// handle lrc
var lrc = lrcAllRegex.exec(rawLrcArray[i]);
if ( lrc && lrc[0] ) {
var times = lrc[1].replace(/\]\[/g,"],[").split(",");
for (var j = 0; j < times.length; j++) {
var time = timeRegex.exec(times[j]);
if ( time && time[0] ) {
this.lrc.push( { "starttime": parseInt(time[1],10) * 60 + parseFloat(time[2]), "line": lrc[2].replace(timeRegexGim,'') } );
};
};
};
};
//sort lrc array
this.lrc.sort(function (a,b) {
return a.starttime - b.starttime;
});
// crate the range lrc array
// dummy lines
for (var i = 0; i < this.showLines; i++) {
this.rangeLrc.push( { "starttime": -1, "endtime": 0, "line": "&nbsp;" } );
};
// real data
var starttime = 0;
var line = "";
for (var i = 0; i < this.lrc.length; i++) {
endtime = parseFloat(this.lrc[i].starttime);
this.rangeLrc.push( { "starttime": starttime, "endtime": endtime, "line": line } );
starttime = endtime;
line = this.lrc[i].line;
};
this.rangeLrc.push( { "starttime": starttime, "endtime": 999.99, "line": line } );
// dummy lines
for (var i = 0; i < this.showLines; i++) {
this.rangeLrc.push( { "starttime": -1, "endtime": 0, "line": "&nbsp;" } );
};
this.totalLines = this.rangeLrc.length;
// set html and move to start
setHtml(this);
this.move(0);
};
var setHtml = function(self) {
self.currentLine = 0;
var container = document.getElementById(self.divID);
container.innerHTML = "";
var ul = document.createElement("ul");
container.appendChild(ul);
for (var i = 0; i < self.totalLines; i++) {
var li = document.createElement("li");
li.innerHTML = self.rangeLrc[i].line;
if (!li.innerHTML) {li.innerHTML="&nbsp;"};
li.setAttribute("id", self.lineidPrefix + i);
if (self.clickable) {
li.onclick = lineClicked(self, i);
li.style.cursor = 'pointer';
}
ul.appendChild(li);
};
// hide the later ones
for (var i = self.showLines; i < self.totalLines; i++) {
document.getElementById(self.lineidPrefix + i).style.display = "none";
};
};
var lineClicked = function(self, id) {
return function(){
var detail = {"time": self.rangeLrc[id].starttime};
var e = new CustomEvent(self.clickEventName, {
'detail': detail,
"bubbles": true
});
var elem = document.getElementById(self.lineidPrefix + id);
elem.dispatchEvent(e);
};
};
Lyricer.prototype.move = function(time) {
for (var i = 0; i < this.totalLines; i++) {
if (time >= this.rangeLrc[i].starttime && time < this.rangeLrc[i].endtime) {
this.currentLine = i;
moveToLine(this,this.currentLine);
return;
};
};
};
var moveToLine = function (self, line) {
var startShow = line - self.showLines;
var endShow = line + self.showLines;
for (var i = 0; i < self.totalLines; i++) {
var li = document.getElementById(self.lineidPrefix + i);
if ( i >= startShow && i <= endShow ) {
li.style.display = "block";
} else{
li.style.display = "none";
};
if (i==line) {
li.className = self.currentcss;
} else {
li.className = "";
};
};
};
window.Lyricer = Lyricer; //exposed to global
})();

View File

@ -102,8 +102,12 @@ function Base64() {
}
}
function getParam(name){
console.log(window.location.href)
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(window.location.href);
let url=window.location.href;
return getParamToUrl(name,url)
}
function getParamToUrl(name,url){
console.log(url)
let results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(url);
if (results == null) {
return null;
} else {