admin
2020-10-10 81db7b3b070c003e6f5f0d1c757ab30b6f42c944
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
package com.yeshi.buwan.sohu;
 
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
 
import javax.annotation.Resource;
 
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.springframework.orm.hibernate4.HibernateCallback;
import org.springframework.stereotype.Component;
 
import com.yeshi.buwan.dao.VideoResourceDao;
import com.yeshi.buwan.dao.juhe.sohu.SoHuVideoDao;
import com.yeshi.buwan.domain.AdminInfo;
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.service.imp.juhe.SoHuService;
import com.yeshi.buwan.sohu.entity.RootCategory;
import com.yeshi.buwan.sohu.entity.SecondCategory;
import com.yeshi.buwan.sohu.entity.SoHuAlbum;
import com.yeshi.buwan.sohu.entity.SoHuVideo;
import com.yeshi.buwan.sohu.entity.SohuVideoContent;
import com.yeshi.buwan.util.JuheVideoUtil;
import com.yeshi.buwan.util.StringUtil;
import com.yeshi.buwan.util.TimeUtil;
 
import net.sf.json.JSONObject;
 
@Component
public class SoHuUtil {
 
 
    public final static int RESOURCE_ID = 14;
    public final static String RESOURCE_NAME = "搜狐";
 
    static Logger logger = Logger.getLogger(SoHuUtil.class);
    @Resource
    private SoHuService soHuService;
    @Resource
    private SoHuVideoDao soHuVideoDao;
    @Resource
    private VideoResourceDao videoResourceDao;
 
    public SoHuVideoDao getSoHuVideoDao() {
        return soHuVideoDao;
    }
 
    public void setSoHuVideoDao(SoHuVideoDao soHuVideoDao) {
        this.soHuVideoDao = soHuVideoDao;
    }
 
    public SoHuService getSoHuService() {
        return soHuService;
    }
 
    public void setSoHuService(SoHuService soHuService) {
        this.soHuService = soHuService;
    }
 
    public static List<RootCategory> getCategory() {
        List<RootCategory> list = SoHuApi.rootCategoryList();
        RootCategory rcg = new RootCategory();
        rcg.setCateId(9004);
        rcg.setCateName("搜狐出品");
        list.add(rcg);
        for (RootCategory rc : list) {
            System.out.println(
                    "主分类:break;//" + rc.getCateId() + ":break;//" + ":break;//" + rc.getCateCode() + rc.getCateName());
            List<SecondCategory> sList = SoHuApi.secondCategoryList(rc.getCateId());
            if (sList != null)
                for (SecondCategory sc : sList)
                    System.out.println("  case " + sc.getSecondCateCode() + ":break;//" + sc.getSecondCateName());
            rc.setScList(sList);
        }
        return list;
    }
 
