package com.yeshi.buwan.iqiyi.util;
|
|
import java.io.IOException;
|
import java.io.Serializable;
|
import java.math.BigInteger;
|
import java.util.ArrayList;
|
import java.util.Collections;
|
import java.util.Comparator;
|
import java.util.List;
|
import java.util.Map;
|
import java.util.Timer;
|
import java.util.TimerTask;
|
import java.util.regex.Matcher;
|
import java.util.regex.Pattern;
|
|
import javax.annotation.Resource;
|
|
import org.apache.log4j.Logger;
|
import org.hibernate.HibernateException;
|
import org.hibernate.Session;
|
import org.jsoup.Jsoup;
|
import org.jsoup.nodes.Document;
|
import org.jsoup.select.Elements;
|
import org.springframework.orm.hibernate4.HibernateCallback;
|
import org.springframework.stereotype.Component;
|
|
import com.google.gson.Gson;
|
import com.google.gson.GsonBuilder;
|
import com.yeshi.buwan.dao.VideoResourceDao;
|
import com.yeshi.buwan.dao.juhe.iqiyi.IqiyiVideoInfoDao;
|
import com.yeshi.buwan.dao.juhe.iqiyi.VideoIqiyiDao;
|
import com.yeshi.buwan.domain.CategoryVideo;
|
import com.yeshi.buwan.domain.VideoInfo;
|
import com.yeshi.buwan.domain.VideoResource;
|
import com.yeshi.buwan.domain.VideoType;
|
import com.yeshi.buwan.domain.entity.PlayUrl;
|
import com.yeshi.buwan.iqiyi.IqiYiAPI;
|
import com.yeshi.buwan.iqiyi.entity.IqiyiAlbum;
|
import com.yeshi.buwan.iqiyi.entity.IqiyiChannel;
|
import com.yeshi.buwan.iqiyi.entity.IqiyiVideoInfo;
|
import com.yeshi.buwan.iqiyi.entity.PlayControls;
|
import com.yeshi.buwan.iqiyi.entity.VideoIqiyi;
|
import com.yeshi.buwan.log.LogHelper;
|
import com.yeshi.buwan.service.imp.juhe.IqiyiService;
|
import com.yeshi.buwan.util.JuheVideoUtil;
|
import com.yeshi.buwan.util.StringUtil;
|
import com.yeshi.buwan.util.TimeUtil;
|
|
import net.sf.json.JSONArray;
|
import net.sf.json.JSONObject;
|
|
@Component
|
public class IqiyiUtil {
|
@Resource
|
private IqiyiVideoInfoDao iqiyiVideoInfoDao;
|
@Resource
|
private VideoIqiyiDao videoIqiyiDao;
|
@Resource
|
private IqiyiService iqiyiService;
|
@Resource
|
private VideoResourceDao videoResourceDao;
|
|
static Logger logger = Logger.getLogger(IqiyiUtil.class);
|
|
public final int PLAY_NONE = 0;// 不能播放
|
public final int PLAY_HTML = 1;// 跳转移动端网页播放
|
public final int PLAY_SWF = 2;// 嵌套网页播放
|
|
public int getPlayType(IqiyiVideoInfo info) {
|
IqiyiVideoInfo vinfo = IqiYiAPI.getVideoInfo(info.getTvId() + "");
|
if (vinfo == null)
|
LogHelper.iqiyi(info.getTvId());
|
if (vinfo != null) {
|
JSONArray array = new JSONArray();
|
for (PlayControls pc : vinfo.getPlayControls()) {
|
if (pc.getPlatformId() == 15)// 移动端
|
array.add(new Gson().toJson(pc));
|
}
|
info.setPlaycontrols(array.toString());
|
iqiyiVideoInfoDao.update(info);
|
info = vinfo;
|
}
|
|
int type = PLAY_NONE;
|
|
if (info.getVideoStatus() == 0)
|
type = PLAY_NONE;
|
|
for (PlayControls pc : info.getPlayControls()) {
|
if (pc.getPlatformId() == 15)// 移动端
|
{
|
if (pc.getAvailableStatus() == 1 && pc.getCooperationAllowed() == 1)
|
type = PLAY_SWF;
|
else if (pc.getAvailableStatus() == 1 && pc.getCooperationAllowed() == 0)
|
type = PLAY_HTML;
|
}
|
}
|
if (info.getCategoryId() == 1 || info.getCategoryId() == 2 || info.getCategoryId() == 4
|
|| info.getCategoryId() == 6) {
|
if (type == PLAY_SWF)
|
type = PLAY_HTML;
|
} else {
|
if (type == PLAY_SWF && info.getTimeLength() > 3600)// 1个小时以上的长视频
|
type = PLAY_HTML;
|
}
|
|
return type;
|
}
|
|
public static String getAlbumTag(IqiyiAlbum album, Session session) {
|
String tag = "";
|
if (album.getCategoryId() == 1) {
|
if (album.getSourceId() > 0)
|
tag = "更新至" + TimeUtil.getGernalTime(TimeUtil.convertGernalTime(album.getTvYear(), "yyyyMMdd"),
|
"yyyy-MM-dd");
|
else
|
tag = "评分:" + album.getScore();
|
} else if (album.getCategoryId() == 2) {
|
if (album.getSourceId() <= 0) {// 剧集形式
|
IqiyiVideoInfo video = IqiyiService.getLatestVideoInfo(album.getAlbumId() + "", session);
|
|
if (video == null) {
|
JSONArray array = JSONArray.fromObject(album.getTvIds());
|
for (int i = 0; i < array.size(); i++)
|
IqiYiAPI.getVideoInfo(array.optString(i));
|
|
if (array.size() > 0)
|
return "";
|
}
|
|
tag = "更新至" + video.getPlayOrder() + "集";
|
if (video.getPlayOrder() == album.getSets()) {
|
tag = album.getSets() + "集全";
|
}
|
} else {// 日期形式
|
tag = "更新至" + TimeUtil.getGernalTime(TimeUtil.convertGernalTime(album.getTvYear(), "yyyyMMdd"),
|
"yyyy-MM-dd");
|
}
|
} else if (album.getCategoryId() == 6) {
|
tag = "更新至"
|
+ TimeUtil.getGernalTime(TimeUtil.convertGernalTime(album.getTvYear(), "yyyyMMdd"), "yyyy-MM-dd")
|
+ "期";
|
} else if (album.getCategoryId() == 4) {
|
if (album.getSourceId() <= 0) {// 剧集形式
|
|
IqiyiVideoInfo video = IqiyiService.getLatestVideoInfo(album.getAlbumId() + "", session);
|
if (video == null) {
|
JSONArray array = JSONArray.fromObject(album.getTvIds());
|
for (int i = 0; i < array.size(); i++)
|
IqiYiAPI.getVideoInfo(array.optString(i));
|
|
if (array.size() > 0)
|
getAlbumTag(album, session);
|
}
|
|
tag = "更新至" + video.getPlayOrder() + "集";
|
if (video.getPlayOrder() == album.getSets()) {
|
tag = album.getSets() + "集全";
|
}
|
} else
|
tag = "更新至" + TimeUtil.getGernalTime(TimeUtil.convertGernalTime(album.getTvYear(), "yyyyMMdd"),
|
"yyyy-MM-dd");
|
}
|
return tag;
|
}
|
|
public static long getType(int categoryId) {
|
if (categoryId == 1) {// 电影
|
return 151;
|
} else if (categoryId == 2) {// 电视剧
|
return 150;
|
} else if (categoryId == 3) {// 娱乐
|
return 155;
|
} else if (categoryId == 4) {// 动漫
|
return 153;
|
} else if (categoryId == 5) {// 音乐
|
return 155;
|
} else if (categoryId == 6) {// 综艺
|
return 153;
|
} else if (categoryId == 7) {// 娱乐
|
return 155;
|
} else if (categoryId == 8) {// 游戏
|
return 154;
|
} else if (categoryId == 9) {//
|
return 151;
|
} else if (categoryId == 10) {// 片花
|
return 152;
|
} else if (categoryId == 12) {// 教育
|
return 157;
|
} else if (categoryId == 13) {// 时尚
|
return 157;
|
} else if (categoryId == 15) {// 少儿
|
return 157;
|
} else if (categoryId == 17) {// 体育
|
return 158;
|
} else if (categoryId == 21) {// 生活
|
return 157;
|
} else if (categoryId == 22) {// 搞笑
|
return 155;
|
} else if (categoryId == 25) {// 资讯
|
return 159;
|
} else if (categoryId == 26) {// 汽车
|
return 156;
|
}
|
|
return categoryId;
|
}
|
|
// 更新聚合形式的专辑
|
public void updateSourceAlbum() {
|
List<List<String>> list = iqiyiService.getSourceAlbumList();
|
for (int i = 0; i < list.size(); i++) {
|
Map<String, Object> map = IqiYiAPI.getAlbumList(list.get(i).get(1), list.get(i).get(0), 1, 1, -1);// addAlbum
|
int count = Integer.parseInt(map.get("count") + "");
|
for (int n = 1; n < count / 100 + 2; n++) {
|
map = IqiYiAPI.getAlbumList(list.get(i).get(1), list.get(i).get(0), n, 100, -1);
|
List<IqiyiAlbum> dataList = (List<IqiyiAlbum>) map.get("data");
|
if (dataList != null && dataList.size() > 0)
|
addAlbum(dataList);
|
}
|
}
|
}
|
|
// 更新聚合形式的专辑
|
public void updateSourceAlbum(String sourceId) {
|
List<IqiyiAlbum> dataAllList = new ArrayList<>();
|
List<List<String>> list = iqiyiService.getSourceAlbumListBySourceId(sourceId);
|
for (int i = 0; i < list.size(); i++) {
|
Map<String, Object> map = IqiYiAPI.getAlbumList(list.get(i).get(1), list.get(i).get(0), 1, 1, -1);// addAlbum
|
int count = Integer.parseInt(map.get("count") + "");
|
for (int n = 1; n < count / 100 + 2; n++) {
|
map = IqiYiAPI.getAlbumList(list.get(i).get(1), list.get(i).get(0), n, 100, -1);
|
List<IqiyiAlbum> dataList = (List<IqiyiAlbum>) map.get("data");
|
if (dataList != null && dataList.size() > 0)
|
dataAllList.addAll(dataList);
|
}
|
}
|
|
for (int i = 0; i < dataAllList.size(); i++) {
|
if (dataAllList.get(i).getContentType() != 1) {
|
dataAllList.remove(i);
|
i--;
|
}
|
}
|
|
addAlbum(dataAllList);
|
}
|
|
/**
|
* 更新所有的专辑
|
*/
|
public void updateAllAlbum() {
|
List<IqiyiChannel> chalList = IqiYiAPI.getChannelList();
|
for (int c = 0; c < chalList.size(); c++) {
|
final String channelId = chalList.get(c).getCategoryId();
|
new Timer().schedule(new TimerTask() {
|
|
@SuppressWarnings("unchecked")
|
@Override
|
public void run() {// 两个小时更新一次
|
long endt = System.currentTimeMillis();
|
Map<String, Object> map = IqiYiAPI.updateAlbum(
|
TimeUtil.getGernalTime(endt - 1000 * 60 * 150L, "yyyyMMddHHmmss"),
|
TimeUtil.getGernalTime(endt, "yyyyMMddHHmmss"), null, 100, Integer.parseInt(channelId), 0);
|
int count = Integer.parseInt(map.get("count") + "");
|
List<IqiyiAlbum> list = (List<IqiyiAlbum>) map.get("data");
|
addAlbum(list);
|
list.clear();
|
|
if (count > 100) {
|
for (int i = 2; i < count / 100 + 2; i++) {
|
map = IqiYiAPI.updateAlbum(
|
TimeUtil.getGernalTime(endt - 1000 * 60 * 60 * 3, "yyyyMMddHHmmss"),
|
TimeUtil.getGernalTime(endt, "yyyyMMddHHmmss"),
|
list.get(list.size() - 1).getAlbumId(), 100, Integer.parseInt(channelId), 0);
|
list = (List<IqiyiAlbum>) map.get("data");
|
addAlbum(list);
|
}
|
}
|
}
|
}, 0, 1000 * 60 * 60 * 2L);
|
}
|
}
|
|
public void updateAll(final String key) {
|
List<IqiyiChannel> chalList = IqiYiAPI.getChannelList();
|
LogHelper.iqiyi("更新" + chalList.size() + "个分类");
|
for (int c = 0; c < chalList.size(); c++) {
|
final String channelId = chalList.get(c).getCategoryId();
|
final IqiyiChannel channel = chalList.get(c);
|
// if (!channel.getCategoryId().equalsIgnoreCase("1"))
|
// continue;
|
LogHelper.iqiyi("更新" + channel.getCategoryName());
|
new Timer().schedule(new TimerTask() {
|
|
@SuppressWarnings("unchecked")
|
@Override
|
public void run() {
|
// if (!StringUtil.isNullOrEmpty(key) &&
|
// !channel.getCategoryName().contains(key))
|
// return;
|
|
long current = System.currentTimeMillis();
|
long endt = System.currentTimeMillis();
|
int day = 10;
|
long spaceTime = 1000 * 60 * 60 * 24 * 2L;
|
if ("2".equalsIgnoreCase(channelId) || "4".equalsIgnoreCase(channelId))
|
day = 10;
|
else
|
day = 2;
|
long startt = endt - spaceTime;// 更新2天的
|
|
// 3小时为一个节点
|
for (int p = 0; p < 8 * day; p++) {
|
endt = current - p * 3 * 1000 * 60 * 60L;
|
startt = endt - 3 * 1000 * 60 * 60L;
|
|
String startTime = TimeUtil.getGernalTime(startt, "yyyyMMddHHmmss");
|
String endTime = TimeUtil.getGernalTime(endt, "yyyyMMddHHmmss");
|
int shortVideo = 0;
|
if ("7".equalsIgnoreCase(channelId) || "25".equalsIgnoreCase(channelId)
|
|| "22".equalsIgnoreCase(channelId) || "1".equalsIgnoreCase(channelId))
|
shortVideo = 1;
|
Map<String, Object> map = IqiYiAPI.updateAlbum(startTime, endTime, null, 20,
|
Integer.parseInt(channelId), shortVideo);
|
|
int count = Integer.parseInt(map.get("count") + "");
|
if (count > 3000)
|
count = 3000;
|
System.out.println(channelId + "--" + channel.getCategoryName() + "--" + count);
|
List<IqiyiAlbum> list = null;
|
for (int i = 1; i < count / 100 + 2; i++) {
|
map = IqiYiAPI.updateAlbum(startTime, endTime,
|
(i == 1 ? null : list.get(list.size() - 1).getAlbumId()), 100,
|
Integer.parseInt(channelId), shortVideo);
|
list = (List<IqiyiAlbum>) map.get("data");
|
System.out.println("频道名称" + channel.getCategoryName() + "页码:" + i);
|
addAlbum(list, channelId);
|
}
|
LogHelper.iqiyi("终于更新" + channel.getCategoryName() + "结束");
|
}
|
}
|
}, 0);
|
}
|
}
|
|
public void updateAlbum(String aid) {
|
IqiyiAlbum album = IqiYiAPI.getAlbumDetail(aid);
|
if (album != null && album.getSourceId() > 0) {
|
updateSourceAlbum(album.getSourceId() + "");
|
}
|
|
List<IqiyiAlbum> list = new ArrayList<IqiyiAlbum>();
|
list.add(album);
|
addAlbum(list);
|
}
|
|
public void updateAll(final int channelId, int hour) {
|
long endt = System.currentTimeMillis();
|
long startt = endt - 1000 * 60 * 60L * hour;
|
String startTime = TimeUtil.getGernalTime(startt, "yyyyMMddHHmmss");
|
String endTime = TimeUtil.getGernalTime(endt, "yyyyMMddHHmmss");
|
Map<String, Object> map = IqiYiAPI.updateAlbum(startTime, endTime, null, 20, channelId, 0);
|
|
int count = Integer.parseInt(map.get("count") + "");
|
if (count > 3000)
|
count = 3000;
|
System.out.println(channelId + "--" + count);
|
List<IqiyiAlbum> list = null;
|
for (int i = 1; i < count / 100 + 2; i++) {
|
map = IqiYiAPI.updateAlbum(startTime, endTime, (i == 1 ? null : list.get(list.size() - 1).getAlbumId()),
|
100, channelId, 0);
|
list = (List<IqiyiAlbum>) map.get("data");
|
System.out.println("页码:" + i);
|
addAlbum(list);
|
}
|
}
|
|
@SuppressWarnings("unchecked")
|
public void parseAll() {
|
final List<IqiyiChannel> list = IqiYiAPI.getChannelList();
|
for (int c = 1; c < list.size(); c++) {
|
final int p = c;
|
new Thread(new Runnable() {
|
|
public void run() {
|
Map<String, Object> map = IqiYiAPI.getAlbumList(list.get(p).getCategoryId(), "", 1, 1, -1);// addAlbum
|
int count = Integer.parseInt(map.get("count") + "");
|
if (count > 5000)
|
count = 5000;
|
for (int i = 1; i < count / 100 + 1; i++) {// 从后往前解析
|
System.out.println("ChannelId:" + list.get(p).getCategoryId() + " ----page:" + i);
|
map = IqiYiAPI.getAlbumList(list.get(p).getCategoryId(), "", i, 100, -1);// addAlbum
|
List<IqiyiAlbum> dataList = (List<IqiyiAlbum>) map.get("data");
|
addAlbum(dataList);
|
}
|
}
|
}).start();
|
|
}
|
}
|
|
public void addAlbum(List<IqiyiAlbum> list) {
|
addAlbum(list, "2");
|
}
|
|
public void addAlbum(List<IqiyiAlbum> list, String channelId) {
|
Gson gson = new GsonBuilder().setVersion(1.0).create();
|
if (list != null)
|
for (IqiyiAlbum ia : list) {
|
|
// if (!ia.getAlbumName().contains("真爱的谎言之破冰者"))
|
// continue;
|
|
final String name = ia.getAlbumName();
|
if (!(Boolean) videoResourceDao.excute(new HibernateCallback<Boolean>() {
|
public Boolean doInHibernate(Session session) throws HibernateException {
|
return JuheVideoUtil.isNeedAdd(session, name);
|
}
|
}))
|
continue;
|
|
System.out.println(ia.getAlbumName());
|
if (ia.getAlbumName().contains("(VR)"))
|
continue;
|
|
// if ((ia.getAlbumId() == ia.getOwnerAlbumId()) ||
|
// ia.getOwnerAlbumId() == -1) {
|
|
try {
|
System.out.println(ia.getAlbumName());
|
ia = IqiYiAPI.getAlbumDetail(ia.getAlbumId() + "");
|
JSONArray array = JSONArray.fromObject(ia.getTvIds());
|
List<IqiyiVideoInfo> videoList = new ArrayList<IqiyiVideoInfo>();
|
for (int p = 0; p < array.size(); p++) {
|
IqiyiVideoInfo info = IqiYiAPI.getVideoInfo(array.optString(p));
|
|
JSONArray obj = new JSONArray();
|
for (PlayControls pc : info.getPlayControls())
|
if (pc.getPlatformId() == 15 && pc.getAvailableStatus() == 1) {
|
obj.add(gson.toJson(pc));
|
}
|
info.setPlaycontrols(obj.toString());
|
if (info.getIsPurchase() == 0)
|
videoList.add(info);
|
}
|
|
Comparator<IqiyiVideoInfo> c = new Comparator<IqiyiVideoInfo>() {
|
|
public int compare(IqiyiVideoInfo o1, IqiyiVideoInfo o2) {
|
return o2.getPlayOrder() - o1.getPlayOrder();
|
}
|
};
|
// if("2".equals(channelId)){
|
LogHelper.iqiyi("名称:" + name + ":" + videoList.size());
|
// }
|
Collections.sort(videoList, c);
|
// 此处暂时无效
|
IqiyiVideoInfo latestInfo = iqiyiService.getLatestVideoInfo(ia.getAlbumId() + "");
|
boolean isUpdate = false;
|
if (latestInfo != null && videoList.size() > 0)
|
isUpdate = videoList.get(0).getPlayOrder() > latestInfo.getPlayOrder();
|
if (ia.getCategoryId() == 6) {
|
for (IqiyiVideoInfo video : videoList)
|
iqiyiService.deleteByTvId(video.getTvId() + "");
|
}
|
|
String aid = iqiyiService.saveAlbumVideoInfo(ia, videoList);// 保存专辑与视频
|
ia.setId(aid);
|
if (!StringUtil.isNullOrEmpty(aid)) {
|
String vid = iqiyiService.insertAlbumToVideoInfo(ia, videoList, isUpdate);// 将专辑加入到videoinfo
|
if (!StringUtil.isNullOrEmpty(vid))
|
insertVideoToVideoType(vid);
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
// }
|
}
|
}
|
|
public void parseSingleAlbum(String albumId) {
|
Gson gson = new GsonBuilder().create();
|
IqiyiAlbum ia = IqiYiAPI.getAlbumDetail(albumId);
|
JSONArray array = JSONArray.fromObject(ia.getTvIds());
|
List<IqiyiVideoInfo> videoList = new ArrayList<IqiyiVideoInfo>();
|
for (int p = 0; p < array.size(); p++) {
|
IqiyiVideoInfo info = IqiYiAPI.getVideoInfo(array.optString(p));
|
|
JSONArray obj = new JSONArray();
|
for (PlayControls pc : info.getPlayControls())
|
if (pc.getPlatformId() == 14 || pc.getPlatformId() == 15) {
|
obj.add(gson.toJson(pc));
|
}
|
info.setPlaycontrols(obj.toString());
|
videoList.add(info);
|
}
|
|
Comparator<IqiyiVideoInfo> c = new Comparator<IqiyiVideoInfo>() {
|
|
public int compare(IqiyiVideoInfo o1, IqiyiVideoInfo o2) {
|
return o2.getPlayOrder() - o1.getPlayOrder();
|
}
|
};
|
|
Collections.sort(videoList, c);
|
// 此处暂时无效
|
IqiyiVideoInfo latestInfo = iqiyiService.getLatestVideoInfo(ia.getAlbumId() + "");
|
boolean isUpdate = false;
|
if (latestInfo != null && videoList.size() > 0)
|
isUpdate = videoList.get(0).getPlayOrder() > latestInfo.getPlayOrder();
|
|
String aid = iqiyiService.saveAlbumVideoInfo(ia, videoList);// 保存专辑与视频
|
ia.setId(aid);
|
if (!StringUtil.isNullOrEmpty(aid)) {
|
String vid = iqiyiService.insertAlbumToVideoInfo(ia, videoList, isUpdate);// 将专辑加入到videoinfo
|
if (!StringUtil.isNullOrEmpty(vid))
|
insertVideoToVideoType(vid);
|
}
|
}
|
|
public PlayUrl getPlayUrl(String detailSystemId, String resourceId, String type, String id) {
|
logger.info(String.format("%s#%s#%s#%s", detailSystemId, resourceId, type, id));
|
VideoResource vr = null;
|
vr = (VideoResource) videoResourceDao.find(VideoResource.class, resourceId);
|
|
long tvid = 0;
|
|
if (type.contains("album")) {// 专辑形式的
|
List<IqiyiVideoInfo> infoList = iqiyiVideoInfoDao.list("from IqiyiVideoInfo i where i.albumId=?",
|
new String[]{id});
|
if (infoList != null && infoList.size() > 0) {// 有数据
|
tvid = infoList.get(0).getTvId();
|
}
|
|
} else if (type.contains("tv")) {// tv形式的
|
|
List<IqiyiVideoInfo> infoList = iqiyiVideoInfoDao.list("from IqiyiVideoInfo i where i.tvId=" + id);
|
if (infoList != null && infoList.size() > 0) {// 有数据
|
tvid = infoList.get(0).getTvId();
|
}
|
}
|
|
if (tvid > 0) {
|
|
List<IqiyiVideoInfo> infoList = iqiyiVideoInfoDao.list("from IqiyiVideoInfo i where i.tvId=" + tvid);
|
IqiyiVideoInfo info = infoList.get(0);
|
|
if (!StringUtil.isNullOrEmpty(info.getPlaycontrols())) {
|
JSONArray array = JSONArray.fromObject(info.getPlaycontrols());
|
Gson gson = new GsonBuilder().setVersion(1.0).create();
|
for (int i = 0; i < array.size(); i++) {
|
if (info.getPlayControls() == null)
|
info.setPlayControls(new ArrayList<PlayControls>());
|
info.getPlayControls().add(gson.fromJson(array.optJSONObject(i).toString(), PlayControls.class));
|
}
|
}
|
int t = getPlayType(info);
|
if (info != null)
|
iqiyiService.addPlayStatistic(detailSystemId, info);
|
|
t = PLAY_HTML;
|
PlayUrl pu = new PlayUrl();
|
pu.setParams("");
|
pu.setPlayType(t);
|
pu.setResource(vr);
|
|
if (t == PLAY_NONE) {
|
pu.setUrl("");
|
} else if (t == PLAY_HTML) {
|
pu.setUrl(info.getHtml5PlayUrl());
|
} else if (t == PLAY_SWF) {
|
if ("44".equalsIgnoreCase(detailSystemId))
|
pu.setPlayType(PLAY_HTML);
|
pu.setUrl(info.getCommonSwf());
|
}
|
|
if (t == PLAY_NONE) {
|
LogHelper.iqiyi(tvid);
|
}
|
|
return pu;
|
}
|
return null;
|
}
|
|
public int getShowType(String videoid) {
|
List<VideoIqiyi> list = videoIqiyiDao.list("from VideoIqiyi vi where vi.video.id=?", 0, 1,
|
new Serializable[]{videoid});
|
if (list != null && list.size() > 0)
|
if (list.get(0).getAlbum().getCategoryId() == 1 || list.get(0).getAlbum().getCategoryId() == 6
|
|| list.get(0).getAlbum().getCategoryId() == 3)
|
return 1;
|
else if (list.get(0).getAlbum().getCategoryId() == 2 || list.get(0).getAlbum().getCategoryId() == 4)
|
return 2;
|
else if (list.get(0).getAlbum().getSourceId() > 0)// 长条
|
return 1;
|
else
|
return 2;// 短条
|
return 1;
|
}
|
|
public List<Integer> getMyCategory(int qiyiType) {
|
List<Integer> list = new ArrayList<Integer>();
|
switch (qiyiType) {
|
|
// 电影类型
|
case 8:
|
list.add(172);
|
break;// 喜剧
|
case 13:
|
list.add(173);
|
break;// 悲剧
|
case 6:
|
list.add(174);
|
break;// 爱情
|
case 11:
|
list.add(175);
|
break;// 动作
|
case 131:
|
list.add(176);
|
break;// 枪战
|
case 291:
|
list.add(177);
|
break;// 犯罪
|
case 128:
|
list.add(178);
|
break;// 惊悚
|
case 10:
|
list.add(179);
|
break;// 恐怖
|
case 289:
|
list.add(180);
|
break;// 悬疑
|
case 12:
|
list.add(181);
|
break;// 动画
|
case 27356:
|
list.add(182);
|
break;// 家庭
|
case 1284:
|
list.add(183);
|
break;// 奇幻
|
case 129:
|
list.add(184);
|
break;// 魔幻
|
case 9:
|
list.add(185);
|
break;// 科幻
|
case 7:
|
list.add(186);
|
break;// 战争
|
case 130:
|
list.add(251);
|
break;// 青春
|
case 1007:
|
list.add(249);
|
break;// 电影片花
|
|
// 电视剧
|
case 20:
|
list.add(160);
|
break;// 言情剧
|
case 21:
|
list.add(161);
|
break;// 历史剧
|
case 23:
|
list.add(162);
|
break;// 武侠剧
|
case 24:
|
list.add(163);
|
break;// 古装剧
|
case 27:
|
list.add(164);
|
break;// 年代剧
|
case 29:
|
list.add(165);
|
break;// 农村剧
|
case 30:
|
list.add(166);
|
break;// 偶像剧
|
case 32:
|
list.add(167);
|
break;// 悬疑剧
|
case 34:
|
list.add(168);
|
break;// 科幻剧
|
case 135:
|
list.add(169);
|
break;// 喜剧
|
case 139:
|
list.add(170);
|
break;// 宫廷剧
|
case 140:
|
list.add(171);
|
break;// 商战剧
|
case 145:
|
list.add(252);
|
break;// 神话剧
|
case 148:
|
list.add(253);
|
break;// 穿越剧
|
case 149:
|
list.add(254);
|
break;// 罪案剧
|
case 290:
|
list.add(255);
|
break;// 谍战剧
|
case 1653:
|
list.add(256);
|
break;// 青春剧
|
case 1654:
|
list.add(257);
|
break;// 家庭剧
|
case 1655:
|
list.add(258);
|
break;// 军旅剧
|
case 24063:
|
list.add(259);
|
break;// 剧情
|
case 24064:
|
list.add(260);
|
break;// 都市
|
case 24065:
|
list.add(261);
|
break;// 网络
|
case 1006:
|
list.add(282);// 电视剧相关
|
break;// 电视剧片花
|
|
// 动漫
|
|
case 41:
|
list.add(197);
|
break;// 动作
|
|
case 42:
|
list.add(198);
|
break;// 热血
|
|
case 43:
|
|
// 机战
|
|
case 44:
|
list.add(199);
|
break;// 战争
|
|
case 47:
|
list.add(200);
|
break;// 侦探
|
|
case 48:
|
list.add(201);
|
break;// 冒险
|
|
case 49:
|
// 竞技
|
|
case 50:
|
list.add(202);
|
break;// 体育
|
|
case 51:
|
list.add(204);
|
break;// 搞笑
|
|
case 52:
|
|
// 言情
|
|
case 53:
|
// 校园
|
|
case 54:
|
list.add(205);
|
break;// 都市
|
|
case 55:
|
|
// 魔幻
|
|
case 56:
|
list.add(206);
|
break;// 科幻
|
|
case 59:
|
list.add(207);
|
break;// 剧情
|
|
case 60:
|
list.add(200);
|
break;// 悬疑
|
|
case 45:
|
// 古代
|
|
case 46:
|
// 未来
|
|
case 61:
|
// 宠物
|
list.add(208);
|
break;
|
case 62:
|
// LOLI
|
case 63:
|
// ACG
|
case 64:
|
// Cosplay
|
|
list.add(283);
|
break;
|
case 297:
|
// 励志
|
|
case 298:
|
// 益智
|
|
case 299:
|
// 童话
|
|
case 300:
|
// 真人
|
|
case 301:
|
// 神话
|
|
case 302:
|
// 青春
|
|
case 316:
|
// 亲子
|
|
case 1092:
|
// 原创
|
|
case 1094:
|
// 传媒大学作品
|
|
case 1095:
|
// 电影学院作品
|
|
case 1096:
|
// 动画电影
|
|
case 1108:
|
// 教育
|
|
case 1309:
|
// 怀旧
|
list.add(208);
|
break;
|
case 2297:
|
// 同人
|
case 2298:
|
list.add(283);
|
break;// 短片
|
|
// 综艺
|
case 155:
|
list.add(187);
|
break; // 播报
|
case 156:
|
list.add(188);
|
break;// 访谈
|
case 157:
|
list.add(189);
|
break;// 搞笑
|
case 158:
|
list.add(190);
|
break;// 游戏
|
case 159:
|
list.add(191);
|
break;// 选秀
|
case 160:
|
list.add(192);
|
break;// 时尚
|
case 163:
|
list.add(193);
|
break;// 情感
|
case 292:
|
list.add(194);
|
break;// 盛会
|
case 293:
|
list.add(195);
|
break;// 曲艺
|
case 1002:
|
list.add(196);
|
break;// 粤语
|
case 1003:
|
list.add(263);
|
list.add(228);
|
break;// 美食
|
case 2117:
|
list.add(264);
|
break;// 少儿
|
case 2118:
|
list.add(265);
|
break;// 脱口秀
|
|
case 2119:// 职场
|
list.add(266);
|
break;
|
case 2120:// 相亲
|
list.add(267);
|
break;
|
case 2121:// 歌舞
|
list.add(268);
|
break;
|
case 2122:// 伦理
|
list.add(269);
|
break;
|
case 2224:// 真人秀
|
list.add(270);
|
break;
|
case 161:// 其它
|
list.add(271);
|
break;
|
|
// 纪录片
|
case 70:// 人物
|
|
case 72:// 军事
|
|
case 74:// 历史
|
|
case 73:// 探索
|
|
case 77:// 文化
|
|
case 71:// 社会
|
|
case 28119:// 科学
|
|
case 310:// 旅游
|
|
case 28137:// 真人秀
|
|
case 28138:// 政治
|
|
break;
|
|
// 资讯
|
case 20031:// 社会
|
list.add(242);
|
break;
|
case 20321:// 科技
|
list.add(244);
|
break;
|
case 21314:// 军事
|
list.add(243);
|
break;
|
case 21315:// 评论
|
list.add(291);
|
break;
|
case 21739:// 国内
|
list.add(290);
|
break;
|
case 21740:// 国际
|
list.add(290);
|
break;
|
|
// 娱乐
|
case 169:// 独家
|
|
case 170:// 热点
|
|
case 171:// 原创
|
|
case 175:// 八卦
|
|
case 176:// 选秀
|
|
case 177:// 情感
|
|
case 178:// 时尚
|
|
case 179:// 游戏
|
|
case 180:// 搞笑
|
|
case 182:// 颁奖
|
|
case 183:// 活动
|
|
case 349:// 结婚
|
|
case 350:// 去世
|
|
case 351:// 生子
|
|
case 352:// 探班
|
|
case 353:// 事故
|
|
case 637:// 票房
|
|
case 950:// 盘点
|
|
case 951:// 纠纷
|
|
case 952:// 官司
|
|
case 1001:// 星座
|
|
case 1088:// 演唱会
|
|
case 1657:// 环保
|
|
case 1658:// 慈善
|
list.add(219);
|
|
break;
|
|
// 财经
|
case 2233:
|
// 宏观
|
case 2234:
|
// 民生
|
case 2235:
|
// 产经
|
case 2236:
|
// 市场
|
case 2237:
|
// 理财
|
case 2238:
|
list.add(227);
|
break; // 访谈
|
|
// 微电影
|
case 1293:
|
case 1294:
|
case 1295:
|
case 1296:
|
case 1297:
|
case 1298:
|
case 1299:
|
case 1300:
|
case 1301:
|
case 1302:
|
case 1303:
|
case 1304:
|
case 1305:
|
case 1306:
|
case 1307:
|
case 1315:
|
case 2287:
|
case 2289:
|
case 2290:
|
case 2329:
|
case 1308:
|
|
break;
|
|
// 游戏
|
case 21275:
|
// 网络游戏
|
case 21276:
|
list.add(212);
|
break;// 电子竞技
|
case 21277:
|
list.add(213);
|
break;// 单机游戏
|
case 21278:
|
list.add(214);
|
break;// 手机游戏
|
case 21279:
|
list.add(272);
|
break;// 游戏美女
|
|
// 音乐
|
case 23556:
|
list.add(301);
|
break;// 单曲MV
|
case 23557:
|
list.add(301);
|
break;// 单曲现场
|
case 23558:
|
list.add(301);
|
break;// 演唱会
|
case 23559:
|
// 新闻
|
case 23560:
|
// 访谈
|
case 23561:
|
// 音乐记录
|
case 23562:
|
|
// 音乐周边
|
case 23563:
|
list.add(280);
|
break;// 音乐节目
|
case 23564:
|
list.add(279);
|
break;// 影视原声
|
case 23565:
|
list.add(280);
|
break;// 音乐短片
|
case 23566:
|
list.add(280);
|
break;// 其他
|
|
// 军事
|
case 21789:
|
// 军情
|
case 21790:
|
// 深度
|
case 21791:
|
// 兵器
|
case 21792:
|
// 战史
|
case 21793:
|
list.add(223);
|
break;// 人物
|
|
// 教育
|
case 1934:// 幼儿
|
break;
|
case 1935:// 小学
|
break;
|
case 1936:// 初中
|
break;
|
case 1937:// 高中
|
break;
|
case 1939:// 外语学习
|
|
case 1940:// 职业教育
|
|
case 1941:// 管理培训
|
|
case 2111:// 学历教育
|
|
case 2124:// 公开课
|
case 28524:// 教育咨询
|
case 21436:// 实用教程
|
case 28530:// 文化艺术
|
list.add(225);
|
break;
|
|
// 体育
|
case 1673:
|
break;// 足球
|
case 1688:
|
break;// 篮球
|
case 1700:
|
break;// 网球
|
case 1707:
|
list.add(292);
|
break;// 高尔夫
|
case 1708:
|
list.add(294);
|
break;// 赛车
|
case 1711:
|
list.add(234);
|
break;// 极限运动
|
case 1712:
|
list.add(293);
|
break;// 台球
|
case 22178:
|
list.add(235);
|
break;// 健身
|
case 1715:
|
list.add(287);
|
break;// 其它
|
|
// 旅游
|
|
case 354:
|
// 风光
|
|
case 355:
|
// 饮食
|
|
case 356:
|
// 住宿
|
|
case 357:
|
// 访谈
|
|
case 638:
|
// 出行
|
|
case 28065:
|
// 综艺
|
|
case 2328:
|
// 啪啪奇
|
|
case 639:
|
list.add(229);
|
break;// 奇趣
|
|
// 时尚
|
case 1229:
|
// 公告牌
|
|
case 1230:
|
// 奇艺自制
|
|
case 1231:
|
// 热门综艺
|
|
case 1232:
|
// 名利场
|
|
case 1233:
|
// 趋势报道
|
|
case 1234:
|
// 本季流行
|
|
case 1235:
|
// 秀场
|
|
case 1236:
|
// 广告大片
|
|
case 1237:
|
// 街拍
|
|
case 1238:
|
// 人物
|
|
case 1239:
|
// 派对&);红毯
|
|
case 1240:
|
// 乐活
|
|
case 1241:
|
list.add(232);
|
break;// 其它
|
|
// 生活
|
case 2218:
|
list.add(228);
|
break;// 美食
|
|
case 1879:
|
list.add(230);
|
break;// 家居
|
|
case 2228:
|
list.add(230);
|
break;// 宠物
|
|
case 1898:
|
list.add(232);
|
break;// 美尚
|
|
case 1878:
|
list.add(230);
|
break;// 健康
|
|
case 2226:
|
list.add(303);
|
break;// 舞蹈
|
|
case 1873:
|
list.add(222);
|
break;// 科技
|
|
case 2225:
|
list.add(230);
|
break;// 健身
|
|
case 2115:
|
break;// 婚嫁
|
|
case 2230:
|
break;// 情感
|
|
case 1876:
|
list.add(288);
|
break;// 奇闻
|
|
case 1899:
|
break;// 汽车
|
|
case 2229:
|
list.add(286);
|
break;// 魔术
|
|
case 2227:
|
break;// 休闲
|
|
case 28901:
|
break;// 书画
|
|
// 汽车
|
|
case 20529:
|
// 资讯
|
|
case 20530:
|
// 专访
|
|
case 20531:
|
// 新车
|
|
case 20532:
|
// 试驾
|
|
case 20533:
|
// 用车
|
|
case 20534:
|
// 赛事
|
|
case 20535:
|
// 交通
|
|
case 20536:
|
// 娱乐
|
|
case 20537:
|
// 车模
|
|
case 20538:
|
// 改装
|
|
case 20539:
|
// 车微剧
|
|
case 20540:
|
// 爱汽车制造
|
|
case 28463:
|
// 品牌
|
|
case 28464:
|
// 车展
|
|
case 28534:
|
// 航空
|
|
case 28535:
|
// 游艇
|
|
case 28536:
|
list.add(226);
|
break;// 轨道
|
|
// 搞笑
|
|
case 22169:
|
// 欢乐精选
|
|
case 29115:
|
// 娱乐八卦
|
|
case 29116:
|
// 搞笑短片
|
|
case 29139:
|
// 影视剧吐槽
|
|
case 22172:
|
// 雷人囧事
|
|
case 22171:
|
// 爆笑节目
|
|
case 1909:
|
// 童趣
|
|
case 1900:
|
// 奇闻趣事
|
|
case 1902:
|
|
list.add(216);
|
break;// 恶搞配音
|
case 1905:
|
list.add(216);
|
list.add(220);
|
// 萌宠
|
break;
|
case 1903:
|
// 相声
|
|
case 1904:
|
list.add(217);
|
break;// 小品
|
|
case 2327:
|
break;// 啪啪奇
|
|
case 22170:
|
list.add(288);
|
// 猎奇
|
break;
|
|
// 母婴
|
case 24083:
|
// 萌宝乐园
|
|
case 24084:
|
// 孕期
|
|
case 24085:
|
// 分娩
|
|
case 24086:
|
// 妈咪饮食
|
|
case 24087:
|
// 宝宝饮食
|
|
case 24088:
|
// 早教课堂
|
|
case 24089:
|
// 婴幼儿常见疾病
|
|
case 27345:
|
// 时尚辣妈圈
|
|
case 27350:
|
// 亲子生活馆
|
|
case 29619:
|
// 宝宝养育
|
|
case 29746:
|
break;// 趣味玩具
|
|
// 科技
|
case 27972:
|
// IT业界
|
|
case 27973:
|
// 互联网
|
|
case 28521:
|
// APP
|
|
case 27942:
|
// 手机
|
|
case 27943:
|
// 笔记本
|
|
case 27944:
|
// 智能硬件
|
|
case 27945:
|
// 平板电脑
|
|
case 27946:
|
// 数码相机
|
|
case 27948:
|
// PC
|
|
case 27949:
|
// 家电
|
|
case 27950:
|
// 游戏机
|
|
case 27953:
|
// 爱科技出品
|
list.add(221);
|
break;
|
case 27951:
|
// 前沿技术
|
|
case 27952:
|
list.add(222);
|
break;// 科学探索
|
|
// 脱口秀
|
case 27507:
|
// 文化
|
case 27508:
|
// 娱乐
|
case 27509:
|
// 访谈
|
case 27510:
|
// 社会
|
case 27511:
|
// 搞笑
|
case 27512:
|
// 财经
|
case 27513:
|
// 时尚
|
case 27514:
|
// 历史
|
case 29117:
|
break;// 电台
|
|
// 健康
|
case 28068:
|
break;// 资讯
|
|
case 28069:
|
break;// 医疗
|
|
case 28081:
|
list.add(230);
|
break;// 两性
|
|
case 28082:
|
break;// 养生
|
|
case 28441:
|
break;// 健身
|
|
case 28449:
|
break;// 美容
|
|
case 28450:
|
break;// 心理
|
|
case 28451:
|
break;// 常识
|
|
case 28452:
|
break;// 儿科
|
|
case 28456:
|
break;// 老年
|
|
case 28459:
|
list.add(230);
|
break;// 宠物
|
|
case 28462:
|
break;// 交流分享
|
|
}
|
|
return list;
|
|
}
|
|
/**
|
* 将视频插入表
|
*
|
* @param videoid
|
*/
|
public void insertVideoToVideoType(String videoid) {
|
|
List<Integer> list = getVideoTypeList(videoid);
|
for (int vt : list) {
|
addVideoToVideoType(videoid, vt + "");
|
}
|
|
}
|
|
public List<Integer> getVideoTypeList(String videoid) {
|
List<Integer> list = new ArrayList<Integer>();
|
|
List<VideoIqiyi> videoList = videoIqiyiDao.list(" from VideoIqiyi vi where vi.video.id=?", 0, 1,
|
new String[]{videoid});
|
if (videoList != null && videoList.size() > 0) {
|
String threeCtgs = videoList.get(0).getAlbum().getThreeCtgs();
|
JSONArray array = JSONArray.fromObject(threeCtgs);
|
for (int i = 0; i < array.size(); i++) {
|
List<Integer> typeList = getMyCategory(array.optJSONObject(i).optInt("id"));
|
for (Integer typeId : typeList) {
|
if (typeId > 0) {
|
if (!list.contains(typeId))
|
list.add(typeId);
|
}
|
}
|
}
|
}
|
|
// 如果为空值就加入默认分类
|
if (list.size() == 0)
|
list.add(299);
|
|
return list;
|
}
|
|
public void addVideoToVideoType(final String videoid, final String typeid) {
|
iqiyiVideoInfoDao.excute(new HibernateCallback() {
|
public Object doInHibernate(Session session) throws HibernateException {
|
try {
|
session.getTransaction().begin();
|
Object obj = session
|
.createQuery(
|
"select count(*) from CategoryVideo cv where cv.video.id=? and cv.videoType.id=?")
|
.setParameter(0, videoid).setParameter(1, Long.parseLong(typeid)).uniqueResult();
|
if (Integer.parseInt(obj + "") <= 0) {
|
CategoryVideo cv = new CategoryVideo();
|
cv.setVideo(new VideoInfo(videoid));
|
cv.setVideoType(new VideoType(Long.parseLong(typeid)));
|
session.persist(cv);
|
}
|
session.flush();
|
session.getTransaction().commit();
|
} catch (Exception e) {
|
logger.error("addVideoToVideoType");
|
logger.error(e.getMessage());
|
e.printStackTrace();
|
}
|
return null;
|
}
|
});
|
|
}
|
|
public String getHighVerPicture(String org) {
|
return org.replace(".jpg", "_260_360.jpg");
|
}
|
|
@SuppressWarnings("rawtypes")
|
public void updateIqiyiAvaiable() {
|
iqiyiVideoInfoDao.excute(new HibernateCallback() {
|
@SuppressWarnings("unchecked")
|
public Object doInHibernate(Session session) throws HibernateException {
|
for (int i = 0; i < 100; i++) {
|
List<IqiyiVideoInfo> list = session.createQuery("from IqiyiVideoInfo iv order by iv.id DESC")
|
.setFirstResult(i * 10000).setMaxResults(1000).list();
|
|
try {
|
for (IqiyiVideoInfo vi : list) {
|
if (!StringUtil.isNullOrEmpty(vi.getPlaycontrols())) {
|
JSONArray array = JSONArray.fromObject(vi.getPlaycontrols());
|
Gson gson = new GsonBuilder().setVersion(1.0).create();
|
for (int n = 0; n < array.size(); n++) {
|
if (vi.getPlayControls() == null)
|
vi.setPlayControls(new ArrayList<PlayControls>());
|
vi.getPlayControls()
|
.add(gson.fromJson(array.optJSONObject(n).toString(), PlayControls.class));
|
}
|
}
|
if (vi.getPlayControls() != null)
|
if (getPlayType(vi) == PLAY_NONE)// 隐藏该视频
|
{
|
List ilist = session.createSQLQuery(
|
"SELECT i.`videoid` FROM wk_iqiyi_album_tvid tv LEFT JOIN wk_video_iqiyi i ON i.`albumid`=tv.`albumid` WHERE tv.`id`="
|
+ vi.getId())
|
.list();
|
if (ilist != null && ilist.size() > 0
|
&& !StringUtil.isNullOrEmpty(ilist.get(0) + "")) {
|
VideoInfo v = (VideoInfo) session.get(VideoInfo.class, ilist.get(0) + "");
|
v.setShow("0");
|
session.getTransaction().begin();
|
session.update(v);
|
session.flush();
|
session.getTransaction().commit();
|
}
|
}
|
}
|
} catch (Exception e) {
|
e.printStackTrace();
|
}
|
}
|
return null;
|
}
|
});
|
|
}
|
|
@SuppressWarnings("unchecked")
|
public List<IqiyiAlbum> getIqiyiAlbumByCatoryIdAndContentType(final int cid, final int ctype) {
|
return (List<IqiyiAlbum>) videoIqiyiDao.excute(new HibernateCallback<List<IqiyiAlbum>>() {
|
|
@Override
|
public List<IqiyiAlbum> doInHibernate(Session session) throws HibernateException {
|
return session
|
.createQuery("from IqiyiAlbum a where a.categoryId=" + cid + " and a.contentType=" + ctype)
|
.list();
|
}
|
});
|
}
|
|
/**
|
* 更新原来属于爱奇艺VIP的视频
|
*/
|
@SuppressWarnings("unchecked")
|
public void updateIqiyiVIP() {
|
List<BigInteger> list = (List<BigInteger>) videoIqiyiDao.excute(new HibernateCallback<List<BigInteger>>() {
|
@Override
|
public List<BigInteger> doInHibernate(Session session) throws HibernateException {
|
List list = session
|
.createSQLQuery(
|
"SELECT a.`albumId` FROM wk_iqiyi_album a WHERE a.`isPurchase`=1 AND a.`contentType`=1 AND a.`categoryId`=1")
|
.list();
|
return (List<BigInteger>) list;
|
}
|
});
|
|
for (BigInteger aid : list) {
|
updateAlbum(aid.toString());
|
}
|
|
}
|
/**
|
* 添加爱奇艺小视频
|
*
|
* @param aid
|
*/
|
public void addShortVideo(String albumId) {
|
IqiyiAlbum album = IqiYiAPI.getAlbumDetail(albumId);
|
// String aid = iqiyiService.saveAlbumVideoInfo(album, videoList);//
|
// 保存专辑与视频
|
// ia.setId(aid);
|
// if (!StringUtil.isNullOrEmpty(aid)) {
|
// String vid = iqiyiService.insertAlbumToVideoInfo(ia, videoList,
|
// isUpdate);// 将专辑加入到videoinfo
|
// if (!StringUtil.isNullOrEmpty(vid))
|
// insertVideoToVideoType(vid);
|
// }
|
|
}
|
|
public static String getHPicture(String url) {
|
String regex = "_m[0-9]+\\.jpg";
|
Pattern p = Pattern.compile(regex);
|
Matcher m = p.matcher(url);
|
if (m.find()) {
|
return url.replace(".jpg", "#.jpg").replace("#", "_480_270");
|
} else {
|
return url;
|
}
|
}
|
|
public static String getVPicture(String url) {
|
String regex = "_m[0-9]+\\.jpg";
|
Pattern p = Pattern.compile(regex);
|
Matcher m = p.matcher(url);
|
if (m.find()) {
|
return url.replace(".jpg", "#.jpg").replace("#", "_260_360");
|
} else {
|
return url;
|
}
|
}
|
|
}
|