Prechádzať zdrojové kódy

update content-service

reghao 7 mesiacov pred
rodič
commit
5f192fe417

+ 8 - 0
content/content-service/src/main/java/cn/reghao/tnb/content/app/vod/controller/VideoController.java

@@ -3,6 +3,7 @@ package cn.reghao.tnb.content.app.vod.controller;
 import cn.reghao.jutil.jdk.result.Result;
 import cn.reghao.jutil.web.WebResult;
 import cn.reghao.tnb.common.auth.AuthUser;
+import cn.reghao.tnb.content.app.vod.model.dto.VideoEdit;
 import cn.reghao.tnb.content.app.vod.model.dto.VideoErrorReport;
 import cn.reghao.tnb.content.app.vod.model.vo.DownloadUrl;
 import cn.reghao.tnb.content.app.vod.service.VideoService;
@@ -57,4 +58,11 @@ public class VideoController {
         Result result = videoService.errorReport(videoErrorReport);
         return WebResult.result(result);
     }
+
+    @Operation(summary = "视频编辑", description = "N")
+    @PostMapping("/edit")
+    public String editVideo(@RequestBody @Validated VideoEdit videoEdit) {
+        videoService.editVideo(videoEdit);
+        return WebResult.success();
+    }
 }

+ 1 - 0
content/content-service/src/main/java/cn/reghao/tnb/content/app/vod/db/mapper/VideoCategoryPostMapper.java

