admin
2021-09-24 f788607ff771a47bc60d6a86e00b3433c40f3d2c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
package com.yeshi.buwan.util.factory;
 
import com.yeshi.buwan.domain.solr.SolrShortVideo;
import com.yeshi.buwan.videos.iqiyi.entity.IqiyiAlbum2;
import com.yeshi.buwan.videos.iqiyi.util.IqiyiUtil2;
import com.yeshi.buwan.videos.tencent.TencentVideoUtil;
import com.yeshi.buwan.util.TimeUtil;
import com.yeshi.buwan.util.video.web.TencentWebUtil;
 
public class SolrShortVideoFactory {
 
    /**
     * @param tencentWebVideoInfo
     * @param area
     * @param rootVideoType
     * @return
     */
    public static SolrShortVideo create(TencentWebUtil.TencentWebVideoInfo tencentWebVideoInfo, String area, int rootVideoType) {
        SolrShortVideo solrShortVideo = new SolrShortVideo();
        solrShortVideo.setArea(area);
        solrShortVideo.setDuration(tencentWebVideoInfo.getDuration());
        solrShortVideo.setId(SolrShortVideo.createId(TencentVideoUtil.RESOURCE_ID, tencentWebVideoInfo.getPlayUrl()));
        solrShortVideo.setName(tencentWebVideoInfo.getTitle());
        solrShortVideo.setNameStr(tencentWebVideoInfo.getTitle());
        solrShortVideo.setPicture(tencentWebVideoInfo.getPicture());
        solrShortVideo.setResourceId(TencentVideoUtil.RESOURCE_ID);
        solrShortVideo.setRootVideoType(rootVideoType);
        solrShortVideo.setThirdUpdateTime(System.currentTimeMillis());
        solrShortVideo.setPlayUrl(tencentWebVideoInfo.getPlayUrl());
        return solrShortVideo;
    }
 
    public static SolrShortVideo create(IqiyiAlbum2 album, int rootVideoType) {
        int h = album.getDuration() / (60 * 60);
        int m = (album.getDuration() - h * 3600) / 60;
        int s = album.getDuration() % 60;
        String duration = "";
        if (h > 0) {
            duration += (h > 9 ? h + "" : "0" + h);
        }
 
        if (duration.length() > 0) {
            duration += ":";
        }
        duration += (m > 9 ? m + "" : "0" + m);
        duration += ":";
        duration += (s > 9 ? s + "" : "0" + s);
 
        SolrShortVideo solrShortVideo = new SolrShortVideo();
        solrShortVideo.setArea(album.getAreas());
        solrShortVideo.setDuration(duration);
        solrShortVideo.setId(SolrShortVideo.createId(IqiyiUtil2.RESOURCE_ID, album.getUrl()));
        solrShortVideo.setPlayUrl(album.getUrl());
        solrShortVideo.setName(album.getName());
        solrShortVideo.setNameStr(album.getName());
        solrShortVideo.setPicture(album.getImageUrl().replace(".jpg", "_480_270.jpg"));
        solrShortVideo.setResourceId(IqiyiUtil2.RESOURCE_ID);
        solrShortVideo.setRootVideoType(rootVideoType);
        solrShortVideo.setTag(album.getThreeCategoryNames());
        solrShortVideo.setThirdUpdateTime(TimeUtil.convertGernalTime(album.getUpdateTime(), "yyyy-MM-dd HH:mm:dd"));
        return solrShortVideo;
    }
 
 
}