|
|
@@ -11,10 +11,25 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
+import org.apache.http.Header;
|
|
|
+import org.apache.http.HttpEntity;
|
|
|
+import org.apache.http.HttpResponse;
|
|
|
+import org.apache.http.NameValuePair;
|
|
|
+import org.apache.http.client.HttpClient;
|
|
|
+import org.apache.http.client.entity.UrlEncodedFormEntity;
|
|
|
+import org.apache.http.client.methods.HttpGet;
|
|
|
+import org.apache.http.client.methods.HttpPost;
|
|
|
+import org.apache.http.message.BasicNameValuePair;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
+import java.io.IOException;
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
@@ -69,6 +84,94 @@ public class DianzhongConfigServiceImpl implements IDianzhongConfigService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void pullMovie() throws IOException {
|
|
|
+ pullMoviePage(0, 100);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void pullMoviePage(int offset, int limit) throws IOException {
|
|
|
+ log.info("拉取: 点众剧目,offset: {}, limit: {}", offset, limit);
|
|
|
+ String url = "https://vip.wqxsw.com/admin/referral/book/index?sort=idx&order=desc&offset="+offset+"&limit="+limit+"&filter=%7B%7D&op=%7B%7D&_="+System.currentTimeMillis();
|
|
|
+ //免费付费剧目ID相同,拉一次就可以
|
|
|
+ Map<String, String> headers = new HashMap<>();
|
|
|
+ headers.put("Cookie", "PHPSESSID=a2t3dp59hn92sjm0a7spe82b2s; keeplogin=29581%7C604800%7C1755853777%7Cea024be2fbc5c0604c25514f216e178f");
|
|
|
+ headers.put("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
|
|
+ headers.put("Accept", "application/json, text/javascript, */*; q=0.01");
|
|
|
+ headers.put("x-requested-with", "XMLHttpRequest");
|
|
|
+
|
|
|
+ String res = HttpUtils.httpGet(url, null, headers);
|
|
|
+ if (StringUtils.isNotEmpty(res)){
|
|
|
+ pullMovieInfo(res);
|
|
|
+ if (offset <=100){ //每次只拉最近300个
|
|
|
+ pullMoviePage(offset+limit, limit);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void pullMovieInfo(String str) throws IOException {
|
|
|
+ JSONObject res = JSONArray.parseObject(str);
|
|
|
+ JSONArray rows = res.getJSONArray("rows");
|
|
|
+ if (rows==null || rows.isEmpty()){
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ for (int i = 0; i < rows.size(); i++) {
|
|
|
+ JSONObject minfo = rows.getJSONObject(i);
|
|
|
+ DianzhongMovieConfig config = new DianzhongMovieConfig();
|
|
|
+ config.setMovieId(minfo.getString("bookId"));
|
|
|
+ config.setMovieName(minfo.getString("bookName"));
|
|
|
+ config.setCoverImgUrl(minfo.getString("coverCutWap"));
|
|
|
+ config.setChapterCount(minfo.getInteger("totalChapterNum"));
|
|
|
+ config.setFreeChapterCount(minfo.getInteger("freeChapterNum"));
|
|
|
+ config.setType1(minfo.getString("bookTypeOne"));
|
|
|
+ config.setType2(minfo.getString("bookTypeTwo"));
|
|
|
+ config.setType3(minfo.getString("bookTypeThree"));
|
|
|
+ config.setFirstShelfTime(minfo.getString("firstShelfTime"));
|
|
|
+ config.setInfoJson(minfo.toJSONString());
|
|
|
+
|
|
|
+ dianzhongConfigMapper.insertConfigSelective(config);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ private void tt() throws Exception {
|
|
|
+ String loginUrl = "https://vip.wqxsw.com/admin/index/login?url=%2Fadmin%2Findex%2Findex";
|
|
|
+ //免费付费剧目ID相同,拉一次就可以
|
|
|
+ HttpPost httpPost = new HttpPost(loginUrl);
|
|
|
+ //PHPSESSID=a2t3dp59hn92sjm0a7spe82b2s; keeplogin=29581%7C604800%7C1755853777%7Cea024be2fbc5c0604c25514f216e178f
|
|
|
+ httpPost.setHeader("Cookie", "PHPSESSID=n3620u5ck12dplrbqfmvslegt2");
|
|
|
+ httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
|
|
|
+ httpPost.setHeader("Accept", "application/json, text/javascript, */*; q=0.01");
|
|
|
+ httpPost.setHeader("x-requested-with", "XMLHttpRequest");
|
|
|
+ List<NameValuePair> params = new ArrayList<>();
|
|
|
+ params.add(new BasicNameValuePair("username", "tjxldyvip1"));
|
|
|
+ params.add(new BasicNameValuePair("password", "Aa112233"));
|
|
|
+ params.add(new BasicNameValuePair("keeplogin", "1"));
|
|
|
+ HttpEntity httpEntity = new UrlEncodedFormEntity(params);
|
|
|
+ httpPost.setEntity(httpEntity);
|
|
|
+
|
|
|
+ HttpClient httpclient = HttpUtils.getHttpclient();
|
|
|
+ HttpResponse response = httpclient.execute(httpPost);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode != 200) {
|
|
|
+ log.error("点众登录失败,状态码: {}", statusCode);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ Header[] headers = response.getHeaders("Set-Cookie");
|
|
|
+ //获取其中的keeplogin
|
|
|
+ String cookie = null;
|
|
|
+ for (Header header : headers) {
|
|
|
+ String value = header.getValue();
|
|
|
+ if (value.contains("keeplogin")) {
|
|
|
+ cookie = value;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
|
@@ -103,54 +206,7 @@ public class DianzhongConfigServiceImpl implements IDianzhongConfigService {
|
|
|
return object;
|
|
|
}
|
|
|
|
|
|
-// private DianZhongConfig.DZConfig getAuthConfig(){
|
|
|
-// return dianZhongConfig.getDzConfig().get(0);
|
|
|
-// }
|
|
|
- //废弃
|
|
|
-@Override
|
|
|
-public void pullMovieInfo(String date, Long channelId) {
|
|
|
- String url = "https://video.wqxsw.com/api/channelapi/books";
|
|
|
- JSONObject requestJson = initRequestJson(dianZhongConfig.getDzConfig().get(0));
|
|
|
- requestJson.put("date", date);
|
|
|
- if (channelId != null){
|
|
|
- requestJson.put("channelId", channelId);
|
|
|
- }
|
|
|
- System.out.println("请求点众书籍列表接口,参数:" + requestJson.toJSONString());
|
|
|
- String res = HttpUtils.httpPostRequest(url, requestJson, null);
|
|
|
- if (StringUtils.isEmpty(res)){
|
|
|
- log.error("点众书籍列表接口返回结果为空");
|
|
|
- return;
|
|
|
- }
|
|
|
- JSONObject resObj = JSONObject.parseObject(res);
|
|
|
- int code = resObj.getIntValue("code");
|
|
|
- if (code >1){
|
|
|
- log.error("点众书籍列表接口返回错误,code: {}, msg: {}", code, resObj.getString("msg"));
|
|
|
- return;
|
|
|
- }
|
|
|
- JSONArray data = resObj.getJSONArray("data");
|
|
|
- if (data == null || data.isEmpty()) {
|
|
|
- System.out.println(res);
|
|
|
- log.info("点众书籍列表接口没有返回数据");
|
|
|
- return;
|
|
|
- }
|
|
|
- for (int i = 0; i < data.size(); i++) {
|
|
|
- JSONObject m = data.getJSONObject(i);
|
|
|
- DianzhongMovieConfig config = new DianzhongMovieConfig();
|
|
|
- config.setMovieId(m.getString("bookId"));
|
|
|
- config.setMovieName(m.getString("bookName"));
|
|
|
- config.setIntroduction(m.getString("introduction"));
|
|
|
- config.setWordCount(m.getInteger("totalWordSize"));
|
|
|
- config.setCoverImgUrl(m.getString("coverWap"));
|
|
|
- config.setType1(m.getString("bookTypeOneText"));
|
|
|
- config.setType2(m.getString("bookTypeTwoText"));
|
|
|
- config.setType3(m.getString("bookTypeThreeText"));
|
|
|
- config.setFirstShelfTime(m.getString("firstShelfTime"));
|
|
|
- config.setShowTitle(m.getString("showTitle"));
|
|
|
- config.setUpdateBy("system");
|
|
|
- config.setCreateBy("system");
|
|
|
-
|
|
|
- System.out.println(JSONObject.toJSONString(config));
|
|
|
- dianzhongConfigMapper.insertConfigSelective(config);
|
|
|
- }
|
|
|
-}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|