@@ -16,6 +16,7 @@ import java.util.List;
 @Mapper
 public interface VideoCategoryPostMapper extends BaseMapper<VideoCategoryPost> {
     void updateVideoCategoryPost(VideoCategoryPost videoCategoryPost);
+    void deleteByCategoryPid(int categoryPid);
 
     int countByCriteria(VideoQuery videoQuery);
     List<VideoCategoryPost> findVideoCategoryPostByPage(@Param("page") Page page, @Param("videoQuery") VideoQuery videoQuery);

+ 6 - 1
content/content-service/src/main/java/cn/reghao/tnb/content/app/vod/db/mapper/VideoPostMapper.java

@@ -33,6 +33,8 @@ public interface VideoPostMapper extends BaseMapper<VideoPost> {
     void updateVideoCached(@Param("videoId") String videoId,
                            @Param("videoInfo") VideoInfo videoInfo,
                            @Param("channelId") int channelId);
+    void updateVideoUser(@Param("newUserId") long newUserId,
+                         @Param("videoIds") List<String> videoIds);
     void deleteByVideoId(String videoId);
 
     /* 根据条件分页获取 */
@@ -52,7 +54,7 @@ public interface VideoPostMapper extends BaseMapper<VideoPost> {
     List<VideoPostCard> findByUserIds(@Param("userIds") List<Long> userIds, @Param("pageSize") int pageSize, @Param("nextId") int nextId);
     int countBySearchCriteria(SearchCriteria searchCriteria);
     List<VideoPost> findSearchCriteriaByPage(@Param("page") Page page, @Param("searchCriteria") SearchCriteria searchCriteria);
-    List<VideoPost> findAllById(int pageSize, int nextId);
+    List<VideoPost> findAllById(@Param("pageSize") int pageSize, @Param("nextId") int nextId);
     @Deprecated
     List<BannerVideo> findBannerVideos(List<String> videoIds);
     List<GroupCount> findPublishByPost();
@@ -60,4 +62,7 @@ public interface VideoPostMapper extends BaseMapper<VideoPost> {
     List<GroupCount> findPublishByImage();
     List<String> findRandomVideoIds(@Param("scopes") List<Integer> scopes, @Param("size") int size);
     List<String> findShortVideo(List<Integer> scopes);
+    List<VideoPost> findGroupByUserAndCategory(int categoryPid);
+    VideoPost findUserAndCategory(@Param("publishBy") long publishBy, @Param("categoryId") int categoryId);
+    List<VideoPost> findByTitle(String title);
 }

+ 22 - 0
content/content-service/src/main/java/cn/reghao/tnb/content/app/vod/model/dto/VideoEdit.java

@@ -0,0 +1,22 @@
+package cn.reghao.tnb.content.app.vod.model.dto;
+
+import lombok.Getter;
+
+import javax.validation.constraints.NotBlank;
+import javax.validation.constraints.NotNull;
+import javax.validation.constraints.Size;
+import java.util.List;
+
+/**
+ * @author reghao
+ * @date 2025-07-23 23:10:37
+ */
+@Getter
+public class VideoEdit {
+    @NotBlank
+    private String oldUserIdStr;
+    @NotNull
+    private Long newUserId;
+    @Size(min = 1, max = 120, message = "视频 ID")
+    private List<String> videoIds;
+}

+ 5 - 0
content/content-service/src/main/java/cn/reghao/tnb/content/app/vod/service/VideoService.java

@@ -112,4 +112,9 @@ public class VideoService {
 
         return null;
     }
+
+    public void editVideo(VideoEdit videoEdit) {
+        long newUserId = videoEdit.getNewUserId();
+        videoPostMapper.updateVideoUser(newUserId, videoEdit.getVideoIds());
+    }
 }

+ 5 - 6
content/content-service/src/main/java/cn/reghao/tnb/content/app/vod/service/impl/SearchServiceImpl.java

@@ -66,12 +66,12 @@ public class SearchServiceImpl implements SearchService {
     }
 
     public PageList<VideoCard> searchByKeyword(String keyword, String nextIdStr, int pageNumber) {
-        int type = 1;
+        int type = 2;
         PageList<VideoCard> pageList;
         if (type == 1) {
             pageList = searchByKeyword1(keyword, nextIdStr, pageNumber);
         } else {
-            pageList = searchByKeyword2(keyword, nextIdStr, pageNumber);
+            pageList = searchByKeyword2(keyword, pageNumber);
         }
 
         return pageList;
@@ -96,10 +96,10 @@ public class SearchServiceImpl implements SearchService {
         return PageList.pageList(pageNumber, pageSize, total, list1);
     }
 
-    public PageList<VideoCard> searchByKeyword2(String keyword, String nextIdStr, int pageNumber) {
+    public PageList<VideoCard> searchByKeyword2(String keyword, int pageNumber) {
         long loginUser = UserContext.getUser();
-        boolean vip = userService.isVip(loginUser);
-        PageList<VideoSummary> pageList = dataSearchService.searchVideo(keyword, vip+"", pageNumber);
+        List<Integer> userScopes = contentPermission.getUserScopes(loginUser);
+        PageList<VideoSummary> pageList = dataSearchService.searchVideo(keyword, userScopes, pageNumber);
         List<VideoSummary> videoSummaryList = pageList.getList();
         Map<String, List<VideoSummary>> map = videoSummaryList.stream().collect(Collectors.groupingBy(VideoSummary::getVideoId));
         List<String> videoIds = new ArrayList<>(map.keySet());
@@ -141,7 +141,6 @@ public class SearchServiceImpl implements SearchService {
         searchRecordMapper.save(new SearchRecord(userId, keyword));
     }
 
-
     public List<HotSearch> getHotSearch() {
         return searchRecordMapper.findHotSearch();
     }

+ 1 - 1
content/content-service/src/main/java/cn/reghao/tnb/content/app/vod/service/impl/VideoPostQueryImpl.java

@@ -49,7 +49,7 @@ public class VideoPostQueryImpl implements VideoPostQuery {
     @DubboReference(check = false)
     private OssService ossService;
 
-    private final int pageSize = 12;
+    private final int pageSize = 120;
     private final VideoPostMapper videoPostMapper;
     private final VideoFileMapper videoFileMapper;
     private final VideoStatisticMapper videoStatisticMapper;

+ 2 - 2
content/content-service/src/main/resources/mapper/vod/VideoPostCategoryMapper.xml

@@ -23,9 +23,9 @@
         where category_id=#{categoryId} and publish_by=#{publishBy}
     </update>
 
-    <delete id="deleteByVideoId">
+    <delete id="deleteByCategoryPid">
         delete from vod_video_category_post
-        where video_id=#{videoId}
+        where category_pid=#{categoryPid}
     </delete>
 
     <select id="countByCriteria" resultType="java.lang.Integer">

+ 29 - 2
content/content-service/src/main/resources/mapper/vod/VideoPostMapper.xml

@@ -44,6 +44,14 @@
         set update_time=now(),duration=#{videoInfo.duration},`status`=2
         where video_id=#{videoId}
     </update>
+    <update id="updateVideoUser">
+        update vod_video_post
+        set publish_by=#{newUserId}
+        where video_id in
+        <foreach collection="videoIds" item="id" index="index" open="(" close=")" separator=",">
+            #{id}
+        </foreach>
+    </update>
 
     <delete id="deleteByVideoId">
         delete from vod_video_post
@@ -396,12 +404,13 @@
     <select id="findAll" resultType="cn.reghao.tnb.content.app.vod.model.po.VideoPost">
         select *
         from vod_video_post
-        limit 1000
+        where deleted=0 and `status`=2 and category_pid=11
     </select>
     <select id="findAllById" resultType="cn.reghao.tnb.content.app.vod.model.po.VideoPost">
         select *
         from vod_video_post
-        where deleted=0 and category_id=4 and id > #{nextId}
+        where deleted=0 and `status`=2 and category_pid!=11 and id > #{nextId}
+        order by id asc
         limit #{pageSize}
     </select>
 
@@ -459,4 +468,22 @@
         </foreach>
         limit 100000
     </select>
+    <select id="findGroupByUserAndCategory" resultType="cn.reghao.tnb.content.app.vod.model.po.VideoPost">
+        select *
+        from vod_video_post
+        where `deleted`=0 and `status`=2 and category_pid=#{categoryPid}
+        group by publish_by,category_id
+    </select>
+    <select id="findUserAndCategory" resultType="cn.reghao.tnb.content.app.vod.model.po.VideoPost">
+        select *
+        from vod_video_post
+        where `deleted`=0 and `status`=2 and publish_by=#{publishBy} and category_id=#{categoryId}
+        order by publish_at desc
+        limit 1
+    </select>
+    <select id="findByTitle" resultType="cn.reghao.tnb.content.app.vod.model.po.VideoPost">
+        select *
+        from vod_video_post
+        where `deleted`=0 and `status`=2 and category_pid=11 and title like concat(#{title},'%')
+    </select>
 </mapper>

+ 34 - 21
content/content-service/src/test/java/cn/reghao/tnb/content/app/vod/service/SearchTest.java

@@ -1,8 +1,12 @@
 package cn.reghao.tnb.content.app.vod.service;
 
 import cn.reghao.jutil.jdk.db.PageList;
+import cn.reghao.tnb.content.api.constant.PostScope;
 import cn.reghao.tnb.content.api.dto.VideoCard;
 import cn.reghao.tnb.content.app.ContentApplication;
+import cn.reghao.tnb.content.app.vod.db.mapper.VideoPostMapper;
+import cn.reghao.tnb.content.app.vod.model.po.VideoPost;
+import cn.reghao.tnb.search.api.dto.VideoSummary;
 import cn.reghao.tnb.search.api.iface.DataSearchService;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.dubbo.config.annotation.DubboReference;
@@ -12,6 +16,10 @@ import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
 import org.springframework.test.context.junit4.SpringRunner;
 
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+
 /**
  * @author reghao
  * @date 2025-04-02 16:10:18
@@ -24,6 +32,8 @@ public class SearchTest {
     DataSearchService dataSearchService;
     @Autowired
     SearchService searchService;
+    @Autowired
+    VideoPostMapper videoPostMapper;
     @Test
     public void searchTest() {
         /*long userId = 10002L;
@@ -36,33 +46,36 @@ public class SearchTest {
             }
         }*/
 
-        /*List<VideoPost> list1 = videoPostMapper.findAll();
-        int i = 1;
-        for (VideoPost videoPost : list1) {
-            String videoId = videoPost.getVideoId();
-            String title = videoPost.getTitle();
-            boolean vip = false;
-            int scope = videoPost.getScope();
-            if (scope == PostScope.PROTECT.getCode()) {
-                vip = true;
+        int pageSize = 1000;
+        int nextId = 0;
+        List<VideoPost> videoPosts = videoPostMapper.findAllById(pageSize, nextId);
+        while (!videoPosts.isEmpty()) {
+            List<VideoSummary> videoSummaryList = videoPosts.stream()
+                    .map(this::getVideoSummary)
+                    .collect(Collectors.toList());
+            if (!videoSummaryList.isEmpty()) {
+                dataSearchService.addVideoSummaryList(videoSummaryList);
             }
 
-            VideoSummary videoSummary = new VideoSummary(videoId, title, vip);
-            try {
-                dataSearchService.addVideoSummary(videoSummary);
-                log.info("add {} doc", i++);
-            } catch (Exception e) {
-                e.printStackTrace();
-            }
-        }*/
+            nextId = videoPosts.get(videoPosts.size()-1).getId();
+            videoPosts = videoPostMapper.findAllById(pageSize, nextId);
+            log.info("start nextId {} with size {}", nextId, videoPosts.size());
+        }
 
         int pn = 1;
         String kw = "隔壁";
-        /*PageList<VideoSummary> pageList = dataSearchService.searchVideo(kw, "", pn);
-        Map<String, List<VideoSummary>> map = pageList.getList().stream()
+        List<Integer> scopes = List.of(PostScope.PUBLIC.getCode(), PostScope.PROTECT.getCode());
+        //PageList<VideoSummary> pageList = dataSearchService.searchVideo(kw, scopes, pn);
+        /*Map<String, List<VideoSummary>> map = pageList.getList().stream()
                 .collect(Collectors.groupingBy(VideoSummary::getVideoId));*/
+//        PageList<VideoCard> pageList1 = searchService.searchByKeyword(kw, "", pn);
+//        System.out.println();
+    }
 
-        PageList<VideoCard> pageList1 = searchService.searchByKeyword(kw, "", pn);
-        System.out.println();
+    private VideoSummary getVideoSummary(VideoPost videoPost) {
+        String videoId = videoPost.getVideoId();
+        String title = videoPost.getTitle();
+        int scope = videoPost.getScope();
+        return new VideoSummary(videoId, title, scope);
     }
 }

+ 93 - 0
content/content-service/src/test/java/cn/reghao/tnb/content/app/vod/service/UnitTest.java

@@ -1,7 +1,9 @@
 package cn.reghao.tnb.content.app.vod.service;
 
+import cn.reghao.jutil.jdk.text.TextFile;
 import cn.reghao.tnb.content.app.vod.db.mapper.VideoPostMapper;
 import cn.reghao.tnb.content.app.vod.db.mongo.UserCommentMongo;
+import cn.reghao.tnb.content.app.vod.model.po.VideoPost;
 import org.junit.Test;
 import org.junit.runner.RunWith;
 import org.mockito.InjectMocks;
@@ -9,6 +11,12 @@ import org.mockito.Mock;
 import org.mockito.Mockito;
 import org.mockito.junit.MockitoJUnitRunner;
 
+import java.io.File;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
 /**
  * @author reghao
  * @date 2025-05-29 09:16:31
@@ -29,4 +37,89 @@ public class UnitTest {
         long total = commentService.countPostComment(videoId);
         System.out.println();
     }
+
+    @Test
+    public void vodTest() {
+        TextFile textFile = new TextFile();
+
+        String filePath = "/home/reghao/Downloads/1_fyt91.txt";
+        List<String> existList = new ArrayList<>();
+        List<String> notexistList = new ArrayList<>();
+        List<String> list = new ArrayList<>();
+        for (String line : textFile.read(filePath)) {
+            if (line.startsWith("exist")) {
+                existList.add(line);
+
+                /*String videoIdsStr = line.split(" videoId ")[1];
+                String[] videoIds = videoIdsStr.replace("[", "")
+                        .replace("]", "")
+                        .split(", ");
+
+                for (String videoId : videoIds) {
+                    VideoPost videoPost = videoPostMapper.findByVideoId(videoId);
+                    long publishBy = videoPost.getPublishBy();
+                }*/
+            } else if (line.startsWith("notexist")) {
+                notexistList.add(line);
+            } else {
+                list.add(line);
+            }
+        }
+
+        textFile.write("/home/reghao/Downloads/1_fyt91.txt_exist", existList);
+        textFile.write("/home/reghao/Downloads/1_fyt91.txt_notexist", notexistList);
+        textFile.write("/home/reghao/Downloads/1_fyt91.txt_list", list);
+    }
+
+    @Test
+    public void vodTest1() {
+        TextFile textFile = new TextFile();
+
+        String filePath = "/home/reghao/Downloads/3.txt";
+        String text = textFile.readFile(filePath);
+        String[] tags = text.replace("[", "")
+                .replace("]", "")
+                .split(", ");
+
+        Set<String> set1 = new HashSet<>();
+        Set<String> set2 = new HashSet<>();
+        String regex = "^[a-z0-9A-Z]+$";
+        for (String tag : tags) {
+            if (tag.equals("tnb")) {
+                set2.add(tag);
+                continue;
+            }
+
+            if (tag.matches(regex)) {
+                set1.add(tag);
+            } else {
+                set2.add(tag);
+            }
+        }
+
+        System.out.println();
+    }
+
+    private void test1() {
+        TextFile textFile = new TextFile();
+
+        String filePath = "/home/reghao/Downloads/1_fyt91.txt_notexist";
+        List<String> existList = new ArrayList<>();
+        List<String> notexistList = new ArrayList<>();
+        List<String> list = new ArrayList<>();
+
+        Set<String> set = new HashSet<>();
+        for (String line : textFile.read(filePath)) {
+            String line1 = line.replace("notexist ", "");
+            set.add(line1);
+        }
+
+        filePath = "/home/reghao/Downloads/1_fytgc.txt_notexist";
+        for (String line : textFile.read(filePath)) {
+            String line1 = line.replace("notexist ", "");
+            if (set.contains(line1)) {
+                System.out.println(line);
+            }
+        }
+    }
 }