    public static List<Integer> getSecondCategory(int scode) {
        List<Integer> list = new ArrayList<Integer>();
 
        switch (scode) {
        // 电视剧
 
        case 101100:
            // type=;
            // 偶像剧
 
        case 101101:
            // 家庭剧
 
        case 101102:
            // 历史剧
 
        case 101103:
            // 年代剧
 
        case 101104:
            // 言情剧
 
        case 101105:
            // 武侠剧
 
        case 101106:
            // 古装剧
 
        case 101107:
            // 都市剧
 
        case 101108:
            // 农村剧
 
        case 101109:
            // 军旅剧
 
        case 101110:
            // 刑侦剧
 
        case 101111:
            // 喜剧
 
        case 101112:
            // 悬疑剧
 
        case 101113:
            // 情景剧
 
        case 101114:
            // 传记剧
 
        case 101115:
            // 科幻剧
 
        case 101116:
            // 动画片
 
        case 101117:
            // 动作剧
 
        case 101118:
            // 真人秀
 
        case 101119:
            // 栏目剧
 
        case 101120:
            // 谍战剧
 
        case 101121:
            // 伦理剧
 
        case 101122:
            // 战争剧
 
        case 101123:
            // 神话剧
 
        case 101124:
            // 惊悚剧
 
        case 101127:
            list.add(150);
            break;// 剧情片
 
        // 电影
        case 100100:
            // 爱情片
 
        case 100101:
            // 战争片
 
        case 100102:
            // 喜剧片
 
        case 100103:
            // 科幻片
 
        case 100104:
            // 恐怖片
 
        case 100105:
            // 动画片
 
        case 100106:
            // 动作片
 
        case 100107:
            // 风月片
 
        case 100108:
            // 剧情片
 
        case 100109:
            // 歌舞片
 
        case 100110:
            // 纪录片
 
        case 100111:
            // 魔幻片
 
        case 100112:
            // 灾难片
 
        case 100113:
            // 悬疑片
 
        case 100114:
            // 传记片
 
        case 100116:
            // 警匪片
 
        case 100117:
            // 伦理片
 
        case 100118:
            // 惊悚片
 
        case 100119:
            // 谍战片
 
        case 100120:
            // 历史片
 
        case 100121:
            // 武侠片
 
        case 100122:
            // 青春片
 
        case 100123:
            // 文艺片
 
        case 100135:
 
        case 100136:
            list.add(151);
            break;// 微电影
 
        // 综艺
        case 106100:
            break;// 访谈
        case 106116:
            break;// 综艺综合
        case 106127:
            break;// 脱口秀
        case 106126:
            break;// 其他
 
        // 动漫
 
        // 游戏
 
        case 128103:
            list.add(212);
            break;// 电子竞技
 
        case 128100:
            list.add(272);
            break;// 游戏头条
 
        case 128105:
            break;// 手游
 
        case 128108:
            list.add(272);
            break;// 集锦TOP
 
        case 128109:
            list.add(212);
 
            break;// 现场赛事
 
        case 128110:
            list.add(272);
            break;// 宣传片CG
 
        case 128111:
            list.add(272);
            break;// 真人秀
 
        case 128112:
            list.add(212);
            break;// DOTA/DOTA2
 
        case 128113:
            list.add(212);
            break;// 英雄联盟
 
        case 128114:
            list.add(212);
            break;// 我的世界
 
        case 128115:
 
            break;// 网络游戏
 
        case 128116:
 
            break;// 单机游戏
 
        case 128020:
            break;// 其他
 
        // 搞笑
        case 133100:
            // 疯狂恶搞
        case 133102:
            // 激萌动物
        case 133104:
            // 原创综合
        case 133107:
            // 搞笑综合
        case 133108:
            // 囧人糗事
        case 133109:
            // 逗乐熊娃
        case 133110:
            // 国外搞笑
        case 133113:
            // 恶搞吐槽
        case 133122:
            // 熊娃萌宠
        case 133126:
            // 混剪配音/穿帮
        case 133112:
            // 原创短剧
        case 133123:
            // 奇闻趣事
        case 133125:
            // 搞笑动画
        case 133121:
            // 其他
        case 133128:
            list.add(216);
            // 音乐歪唱
            break;
        case 133124:
            list.add(216);
            list.add(217);
 
            break;// 相声小品
        case 133129:
            list.add(216);
            list.add(220);
            break;// 萌宠
 
        // 娱乐八卦
        case 202101:
            // 娱乐大事件
        case 202100:
            list.add(219);
            break;// 影视赏析
 
        // 科技
        case 127100:
            // 随身数码
        case 127102:
            // 智能手机
        case 127103:
            // PC/PAD
        case 127115:
            // 智能家居
        case 127119:
            // 科技评测
        case 127116:
            // IT业界
        case 127120:
            // 软件应用
        case 127106:
            // 科技资讯
        case 127117:
            // 科技广告
        case 127118:
            // 其他
        case 127109:
            // 新奇酷玩
        case 127121:
            list.add(221);
            break;// 航拍
 
        // 汽车
        case 126100:
            // 车讯
        case 126101:
            // 新车
        case 126102:
            // 试车
        case 126107:
            // 赛车
        case 126120:
            // 用车常识
        case 126109:
            // 用车
        case 126111:
            // 玩车
        case 126116:
            // 摩托
        case 126117:
            // 试驾
        case 126118:
            // 评测
        case 126124:
            // 试驾评测
        case 126108:
            // 香车美女
        case 126125:
            // 新车资讯
        case 126121:
            // 玩车改装
        case 126122:
            // 交通警示
        case 126123:
            // 其他
        case 126126:
            // 业界动态
        case 126119:
            list.add(226);
            break;// 赛事
 
        // 公开课
        case 204100:
            // 社会人文
        case 204101:
            // 名师在线
        case 204102:
            // 纪实纪录
        case 204103:
            // 国内大学
        case 204104:
            list.add(225);
            break;// 职业考试
 
        // 做饭
        case 208100:
            // 家常菜
        case 208101:
            // 日韩料理
        case 208102:
            // 西餐
        case 208103:
            list.add(228);
            break;// 甜品烘焙
        // 旅游
        case 131120:
            // 城市
        case 131128:
            // 国内游
        case 131130:
            // 东南亚
        case 131129:
            // 旅游综合
        case 131107:
            // 人文
        case 131131:
            // 欧洲
        case 131132:
            // 澳洲
        case 131133:
            // 奇闻探险
        case 131113:
            // 旅游攻略
        case 131126:
            // 旅游资讯
        case 131114:
            // 风俗趣闻
        case 131117:
            list.add(229);
            break;// 其他
 
        // 健康养身
        case 209100:
            // 医学常识
        case 209101:
            list.add(230);
            break;// 养生
 
        // 时尚
        case 190100:
            // 服装饰品
        case 190107:
            // 时尚街拍
        case 190104:
            // 服饰搭配
        case 190108:
            // 明星名模
        case 190106:
            list.add(232);
            break;// 其他
 
        // 母婴
        case 132119:
            // 少儿卡通
        case 132120:
            // 母婴宝典
        case 132121:
            // 萌娃秀
        case 132123:
            // 孕产知识
        case 132124:
            // 育儿健康
        case 132125:
            list.add(233);
            break;// 早教
 
        // 运动健身
        case 125100:
            list.add(273);
            break;// 体育资讯
        case 125103:
            list.add(236);
            break;// 足球
        case 125111:
            list.add(273);
            break;// 体育综合
        case 125104:
            list.add(234);
            break;// 极限运动
        case 125116:
            list.add(292);
            break;// 球类
        case 125117:
            list.add(273);
            break;// 运动装备
        case 125118:
            list.add(273);
            break;// 舞蹈
        case 125119:
            list.add(273);
            break;// 跑步
        case 125120:
            list.add(273);
            break;// 运动常识
        case 125121:
            list.add(235);
            break;// 健身塑形
 
        // 音乐
        case 121114:
            list.add(304);
            break;// 原创
        case 121115:
            break;// 音乐综合
        case 121121:
            list.add(304);
            break;// 原创MV
        case 121122:
 
            break;// 音乐现场
        case 121120:
            break;// 其他
        case 121123:
            break;// 好歌曲
        case 121124:
            list.add(304);
            break;// 翻唱
        case 121125:
            list.add(280);
            break;// 音乐策划
        case 121126:
            list.add(280);
            break;// 花絮
 
        // 千里眼
        case 212109:
            list.add(291);
            break;// 镜头故事
 
        }
 
        return list;
    }
 
