Forráskód Böngészése

update:如遇到手动更新番号的数据失败重试任务的处理v1

tujidelv 3 éve
szülő
commit
bbdffb6cc4

+ 5 - 0
src/main/java/top/lvzhiqiang/entity/CrawlerLoveFoot.java

@@ -91,6 +91,11 @@ public class CrawlerLoveFoot implements Serializable {
     private Integer status;
 
     /**
+     * 1是2否,默认2
+     */
+    private Integer changeTitleFlag;
+
+    /**
      * 失败原因
      */
     private String failureCause;

+ 24 - 5
src/main/java/top/lvzhiqiang/service/impl/Crawler4LoveFootServiceImpl.java

@@ -166,6 +166,7 @@ public class Crawler4LoveFootServiceImpl implements Crawler4LoveFootService {
                 String searchUrl = null;
                 Elements itembSelects = null;
                 try {
+                    String javbusCodeUrl = null;
                     if ("javbus".equals(website)) {
                         String javbusUrl = javbusUrlList.get((int) (0 + Math.random() * (javbusUrlList.size())));
                         searchUrl = javbusUrl.concat("/search/").concat(crawlerLoveFoot.getName()).concat("&parent=ce");
@@ -205,16 +206,28 @@ public class Crawler4LoveFootServiceImpl implements Crawler4LoveFootService {
                                     try {
                                         searchDocument = JsoupUtil.requestDocument(searchUrl, JsoupUtil.HTTP_GET, proxy, null, null, null);
                                     } catch (Exception eeee) {
-                                        throw new BusinessException(30000, "javbus search result null");
+                                        // throw new BusinessException(30000, "javbus search result null");
                                     }
                                 }
                             }
                         }
 
-                        itembSelects = searchDocument.select("div#waterfall").select("div.item");
+                        if (null == searchDocument) {
+                            if (crawlerLoveFoot.getIdentificationCode().length() < 32) {
+                                javbusCodeUrl = javbusUrl.concat("/").concat(crawlerLoveFoot.getIdentificationCode());
+                                itembSelects = new Elements();
+                            } else {
+                                throw new BusinessException(30000, "javbus search result null");
+                            }
+                        } else {
+                            itembSelects = searchDocument.select("div#waterfall").select("div.item");
+                            if (itembSelects.size() == 0) {
+                                throw new BusinessException(30000, "javbus search result null");
+                            }
 
-                        if (itembSelects.size() == 0) {
-                            throw new BusinessException(30000, "javbus search result null");
+                            if (crawlerLoveFoot.getIdentificationCode().length() < 32) {
+                                javbusCodeUrl = javbusUrl.concat("/").concat(crawlerLoveFoot.getIdentificationCode());
+                            }
                         }
                     } else if ("javdb".equals(website)) {
                         searchUrl = javdbConstantMap.get("javdb").concat("search?q=").concat(crawlerLoveFoot.getName()).concat("&f=all");
@@ -267,6 +280,12 @@ public class Crawler4LoveFootServiceImpl implements Crawler4LoveFootService {
                                 break;
                             }
                         }
+
+                        if (StringUtils.isEmpty(codeUrl) && StringUtils.isNotEmpty(javbusCodeUrl)) {
+                            codeUrl = javbusCodeUrl;
+                            crawlerLoveFoot.setChangeTitleFlag(1);
+                        }
+
                         if (StringUtils.isEmpty(codeUrl)) {
                             throw new BusinessException(30000, "javbus search result mismatch");
                         }
@@ -715,7 +734,7 @@ public class Crawler4LoveFootServiceImpl implements Crawler4LoveFootService {
         long start = System.currentTimeMillis();
         Connection.Response response = Jsoup.connect(href).method(Connection.Method.GET).ignoreContentType(true).timeout(50 * 1000).execute();
 
-        String fileName = issueDate.concat(" ").concat(h3);
+        String fileName = issueDate.concat(" ").concat(h3).replace("/", "_");
         byte[] imgUrlBytes = fileName.getBytes(StandardCharsets.UTF_8);
         if (imgUrlBytes.length > 251) {
             byte[] imgUrlDestBytes = new byte[251];

+ 3 - 0
src/main/resources/mapper/VideoInfoLoveFootMapper.xml

@@ -81,6 +81,9 @@
             <if test="status != null">
                 status = #{status},
             </if>
+            <if test="changeTitleFlag != null">
+                change_title_flag = #{changeTitleFlag},
+            </if>
             <if test="failureCause != null">
                 failure_cause = #{failureCause},
             </if>