Video.php 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868
  1. <?php
  2. // +—————————————————————————————————————————————————————————————————————
  3. // | Created by Yunbao
  4. // +—————————————————————————————————————————————————————————————————————
  5. // | Copyright (c) 2013~2022 http://www.yunbaokj.com All rights reserved.
  6. // +—————————————————————————————————————————————————————————————————————
  7. // | Author: https://gitee.com/yunbaokeji
  8. // +—————————————————————————————————————————————————————————————————————
  9. // | Date: 2022-04-30
  10. // +—————————————————————————————————————————————————————————————————————
  11. session_start();
  12. class Model_Video extends PhalApi_Model_NotORM {
  13. /* 发布视频 */
  14. public function setVideo($data,$music_id) {
  15. $uid=$data['uid'];
  16. //获取后台配置的初始曝光值
  17. $configPri=getConfigPri();
  18. if($configPri['video_audit_switch']==0){
  19. $data['status']=1;
  20. }
  21. $data['thumb']=setCloudType($data['thumb']);
  22. $data['thumb_s']=setCloudType($data['thumb_s']);
  23. $data['href']=setCloudType($data['href']);
  24. $data['href_w']=setCloudType($data['href_w']);
  25. $result= DI()->notorm->user_video->insert($data);
  26. if($music_id>0){ //更新背景音乐被使用次数
  27. DI()->notorm->user_music
  28. ->where("id = '{$music_id}'")
  29. ->update( array('use_nums' => new NotORM_Literal("use_nums + 1") ) );
  30. }
  31. return $result;
  32. }
  33. /* 评论/回复 */
  34. public function setComment($data) {
  35. $videoid=$data['videoid'];
  36. $res=DI()->notorm->user_video_comments->insert($data);
  37. if(!$res){
  38. return 1001;
  39. }
  40. /* 更新 视频 */
  41. DI()->notorm->user_video
  42. ->where("id = '{$videoid}'")
  43. ->update( array('comments' => new NotORM_Literal("comments + 1") ) );
  44. $videoinfo=DI()->notorm->user_video
  45. ->select("comments")
  46. ->where('id=?',$videoid)
  47. ->fetchOne();
  48. $count=DI()->notorm->user_video_comments
  49. ->where("commentid='{$data['commentid']}'")
  50. ->count();
  51. $rs=array(
  52. 'comments'=>$videoinfo['comments'],
  53. 'replys'=>$count,
  54. );
  55. //他人直接对视频进行的评论,向评论信息表中写入记录
  56. if($data['uid']!=$data['touid']){
  57. $data2=array("uid"=>$data['uid'],"touid"=>$data['touid'],"videoid"=>$data['videoid'],"content"=>$data['content'],"addtime"=>time());
  58. DI()->notorm->user_video_comments_messages->insert($data2);
  59. //$data['touid']为视频发布者ID或评论者ID
  60. }
  61. return $rs;
  62. }
  63. /* 阅读 */
  64. public function addView($uid,$videoid){
  65. /* 观看记录 */
  66. $nowtime=time();
  67. $ifok=DI()->notorm->user_video_view
  68. ->where('uid=? and videoid=?',$uid,$videoid)
  69. ->update(['addtime'=>$nowtime]);
  70. if(!$ifok){
  71. DI()->notorm->user_video_view
  72. ->insert(array("uid"=>$uid,"videoid"=>$videoid,"addtime"=>$nowtime ));
  73. }
  74. /* 减少上热门 */
  75. DI()->notorm->user_video
  76. ->where("id = ? and p_expire>? and p_nums>=1",$videoid,$nowtime)
  77. ->update( array('p_nums' => new NotORM_Literal("p_nums - 1") ) );
  78. DI()->notorm->user_video
  79. ->where("id = '{$videoid}'")
  80. ->update( array('views' => new NotORM_Literal("views + 1") ) );
  81. return 0;
  82. }
  83. /* 点赞 */
  84. public function addLike($uid,$videoid){
  85. $rs=array(
  86. 'islike'=>'0',
  87. 'likes'=>'0',
  88. );
  89. $video=DI()->notorm->user_video
  90. ->select("likes,uid,thumb")
  91. ->where("id = '{$videoid}'")
  92. ->fetchOne();
  93. if(!$video){
  94. return 1001;
  95. }
  96. if($video['uid']==$uid){
  97. return 1002;//不能给自己点赞
  98. }
  99. $like=DI()->notorm->user_video_like
  100. ->select("id")
  101. ->where("uid='{$uid}' and videoid='{$videoid}'")
  102. ->fetchOne();
  103. if($like){
  104. DI()->notorm->user_video_like
  105. ->where("uid='{$uid}' and videoid='{$videoid}'")
  106. ->delete();
  107. DI()->notorm->user_video
  108. ->where("id = '{$videoid}' and likes>0")
  109. ->update( array('likes' => new NotORM_Literal("likes - 1") ) );
  110. $rs['islike']='0';
  111. }else{
  112. DI()->notorm->user_video_like
  113. ->insert(array("uid"=>$uid,"videoid"=>$videoid,"addtime"=>time() ));
  114. DI()->notorm->user_video
  115. ->where("id = '{$videoid}'")
  116. ->update( array('likes' => new NotORM_Literal("likes + 1") ) );
  117. $rs['islike']='1';
  118. }
  119. $video=DI()->notorm->user_video
  120. ->select("likes,uid,thumb")
  121. ->where("id = '{$videoid}'")
  122. ->fetchOne();
  123. $rs['likes']=NumberFormat($video['likes']);
  124. return $rs;
  125. }
  126. /* 分享 */
  127. public function addShare($uid,$videoid){
  128. $rs=array(
  129. 'isshare'=>'0',
  130. 'shares'=>'0',
  131. );
  132. DI()->notorm->user_video
  133. ->where("id = '{$videoid}'")
  134. ->update( array('shares' => new NotORM_Literal("shares + 1") ) );
  135. $rs['isshare']='1';
  136. $video=DI()->notorm->user_video
  137. ->select("shares")
  138. ->where("id = '{$videoid}'")
  139. ->fetchOne();
  140. $rs['shares']=NumberFormat($video['shares']);
  141. return $rs;
  142. }
  143. /* 评论/回复 点赞 */
  144. public function addCommentLike($uid,$commentid){
  145. $rs=array(
  146. 'islike'=>'0',
  147. 'likes'=>'0',
  148. );
  149. //根据commentid获取对应的评论信息
  150. $commentinfo=DI()->notorm->user_video_comments
  151. ->where("id='{$commentid}'")
  152. ->fetchOne();
  153. if(!$commentinfo){
  154. return 1001;
  155. }
  156. $like=DI()->notorm->user_video_comments_like
  157. ->select("id")
  158. ->where("uid='{$uid}' and commentid='{$commentid}'")
  159. ->fetchOne();
  160. if($like){
  161. DI()->notorm->user_video_comments_like
  162. ->where("uid='{$uid}' and commentid='{$commentid}'")
  163. ->delete();
  164. DI()->notorm->user_video_comments
  165. ->where("id = '{$commentid}' and likes>0")
  166. ->update( array('likes' => new NotORM_Literal("likes - 1") ) );
  167. $rs['islike']='0';
  168. }else{
  169. DI()->notorm->user_video_comments_like
  170. ->insert(array("uid"=>$uid,"commentid"=>$commentid,"addtime"=>time(),"touid"=>$commentinfo['uid'],"videoid"=>$commentinfo['videoid'] ));
  171. DI()->notorm->user_video_comments
  172. ->where("id = '{$commentid}'")
  173. ->update( array('likes' => new NotORM_Literal("likes + 1") ) );
  174. $rs['islike']='1';
  175. }
  176. $video=DI()->notorm->user_video_comments
  177. ->select("likes")
  178. ->where("id = '{$commentid}'")
  179. ->fetchOne();
  180. //获取视频信息
  181. $videoinfo=DI()->notorm->user_video->select("thumb")->where("id='{$commentinfo['videoid']}'")->fetchOne();
  182. $rs['likes']=$video['likes'];
  183. return $rs;
  184. }
  185. /* 热门视频 */
  186. public function getVideoList($uid,$p){
  187. $nums=20;
  188. $start=($p-1)*$nums;
  189. $videoids_s='';
  190. $where="isdel=0 and status=1"; //上架且审核通过
  191. $video=DI()->notorm->user_video
  192. ->select("*")
  193. ->where($where)
  194. ->order("RAND()")
  195. ->limit($start,$nums)
  196. ->fetchAll();
  197. //敏感词树
  198. $tree=trieTreeBasic();
  199. foreach($video as $k=>$v){
  200. $v=handleVideo($uid,$v,$tree);
  201. $video[$k]=$v;
  202. }
  203. return $video;
  204. }
  205. /* 视频详情 */
  206. public function getVideo($uid,$videoid){
  207. $video=DI()->notorm->user_video
  208. ->select("*")
  209. ->where("id = {$videoid} and status=1 ")
  210. ->fetchOne();
  211. if(!$video){
  212. return 1000;
  213. }
  214. //敏感词树
  215. $tree=trieTreeBasic();
  216. $video=handleVideo($uid,$video,$tree);
  217. return $video;
  218. }
  219. /* 评论列表 */
  220. public function getComments($uid,$videoid,$p){
  221. $nums=20;
  222. $start=($p-1)*$nums;
  223. $comments=DI()->notorm->user_video_comments
  224. ->select("*")
  225. ->where("videoid='{$videoid}' and parentid='0'")
  226. ->order("addtime desc")
  227. ->limit($start,$nums)
  228. ->fetchAll();
  229. //敏感词树
  230. $tree=trieTreeBasic();
  231. foreach($comments as $k=>$v){
  232. $comments[$k]['userinfo']=getUserInfo($v['uid'],$tree);
  233. $comments[$k]['datetime']=datetime($v['addtime']);
  234. $comments[$k]['likes']=NumberFormat($v['likes']);
  235. if($uid){
  236. $comments[$k]['islike']=(string)$this->ifCommentLike($uid,$v['id']);
  237. }else{
  238. $comments[$k]['islike']='0';
  239. }
  240. if($v['touid']>0){
  241. $touserinfo=getUserInfo($v['touid'],$tree);
  242. }
  243. if(!$touserinfo){
  244. $touserinfo=(object)array();
  245. $comments[$k]['touid']='0';
  246. }
  247. $comments[$k]['touserinfo']=$touserinfo;
  248. $count=DI()->notorm->user_video_comments
  249. ->where("commentid='{$v['id']}'")
  250. ->count();
  251. $comments[$k]['replys']=$count;
  252. $comments[$k]['content']=eachReplaceSensitiveWords($tree,$v['content']);
  253. /* 回复 */
  254. $reply=DI()->notorm->user_video_comments
  255. ->select("*")
  256. ->where("commentid='{$v['id']}'")
  257. ->order("addtime desc")
  258. ->limit(0,1)
  259. ->fetchAll();
  260. foreach($reply as $k1=>$v1){
  261. $v1['userinfo']=getUserInfo($v1['uid'],$tree);
  262. $v1['datetime']=datetime($v1['addtime']);
  263. $v1['likes']=NumberFormat($v1['likes']);
  264. $v1['islike']=(string)$this->ifCommentLike($uid,$v1['id']);
  265. if($v1['touid']>0){
  266. $touserinfo=getUserInfo($v1['touid'],$tree);
  267. }
  268. if(!$touserinfo){
  269. $touserinfo=(object)array();
  270. $v1['touid']='0';
  271. }
  272. if($v1['parentid']>0 && $v1['parentid']!=$v['id']){
  273. $tocommentinfo=DI()->notorm->user_video_comments
  274. ->select("content,at_info")
  275. ->where("id='{$v1['parentid']}'")
  276. ->fetchOne();
  277. }else{
  278. $tocommentinfo=(object)array();
  279. $touserinfo=(object)array();
  280. $v1['touid']='0';
  281. }
  282. $v1['touserinfo']=$touserinfo;
  283. $v1['tocommentinfo']=$tocommentinfo;
  284. $v1['content']=eachReplaceSensitiveWords($tree,$v1['content']);
  285. $reply[$k1]=$v1;
  286. }
  287. $comments[$k]['replylist']=$reply;
  288. }
  289. $commentnum=DI()->notorm->user_video_comments
  290. ->where("videoid='{$videoid}'")
  291. ->count();
  292. $rs=array(
  293. "comments"=>$commentnum,
  294. "commentlist"=>$comments,
  295. );
  296. return $rs;
  297. }
  298. /* 回复列表 */
  299. public function getReplys($uid,$commentid,$last_replyid,$p){
  300. if($last_replyid==0){ //获取回复列表里最新的一条
  301. $comment=DI()->notorm->user_video_comments
  302. ->select("*")
  303. ->where("commentid='{$commentid}'")
  304. ->order("addtime desc")
  305. ->fetchOne();
  306. $comments[]=$comment;
  307. }else{
  308. if($p<1){
  309. $p=1;
  310. }
  311. //第一页获取2条数据,从第二页开始每页获取10条数据
  312. $nums=10;
  313. if($p==1){
  314. $nums=2;
  315. }
  316. $start=0;
  317. $comments=DI()->notorm->user_video_comments
  318. ->select("*")
  319. ->where("commentid='{$commentid}' and id< '{$last_replyid}'")
  320. ->order("addtime desc")
  321. ->limit($start,$nums)
  322. ->fetchAll();
  323. }
  324. //敏感词树
  325. $tree=trieTreeBasic();
  326. foreach($comments as $k=>$v){
  327. $comments[$k]['userinfo']=getUserInfo($v['uid'],$tree);
  328. $comments[$k]['datetime']=datetime($v['addtime']);
  329. $comments[$k]['likes']=NumberFormat($v['likes']);
  330. $comments[$k]['islike']=(string)$this->ifCommentLike($uid,$v['id']);
  331. if($v['touid']>0){
  332. $touserinfo=getUserInfo($v['touid'],$tree);
  333. }
  334. if(!$touserinfo){
  335. $touserinfo=(object)array();
  336. $comments[$k]['touid']='0';
  337. }
  338. if($v['parentid']>0 && $v['parentid']!=$commentid){
  339. $tocommentinfo=DI()->notorm->user_video_comments
  340. ->select("content,at_info")
  341. ->where("id='{$v['parentid']}'")
  342. ->fetchOne();
  343. }else{
  344. $tocommentinfo=(object)array();
  345. $touserinfo=(object)array();
  346. $comments[$k]['touid']='0';
  347. }
  348. $comments[$k]['touserinfo']=$touserinfo;
  349. $comments[$k]['tocommentinfo']=$tocommentinfo;
  350. $comments[$k]['content']=eachReplaceSensitiveWords($tree,$v['content']);
  351. }
  352. //该评论下的总回复数
  353. $count=DI()->notorm->user_video_comments
  354. ->where("commentid='{$commentid}'")
  355. ->count();
  356. $res['lists']=$comments;
  357. $res['replys']=$count;
  358. return $res;
  359. }
  360. /*删除评论 删除子级评论*/
  361. public function delComments($uid,$videoid,$commentid,$commentuid) {
  362. $result=DI()->notorm->user_video
  363. ->select("uid")
  364. ->where("id='{$videoid}'")
  365. ->fetchOne();
  366. if(!$result){
  367. return 1001;
  368. }
  369. if($uid!=$commentuid){
  370. if($uid!=$result['uid']){
  371. return 1002;
  372. }
  373. }
  374. // 删除 评论记录
  375. DI()->notorm->user_video_comments
  376. ->where("id='{$commentid}'")
  377. ->delete();
  378. //删除视频评论喜欢
  379. DI()->notorm->user_video_comments_like
  380. ->where("commentid='{$commentid}'")
  381. ->delete();
  382. /* 更新 视频 */
  383. DI()->notorm->user_video
  384. ->where("id = '{$videoid}' and comments>0")
  385. ->update( array('comments' => new NotORM_Literal("comments - 1") ) );
  386. //删除相关的子级评论
  387. $lists=DI()->notorm->user_video_comments
  388. ->select("*")
  389. ->where("commentid='{$commentid}' or parentid='{$commentid}'")
  390. ->fetchAll();
  391. foreach($lists as $k=>$v){
  392. //删除 评论记录
  393. DI()->notorm->user_video_comments
  394. ->where("id='{$v['id']}'")
  395. ->delete();
  396. //删除视频评论喜欢
  397. DI()->notorm->user_video_comments_like
  398. ->where("commentid='{$v['id']}'")
  399. ->delete();
  400. /* 更新 视频 */
  401. DI()->notorm->user_video
  402. ->where("id = '{$v['videoid']}' and comments>0")
  403. ->update( array('comments' => new NotORM_Literal("comments - 1") ) );
  404. }
  405. return 0;
  406. }
  407. /* 评论/回复 是否点赞 */
  408. public function ifCommentLike($uid,$commentid){
  409. $like=DI()->notorm->user_video_comments_like
  410. ->select("id")
  411. ->where("uid='{$uid}' and commentid='{$commentid}'")
  412. ->fetchOne();
  413. if($like){
  414. return 1;
  415. }else{
  416. return 0;
  417. }
  418. }
  419. /* 我的视频 */
  420. public function getMyVideo($uid,$p){
  421. $nums=20;
  422. $start=($p-1)*$nums;
  423. $video=DI()->notorm->user_video
  424. ->select("*")
  425. ->where('uid=? and status=1',$uid)
  426. ->order("addtime desc")
  427. ->limit($start,$nums)
  428. ->fetchAll();
  429. //敏感词树
  430. $tree=trieTreeBasic();
  431. foreach($video as $k=>$v){
  432. $v=handleVideo($uid,$v,$tree);
  433. $video[$k]=$v;
  434. }
  435. return $video;
  436. }
  437. /* 删除视频 */
  438. public function del($uid,$videoid){
  439. $result=DI()->notorm->user_video
  440. ->select("*")
  441. ->where("id='{$videoid}' and uid='{$uid}'")
  442. ->fetchOne();
  443. if($result){
  444. //将评论信息列表的状态更改
  445. DI()->notorm->user_video_comments_messages
  446. ->where("videoid='{$videoid}'")
  447. ->update(array("status"=>0));
  448. //将喜欢的视频列表状态修改
  449. DI()->notorm->user_video_like
  450. ->where("videoid='{$videoid}'")
  451. ->update(array("status"=>0));
  452. //将喜欢的视频列表状态修改
  453. DI()->notorm->user_video_view
  454. ->where("videoid='{$videoid}'")
  455. ->update(array("status"=>0));
  456. DI()->notorm->user_video
  457. ->where("id='{$videoid}'")
  458. ->update( array( 'isdel'=>1 ) );
  459. }
  460. return 0;
  461. }
  462. /* 个人主页视频 */
  463. public function getHomeVideo($uid,$touid,$p){
  464. $nums=20;
  465. $start=($p-1)*$nums;
  466. if($uid==$touid){ //自己的视频(需要返回视频的状态前台显示)
  467. $where=" uid={$uid} and isdel='0' and status=1";
  468. }else{ //访问其他人的主页视频
  469. $where=" uid={$touid} and isdel='0' and status=1";
  470. }
  471. $video=DI()->notorm->user_video
  472. ->select("*")
  473. ->where($where)
  474. ->order("addtime desc")
  475. ->limit($start,$nums)
  476. ->fetchAll();
  477. //敏感词树
  478. $tree=trieTreeBasic();
  479. foreach($video as $k=>$v){
  480. $v=handleVideo($uid,$v,$tree);
  481. $video[$k]=$v;
  482. }
  483. return $video;
  484. }
  485. /* 举报 */
  486. public function report($data) {
  487. $video=DI()->notorm->user_video
  488. ->select("uid")
  489. ->where("id='{$data['videoid']}' and status=1")
  490. ->fetchOne();
  491. if(!$video){
  492. return 1000;
  493. }
  494. $data['touid']=$video['uid'];
  495. $result= DI()->notorm->user_video_report->insert($data);
  496. return 0;
  497. }
  498. public function getRecommendVideos($uid,$p,$isstart,$mobileid){
  499. $pnums=20;
  500. $start=($p-1)*$pnums;
  501. $nowtime=time();
  502. $configPri=getConfigPri();
  503. if($p==1){
  504. if($uid>0){
  505. DI()->redis -> del('readvideo_'.$uid);
  506. }else{
  507. DI()->redis -> del('readvideo_'.$mobileid);
  508. }
  509. }
  510. //去除看过的视频
  511. $where=array();
  512. if($uid>0){
  513. $readLists=DI()->redis -> Get('readvideo_'.$uid);
  514. }else{
  515. $readLists=DI()->redis -> Get('readvideo_'.$mobileid);
  516. }
  517. if($readLists){
  518. $where=json_decode($readLists,true);
  519. }
  520. $info=DI()->notorm->user_video
  521. ->where("isdel=0 and status=1")
  522. ->where('not id',$where)
  523. ->order("rand()")
  524. ->limit($pnums)
  525. ->fetchAll();
  526. $where1=array();
  527. foreach ($info as $k => $v) {
  528. if(!in_array($v['id'],$where)){
  529. $where1[]=$v['id'];
  530. }
  531. }
  532. //将两数组合并
  533. $where2=array_merge($where,$where1);
  534. if($uid>0){
  535. DI()->redis -> set('readvideo_'.$uid,json_encode($where2));
  536. }else{
  537. DI()->redis -> set('readvideo_'.$mobileid,json_encode($where2));
  538. }
  539. if(!$info){
  540. return 1001;
  541. }
  542. $videoCount=count($info);
  543. //敏感词树
  544. $tree=trieTreeBasic();
  545. foreach($info as $k=>$v){
  546. $v=handleVideo($uid,$v,$tree);
  547. $info[$k]=$v;
  548. }
  549. return $info;
  550. }
  551. /* 举报分类列表 */
  552. public function getReportContentlist() {
  553. $reportlist=DI()->notorm->user_video_report_classify
  554. ->select("*")
  555. ->order("orderno asc")
  556. ->fetchAll();
  557. if(!$reportlist){
  558. return 1001;
  559. }
  560. //添加固定项 其他
  561. $reportlist[]=array(
  562. 'id'=>'-1',
  563. 'orderno'=>'1000',
  564. 'name'=>'其他',
  565. 'addtime'=>'1589872429'
  566. );
  567. return $reportlist;
  568. }
  569. /*更新视频看完次数*/
  570. public function setConversion($videoid){
  571. //更新视频看完次数
  572. $res=DI()->notorm->user_video
  573. ->where("id = '{$videoid}' and status=1")
  574. ->update( array('watch_ok' => new NotORM_Literal("watch_ok + 1") ) );
  575. return 1;
  576. }
  577. /* 标签下视频列表 */
  578. public function getLabelVideoList($uid,$labelid,$p){
  579. if($p<1){
  580. $p=1;
  581. }
  582. $nums=50;
  583. $start=($p-1)*$nums;
  584. $list=DI()->notorm->user_video
  585. ->select("*")
  586. ->where('labelid=? and status=1',$labelid)
  587. ->order("id desc")
  588. ->limit($start,$nums)
  589. ->fetchAll();
  590. //敏感词树
  591. $tree=trieTreeBasic();
  592. foreach($list as $k=>$v){
  593. $v=handleVideo($uid,$v,$tree);
  594. $list[$k]=$v;
  595. }
  596. return $list;
  597. }
  598. //根据音乐id获取同类型视频列表
  599. public function getVideoListByMusic($uid,$musicid,$p){
  600. if($p<1){
  601. $p=1;
  602. }
  603. $where="isdel=0 and status=1";
  604. $pnums=20;
  605. if($p!=1){
  606. $endtime=$_SESSION['music_video_endtime'];
  607. if($endtime){
  608. $where.=" and addtime<{$endtime}";
  609. }
  610. }
  611. $list=DI()->notorm->user_video
  612. ->where("music_id=?",$musicid)
  613. ->where($where)
  614. ->order("addtime desc")
  615. ->limit($pnums)
  616. ->fetchAll();
  617. //敏感词树
  618. $tree=trieTreeBasic();
  619. foreach($list as $k=>$v){
  620. $v=handleVideo($uid,$v,$tree);
  621. $list[$k]=$v;
  622. }
  623. if($list){
  624. $end=end($list);
  625. $_SESSION['music_video_endtime']=$end['addtime_format'];
  626. }
  627. return $list;
  628. }
  629. //获取音乐信息
  630. public function getMusicInfo($musicid){
  631. $musicinfo=DI()->notorm->user_music->select("title,author,img_url,file_url,use_nums,length")->where("id=? and isdel=0",$musicid)->fetchOne();
  632. if(!$musicinfo){
  633. return 1001;
  634. }
  635. $musicinfo['img_url']=get_upload_path($musicinfo['img_url']);
  636. $musicinfo['file_url']=get_upload_path($musicinfo['file_url']);
  637. $musicinfo['use_nums']=$musicinfo['use_nums'].'人参与';
  638. return $musicinfo;
  639. }
  640. }