    @SuppressWarnings("unchecked")
    public void parseAll() {
        List<RootCategory> list =new ArrayList<RootCategory>(); //SoHuApi.rootCategoryList();
        RootCategory rc = new RootCategory();
        rc.setCateId(9004);
        list.add(rc);
        Collections.reverse(list);
        // 获取内容列表
        for (RootCategory rcy : list) {
 
            final RootCategory fcy = rcy;
            new Thread(new Runnable() {
 
                public void run() {
                    Map<String, Object> map = SoHuApi.getContentList(fcy.getCateId(), 0, 1, 20);
                    if (map.get("count") != null) {
                        int count = Integer.parseInt(map.get("count") + "");
                        if (count > 1000)
                            count = 1000;
                        for (int i = 1; i < count / 50 + 2; i++) {
                            System.out.println("分类--" + fcy.getCateName());
 
                            map = SoHuApi.getContentList(fcy.getCateId(), 0, i, 50);
                            List<SohuVideoContent> slist = (List<SohuVideoContent>) map.get("data");
                            if (slist != null && slist.size() > 0) {
                                for (SohuVideoContent svc : slist) {
                                    final String name = svc.getVideo_name();
                                    if (!(Boolean) videoResourceDao.excute(new HibernateCallback<Boolean>() {
                                        public Boolean doInHibernate(Session session) throws HibernateException {
                                            return JuheVideoUtil.isNeedAdd(session, name);
                                        }
                                    }))
                                        continue;
 
                                    System.out.println("分类--" + fcy.getCateName() + " 页码:" + i);
                                    SoHuAlbum sa = SoHuApi.getAlbumDetail(svc.getAid());
                                    if (sa != null) {// 有专辑详情
                                        sa.setArea(svc.getArea());
                                        if (!StringUtil.isNullOrEmpty(sa.getArea())) {
                                            if (sa.getArea().contains("内地"))
                                                sa.setArea("内地");
                                            if (sa.getArea().contains("韩"))
                                                sa.setArea("韩国");
                                            if (sa.getArea().contains("日"))
                                                sa.setArea("日本");
                                            if (sa.getArea().contains("港"))
                                                sa.setArea("香港");
                                            if (sa.getArea().contains("台"))
                                                sa.setArea("台湾");
                                        }
                                        sa.setTip(svc.getTip());
                                        String c = SoHuApi.getVideoList(sa.getAid(), 1, 20).get("count") + "";
                                        if (!StringUtil.isNullOrEmpty(c)) {
                                            List<SoHuVideo> vlist = new ArrayList<SoHuVideo>();
                                            for (int p = 1; p < Integer.parseInt(c) / 50 + 2; p++) {
                                                List<SoHuVideo> videoList = (List<SoHuVideo>) SoHuApi
                                                        .getVideoList(sa.getAid(), p, 50).get("data");
                                                if (videoList != null && videoList.size() > 0) {
                                                    vlist.addAll(videoList);
                                                }
                                            }
                                            sa.setVideoList(vlist);
                                        }
 
                                        Collections.sort(sa.getVideoList(), new Comparator<SoHuVideo>() {
                                            public int compare(SoHuVideo o1, SoHuVideo o2) {
                                                return o2.getVideo_order() - o1.getVideo_order();
                                            }
                                        });
                                        boolean isUpdate = false;
                                        try {
                                            if (sa.getVideoList().size() > 1) {
                                                if (sa.getVideoList().get(0).getVideo_order() > soHuService
                                                        .getLatestSoHuVideo(sa.getAid()).getVideo_order())
                                                    isUpdate = true;
                                            }
                                        } catch (Exception e) {
 
                                        }
 
                                        String id = soHuService.addAlbum(sa);
                                        sa.setId(id);
 
                                        // 添加到视频
                                        String vid = soHuService.addToVideoInfo(sa, isUpdate);
 
                                        // 添加到分类视频
                                        List<VideoType> li = soHuService.getVideoTypeList(sa);
                                        for (VideoType vt : li) {
                                            soHuService.addToCategoryVideo(vid, vt.getId());
                                        }
 
                                    }
 
                                }
 
                            }
                        }
                    }
                }
            }).start();
        }
    }
 
