Quellcode durchsuchen

批量传麻将侠

licailing vor 4 Jahren
Ursprung
Commit
3d2a088922
1 geänderte Dateien mit 23 neuen und 7 gelöschten Zeilen
  1. 23 7
      src/test/java/com/izouma/nineth/service/CollectionServiceTest.java

+ 23 - 7
src/test/java/com/izouma/nineth/service/CollectionServiceTest.java

@@ -30,6 +30,7 @@ import java.text.SimpleDateFormat;
 import java.time.LocalDateTime;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicInteger;
+import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 import java.util.stream.Collectors;
 
@@ -59,22 +60,28 @@ class CollectionServiceTest extends ApplicationTests {
         AtomicInteger num = new AtomicInteger(1);
         List<BlindBoxItem> items = new ArrayList<>();
         String jsonStr = FileUtils.readFileToString(new File("/Users/qiufangchao/Desktop/mj.json"), "UTF-8");
-        Arrays.stream(new File("/Users/qiufangchao/Desktop/mahjong/dong").listFiles())
+        Arrays.stream(new File("/Users/qiufangchao/Desktop/majiang").listFiles())
                 .filter(f -> !f.getName().contains(".DS_Store"))
                 .parallel().forEach(file -> {
                     try {
+                        String name = file.getName();
+                        Pattern p = Pattern.compile("(\\d+)-(\\d+)");
+                        Matcher matcher = p.matcher(name);
+                        matcher.find();
+                        String findname = matcher.group();
+
                         Collection collection = JSON.parseObject(jsonStr, Collection.class);
                         collection.setId(null);
-                        collection.setName("MAHJONGMAN 麻将侠: 十三幺 1-" + num.getAndIncrement());
+                        collection.setName("MAHJONGMAN 麻将侠: 十三幺 " + findname);
                         collection.setStock(1);
                         collection.setTotal(1);
                         collection.setSale(0);
                         collection.setMinterId(7150L);
                         collection.setOnShelf(false);
                         collection.setSalable(false);
-                        String thumbPath = "https://cdn.raex.vip/thumb_image/mahjong/" + file.getName()
+                        String thumbPath = "https://cdn.raex.vip/thumb_image/mahjongman/" + file.getName()
                                 .substring(0, file.getName().lastIndexOf(".")) + ".jpg";
-                        collection.setPic(Collections.singletonList(new FileObject("", "https://cdn.raex.vip/video/mahjong/" + file.getName(), thumbPath, "video/mp4")));
+                        collection.setPic(Collections.singletonList(new FileObject("", "https://cdn.raex.vip/video/mahjongman/" + file.getName(), thumbPath, "video/mp4")));
 
                         collectionRepo.save(collection);
                         System.out.println("保存成功" + collection.getId());
@@ -158,8 +165,8 @@ class CollectionServiceTest extends ApplicationTests {
                 .forEach(file -> {
                     System.out.println(file.getName());
                     try {
-                        String url = storageService.uploadFromInputStream(new FileInputStream(file), "video/mahjong/" + file.getName());
-                        String thumbPath = "thumb_image/mahjong/" + file.getName()
+                        String url = storageService.uploadFromInputStream(new FileInputStream(file), "video/mahjongman/" + file.getName());
+                        String thumbPath = "thumb_image/mahjongman/" + file.getName()
                                 .substring(0, file.getName().lastIndexOf(".")) + ".jpg";
 
                         FFmpegFrameGrabber frameGrabber = new FFmpegFrameGrabber(file);
@@ -187,8 +194,17 @@ class CollectionServiceTest extends ApplicationTests {
                     } catch (Exception e) {
                     }
                 });
+    }
 
-
+    @Test
+    public void test2() {
+        String name = "/Users/qiufangchao/Desktop/majiang/bai1-1.mp4";
+        Pattern p = Pattern.compile("(\\d+)-(\\d+)");
+        Matcher matcher = p.matcher(name);
+        matcher.find();
+        String firstHour = matcher.group();
+        System.out.println(matcher.start());
+        System.out.println(firstHour);
     }
 
 }