Przeglądaj źródła

快手热门音乐数据

syh 4 lat temu
rodzic
commit
cf5db29e81

+ 143 - 0
jeecg-boot-module-system/src/main/java/org/jeecg/modules/ctop/controller/MusicKuaishouTypeController.java

@@ -0,0 +1,143 @@
+package org.jeecg.modules.ctop.controller;
+
+import cn.com.ctop.crawler.modules.music.entity.MusicKuaishouType;
+import cn.com.ctop.crawler.modules.music.service.IMusicKuaishouTypeService;
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import lombok.extern.slf4j.Slf4j;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.Arrays;
+
+ /**
+ * 快手音乐类别
+ * @author jeecg-boot
+ * @date   2020-09-11
+ * @version V1.0
+ */
+@Slf4j
+@Api(tags="快手音乐类别")
+@RestController
+@RequestMapping("/ctop/musicKuaishouType")
+public class MusicKuaishouTypeController {
+	@Autowired
+	private IMusicKuaishouTypeService musicKuaishouTypeService;
+
+	/**
+	  * 分页列表查询
+	 * @param musicKuaishouType
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	@GetMapping(value = "/list")
+	public Result<IPage<MusicKuaishouType>> queryPageList(MusicKuaishouType musicKuaishouType,
+														  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+														  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+														  HttpServletRequest req) {
+		Result<IPage<MusicKuaishouType>> result = new Result<>();
+		QueryWrapper<MusicKuaishouType> queryWrapper = QueryGenerator.initQueryWrapper(musicKuaishouType, req.getParameterMap());
+		Page<MusicKuaishouType> page = new Page<>(pageNo, pageSize);
+		IPage<MusicKuaishouType> pageList = musicKuaishouTypeService.page(page, queryWrapper);
+		result.setSuccess(true);
+		result.setResult(pageList);
+		return result;
+	}
+
+	/**
+	  *   添加
+	 * @param musicKuaishouType
+	 * @return
+	 */
+	@PostMapping(value = "/add")
+	public Result<MusicKuaishouType> add(@RequestBody MusicKuaishouType musicKuaishouType) {
+		Result<MusicKuaishouType> result = new Result<>();
+		try {
+			musicKuaishouTypeService.save(musicKuaishouType);
+			result.success("添加成功!");
+		} catch (Exception e) {
+			log.error(e.getMessage(),e);
+			result.error500("操作失败");
+		}
+		return result;
+	}
+
+	/**
+	  *  编辑
+	 * @param musicKuaishouType
+	 * @return
+	 */
+	@PutMapping(value = "/edit")
+	public Result<MusicKuaishouType> edit(@RequestBody MusicKuaishouType musicKuaishouType) {
+		Result<MusicKuaishouType> result = new Result<>();
+		MusicKuaishouType musicKuaishouTypeEntity = musicKuaishouTypeService.getById(musicKuaishouType.getId());
+		if(musicKuaishouTypeEntity==null) {
+			result.error500("未找到对应实体");
+		}else {
+			boolean ok = musicKuaishouTypeService.updateById(musicKuaishouType);
+			if(ok) {
+				result.success("修改成功!");
+			}
+		}
+
+		return result;
+	}
+
+	/**
+	  *   通过id删除
+	 * @param id
+	 * @return
+	 */
+	@DeleteMapping(value = "/delete")
+	public Result<?> delete(@RequestParam(name="id",required=true) String id) {
+		try {
+			musicKuaishouTypeService.removeById(id);
+		} catch (Exception e) {
+			log.error("删除失败",e.getMessage());
+			return Result.error("删除失败!");
+		}
+		return Result.ok("删除成功!");
+	}
+
+	/**
+	  *  批量删除
+	 * @param ids
+	 * @return
+	 */
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<MusicKuaishouType> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		Result<MusicKuaishouType> result = new Result<>();
+		if(ids==null || "".equals(ids.trim())) {
+			result.error500("参数不识别!");
+		}else {
+			this.musicKuaishouTypeService.removeByIds(Arrays.asList(ids.split(",")));
+			result.success("删除成功!");
+		}
+		return result;
+	}
+
+	/**
+	  * 通过id查询
+	 * @param id
+	 * @return
+	 */
+	@GetMapping(value = "/queryById")
+	public Result<MusicKuaishouType> queryById(@RequestParam(name="id",required=true) String id) {
+		Result<MusicKuaishouType> result = new Result<>();
+		MusicKuaishouType musicKuaishouType = musicKuaishouTypeService.getById(id);
+		if(musicKuaishouType==null) {
+			result.error500("未找到对应实体");
+		}else {
+			result.setResult(musicKuaishouType);
+			result.setSuccess(true);
+		}
+		return result;
+	}
+}