+ 229 - 0
content/content-service/src/test/java/cn/reghao/tnb/content/app/vod/service/VideoPostTest.java

@@ -1,5 +1,10 @@
 package cn.reghao.tnb.content.app.vod.service;
 
+import cn.reghao.jutil.jdk.converter.DateTimeConverter;
+import cn.reghao.jutil.jdk.serializer.JsonConverter;
+import cn.reghao.jutil.jdk.text.TextFile;
+import cn.reghao.jutil.jdk.thread.ThreadPoolWrapper;
+import cn.reghao.tnb.content.api.constant.PostScope;
 import cn.reghao.tnb.content.api.dto.VideoCard;
 import cn.reghao.tnb.content.app.ContentApplication;
 import cn.reghao.tnb.content.app.vod.db.mapper.*;
@@ -10,14 +15,20 @@ import cn.reghao.tnb.content.app.util.redis.ds.RedisSortedSet;
 import cn.reghao.tnb.content.app.vod.model.vo.BannerVideoVO;
 import cn.reghao.tnb.content.app.vod.service.rcmd.RedisKeys;
 import cn.reghao.tnb.content.app.vod.service.rcmd.UserInterestBased;
+import com.google.gson.JsonElement;
+import com.google.gson.JsonObject;
 import lombok.extern.slf4j.Slf4j;
 import org.junit.jupiter.api.Test;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.boot.test.context.SpringBootTest;
 import org.springframework.test.context.ActiveProfiles;
