admin
2024-09-05 8631bb49abe5dfed233bc579a228c578232f8079
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
package com.hxh.spring.test;
 
import com.yeshi.buwan.dao.juhe.funtv.FunTVAlbum2Dao;
import com.yeshi.buwan.dao.juhe.funtv.FunTVVideo2Dao;
import com.yeshi.buwan.dao.juhe.funtv.VideoFunTV2Dao;
import com.yeshi.buwan.dao.juhe.funtv.VideoFunTVNewDao;
import com.yeshi.buwan.job.video.FunTV2VideoUpdate;
import com.yeshi.buwan.service.imp.ResourceVideoService;
import com.yeshi.buwan.service.imp.VideoInfoService;
import com.yeshi.buwan.service.inter.juhe.FunTV2Service;
import com.yeshi.buwan.util.HtmlToolUtil;
import com.yeshi.buwan.videos.funtv.FunTVUtil;
import com.yeshi.buwan.videos.funtv.entity.FunTVAlbum2;
import com.yeshi.buwan.videos.funtv.entity.FunTVVideo2;
import com.yeshi.buwan.videos.funtv.entity.VideoFunTV2;
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.FileInputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
 
@RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试
@ContextConfiguration(locations = {"classpath:spring.xml"})
@WebAppConfiguration
public class FunTV2 {
 
    @Resource
    private FunTV2Service funTV2Service;
 
    @Resource
    private FunTVAlbum2Dao funTVAlbum2Dao;
 
    @Resource
    private FunTVVideo2Dao funTVVideo2Dao;
 
    @Resource
    private FunTV2VideoUpdate funTV2VideoUpdate;
 
    @Resource
    private VideoInfoService videoInfoService;
 
    @Resource
    private VideoFunTV2Dao videoFunTV2Dao;
 
    @Resource
    private ResourceVideoService resourceVideoService;
 
 
    @Test
    public void addToVideoInfo() {
        List<FunTVAlbum2> album2List = funTVAlbum2Dao.listByChannelId(3, 0, 1000);
        for (FunTVAlbum2 album2 : album2List) {
            //只加入免费的
            if (!album2.getFeeMode().equalsIgnoreCase("0")) {
                continue;
            }
            System.out.println(album2.getName());
            List<FunTVVideo2> list = funTVVideo2Dao.listByMediaId(album2.getId(), 0, 2000);
            album2.setEpisodes(list);
            try {
                funTV2Service.processAlbum(album2);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
 
    @Test
    public void addToVideoInfo1() {
        videoInfoService.statisticVideoExtraInfo(179210 + "");
    }
 
 
    @Test
    public void addResource() {
//        List<String> videoIds = new ArrayList<>();
//        List<VideoFunTV2> list = videoFunTV2Dao.listAll(0, 5000);
//        for (VideoFunTV2 funTV2 : list) {
//            long count = resourceVideoService.countByVideoIdAndResourceId(funTV2.getVideoId() + "", FunTVUtil2.RESOURCE_ID);
//            if (count == 0L) {
//                videoIds.add(funTV2.getVideoId() + "");
//            }
//        }
//        System.out.println(new Gson().toJson(videoIds));
 
//        String json = "[\"7993076\",\"7993077\",\"7993078\"]";
//        JSONArray array = JSONArray.fromObject(json);
//        for (int i = 0; i < array.size(); i++) {
//            resourceVideoService.addVideoResource(array.optString(i), FunTVUtil2.RESOURCE_ID + "");
//        }
//
//        CMQManager.getInstance().addVideoExtraInfoChanged(new VideoExtraInfoChangeMQMsg(VideoExtraInfoChangeMQMsg.TYPE_RESOURCE, "7993076", VideoExtraInfoChangeMQMsg.ACTION_ADD));
 
//        resourceVideoService.addVideoResource("7993076", FunTVUtil2.RESOURCE_ID + "");
    }
 
 
    @Test
    public void offLine() {
        funTV2Service.offLineAlbum("565");
    }
 
 
    @Resource
    private VideoFunTVNewDao videoFunTVNewDao;
 
    @Test
    public void deleteOldFunTVVideo() {
        List<String[]> list = HtmlToolUtil.parseSQLYogExportHtmData("C:\\Users\\Administrator\\Desktop\\风行老版正片.htm", 3);
        for (String[] sts : list) {
            String videoId = sts[0];
            resourceVideoService.delete(videoId, FunTVUtil.RESOURCE_ID + "");
//            List<VideoFunTV> list1 = videoFunTVNewDao.listByVideoId(Long.parseLong(videoId));
//
//            if (list1 != null)
//                for (VideoFunTV videoIqiyi : list1)
//                    videoFunTVNewDao.delete(videoIqiyi.getId());
        }
    }
 
    @Test
    public void removeAlbum() {
        for (int i = 0; i < 100; i++) {
            List<VideoFunTV2> list = videoFunTV2Dao.listAll(0, 100);
            for (VideoFunTV2 tv2 : list) {
                try {
                    funTV2Service.offLineAlbum(tv2.getMediaId());
                } catch (Exception e) {
 
                }
            }
        }
    }
 
 
    public static void main(String[] args) {
        String[] files = new String[]{
                "video_play.2021-01-06.log", "video_play.2021-01-07.log", "video_play.2021-01-08.log", "video_play.2021-01-09.log", "video_play.2021-01-10.log", "video_play.2021-01-11.log", "video_play.2021-01-12.log", "video_play.2021-01-13.log", "video_play.2021-01-14.log"
        };
        for (String file : files) {
            try {
                List<String> list = getFunTVPlayData("C:\\Users\\Administrator\\Desktop\\日志\\布丸播放\\" + file);
                System.out.println(list.size());
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    }
 
    private static List<String> getFunTVPlayData(String path) throws Exception {
        List<String> list = new ArrayList<>();
 
        Scanner scanner = new Scanner(new FileInputStream(path));
        while (scanner.hasNextLine()) {
            String line = scanner.nextLine();
            if (line.contains("playStatistic") && line.contains("#24")) {
                list.add(line);
            }
        }
        scanner.close();
        return list;
    }
 
}