    private static VideoType getVideoType(String catCode) {
 
        if (StringUtil.isNullOrEmpty(catCode))
            return null;
        String mainCode = catCode.split(";")[0];
        int id = 1;
        if (Integer.parseInt(mainCode) < 1000) {
            switch (Integer.parseInt(mainCode)) {
            case 100:
                id = 151;
                break;
            case 101:
                id = 150;
                break;
            case 106:
                id = 152;
                break;
            case 107:
                break;
            case 115:
                id = 153;
                break;
            case 119:
                break;
            case 121:
                break;
            case 124:
                break;
            case 125:
                break;
            case 126:
                break;
            case 127:
                break;
            case 128:
                break;
 
            case 129:
                break;
            case 130:
                break;
            case 131:
                break;
            case 132:
                break;
 
            case 133:
                break;
 
            case 190:
                break;
 
            case 192:
                break;
 
            case 194:
                break;
 
            case 204:
                break;
            }
        } else {
            int code = Integer.parseInt(mainCode);
            if (code >= 101100 && code <= 101127)
                id = 150;
            else if (code >= 100100 && code <= 100135)
                id = 151;
            else if (code >= 115100 && code <= 115140)
                id = 153;
            else if (code >= 106100 && code <= 106140)// 106100
                id = 152;
        }
 
        return new VideoType(id);
    }
 