+import org.springframework.util.StringUtils;
 
+import java.io.File;
+import java.io.IOException;
 import java.time.LocalDateTime;
 import java.util.*;
+import java.util.concurrent.*;
 import java.util.stream.Collectors;
 
 /**
@@ -173,4 +184,222 @@ public class VideoPostTest {
         List<BannerVideoVO> list1 =  bannerVideoMapper.findBannerVideos();
         System.out.println();
     }
+
+    @Autowired
+    VideoCategoryPostMapper videoCategoryPostMapper;
+    @Test
+    public void videoCategoryPostTest() {
+        List<VideoCategoryPost> videoCategoryPostList = new ArrayList<>();
+        int categoryPid = 11;
+        List<VideoPost> list = videoPostMapper.findGroupByUserAndCategory(categoryPid);
+        for (VideoPost videoPost : list) {
+            long publishBy = videoPost.getPublishBy();
+            int categoryId = videoPost.getCategoryId();
+            VideoPost videoPost1 = videoPostMapper.findUserAndCategory(publishBy, categoryId);
+            videoCategoryPostList.add(new VideoCategoryPost(videoPost1));
+        }
+
+        if (!videoCategoryPostList.isEmpty()) {
+            videoCategoryPostMapper.deleteByCategoryPid(categoryPid);
+            videoCategoryPostMapper.saveAll(videoCategoryPostList);
+        }
+    }
+
+    @Test
+    public void videoPostTagTest() {
+        Map<String, List<VideoPost>> map = new ConcurrentHashMap<>();
+        Set<String> tagList = new HashSet<>();
+        List<VideoPost> videoPostList = videoPostMapper.findAll();
+
+        for (VideoPost videoPost : videoPostList) {
+            String title = videoPost.getTitle();
+            /*List<VideoPost> list = map.computeIfAbsent(title, v -> new ArrayList<>());
+            if (!list.isEmpty()) {
+                VideoPost videoPost1 = list.get(0);
+                if (videoPost1.getDuration() == videoPost.getDuration() &&
+                        videoPost1.getHorizontal() == videoPost.getHorizontal()) {
+                    list.add(videoPost);
+                }
+            } else {
+                list.add(videoPost);
+            }*/
+
+            String videoId = videoPost.getVideoId();
+            List<String> tags = videoTagMapper.findVideoTags(videoId);
+            tagList.addAll(tags);
+        }
+
+        /*List<String> urls = new ArrayList<>();
+        map.forEach((k, v) -> {
+            if (v.size() <= 1) {
+                map.remove(k);
+            } else {
+                StringBuilder sb = new StringBuilder();
+                boolean contain = false;
+                for (VideoPost  videoPost : v) {
+                    long publishBy = videoPost.getPublishBy();
+                    if (publishBy == 11002) {
+                        contain = true;
+                        break;
+                    }
+                }
+
+                if (contain) {
+                    for (VideoPost  videoPost : v) {
+                        String url = String.format("https://reghao.cn/video/%s", videoPost.getVideoId());
+                        sb.append(url).append(" - ");
+                    }
+                    urls.add(sb.toString());
+                }
+            }
+        });
+
+        for (int i = 0; i < urls.size(); i++) {
+            System.out.printf("%s -> %s\n", i, urls.get(i));
+        }*/
+
+        System.out.println();
+    }
+
+    @Test
+    public void videoTest() throws IOException, InterruptedException {
+        List<String> list = new ArrayList<>();
+        File dir = new File("/home/reghao/Downloads/tele/1");
+        for (File file : dir.listFiles()) {
+            parseJson(file, list);
+        }
+
+        Set<String> set = new HashSet<>(list);
+        Queue<String> queue = new ArrayDeque<>(set);
+        ExecutorService threadPool = ThreadPoolWrapper.threadPool("search-pool", 20);
+        ThreadPoolExecutor tpe = (ThreadPoolExecutor) threadPool;
+        while (!Thread.interrupted()) {
+            try {
+                if (tpe.getActiveCount() < 20) {
+                    String line = queue.poll();
+                    if (line != null) {
+                        String title = "";
+                        if (line.endsWith(".mp4")) {
+                            title = line.replace(".mp4", "");
+                        } else if (line.endsWith(".MP4")) {
+                            title = line.replace(".MP4", "");
+                        } else if (line.endsWith(".mov")) {
+                            title = line.replace(".mov", "");
+                        } else if (line.endsWith(".MOV")) {
+                            title = line.replace(".MOV", "");
+                        } else if (line.endsWith(".m4v")) {
+                            title = line.replace(".m4v", "");
+                        } else {
+                            title = StringUtils.trimAllWhitespace(line);
+                        }
+
+                        threadPool.submit(new SearchTask(title));
+                    } else {
+                        log.info("queue is empty");
+                    }
+                } else {
+                    //log.info("当前线程队列有 {} 个线程, 其中 {} 个活跃线程, 休眠 1s 等待线程池空闲...", tpe.getQueue().size(), tpe.getActiveCount());
+                    Thread.sleep(1_000);
+                }
+            } catch (Exception e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
+    class SearchTask implements Runnable {
+        private String title;
+
+        public SearchTask(String title) {
+            this.title = title;
+        }
+
+        public void run() {
+            List<VideoPost> list1 = videoPostMapper.findByTitle(title);
+            if (list1.isEmpty()) {
+                log.info("notexist {}", title);
+            } else {
+                List<String> videoIds = list1.stream().map(VideoPost::getVideoId).collect(Collectors.toList());
+                log.info("exist {} videoId {}", title, videoIds);
+            }
+        }
+    }
+
+    private void parseJson(File jsonFile, List<String> list) {
+        JsonObject jsonObject = JsonConverter.jsonFileToObject(jsonFile, JsonObject.class);
+        for (JsonElement jsonElement : jsonObject.get("messages").getAsJsonArray()) {
+            try {
+                JsonObject jsonObject1 = jsonElement.getAsJsonObject();
+                String filename = jsonObject1.get("file_name").getAsString();
+                if (filename.isBlank()) {
+                    continue;
+                }
+
+                long dateUnixtime = jsonObject1.get("date_unixtime").getAsLong();
+                DateTimeConverter.localDateTime(dateUnixtime*1000);
+                list.add(filename);
+            } catch (Exception e) {
+                //e.printStackTrace();
+            }
+        }
+    }
+
+    @Test
+    public void vodTest() {
+        File dir = new File("/home/reghao/disk/2/vod/tg/");
+        for (File file : dir.listFiles()) {
+            if (file.isDirectory()) {
+                continue;
+            }
+
+            String filename = file.getName();
+            String title = "";
+            if (filename.endsWith(".mp4")) {
+                title = filename.replace(".mp4", "");
+            } else if (filename.endsWith(".mov")) {
+                title = filename.replace(".mov", "");
+            } else if (filename.endsWith(".MP4")) {
+                title = filename.replace(".MP4", "");
+            }
+
+            List<VideoPost> list1 = videoPostMapper.findByTitle(title);
+            if (list1.isEmpty()) {
+                //log.info("notexist {}", title);
+            } else {
+                List<String> videoIds = list1.stream().map(VideoPost::getVideoId).collect(Collectors.toList());
+                log.info("exist {} videoId {}", title, videoIds);
+            }
+        }
+    }
+
+    private void test1() {
+        String tagId = "77d4093c54aa4e568ea58788e5b1bfaa";
+        int scope = PostScope.PROTECT.getCode();
+        //videoPostTagMapper.saveAll(list1);
+
+        TextFile textFile = new TextFile();
+        StringBuilder sb = new StringBuilder();
+        String filePath = "/home/reghao/Downloads/1_fyt91.txt";
+        //filePath = "/home/reghao/Downloads/1_fytgc.txt";
+
+        List<VideoPostTag> list = new ArrayList<>();
+        for (String line : textFile.read(filePath)) {
+            if (line.startsWith("exist")) {
+                String videoIdsStr = line.split(" videoId ")[1];
+                String[] videoIds = videoIdsStr.replace("[", "")
+                        .replace("]", "")
+                        .split(", ");
+
+                for (String videoId : videoIds) {
+                    /*VideoPost videoPost = videoPostMapper.findByVideoId(videoId);
+                    long publishBy = videoPost.getPublishBy();*/
+                    sb.append("'").append(videoId).append("',");
+                    list.add(new VideoPostTag(videoId, scope, tagId));
+                }
+            }
+        }
+
+        videoPostTagMapper.saveAll(list);
+        System.out.println(sb.toString());
+    }
 }