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();
|
}
|
|
}
|