package com.hxh.spring.test;
|
|
import com.newvideo.dao.juhe.funtv.FunTVAlbum2Dao;
|
import com.newvideo.dao.juhe.funtv.FunTVVideo2Dao;
|
import com.newvideo.dao.juhe.funtv.VideoFunTV2Dao;
|
import com.newvideo.funtv.FunTVNewApi;
|
import com.newvideo.funtv.Funtv2ResultVO;
|
import com.newvideo.funtv.entity.FunTVAlbum2;
|
import com.newvideo.funtv.entity.FunTVVideo2;
|
import com.newvideo.funtv.entity.VideoFunTV2;
|
import com.newvideo.service.imp.ResourceVideoService;
|
import com.newvideo.service.imp.VideoInfoService;
|
import com.newvideo.service.inter.FunTV2Service;
|
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.Serializable;
|
import java.util.List;
|
@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 VideoInfoService videoInfoService;
|
|
@Resource
|
private VideoFunTV2Dao videoFunTV2Dao;
|
|
@Resource
|
private ResourceVideoService resourceVideoService;
|
|
|
|
@Test
|
public void syncAlbum() {
|
//1-电影 2-电视剧 3-动漫 4-综艺 5-少儿
|
int channelId = 2;
|
Funtv2ResultVO vo = FunTVNewApi.getAlbums(1, 20, null, null, 1);
|
int totalCount = vo.getCount();
|
int pageSize = 20;
|
int totalPage =10; //totalCount % pageSize == 0 ? totalCount / pageSize : totalCount / pageSize + 1;
|
for (int p = 0; p < totalPage; p++) {
|
Funtv2ResultVO result = FunTVNewApi.getAlbums(p + 1, pageSize, null, null, 1);
|
if (result != null)
|
for (Serializable a : result.getList()) {
|
FunTVAlbum2 album2 = (FunTVAlbum2) a;
|
funTV2Service.saveAlbum(album2);
|
if (album2.getEpisodes() != null)
|
for (FunTVVideo2 video2 : album2.getEpisodes())
|
funTV2Service.saveVideo(video2);
|
}
|
}
|
}
|
|
@Test
|
public void addToVideoInfo() {
|
List<FunTVAlbum2> album2List = funTVAlbum2Dao.listByChannelId(1, 0, 100);
|
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 getAccessToken() {
|
System.out.println(FunTVNewApi.getAccessToken());
|
}
|
|
|
@Test
|
public void offLine() {
|
funTV2Service.offLineAlbum("565");
|
}
|
|
|
|
@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 authCode = FunTVNewApi.getAuthCode();
|
System.out.println(authCode);
|
}
|
|
}
|