New file |
| | |
| | | package com.yeshi.buwan.controller.admin.api; |
| | | |
| | | import com.yeshi.buwan.domain.VideoType; |
| | | import com.yeshi.buwan.service.imp.VideoTypeService; |
| | | import com.yeshi.buwan.service.inter.juhe.BilibiliVideoService; |
| | | import com.yeshi.buwan.util.JsonUtil; |
| | | import com.yeshi.buwan.videos.bilibili.BilibiliApiUtil; |
| | | import com.yeshi.buwan.videos.bilibili.entity.BilibiliMediaInfo; |
| | | import com.yeshi.buwan.videos.bilibili.entity.BilibiliVideo; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestMethod; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.PrintWriter; |
| | | |
| | | @Controller |
| | | @RequestMapping("admin/new/api/bilibili") |
| | | public class BilibiliAdminController { |
| | | |
| | | @Resource |
| | | private VideoTypeService videoTypeService; |
| | | |
| | | @Resource |
| | | private BilibiliVideoService bilibiliVideoService; |
| | | |
| | | @RequestMapping(value = "/addVideo", method = RequestMethod.POST) |
| | | public void addVideo(String url, int type, PrintWriter out) { |
| | | VideoType videoType = videoTypeService.getVideoType(type); |
| | | if (videoType == null) { |
| | | out.print(JsonUtil.loadFalseAdmin("视频分类不存在")); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | BilibiliVideo bilibiliVideo = BilibiliApiUtil.parseShortVideo(url); |
| | | if (bilibiliVideo == null) { |
| | | out.print(JsonUtil.loadFalseAdmin("链接解析失败")); |
| | | return; |
| | | } |
| | | bilibiliVideoService.addToInternetSearch(bilibiliVideo, type); |
| | | out.print(JsonUtil.loadTrueAdmin("")); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseAdmin(e.getMessage())); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | |
| | | @RequestMapping(value = "/addMedia", method = RequestMethod.POST) |
| | | public void addMedia(String url, PrintWriter out) { |
| | | try { |
| | | BilibiliMediaInfo mediaInfo = BilibiliApiUtil.parseMediaInfo(url); |
| | | if (mediaInfo == null) { |
| | | out.print(JsonUtil.loadFalseAdmin("链接解析失败")); |
| | | return; |
| | | } |
| | | bilibiliVideoService.addToInternetSearch(mediaInfo); |
| | | out.print(JsonUtil.loadTrueAdmin("")); |
| | | } catch (Exception e) { |
| | | out.print(JsonUtil.loadFalseAdmin(e.getMessage())); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import com.yeshi.buwan.util.log.LoggerUtil; |
| | | import com.yeshi.buwan.util.log.UserActiveLogFactory; |
| | | import com.yeshi.buwan.util.log.VideoLogFactory; |
| | | import com.yeshi.buwan.videos.bilibili.BilibiliUtil; |
| | | import com.yeshi.buwan.vo.AcceptData; |
| | | import com.yeshi.buwan.vo.video.VideoDetailVO; |
| | | import com.yeshi.buwan.youku.YouKuUtil; |
| | |
| | | private TencentVideoUtil tencentVideoUtil; |
| | | |
| | | @Resource |
| | | private BilibiliUtil bilibiliUtil; |
| | | |
| | | @Resource |
| | | private VideoPlayStatisticManager videoPlayStatisticManager; |
| | | |
| | | |
| | |
| | | out.print(JsonUtil.loadFalseAdmin(e.getMessage())); |
| | | return; |
| | | } |
| | | }else if (Integer.parseInt(resourceId) == BilibiliUtil.RESOURCE_ID) { |
| | | try { |
| | | info = bilibiliUtil.getVideoInfo(internetSearchVideo, pageSize); |
| | | } catch (Exception e) { |
| | | logger.error("全网搜视频详情出错:" + videoId); |
| | | out.print(JsonUtil.loadFalseAdmin(e.getMessage())); |
| | | return; |
| | | } |
| | | } |
| | | |
| | | if (info != null) |
| | |
| | | list.addAll(list1); |
| | | } |
| | | |
| | | Set<String> set = new HashSet<>(); |
| | | |
| | | if (list != null) { |
| | | for (String st : list) { |
| | | set.add(st); |
| | | } |
| | | list.clear(); |
| | | list.addAll(set); |
| | | } |
| | | |
| | | //按关键词的匹配度排序 |
| | | Comparator<String> cm = new Comparator<String>() { |
| | | @Override |
| | |
| | | public List<BilibiliEpInfo> listByMediaId(Long mediaId, int start, int count) { |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("mediaId").is(mediaId)); |
| | | query.with(new Sort(new Sort.Order(Sort.Direction.ASC, "pub_time"))); |
| | | query.with(new Sort(new Sort.Order(Sort.Direction.ASC, "_id"))); |
| | | query.skip(start); |
| | | query.limit(count); |
| | | return findList(query); |
| | |
| | | update.set("updateTime", new Date()); |
| | | update(query, update); |
| | | } |
| | | |
| | | |
| | | public BilibiliSearchVideoMap selectByVideoId(String videoId) { |
| | | return get(videoId); |
| | | } |
| | | |
| | | } |
| | |
| | | import org.springframework.data.mongodb.core.mapping.Document; |
| | | |
| | | import javax.persistence.Entity; |
| | | import java.io.Serializable; |
| | | import java.math.BigInteger; |
| | | import java.util.Date; |
| | | |
| | |
| | | * @author Administrator |
| | | */ |
| | | @Document(collection = "systemConfig") |
| | | public class SystemConfig { |
| | | public class SystemConfig implements Serializable { |
| | | @Id |
| | | private String id; |
| | | private String name; |
| | |
| | | |
| | | private String desc; |
| | | |
| | | private String types; |
| | | |
| | | private String score; |
| | | |
| | | public String getScore() { |
| | | return score; |
| | | } |
| | | |
| | | public void setScore(String score) { |
| | | this.score = score; |
| | | } |
| | | |
| | | public String getTypes() { |
| | | return types; |
| | | } |
| | | |
| | | public void setTypes(String types) { |
| | | this.types = types; |
| | | } |
| | | |
| | | public Date getSolrTime() { |
| | | return solrTime; |
| | | } |
| | |
| | | if (sql.endsWith("UNION ALL")) |
| | | sql = sql.substring(0, sql.length() - 9); |
| | | |
| | | if (StringUtil.isNullOrEmpty(sql)) { |
| | | return list; |
| | | } |
| | | |
| | | try { |
| | | List rlist = session.createSQLQuery(sql).list(); |
| | | for (int i = 0; i < rlist.size(); i++) { |
| | |
| | | import com.yeshi.buwan.dao.juhe.bilibili.BilibiliSearchVideoMapDao; |
| | | import com.yeshi.buwan.dao.juhe.bilibili.BilibiliVideoDao; |
| | | import com.yeshi.buwan.domain.VideoDetailInfo; |
| | | import com.yeshi.buwan.domain.video.InternetSearchVideo; |
| | | import com.yeshi.buwan.service.inter.juhe.BilibiliVideoService; |
| | | import com.yeshi.buwan.service.inter.juhe.InternetSearchVideoService; |
| | | import com.yeshi.buwan.tencent.entity.TencentSearchVideoMap; |
| | | import com.yeshi.buwan.util.factory.InternetSearchVideoFactory; |
| | | import com.yeshi.buwan.videos.bilibili.BilibiliUtil; |
| | | import com.yeshi.buwan.videos.bilibili.entity.BilibiliEpInfo; |
| | | import com.yeshi.buwan.videos.bilibili.entity.BilibiliMediaInfo; |
| | | import com.yeshi.buwan.videos.bilibili.entity.BilibiliSearchVideoMap; |
| | | import com.yeshi.buwan.videos.bilibili.entity.BilibiliVideo; |
| | | import org.springframework.data.mongodb.core.query.Criteria; |
| | | import org.springframework.data.mongodb.core.query.Query; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | |
| | | private BilibiliVideoDao bilibiliVideoDao; |
| | | @Resource |
| | | private BilibiliSearchVideoMapDao bilibiliSearchVideoMapDao; |
| | | @Resource |
| | | private InternetSearchVideoService internetSearchVideoService; |
| | | |
| | | |
| | | @Override |
| | |
| | | bilibiliMediaInfoDao.save(mediaInfo); |
| | | |
| | | if (mediaInfo.getEpList() != null) { |
| | | int orderBy = 0; |
| | | for (BilibiliEpInfo ep : mediaInfo.getEpList()) { |
| | | ep.setMediaId(mediaInfo.getMedia_id()); |
| | | ep.setOrderBy(++orderBy); |
| | | if (ep.getCreateTime() == null) |
| | | ep.setCreateTime(new Date()); |
| | | bilibiliEpInfoDao.save(ep); |
| | |
| | | |
| | | @Override |
| | | public BilibiliMediaInfo getSimpleMediaDetail(Long mediaId) { |
| | | BilibiliMediaInfo mediaInfo = bilibiliMediaInfoDao.get(mediaId); |
| | | return mediaInfo; |
| | | Query query = new Query(); |
| | | query.addCriteria(Criteria.where("_id").is(mediaId)); |
| | | return bilibiliMediaInfoDao.findOne(query); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | @Override |
| | | public List<VideoDetailInfo> getVideoDetailList(String videoid, int page, int pageSize) { |
| | | BilibiliSearchVideoMap map = selectMapByVideoId(videoid); |
| | | if (map == null) |
| | | return null; |
| | | |
| | | if (map.getMediaId() != null) { |
| | | BilibiliMediaInfo bilibiliMediaInfo = bilibiliMediaInfoDao.get(map.getMediaId()); |
| | | List<BilibiliEpInfo> bilibiliEpInfos = bilibiliEpInfoDao.listByMediaId(map.getMediaId(), (page - 1) * pageSize, pageSize); |
| | | List<VideoDetailInfo> list = BilibiliUtil.convertToDetail(bilibiliEpInfos, bilibiliMediaInfo); |
| | | return list; |
| | | } else if (map.getVid() != null) { |
| | | BilibiliVideo video = bilibiliVideoDao.get(map.getVid()); |
| | | VideoDetailInfo detailInfo = BilibiliUtil.convertToDetail(video); |
| | | if (detailInfo == null) |
| | | return null; |
| | | List<VideoDetailInfo> detailInfoList = new ArrayList<>(); |
| | | detailInfoList.add(detailInfo); |
| | | return detailInfoList; |
| | | } |
| | | |
| | | |
| | | return null; |
| | | } |
| | | |
| | | @Override |
| | | public BilibiliSearchVideoMap selectMapByVideoId(String videoId) { |
| | | return null; |
| | | return bilibiliSearchVideoMapDao.selectByVideoId(videoId); |
| | | } |
| | | |
| | | @Override |
| | | public void addToInternetSearch(BilibiliMediaInfo mediaInfo) throws Exception { |
| | | |
| | | if (mediaInfo == null) |
| | | return; |
| | | save(mediaInfo); |
| | | InternetSearchVideo video = InternetSearchVideoFactory.create(mediaInfo); |
| | | if (internetSearchVideoService.save(video) == null) { |
| | | return; |
| | | } |
| | | BilibiliSearchVideoMap map = new BilibiliSearchVideoMap(); |
| | | map.setMediaId(mediaInfo.getMedia_id()); |
| | | map.setVideoId(video.getId()); |
| | | map.setCreateTime(new Date()); |
| | | bilibiliSearchVideoMapDao.save(map); |
| | | } |
| | | |
| | | @Override |
| | | public void addToInternetSearch(BilibiliVideo video) throws Exception { |
| | | |
| | | public void addToInternetSearch(BilibiliVideo video, Integer videoType) throws Exception { |
| | | save(video); |
| | | InternetSearchVideo internetSearchVideo = InternetSearchVideoFactory.create(video, videoType); |
| | | if (internetSearchVideoService.save(internetSearchVideo) == null) { |
| | | return; |
| | | } |
| | | BilibiliSearchVideoMap map = new BilibiliSearchVideoMap(); |
| | | map.setVid(video.getAid() + ""); |
| | | map.setVideoId(internetSearchVideo.getId()); |
| | | map.setCreateTime(new Date()); |
| | | bilibiliSearchVideoMapDao.save(map); |
| | | } |
| | | } |
| | |
| | | } else { |
| | | internetSearchVideoDao.updateSelective(video); |
| | | } |
| | | |
| | | InternetSearchVideoMQMsg msg = new InternetSearchVideoMQMsg(); |
| | | msg.setId(video.getId()); |
| | | msg.setResourceId(resourceId); |
| | | CMQManager.getInstance().addInternetSearchVideoUpdateMsg(msg); |
| | | //小视频不加入搜索引擎 |
| | | // InternetSearchVideoMQMsg msg = new InternetSearchVideoMQMsg(); |
| | | // msg.setId(video.getId()); |
| | | // msg.setResourceId(resourceId); |
| | | // CMQManager.getInstance().addInternetSearchVideoUpdateMsg(msg); |
| | | |
| | | return video; |
| | | } |
| | |
| | | */ |
| | | public void addToInternetSearch(BilibiliMediaInfo mediaInfo) throws Exception; |
| | | |
| | | public void addToInternetSearch(BilibiliVideo video) throws Exception; |
| | | public void addToInternetSearch(BilibiliVideo video,Integer videoType) throws Exception; |
| | | |
| | | } |
| | |
| | | import com.yeshi.buwan.domain.video.InternetSearchVideo; |
| | | import com.yeshi.buwan.mogotv.entity.MogoTVClipInfo; |
| | | import com.yeshi.buwan.tencent.entity.TencentCoverInfo; |
| | | import com.yeshi.buwan.util.TimeUtil; |
| | | import com.yeshi.buwan.util.video.VideoConstant; |
| | | import com.yeshi.buwan.videos.bilibili.entity.BilibiliMediaInfo; |
| | | import com.yeshi.buwan.videos.bilibili.BilibiliUtil; |
| | | import com.yeshi.buwan.videos.bilibili.entity.BilibiliVideo; |
| | | import com.yeshi.buwan.youku.entity.YouKuShowDetail; |
| | | import org.yeshi.utils.StringUtil; |
| | | |
| | |
| | | |
| | | int videoCount = info.getTotal(); |
| | | |
| | | Date pubTime = new Date(TimeUtil.convertGernalTime(info.getPubInfo().getPub_time(), "yyyy-MM-dd HH:mm:ss")); |
| | | |
| | | InternetSearchVideo video = new InternetSearchVideo(); |
| | | video.setActors(""); |
| | | video.setArea(""); |
| | | |
| | | |
| | | video.setDirector(""); |
| | | video.setHpicture(null); |
| | | video.setVpicture(info.getCover()); |
| | | video.setName(info.getTitle()); |
| | | video.setNameStr(info.getTitle()); |
| | | // video.setResourceIds(BilibiliUtil.RESOURCE_ID + ""); |
| | | // if (info.getType_name().equalsIgnoreCase("电影")) { |
| | | // video.setRootType(VideoConstant.VIDEO_CATEGORY_DIANYING); |
| | | // } else if (info.getType_name().equalsIgnoreCase("电视剧")) { |
| | | // video.setRootType(VideoConstant.VIDEO_CATEGORY_DIANSHIJU); |
| | | // } else if (info.getType_name().equalsIgnoreCase("动漫")) { |
| | | // video.setRootType(VideoConstant.VIDEO_CATEGORY_DONGMAN); |
| | | // } else if (info.getType_name().equalsIgnoreCase("综艺")) { |
| | | // video.setRootType(VideoConstant.VIDEO_CATEGORY_ZONGYI); |
| | | // } |
| | | // if (info.getType_name().equalsIgnoreCase("电影")) { |
| | | // video.setTag("评分:" + info.getScore().getScore()); |
| | | // } else |
| | | // video.setTag(info.getEpisode_updated()); |
| | | // video.setUpdateTime(new Date()); |
| | | // video.setVideoCount(videoCount); |
| | | // video.setYear(info.getYear()); |
| | | video.setResourceIds(BilibiliUtil.RESOURCE_ID + ""); |
| | | if (info.getType() == BilibiliUtil.TYPE_DIANYING) { |
| | | video.setRootType(VideoConstant.VIDEO_CATEGORY_DIANYING); |
| | | video.setTag("评分:" + info.getMediaRating().getScore()); |
| | | } else if (info.getType() == BilibiliUtil.TYPE_DIANSHIJU) { |
| | | video.setRootType(VideoConstant.VIDEO_CATEGORY_DIANSHIJU); |
| | | if (info.getNewestEp().getDesc().contains("已完结")) { |
| | | video.setTag(info.getNewestEp().getTitle() + "集全"); |
| | | } else { |
| | | video.setTag("更新至" + info.getNewestEp().getTitle() + "集"); |
| | | } |
| | | } else if (info.getType() == BilibiliUtil.TYPE_GUOMAN || info.getType() == BilibiliUtil.TYPE_FANJU) { |
| | | video.setRootType(VideoConstant.VIDEO_CATEGORY_DONGMAN); |
| | | if (info.getNewestEp().getDesc().contains("已完结")) { |
| | | video.setTag(info.getNewestEp().getTitle() + "集全"); |
| | | } else { |
| | | video.setTag("更新至" + info.getNewestEp().getTitle() + "集"); |
| | | } |
| | | } else if (info.getType() == BilibiliUtil.TYPE_JILUPIAN) { |
| | | video.setRootType(VideoConstant.VIDEO_CATEGORY_JILUPIAN); |
| | | if (info.getNewestEp().getDesc().contains("已完结")) { |
| | | video.setTag(info.getNewestEp().getTitle() + "集全"); |
| | | } else { |
| | | video.setTag("更新至" + info.getNewestEp().getTitle() + "集"); |
| | | } |
| | | } |
| | | video.setUpdateTime(new Date()); |
| | | video.setVideoCount(videoCount); |
| | | video.setYear(TimeUtil.getGernalTime(pubTime.getTime(), "yyyy")); |
| | | video.setId(InternetSearchVideo.createId(video.getName(), video.getRootType(), video.getYear())); |
| | | if (info.getMediaRating() != null) |
| | | video.setScore(info.getMediaRating().getScore()); |
| | | return video; |
| | | } |
| | | |
| | | |
| | | public static InternetSearchVideo create(BilibiliVideo info, Integer videoType) { |
| | | int videoCount = 1; |
| | | Date pubTime = new Date(info.getPubdate()); |
| | | InternetSearchVideo video = new InternetSearchVideo(); |
| | | video.setActors(null); |
| | | video.setArea(null); |
| | | video.setDirector(null); |
| | | video.setHpicture(null); |
| | | video.setVpicture(info.getPic()); |
| | | video.setName(info.getTitle()); |
| | | video.setNameStr(info.getTitle()); |
| | | video.setResourceIds(BilibiliUtil.RESOURCE_ID + ""); |
| | | video.setTag(""); |
| | | video.setRootType(videoType); |
| | | video.setUpdateTime(new Date()); |
| | | video.setVideoCount(videoCount); |
| | | video.setYear(TimeUtil.getGernalTime(pubTime.getTime(), "yyyy")); |
| | | video.setId(InternetSearchVideo.createId(video.getName(), video.getRootType(), video.getYear())); |
| | | return video; |
| | | } |
| | |
| | | public class VideoConstant { |
| | | |
| | | |
| | | public final static List<String> iqiyiSpecialNames = Arrays.asList(new String[]{ |
| | | //不参与过滤的词 |
| | | "《卧底》","没关系,是青春啊!","山海情(原声版)","我的时代,你的时代","你好,安怡" |
| | | }); |
| | | |
| | | |
| | | public final static int VIDEO_CATEGORY_DIANYING = 151; |
| | | public final static int VIDEO_CATEGORY_DIANSHIJU = 150; |
| | | public final static int VIDEO_CATEGORY_DONGMAN = 153; |
| | | public final static int VIDEO_CATEGORY_ZONGYI = 152; |
| | | public final static int VIDEO_CATEGORY_JILUPIAN = 313; |
| | | |
| | | /** |
| | | * 是否为主要分类 |
| | |
| | | return true; |
| | | if (id == VIDEO_CATEGORY_ZONGYI) |
| | | return true; |
| | | if (id == VIDEO_CATEGORY_JILUPIAN) |
| | | return true; |
| | | return false; |
| | | } |
| | | |
| | |
| | | return "动漫"; |
| | | if (id == VIDEO_CATEGORY_ZONGYI) |
| | | return "综艺"; |
| | | if (id == VIDEO_CATEGORY_JILUPIAN) |
| | | return "纪录片"; |
| | | return ""; |
| | | } |
| | | |
| | |
| | | import com.yeshi.buwan.tencent.TencentVideoUtil; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.log.VideoLogFactory; |
| | | import com.yeshi.buwan.videos.bilibili.BilibiliUtil; |
| | | import com.yeshi.buwan.vo.AcceptData; |
| | | import com.yeshi.buwan.youku.YouKuUtil; |
| | | import org.hibernate.HibernateException; |
| | |
| | | |
| | | @Resource |
| | | private TencentVideoUtil tencentVideoUtil; |
| | | |
| | | @Resource |
| | | private BilibiliVideoService bilibiliVideoService; |
| | | |
| | | @Resource |
| | | private BilibiliUtil bilibiliUtil; |
| | | |
| | | @SuppressWarnings("unchecked") |
| | | // @Cacheable(value = "homeCache", key = "'getVideoInfo'+'-'+#videoid+'-'+#resourceId+'-'+#cacheMD5") |
| | |
| | | return mogoTVService.getVideoDetailList(videoid, page, pageSize); |
| | | case TencentVideoUtil.RESOURCE_ID: |
| | | return tencentVideoService.getVideoDetailList(videoid, page, pageSize); |
| | | case BilibiliUtil.RESOURCE_ID: |
| | | return bilibiliVideoService.getVideoDetailList(videoid, page, pageSize); |
| | | default: |
| | | return null; |
| | | } |
| | |
| | | return mogoTVUtil.getPlayUrl(detailSystemId, id, type, resourceid, videoid); |
| | | case TencentVideoUtil.RESOURCE_ID: |
| | | return tencentVideoUtil.getPlayUrl(detailSystemId, id, type, resourceid, videoid); |
| | | case BilibiliUtil.RESOURCE_ID: |
| | | return bilibiliUtil.getPlayUrl(detailSystemId, id, type, resourceid, videoid); |
| | | default: |
| | | return null; |
| | | } |
| | |
| | | package com.yeshi.buwan.videos.bilibili; |
| | | |
| | | import com.google.gson.Gson; |
| | | import com.yeshi.buwan.util.HttpUtil; |
| | | import com.yeshi.buwan.videos.bilibili.entity.BilibiliMediaInfo; |
| | | import com.yeshi.buwan.videos.bilibili.entity.BilibiliVideo; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | import org.jsoup.Jsoup; |
| | | import org.jsoup.nodes.Document; |
| | |
| | | import javax.script.ScriptEngineManager; |
| | | import javax.script.ScriptException; |
| | | import java.io.IOException; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | public class BilibiliApiUtil { |
| | | |
| | |
| | | JSONObject root = JSONObject.fromObject(result); |
| | | BilibiliMediaInfo mediaInfo = parseMedia(root); |
| | | return mediaInfo; |
| | | } |
| | | |
| | | /** |
| | | * @param type |
| | | * @param order 2-追番人数 |
| | | * @param page 0-最近更新 |
| | | * @return |
| | | */ |
| | | public static MediaUrlResult getMediaList(int type, int order, int page) { |
| | | String url = String.format("https://api.bilibili.com/pgc/season/index/result?style_id=-1&producer_id=-1&release_date=-1&season_status=-1&order=%s&st=%s&sort=0&page=%s&season_type=%s&pagesize=20&type=1", order, type, page, type); |
| | | String result = HttpUtil.get(url); |
| | | JSONObject resultJSON = JSONObject.fromObject(result); |
| | | if (resultJSON.optInt("code") == 0) { |
| | | JSONObject data = resultJSON.optJSONObject("data"); |
| | | int total = data.optInt("total"); |
| | | JSONArray list = data.optJSONArray("list"); |
| | | List<String> urlList = new ArrayList<>(); |
| | | for (int i = 0; i < list.size(); i++) { |
| | | JSONObject item = list.optJSONObject(i); |
| | | urlList.add(item.optString("link")); |
| | | } |
| | | return new MediaUrlResult(total, urlList); |
| | | } |
| | | return null; |
| | | } |
| | | |
| | | |
| | |
| | | mediaJson.put("mediaRating", root.optJSONObject("mediaRating")); |
| | | mediaJson.put("newestEp", root.optJSONObject("newestEp")); |
| | | mediaJson.put("epList", root.optJSONArray("epList")); |
| | | mediaJson.put("pubInfo", root.optJSONObject("pubInfo")); |
| | | return new Gson().fromJson(mediaJson.toString(), BilibiliMediaInfo.class); |
| | | } |
| | | return null; |
| | |
| | | |
| | | |
| | | public static void main(String[] args) throws IOException, ScriptException, NoSuchMethodException { |
| | | MediaUrlResult result = getMediaList(BilibiliUtil.TYPE_DIANSHIJU, 2, 1); |
| | | System.out.println(result); |
| | | } |
| | | |
| | | String[] urls = new String[]{ |
| | | "https://www.bilibili.com/bangumi/play/ss38129?theme=movie&from_spmid=666.7", "https://www.bilibili.com/bangumi/play/ss38611?theme=movie&from_spmid=666.7" |
| | | }; |
| | | //3-记录片 5-电视剧 4-国漫 1-番剧 2-电影 |
| | | try { |
| | | for (String url : urls) { |
| | | BilibiliMediaInfo mediaInfo = parseMediaInfo(url); |
| | | System.out.println("type:" + mediaInfo.getType()); |
| | | public static class MediaUrlResult { |
| | | private int total; |
| | | private List<String> result; |
| | | |
| | | public MediaUrlResult(int total, List<String> result) { |
| | | this.total = total; |
| | | this.result = result; |
| | | } |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | |
| | | public int getTotal() { |
| | | return total; |
| | | } |
| | | |
| | | public void setTotal(int total) { |
| | | this.total = total; |
| | | } |
| | | |
| | | public List<String> getResult() { |
| | | return result; |
| | | } |
| | | |
| | | public void setResult(List<String> result) { |
| | | this.result = result; |
| | | } |
| | | } |
| | | |
| | | } |
| | |
| | | import com.yeshi.buwan.service.imp.VideoTypeService; |
| | | import com.yeshi.buwan.service.inter.juhe.BilibiliVideoService; |
| | | import com.yeshi.buwan.service.inter.juhe.InternetSearchVideoService; |
| | | import com.yeshi.buwan.util.StringUtil; |
| | | import com.yeshi.buwan.util.factory.VideoInfoFactory; |
| | | import com.yeshi.buwan.util.video.VideoConstant; |
| | | import com.yeshi.buwan.videos.bilibili.entity.BilibiliEpInfo; |
| | |
| | | public class BilibiliUtil { |
| | | |
| | | |
| | | //3-记录片 5-电视剧 4-国漫 1-番剧 2-电影 |
| | | |
| | | public final static int TYPE_DIANYING = 2; |
| | | public final static int TYPE_DIANSHIJU = 5; |
| | | public final static int TYPE_JILUPIAN = 3; |
| | | public final static int TYPE_GUOMAN = 4; |
| | | public final static int TYPE_FANJU = 1; |
| | | |
| | | |
| | | @Resource |
| | | private InternetSearchVideoService internetSearchVideoService; |
| | | |
| | |
| | | @Resource |
| | | private VideoTypeService videoTypeService; |
| | | |
| | | public final static int RESOURCE_ID = 17; |
| | | public final static int RESOURCE_ID = 27; |
| | | |
| | | public static VideoDetailInfo convertToDetail(BilibiliEpInfo epInfo) { |
| | | VideoDetailInfo detail = new VideoDetailInfo(); |
| | |
| | | VideoInfo info = VideoInfoFactory.create(internetSearchVideo); |
| | | info.setResourceList(resourceList); |
| | | info.setShowType(YouKuUtil.getShowType(internetSearchVideo)); |
| | | info.setPlayPicture(info.getHpicture()); |
| | | info.setPlayPicture(StringUtil.isNullOrEmpty(info.getHpicture())?info.getVpicture():info.getHpicture()); |
| | | //获取分类详情 |
| | | info.setVideoType(videoTypeService.getVideoType(info.getVideoType().getId())); |
| | | info.setCommentCount(0); |
| | |
| | | if ("ep".equalsIgnoreCase(type)) { |
| | | BilibiliEpInfo epInfo = bilibiliVideoService.selectEPInfoByPrimaryKey(Long.parseLong(id)); |
| | | if (epInfo != null) { |
| | | playUrl.setUrl(epInfo.getLink()); |
| | | playUrl.setUrl(epInfo.getLink()+"?bsource=baidu_aladdin"); |
| | | } |
| | | } else { |
| | | BilibiliVideo bilibiliVideo = bilibiliVideoService.selectVideoByPrimaryKey(Long.parseLong(id)); |
| | | playUrl.setUrl("https://www.bilibili.com/video/" + bilibiliVideo.getBvid()); |
| | | playUrl.setUrl("https://www.bilibili.com/video/" + bilibiliVideo.getBvid()+"?bsource=baidu_aladdin"); |
| | | } |
| | | |
| | | return playUrl; |
| | |
| | | private Long cid; |
| | | private String cover; |
| | | |
| | | private Integer orderBy; |
| | | |
| | | |
| | | private String link; |
| | | private String long_title; |
| | | @Indexed |
| | |
| | | private Date createTime; |
| | | private Date updateTime; |
| | | |
| | | public Integer getOrderBy() { |
| | | return orderBy; |
| | | } |
| | | |
| | | public void setOrderBy(Integer orderBy) { |
| | | this.orderBy = orderBy; |
| | | } |
| | | |
| | | public Date getCreateTime() { |
| | | return createTime; |
| | | } |
| | |
| | | * total : 24 |
| | | * type : 4 |
| | | * mediaRating : {"count":17848,"score":9.1} |
| | | * pubInfo : {"is_finish":1,"is_started":1,"pub_time":"2021-04-26 19:00:00","pub_time_show":"04月26日19:00","unknow_pub_date":0,"weekday":0} |
| | | * newestEp : {"desc":"已完结, 全24话","id":96832,"is_new":0,"title":"24"} |
| | | */ |
| | | |
| | |
| | | private Integer type; |
| | | private MediaRatingBean mediaRating; |
| | | private NewestEpBean newestEp; |
| | | private PubInfoBean pubInfo;//发布信息 |
| | | |
| | | |
| | | @Transient |
| | | private List<BilibiliEpInfo> epList; |
| | |
| | | this.newestEp = newestEp; |
| | | } |
| | | |
| | | public PubInfoBean getPubInfo() { |
| | | return pubInfo; |
| | | } |
| | | |
| | | public void setPubInfo(PubInfoBean pubInfo) { |
| | | this.pubInfo = pubInfo; |
| | | } |
| | | |
| | | public static class SeriesBean { |
| | | /** |
| | | * series_id : 2272 |
| | |
| | | this.title = title; |
| | | } |
| | | } |
| | | |
| | | public static class PubInfoBean { |
| | | /** |
| | | * is_finish : 1 |
| | | * is_started : 1 |
| | | * pub_time : 2021-04-26 19:00:00 |
| | | * pub_time_show : 04月26日19:00 |
| | | * unknow_pub_date : 0 |
| | | * weekday : 0 |
| | | */ |
| | | |
| | | private int is_finish; |
| | | private int is_started; |
| | | private String pub_time; |
| | | private String pub_time_show; |
| | | private int unknow_pub_date; |
| | | private int weekday; |
| | | |
| | | public int getIs_finish() { |
| | | return is_finish; |
| | | } |
| | | |
| | | public void setIs_finish(int is_finish) { |
| | | this.is_finish = is_finish; |
| | | } |
| | | |
| | | public int getIs_started() { |
| | | return is_started; |
| | | } |
| | | |
| | | public void setIs_started(int is_started) { |
| | | this.is_started = is_started; |
| | | } |
| | | |
| | | public String getPub_time() { |
| | | return pub_time; |
| | | } |
| | | |
| | | public void setPub_time(String pub_time) { |
| | | this.pub_time = pub_time; |
| | | } |
| | | |
| | | public String getPub_time_show() { |
| | | return pub_time_show; |
| | | } |
| | | |
| | | public void setPub_time_show(String pub_time_show) { |
| | | this.pub_time_show = pub_time_show; |
| | | } |
| | | |
| | | public int getUnknow_pub_date() { |
| | | return unknow_pub_date; |
| | | } |
| | | |
| | | public void setUnknow_pub_date(int unknow_pub_date) { |
| | | this.unknow_pub_date = unknow_pub_date; |
| | | } |
| | | |
| | | public int getWeekday() { |
| | | return weekday; |
| | | } |
| | | |
| | | public void setWeekday(int weekday) { |
| | | this.weekday = weekday; |
| | | } |
| | | } |
| | | } |
New file |
| | |
| | | <html lang="zh-cn"> |
| | | |
| | | <head> |
| | | <meta charset="utf-8"> |
| | | <meta http-equiv="X-UA-Compatible" content="IE=edge"> |
| | | <meta name="viewport" content="width=device-width, initial-scale=1"> |
| | | <meta name="referrer" content="never"> |
| | | <title>Bilibili视频更新</title> |
| | | <link href="css/bootstrap.min.css" rel="stylesheet"> |
| | | <link href="css/maincontent.css" rel="stylesheet"> |
| | | <link href="css/tablestyle.css" rel="stylesheet"> |
| | | <style> |
| | | .form-group { |
| | | margin-bottom: 30px; |
| | | } |
| | | |
| | | .checkbox input[type=checkbox] { |
| | | top: 6px; |
| | | } |
| | | |
| | | #dialog-chooselink select { |
| | | width: 100px; |
| | | } |
| | | |
| | | #dialog-chooselink label { |
| | | display: inline; |
| | | } |
| | | |
| | | #dialog-chooselink input[type=text] { |
| | | display: inline; |
| | | width: 500px; |
| | | } |
| | | |
| | | #dialog-chooselink ul { |
| | | display: block; |
| | | list-style: none; |
| | | } |
| | | |
| | | #dialog-chooselink ul li { |
| | | display: inline; |
| | | list-style: none; |
| | | width: 33%; |
| | | float: left; |
| | | } |
| | | |
| | | #dialog-chooselink input[type=radio] { |
| | | width: 20px; |
| | | height: 20px; |
| | | } |
| | | |
| | | #dialog-chooselink .search-result { |
| | | height: 630px; |
| | | overflow-y: scroll; |
| | | } |
| | | |
| | | .form-group { |
| | | display: flex; |
| | | } |
| | | </style> |
| | | </head> |
| | | |
| | | <body> |
| | | <nav class="navbar navbar-default navbar-fixed-top"></nav> |
| | | <div id="mainbody"> |
| | | <div id="sidebar"> |
| | | <dl> |
| | | </dl> |
| | | </div> |
| | | <div id="neirong"> |
| | | <div class="erjidh"> |
| | | <ol class="breadcrumb"> |
| | | <li><a href="tuijian-lanmuneirong.html">设置</a></li> |
| | | <li class="active">Bilibili视频更新</li> |
| | | </ol> |
| | | </div> |
| | | <form class="form-horizontal" |
| | | style="width: 800px; margin-top: 10px; border-style: solid; border-width: 2px; padding: 10px;"> |
| | | |
| | | <h4>长视频更新</h4> |
| | | |
| | | <div class="form-group"> |
| | | <label class="changdu1 control-label">Bilibili播放链接</label> |
| | | <div class="col-sm-7"> |
| | | <input type="text" class="form-control" id="mediaUrl" |
| | | placeholder="bilibili播放链接"> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="button0"> |
| | | <div class="button"> |
| | | <button type="button" class="btn btn-primary addMedia">添加</button> |
| | | </div> |
| | | <div class="button"> |
| | | <input type="reset" class="btn btn-default" value="重置"/> |
| | | </div> |
| | | </div> |
| | | </form> |
| | | |
| | | |
| | | <div |
| | | style="width: 800px; margin-top: 100px; border-style: solid; border-width: 2px; padding: 10px;"> |
| | | <h4>短视频更新</h4> |
| | | |
| | | <div class="form-group"> |
| | | <label class="changdu1 control-label">选择分类</label> |
| | | <div class="col-sm-7"> |
| | | <select id="clazz"> |
| | | |
| | | </select> |
| | | </div> |
| | | </div> |
| | | |
| | | |
| | | <div class="form-group"> |
| | | <label class="changdu1 control-label">Bilibili播放链接</label> |
| | | <div class="col-sm-7"> |
| | | <input type="text" class="form-control" id="videoUrl" |
| | | placeholder="bilibili播放链接"> |
| | | </div> |
| | | </div> |
| | | |
| | | <div class="button0"> |
| | | <div class="button"> |
| | | <button type="button" class="btn btn-primary addVideo">添加</button> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | </div> |
| | | |
| | | <script src="//cdn.bootcss.com/jquery/1.10.1/jquery.min.js"></script> |
| | | <script src="js/bootstrap.min.js"></script> |
| | | <script src="js/nav.js"></script> |
| | | <script src="js/common.js"></script> |
| | | <script src="layer/layer.js"></script> |
| | | <script> |
| | | $(function () { |
| | | //获取正在上线的版本 |
| | | $.post('/BuWan/admin/new/api/class/getnextclass', {pid: 0}, function (data) { |
| | | if (data.code == 0) { |
| | | $("#clazz").empty(); |
| | | for (var i = 0; i < data.data.length; i++) { |
| | | $("#clazz").append("<option value=" + data.data[i].id + ">" + data.data[i].name + "</option>"); |
| | | } |
| | | } |
| | | }, 'json'); |
| | | |
| | | //设置版本 |
| | | $(".addMedia").click( |
| | | function () { |
| | | if ($("#mediaUrl").val() == '' |
| | | || $("#mediaUrl").val().length <= 0) |
| | | return; |
| | | |
| | | $.post('/BuWan/admin/new/api/bilibili/addMedia', { |
| | | url: $("#mediaUrl").val() |
| | | }, function (data) { |
| | | if (data.code == 0) { |
| | | alert("更新成功") |
| | | } else { |
| | | alert(data.msg) |
| | | } |
| | | }, 'json'); |
| | | }); |
| | | |
| | | //设置版本上线 |
| | | $(".addVideo").click( |
| | | function () { |
| | | if ($("#videoUrl").val() == '' |
| | | || $("#videoUrl").val().length <= 0) |
| | | return; |
| | | |
| | | $.post('/BuWan/admin/new/api/bilibili/addVideo', { |
| | | url: $("#videoUrl").val(), |
| | | type: $("#clazz").val(), |
| | | }, function (data) { |
| | | if (data.code == 0) { |
| | | alert("添加成功") |
| | | } else { |
| | | alert(data.msg) |
| | | } |
| | | }, 'json'); |
| | | }); |
| | | }); |
| | | </script> |
| | | |
| | | </body> |
| | | |
| | | </html> |
| | |
| | | <url></url> |
| | | </secondNav> |
| | | |
| | | <secondNav url="add-bilibili-video.html" name="B站视频更新"> |
| | | <!-- 网页链接 --> |
| | | <url></url> |
| | | </secondNav> |
| | | |
| | | <secondNav url="ad-update.html" name="广告设置"> |
| | | <!-- 网页链接 --> |
| | | <url></url> |
| | |
| | | @Test |
| | | public void videoPlay() throws Exception { |
| | | Set<String> sets = new HashSet<>(); |
| | | Set<String> totalSets = new HashSet<>(); |
| | | Gson gson = new Gson(); |
| | | Scanner scanner = new Scanner(new FileInputStream("C:\\Users\\Administrator\\Desktop\\日志\\布丸播放\\play_2021_04_07.log")); |
| | | Scanner scanner = new Scanner(new FileInputStream("D:\\文件传输\\日志\\2021_04_27.log")); |
| | | Map<String, Integer> countMap = new HashMap<>(); |
| | | List<String> videoList = new ArrayList<>(); |
| | | int ppcount = 0; |
| | | int count = 0; |
| | | while (scanner.hasNextLine()) { |
| | | count++; |
| | | String text = scanner.nextLine(); |
| | | UserVideoPlayLogInfo logInfo = gson.fromJson(text, UserVideoPlayLogInfo.class); |
| | | if ("25".equalsIgnoreCase(logInfo.getResourceId())) |
| | | totalSets.add(logInfo.getUtdId()); |
| | | if ("25".equalsIgnoreCase(logInfo.getResourceId())) { |
| | | sets.add(logInfo.getUtdId()); |
| | | ppcount++; |
| | | } |
| | | if (countMap.get(logInfo.getUtdId()) == null) { |
| | | countMap.put(logInfo.getUtdId(), 0); |
| | | } |
| | |
| | | countMap.put(logInfo.getUtdId(), countMap.get(logInfo.getUtdId()) + 1); |
| | | System.out.println(logInfo); |
| | | } |
| | | System.out.println(sets.size()); |
| | | System.out.println("播放UV总数为:" + totalSets.size()); |
| | | System.out.println("PPTV UV播放总数为:" + sets.size()); |
| | | System.out.println("PPTV UV比例:" + new BigDecimal(sets.size()).divide(new BigDecimal(totalSets.size()), 2, RoundingMode.FLOOR)); |
| | | |
| | | System.out.println("播放总数为:" + count); |
| | | System.out.println("PPTV 播放总数为:" + ppcount); |
| | | System.out.println("PPTV 比例:" + new BigDecimal(ppcount).divide(new BigDecimal(count), 2, RoundingMode.FLOOR)); |
| | | |
| | | scanner.close(); |
| | | |
| | | for (String st : videoList) { |
| | |
| | | @Test |
| | | public void userActive() throws Exception { |
| | | Gson gson = new Gson(); |
| | | List<String> list = loadLog("C:\\Users\\Administrator\\Desktop\\日志\\布丸播放\\active_2021_04_07.log"); |
| | | List<String> list = loadLog("D:\\文件传输\\日志\\active_2021_04_27.log"); |
| | | Map<String, List<UserActiveLogInfo>> map = new HashMap<>(); |
| | | for (String st : list) { |
| | | UserActiveLogInfo activeLogInfo = gson.fromJson(st, UserActiveLogInfo.class); |
| | |
| | | |
| | | @Test |
| | | public void addInternet() { |
| | | InternetSearchVideo list = internetSearchVideoService.selectByPrimaryKey("9693a5f3de443fe48a5272ce12c859f3"); //listAll(1, 10); |
| | | InternetSearchVideo list = internetSearchVideoService.selectByPrimaryKey("38ac0127d0cc3433e09964e757ab3505"); //listAll(1, 10); |
| | | solrInternetSearchVideoDataManager.saveOrUpdate(list); |
| | | } |
| | | |
New file |
| | |
| | | package com.hxh.spring.test.video; |
| | | |
| | | |
| | | import com.yeshi.buwan.job.video.MogoTVVideoUpdate; |
| | | import com.yeshi.buwan.mogotv.entity.MogoTVClipInfo; |
| | | import com.yeshi.buwan.service.inter.juhe.BilibiliVideoService; |
| | | import com.yeshi.buwan.service.inter.juhe.InternetSearchVideoService; |
| | | import com.yeshi.buwan.service.inter.juhe.MogoTVService; |
| | | import com.yeshi.buwan.service.manager.SolrInternetSearchVideoDataManager; |
| | | import com.yeshi.buwan.videos.bilibili.BilibiliApiUtil; |
| | | import com.yeshi.buwan.videos.bilibili.BilibiliUtil; |
| | | import com.yeshi.buwan.videos.bilibili.entity.BilibiliMediaInfo; |
| | | 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.util.List; |
| | | |
| | | // |
| | | @RunWith(SpringJUnit4ClassRunner.class) //使用junit4进行测试 |
| | | @ContextConfiguration(locations = {"classpath:spring.xml"}) |
| | | @WebAppConfiguration |
| | | public class BilibiliTest { |
| | | |
| | | @Resource |
| | | private BilibiliVideoService bilibiliVideoService; |
| | | |
| | | |
| | | @Resource |
| | | private InternetSearchVideoService internetSearchVideoService; |
| | | |
| | | @Resource |
| | | private SolrInternetSearchVideoDataManager solrInternetSearchVideoDataManager; |
| | | |
| | | |
| | | @Test |
| | | public void test2() throws Exception { |
| | | BilibiliApiUtil.MediaUrlResult result = BilibiliApiUtil.getMediaList(BilibiliUtil.TYPE_DIANSHIJU, 2, 1); |
| | | int page = result.getTotal() % 20 == 0 ? result.getTotal() / 20 : result.getTotal() / 20 + 1; |
| | | for (int i = 0; i < page; i++) { |
| | | System.out.println("page:"+i); |
| | | result = BilibiliApiUtil.getMediaList(BilibiliUtil.TYPE_DIANSHIJU, 2, i + 1); |
| | | if (result.getResult() != null) |
| | | for (String url : result.getResult()) { |
| | | try { |
| | | BilibiliMediaInfo mediaInfo = BilibiliApiUtil.parseMediaInfo(url); |
| | | bilibiliVideoService.addToInternetSearch(mediaInfo); |
| | | Thread.sleep(200); |
| | | } catch (Exception e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | } |
| | | |
| | | @Test |
| | | public void addToSearch() throws Exception { |
| | | BilibiliMediaInfo mediaInfo = bilibiliVideoService.getSimpleMediaDetail(28223059L); |
| | | bilibiliVideoService.addToInternetSearch(mediaInfo); |
| | | |
| | | |
| | | // |
| | | // for (MogoTVClipInfo info : list) { |
| | | // try { |
| | | // bilibiliVideoService.addToInternetSearch(info); |
| | | // } catch (Exception e) { |
| | | // e.printStackTrace(); |
| | | // } |
| | | // } |
| | | } |
| | | |
| | | |
| | | } |