package com.hxh.spring.test;
|
|
import com.yeshi.buwan.dao.VideoInfoDao;
|
import com.yeshi.buwan.domain.system.DetailSystem;
|
import com.yeshi.buwan.domain.VideoInfo;
|
import com.yeshi.buwan.domain.entity.PlayUrl;
|
import com.yeshi.buwan.exception.video.VideoPlayException;
|
import com.yeshi.buwan.videos.iqiyi.IqiYiNewAPI;
|
import com.yeshi.buwan.videos.iqiyi.entity.IqiyiUpdateQueue;
|
import com.yeshi.buwan.videos.iqiyi.util.IqiyiUtil;
|
import com.yeshi.buwan.service.imp.*;
|
import com.yeshi.buwan.service.imp.juhe.IqiyiQueueService;
|
import com.yeshi.buwan.util.BeanUtil;
|
import com.yeshi.buwan.util.StringUtil;
|
import com.yeshi.buwan.util.VideoPictureUtil;
|
import com.yeshi.buwan.util.video.VideoDetailUtil;
|
import org.hibernate.HibernateException;
|
import org.hibernate.Session;
|
import org.junit.Test;
|
import org.junit.runner.RunWith;
|
import org.springframework.orm.hibernate4.HibernateCallback;
|
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.Serializable;
|
import java.util.ArrayList;
|
import java.util.List;
|
import java.util.regex.Pattern;
|
|
@RunWith(SpringJUnit4ClassRunner.class)
|
@ContextConfiguration(locations = {"classpath:spring.xml"})
|
@WebAppConfiguration
|
public class VideoTest {
|
|
public static void main(String[] args) {
|
// pptv();
|
VideoService videoService = BeanUtil.getBean(VideoService.class);
|
for (int i = 0; i < 50; i++) {
|
videoService.addNOAddToCategoryVideo();
|
}
|
}
|
|
|
@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() {
|
|
SystemService systemService = BeanUtil.getBean(SystemService.class);
|
|
VideoDetailUtil videoDeailUtil = BeanUtil.getBean(VideoDetailUtil.class);
|
|
DetailSystem detailSystem = systemService.getDetailSystemByPackage("com.doudou.ysvideo");
|
|
try {
|
PlayUrl pu = videoDeailUtil.getPlayUrl(null, detailSystem.getId(), 3357160 + "", "acFunVideo",
|
Integer.parseInt(21 + ""), 3357160 + "");
|
} catch (VideoPlayException e) {
|
e.printStackTrace();
|
}
|
}
|
|
@org.junit.Test
|
public void test2() {
|
|
StatisticsService statisticsService = BeanUtil.getBean(StatisticsService.class);
|
|
statisticsService.categoryPlayStatistic();
|
|
}
|
|
@org.junit.Test
|
public void test3() {
|
VideoService videoService = BeanUtil.getBean(VideoService.class);
|
List<VideoInfo> list = videoService.guessLike(1);
|
System.out.println(list);
|
}
|
|
@org.junit.Test
|
public void test4() {
|
IqiyiQueueService iqiyiQueueService = BeanUtil.getBean(IqiyiQueueService.class);
|
IqiyiUtil iqiyiUtil = BeanUtil.getBean(IqiyiUtil.class);
|
List<IqiyiUpdateQueue> queueList = iqiyiQueueService.listUpdateQueue();
|
for (IqiyiUpdateQueue queue : queueList) {
|
String aid = null;
|
int count = 0;
|
while (StringUtil.isNullOrEmpty(aid) && count < 3) {
|
if (StringUtil.isNullOrEmpty(queue.getAid())) {
|
aid = IqiYiNewAPI.getAidByUrl(queue.getUrl());
|
count++;
|
try {
|
Thread.sleep(1000 * 2);
|
} catch (InterruptedException e) {
|
e.printStackTrace();
|
}
|
} else
|
aid = queue.getAid();
|
}
|
if (!StringUtil.isNullOrEmpty(aid)) {
|
queue.setAid(aid);
|
iqiyiQueueService.updateUpdateQueue(queue);
|
iqiyiUtil.updateAlbum(aid);
|
}
|
}
|
|
}
|
|
@Test
|
public void test111() {
|
String regx = "^[(\\u4e00-\\u9fa5)()a-zA-Z0-9]+$";
|
boolean isMatch = Pattern.matches(regx, "今天 hello");
|
System.out.println(isMatch);
|
}
|
|
|
@Resource
|
private VideoManager videoManager;
|
|
@Test
|
public void deleteVideo() {
|
videoManager.deleteVideo("8234976");
|
videoManager.deleteVideo("8254725");
|
videoManager.deleteVideo("8254726");
|
}
|
|
}
|