admin
2022-04-16 04f09e52ffd4681bdfd85e51acd3da0d1280c3d3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
package com.hxh.spring.test.video;
 
import com.google.gson.Gson;
import com.yeshi.buwan.dao.video.VideoInfoV2Dao;
import com.yeshi.buwan.domain.VideoInfo;
import com.yeshi.buwan.domain.video.VideoInfoV2;
import com.yeshi.buwan.service.inter.video.VideoV2ConvertService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
 
import javax.annotation.Resource;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
 
/**
 * @author hxh
 * @title: VideoV2Test
 * @description: 视频测试
 * @date 2022/3/16 17:18
 */
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:spring.xml"})
@WebAppConfiguration
public class VideoV2Test {
    @Resource
    private VideoInfoV2Dao videoInfoV2Dao;
 
    @Resource
    private VideoV2ConvertService videoV2ConvertService;
 
 
    @Test
    public void save() {
        VideoInfoV2 infoV2 = new VideoInfoV2();
        infoV2.setId("123456789");
        infoV2.setActors(Arrays.asList(new String[]{"沈腾", "马丽", "章宇"}));
 
        infoV2 = new VideoInfoV2();
        infoV2.setId("12345678");
        infoV2.setActors(Arrays.asList(new String[]{"沈腾", "测试", "测试2"}));
 
        videoInfoV2Dao.save(infoV2);
    }
 
 
    @Test
    public void query() {
        VideoInfoV2Dao.DaoQuery query = new VideoInfoV2Dao.DaoQuery();
        query.actors = Arrays.asList(new String[]{"测试", "沈腾"});
        query.count = 10;
 
        List<VideoInfoV2> list = videoInfoV2Dao.list(query);
        System.out.println(list);
    }
 
 
    //同步老数据到新数据
    @Test
    public void syncVideo() throws FileNotFoundException {
        Scanner scanner = new Scanner(new FileInputStream(new File("F:\\影视信息\\片名.txt")));
        List<String> idList = new ArrayList<>();
        while (scanner.hasNextLine()) {
            String st = scanner.nextLine();
            VideoInfo videoInfo = new Gson().fromJson(st, VideoInfo.class);
            idList.add(videoInfo.getId());
        }
        scanner.close();
        for (int i = 23000; i < idList.size(); i++) {
            try {
                videoV2ConvertService.asyncOldVideo(idList.get(i));
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
 
    @Test
    public void syncSingleVideo() throws Exception {
        videoV2ConvertService.asyncOldVideo("228351");
    }
 
}