+ 21 - 24
jeecg-boot-module-system/src/test/java/org/jeecg/SampleTest.java

@@ -5,11 +5,12 @@ import cn.com.ctop.check.entity.CtopCheckTaskList;
 import cn.com.ctop.check.service.ICtopCheckTaskListService;
 import cn.com.ctop.common.module.entity.BindAccountLogin;
 import cn.com.ctop.common.module.entity.CtopOauthToken;
-import cn.com.ctop.common.module.entity.UReportSubscriber;
 import cn.com.ctop.common.module.entity.UserAllocation;
 import cn.com.ctop.common.module.message.handle.impl.EmailSendMsgHandle;
 import cn.com.ctop.common.module.service.*;
 import cn.com.ctop.common.module.utils.CtopAdConstant;
+import cn.com.ctop.crawler.modules.core.service.IKuaishouCrawlerService;
+import cn.com.ctop.crawler.modules.music.service.IMusicKuaishouTypeService;
 import cn.com.ctop.kuaishou.modules.graphql.service.IKuaishouWebInterfaceService;
 import cn.com.ctop.kuaishou.modules.report.service.IKuaishouReportDailyAgentService;
 import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
@@ -27,7 +28,6 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.junit4.SpringRunner;
 
-import java.io.File;
 import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
@@ -256,28 +256,25 @@ public class SampleTest {
     @Autowired
     IUReportService uReportService;
 
+    @Autowired
+    private IKuaishouCrawlerService crawlerService;
+    @Autowired
+    private IMusicKuaishouTypeService musicKuaishouTypeService;
     @Test
-    public void sendUReport() {
-        uReportService.uReportList().forEach(uReport -> {
-            List<UReportSubscriber> uReportSubscriber = uReportService.getUReportSubscriberByFileId(uReport.getString("id"));
-            if (!uReportSubscriber.isEmpty()) {
-                String title = uReport.getString("name").replace(".ureport.xml", "");
-                String content = "您订阅的日报在附件中请注意查收》》》";
-                //下载文件到本地
-                uReportExportService.exportExcel(uReport.getString("name"));
-                uReportSubscriber.forEach(sender -> {
-                    emailSendMsgHandle.SendAttachment("bijiequan@c-top.com.cn", title, content,
-                            new File(System.getProperty("user.dir") + File.separator + "uReport" + File.separator + uReport.getString("name").replace("ureport.xml", "") + "xlsx"));
-                });
-            }
-        });
-        //发完全部订阅,删除文件
-        File file = new File(System.getProperty("user.dir") + File.separator + "uReport");
-        File[] files = file.listFiles();
-        if (files != null && files.length > 0) {
-            for (File f : files) {
-                f.delete();
-            }
-        }
+    public void loadKuaishouMusicInfo(){
+//        String musicTypeString = crawlerService.getMusicTypeList("");
+//        String llsid = JSONObject.parseObject(musicTypeString).getString("llsid");
+//        System.out.println(llsid);
+//        JSONArray channels = JSONObject.parseObject(musicTypeString).getJSONArray("channels");
+//        if (null!=channels&&!channels.isEmpty()){
+//            for(int i=0;i<channels.size();i++){
+//                JSONObject object = channels.getJSONObject(i);
+//                MusicKuaishouType kuaishouType = new MusicKuaishouType(object);
+//                musicKuaishouTypeService.save(kuaishouType);
+//            }
+//        }
+        String llsid = "2000106667298730337";
+        String musicTypeString = crawlerService.getMusicList("200032",llsid);
+        System.out.println(musicTypeString);
     }
 }

+ 11 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/service/IKuaishouCrawlerService.java

@@ -4,10 +4,21 @@ import cn.com.ctop.crawler.modules.account.entity.KuaishouAdAccount;
 import cn.com.ctop.crawler.modules.account.entity.KuaishouAppAccount;
 import cn.com.ctop.crawler.modules.account.entity.KuaishouIosAccount;
 
+import java.io.UnsupportedEncodingException;
+
 public interface IKuaishouCrawlerService {
     String getVideoFeeds(KuaishouAppAccount kuaishouAppAccount,Integer page);
     String getVideoFeeds(KuaishouIosAccount kuaishouIosAccount);
     String getAdAccountVideoFeeds(KuaishouAdAccount kuaishouAdAccount,String pcursor);
+
+    String getMusicTypeList(String llsid);
+
+    String musicSearchSuggest(String keyword) throws UnsupportedEncodingException;
+
+    String musicSearchList(String keyword) throws UnsupportedEncodingException;
+
+    String getMusicList(String channel, String llsid);
+
     String getAdFeeds();
     String getUserProfile(Long userId);
 }

+ 14 - 5
module-crawler/src/main/java/cn/com/ctop/crawler/modules/core/service/impl/KuaishouCrawlerServiceImpl.java

@@ -77,6 +77,7 @@ public class KuaishouCrawlerServiceImpl implements IKuaishouCrawlerService {
         return null;
     }
 
+    @Override
     public String getMusicTypeList(String llsid){
 //        IpPool ipPool = iIpPoolService.getAvaliableIp();
         String token = "a7805c554d6a453ea3350b629b28fed9-1144829703";
@@ -86,9 +87,14 @@ public class KuaishouCrawlerServiceImpl implements IKuaishouCrawlerService {
         String url = "http://apihb6.gifshow.com";
         String path = "/rest/n/music/channel/music";
         CrawlerLog crawlerLog = KuaishouUtil.kuaishouAppDataFeatch(url, path, staticStr, paramStr, headerStr, token, null);
-        return crawlerLog.getRequestBody();
+        return crawlerLog.getResponseBody();
+    }
+
+    public static void main(String[] args) {
+
     }
 
+    @Override
     public String musicSearchSuggest(String keyword) throws UnsupportedEncodingException {
 //        IpPool ipPool = iIpPoolService.getAvaliableIp();
         String token = "a7805c554d6a453ea3350b629b28fed9-1144829703";
@@ -98,9 +104,10 @@ public class KuaishouCrawlerServiceImpl implements IKuaishouCrawlerService {
         String url = "http://apihb6.gifshow.com";
         String path = "/rest/n/music/search/suggest";
         CrawlerLog crawlerLog = KuaishouUtil.kuaishouAppDataFeatch(url, path, staticStr, paramStr, headerStr, token, null);
-        return crawlerLog.getRequestBody();
+        return crawlerLog.getResponseBody();
     }
 
+    @Override
     public String musicSearchList(String keyword) throws UnsupportedEncodingException {
 //        IpPool ipPool = iIpPoolService.getAvaliableIp();
         String token = "a7805c554d6a453ea3350b629b28fed9-1144829703";
@@ -110,10 +117,11 @@ public class KuaishouCrawlerServiceImpl implements IKuaishouCrawlerService {
         String url = "http://apihb6.gifshow.com";
         String path = "/rest/n/music/search/v3";
         CrawlerLog crawlerLog = KuaishouUtil.kuaishouAppDataFeatch(url, path, staticStr, paramStr, headerStr, token, null);
-        return crawlerLog.getRequestBody();
+        return crawlerLog.getResponseBody();
     }
 
-    public String getMusicList(String channel,String llsid){
+    @Override
+    public String getMusicList(String channel, String llsid){
 //        IpPool ipPool = iIpPoolService.getAvaliableIp();
         String token = "a7805c554d6a453ea3350b629b28fed9-1144829703";
         String staticStr = String.format("app=0&kpf=ANDROID_PHONE&ver=6.5&c=HUAWEI&mod=HUAWEI(VOG-AL10)&appver=6.5.5.9591&ftt=&isp=CUCC&kpn=KUAISHOU&lon=0&language=zh-cn&sys=ANDROID_9&max_memory=384&ud=1144829703&country_code=cn&pm_tag=&oc=HUAWEI&hotfix_ver=&did_gt=%s&iuid=&extId=4db221a192e4d1d713c5dafb204400a8&net=WIFI&did=ANDROID_07264410e70db2ca&lat=0", String.valueOf(System.currentTimeMillis()));
@@ -122,9 +130,10 @@ public class KuaishouCrawlerServiceImpl implements IKuaishouCrawlerService {
         String url = "http://apihb6.gifshow.com";
         String path = "/rest/n/music/channel/music";
         CrawlerLog crawlerLog = KuaishouUtil.kuaishouAppDataFeatch(url, path, staticStr, paramStr, headerStr, token, null);
-        return crawlerLog.getRequestBody();
+        return crawlerLog.getResponseBody();
     }
 
+
     @Override
     public String getAdFeeds(){
         IpPool ipPool = iIpPoolService.getAvaliableIp();

+ 45 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/music/entity/MusicKuaishouType.java

@@ -0,0 +1,45 @@
+package cn.com.ctop.crawler.modules.music.entity;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import io.swagger.annotations.ApiModel;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+import java.util.Date;
+
+/**
+ * 快手音乐类别
+ * @author jeecg-boot
+ * @date   2020-09-11
+ * @version V1.0
+ */
+@Data
+@TableName("ctop_music_kuaishou_type")
+@EqualsAndHashCode(callSuper = false)
+@Accessors(chain = true)
+@ApiModel(value="ctop_music_kuaishou_type对象", description="快手音乐类别")
+public class MusicKuaishouType {
+
+	@TableId
+    private Long id;
+	private String type;
+	private String name;
+	private String icon;
+	private Date createTime;
+	private Date updateTime;
+
+	public MusicKuaishouType(JSONObject data) {
+		this.setIcon(data.getString("icon"));
+		this.setName(data.getString("name"));
+		this.setType(data.getString("type"));
+		this.setId(data.getLong("id"));
+	}
+
+	public MusicKuaishouType() {
+
+	}
+
+}

+ 14 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/music/mapper/MusicKuaishouTypeMapper.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.crawler.modules.music.mapper;
+
+import cn.com.ctop.crawler.modules.music.entity.MusicKuaishouType;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * 快手音乐类别
+ * @author: jeecg-boot
+ * @date:   2020-09-11
+ * @cersion: V1.0
+ */
+public interface MusicKuaishouTypeMapper extends BaseMapper<MusicKuaishouType> {
+
+}

+ 5 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/music/mapper/xml/MusicKuaishouTypeMapper.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="cn.com.ctop.crawler.modules.music.mapper.MusicKuaishouTypeMapper">
+
+</mapper>

+ 14 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/music/service/IMusicKuaishouTypeService.java

@@ -0,0 +1,14 @@
+package cn.com.ctop.crawler.modules.music.service;
+
+import cn.com.ctop.crawler.modules.music.entity.MusicKuaishouType;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 快手音乐类别
+ * @Author: jeecg-boot
+ * @Date:   2020-09-11
+ * @Version: V1.0
+ */
+public interface IMusicKuaishouTypeService extends IService<MusicKuaishouType> {
+
+}

+ 18 - 0
module-crawler/src/main/java/cn/com/ctop/crawler/modules/music/service/impl/MusicKuaishouTypeServiceImpl.java

@@ -0,0 +1,18 @@
+package cn.com.ctop.crawler.modules.music.service.impl;
+
+import cn.com.ctop.crawler.modules.music.entity.MusicKuaishouType;
+import cn.com.ctop.crawler.modules.music.mapper.MusicKuaishouTypeMapper;
+import cn.com.ctop.crawler.modules.music.service.IMusicKuaishouTypeService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * 快手音乐类别
+ * @author jeecg-boot
+ * @date   2020-09-11
+ * @version V1.0
+ */
+@Service
+public class MusicKuaishouTypeServiceImpl extends ServiceImpl<MusicKuaishouTypeMapper, MusicKuaishouType> implements IMusicKuaishouTypeService {
+
+}