    private static String getTag(SoHuAlbum sa) {
        VideoType vt = getVideoType(sa.getCate_code());
        String tag = "";
        if (vt.getId() != 0) {
            if (vt.getId() == 151) {// 电影
                tag = "评分:" + sa.getScore();
            } else if (vt.getId() == 150) {// 电视剧
                if ("1".equalsIgnoreCase(sa.getOver()))// 完结
                    tag = sa.getLatest_video_count() + "集全";
                else
                    tag = "更新至" + sa.getLatest_video_count() + "集";
 
            } else if (vt.getId() == 152) {// 综艺
                if (sa.getVideoList() != null && sa.getVideoList().size() > 0) {
                    SoHuVideo sv = sa.getVideoList().get(0);
                    String date = StringUtil.isNullOrEmpty(sv.getShow_date()) ? sv.getCreate_date() : sv.getShow_date();
                    tag = "更新至" + date;
                }
 
            } else if (vt.getId() == 153) {// 动漫
                if ("1".equalsIgnoreCase(sa.getOver()))// 完结
                    tag = sa.getLatest_video_count() + "集全";
                else
                    tag = "更新至" + sa.getLatest_video_count() + "集";
            } else {
                if (sa.getVideoList() != null && sa.getVideoList().size() > 0) {
                    SoHuVideo sv = sa.getVideoList().get(0);
                    String date = StringUtil.isNullOrEmpty(sv.getShow_date()) ? sv.getCreate_date() : sv.getShow_date();
                    tag = date;
                }
            }
        }
        return tag;
 
    }
 
