admin
2021-01-04 aa6ef62aef83e277d4171df1d9f0803f91738216
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
package com.hxh.spring.test;
 
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
 
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate4.HibernateCallback;
 
import com.newvideo.dao.VideoInfoDao;
import com.newvideo.dao.juhe.ProgramVideoDao;
import com.newvideo.domain.VideoInfo;
import com.newvideo.pptv.PPTVUtil;
import com.newvideo.service.imp.AttentionService;
import com.newvideo.service.imp.VideoManager;
import com.newvideo.service.imp.VideoService;
import com.newvideo.util.BeanUtil;
import com.newvideo.util.VideoPictureUtil;
import com.newvideo.youku.YouKuApi;
import com.newvideo.youku.entity.ProgramVideo;
 
public class VideoTest {
 
    public static void main(String[] args) {
        pptv();
    }
 
    // @Test
    public static void pptv() {
        PPTVUtil pptvUtil = BeanUtil.getBean(PPTVUtil.class);
        pptvUtil.startParseShow();
    }
 
    // @Test
    public void updateCopyRight() {
        ProgramVideoDao programVideoDao = (ProgramVideoDao) BeanUtil.getBean("programVideoDao");
        List<ProgramVideo> list = programVideoDao.list("from ProgramVideo pv where pv.copyright_type is null", 0, 10000,
                null);
        for (ProgramVideo pv : list) {
            pv = YouKuApi.getVideoDetail(pv.getId());
            try {
                programVideoDao.update(pv);
            } catch (Exception e) {
 
            }
 
        }
    }
 
    @SuppressWarnings("unchecked")
    public static void deleteDuplicateVideo() {
        final VideoManager vs = (VideoManager) BeanUtil.getBean("videoManager");
 
        final VideoInfoDao infoDao = (VideoInfoDao) BeanUtil.getBean("videoInfoDao");
        List<String> names = (List<String>) infoDao.excute(new HibernateCallback<List<String>>() {
            public List<String> doInHibernate(Session session) throws HibernateException {
                List list = session
                        .createSQLQuery(
                                "SELECT v.`name`,COUNT(*) c FROM wk_video_video v GROUP BY v.`name` HAVING c>2 ORDER BY c DESC;")
                        .list();
                List<String> nameList = new ArrayList<String>();
                for (int i = 0; i < list.size(); i++) {
                    Object[] objs = (Object[]) list.get(i);
                    nameList.add(objs[0] + "");
                }
 
                return nameList;
            }
        });
 
        for (String name : names) {
            List<VideoInfo> list = infoDao.list("from VideoInfo v where v.name=?", new Serializable[] { name });
            if (list.size() > 1)
                for (int i = 1; i < list.size(); i++)
                    vs.deleteVideo(list.get(i).getId());
        }
 
    }
 
    // @Test
    public static void getVideoInfo() {
        VideoService vs = (VideoService) BeanUtil.getBean("videoService");
        VideoInfo vi = vs.getVideoInfo("261878");
        VideoPictureUtil.getShowPicture(vi, "android", "35");
 
    }
 
    // @Test
    public void attention() {
        AttentionService attentionService = (AttentionService) BeanUtil.getBean("attentionService");
 
        attentionService.getAttentionVideoListByLoginUid(60192, 1);
 
    }
 
    @org.junit.Test
    public void test1() {
        VideoService videoService =  BeanUtil.getBean(VideoService.class);
        videoService.addNOAddToCategoryVideo();
    }
 
}