    public static VideoInfo convertAlBumToVideoInfo(SoHuAlbum sa) {
        String date = "";
        int year = 2016;
        int month = 1;
        int day = 1;
        VideoInfo vi = new VideoInfo();
        if (sa.getVideoList() != null && sa.getVideoList().size() > 0) {
            SoHuVideo sv = sa.getVideoList().get(0);
            date = StringUtil.isNullOrEmpty(sv.getShow_date()) ? sv.getCreate_date() : sv.getShow_date();
            long time = TimeUtil.convertGernalTime(date, "yyyy-MM-dd");
            Calendar ca = Calendar.getInstance();
            ca.setTimeInMillis(time);
            day = ca.get(Calendar.DAY_OF_MONTH);
            month = ca.get(Calendar.MONTH) + 1;
            year = ca.get(Calendar.YEAR);
            vi.setUpdatetime(time + "");
            vi.setLatestHpicture(sv.getHor_high_pic());
            vi.setLatestVpicture(sv.getVer_high_pic());
        }
 
        vi.setAdmin(new AdminInfo("1"));
        vi.setArea("");
        vi.setBaseurl("");
        vi.setBeizhu("");
        vi.setCanSave(false);
        vi.setCommentCount(0);
        if ("0".equalsIgnoreCase(sa.getTrailer()))
            vi.setContentType(1);// 正片
        else
            vi.setContentType(2);// 片花
        vi.setCreatetime(System.currentTimeMillis() );
        vi.setCommentCount(0);
        vi.setDay(day + "");
        vi.setDirector(sa.getDirector());
        vi.setDuration("0");
        vi.setFinish("1");
        vi.setFocus("");
        vi.setIntroduction(sa.getAlbum_desc());
        vi.setKeyword("");
        vi.setLeafctgs("");
        vi.setMainActor(sa.getModerator());
        vi.setMonth(month + "");
        vi.setName(sa.getAlbum_name());
        vi.setNowNumber("0");
        vi.setOrderby(20 + "");
        vi.setPicture("");
        vi.setPlayPicture("");
        vi.setQulity("");
        vi.setScore(sa.getScore());
        vi.setShare("0");
        vi.setShow("1");
        vi.setShowType(1);
        vi.setTag(sa.getTip());
        vi.setThirdType("1");
        vi.setTotalNumber("0");
        vi.setType("");
        vi.setVideoType(getVideoType(sa.getCate_code()));
        vi.setWatchCount(0 + "");
        vi.setYear(year + "");
        vi.setVpicture(sa.getVer_high_pic());
        vi.setHpicture(sa.getHor_high_pic());
        vi.setPicture(sa.getVer_high_pic());
        vi.setVideocount(sa.getVideoList() != null ? sa.getVideoList().size() : 1);
        vi.setArea(sa.getArea());
        return vi;
    }
 
    @SuppressWarnings("unchecked")
    public int getShowType(final String vid) {
        return (Integer) soHuVideoDao.excute(new HibernateCallback<Integer>() {
            public Integer doInHibernate(Session session) throws HibernateException {
                try {
                    List<SoHuAlbum> list = session.createQuery("select vs.album From VideoSoHu vs where vs.video.id=?")
                            .setParameter(0, vid).list();
                    if (list != null && list.size() > 0) {
                        String cate = list.get(0).getCate_code();
                        if (!StringUtil.isNullOrEmpty(cate)) {
                            cate = cate.split(";")[0];
                            if (getVideoType(cate).getId() == 150 || getVideoType(cate).getId() == 153)// 电视剧和动漫
                                return 2;
                        }
                    }
                } catch (Exception e) {
                    e.printStackTrace();
                }
                return 1;
            }
        });
 
    }
 
    public PlayUrl getPlayUrl(String detailSystemId, String resourceId, String type, String id) {
        logger.info(String.format("%s#%s#%s#%s", detailSystemId, resourceId, type, id));
        PlayUrl playUrl = new PlayUrl();
        playUrl.setPlayType(2);
        try {
            List<VideoResource> list = videoResourceDao.list("from VideoResource vr where vr.id=" + resourceId);
            if (list != null && list.size() > 0)
                playUrl.setResource(list.get(0));
            playUrl.setPlayType(2);
            List<SoHuVideo> svList = soHuVideoDao.list("from SoHuVideo sv where sv.id=" + id);
            if (svList != null && svList.size() > 0) {
                JSONObject object = new JSONObject();
                SoHuVideo sv = svList.get(0);
                if (sv != null) {// 添加
                    soHuService.addPlayStatistics(detailSystemId, sv);
                }
                object.put("aid", sv.getAid());
                object.put("site", sv.getSite() + "");
                object.put("vid", sv.getVid());
 
                // playUrl.setUrl(sv.getUrl_html5());
                playUrl.setUrl(
                        String.format("http://video.yeshitv.com:8089/BuWan/sohuplay.jsp?vid=%s&width=%s&height=%s",
                                sv.getVid(), 640 + "", 480 + ""));
                playUrl.setParams(object.toString());
            } else
                return null;
        } catch (Exception e) {
            e.printStackTrace();
        }
        return playUrl;
    }
}