New Feeds

[활용팁] 유튜브 쇼츠 적용

작성자 정보

  • 나리야 작성
  • 작성일

컨텐츠 정보

본문

=============================================


골드테마 쇼츠도 적용되길래 신기해서 손꾸락만 빨다가 한번 해봤어요


우선 apms.lib.php에서 수정했어요


코어를 건드려서 수정하는 만큼, 원본은 항상 따로 가지고 계셔야겠고, 수정한 위치도 항상 기억을 해놔야할거 같아요




apms.lib.php안에서 2곳을 손봤는데요. 우선



// 동영상 종류 파악

function apms_video_info($video_url) {


함수가 있던데, 원본코드 내용은 아래와 같아요. 주소를 가져오는곳이겠죠


if($info['host'] == "youtu.be") { //유튜브

$video['type'] = 'youtube';

$video['vid'] = trim(str_replace("/","", trim($info['path'])));

$video['vid'] = substr($video['vid'], 0, 11);

$video['vlist'] = (isset($query['list']) && $query['list']) ? $query['list'] : '';

$query['autoplay'] = (isset($query['autoplay']) && $query['autoplay']) ? $query['autoplay'] : '';

$video['auto'] = (isset($option['auto']) && $option['auto']) ? $option['auto'] : $query['autoplay'];

$video['start'] = (isset($option['start']) && $option['start']) ? $option['start'] : $query['start'];

$video['s'] = (isset($option['s']) && $option['s']) ? $option['s'] : $query['s'];

} else if($info['host'] == "www.youtube.com" || $info['host'] == "m.youtube.com") { //유튜브

$video['type'] = 'youtube';

if(preg_match('//embed//i', $video['video_url'])) {

list($youtube_url, $youtube_opt) = explode("/embed/", $video['video_url']);

$vids = explode("?", $youtube_opt);

$video['vid'] = $vids[0];

} else {

$video['vid'] = (isset($query['v']) && $query['v']) ? $query['v'] : '';

$video['vlist'] = (isset($query['list']) && $query['list']) ? $query['list'] : '';

}

$query['autoplay'] = (isset($query['autoplay']) && $query['autoplay']) ? $query['autoplay'] : '';

$video['auto'] = (isset($option['auto']) && $option['auto']) ? $option['auto'] : $query['autoplay'];

$video['start'] = (isset($option['start']) && $option['start']) ? $option['start'] : $query['start'];

$video['s'] = (isset($option['s']) && $option['s']) ? $option['s'] : $query['s'];



위 코드를 아래로 교채 [ 아미나 안에서 검색해서, 현재시각 동영상 가져오는 $query['t'] 부분도 적용 ]


골드테마에서는 타입으로 라이브까지 나눠있던데..단순히 쇼츠만 추가하려고 ( 사실 라이브가 어떻게 적용되는지도 모름 )


쇼츠의 기본값은 


$video['is_shorts'] = false;  로 해두고


쇼츠코드에서만  $video['is_shorts'] = true;로


정규식은 골드테마에서 대충 업어옴 / 나머지는 그대로 처리


============================================= 



if($info['host'] == "youtu.be") { //유튜브

$video['type'] = 'youtube';

$video['vid'] = trim(str_replace("/","", trim($info['path'])));

$video['vid'] = substr($video['vid'], 0, 11);

$video['vlist'] = (isset($query['list']) && $query['list']) ? $query['list'] : '';

$query['autoplay'] = (isset($query['autoplay']) && $query['autoplay']) ? $query['autoplay'] : '';

$video['auto'] = (isset($option['auto']) && $option['auto']) ? $option['auto'] : $query['autoplay'];

$video['start'] = (isset($option['start']) && $option['start']) ? $option['start'] : (isset($query['t']) ? $query['t'] : $query['start']);

$video['s'] = (isset($option['s']) && $option['s']) ? $option['s'] : $query['s'];

$video['is_shorts'] = false; // 기본값은 쇼츠가 아닌걸로

} else if($info['host'] == "www.youtube.com" || $info['host'] == "m.youtube.com") { // 유튜브 + 쇼츠 추가)

$video['type'] = 'youtube';

if(preg_match('//shorts//i', $video['video_url'])) { 

        // 유튜브 쇼츠 (Shorts) URL 처리 2025.03.06

        $video['vid'] = trim(str_replace("/shorts/", "", $info['path']));

        $video['is_shorts'] = true; // 쇼츠 여부 확인용 추가

} else if(preg_match('//embed//i', $video['video_url'])) {

        // 임베드 URL 처리

        list($youtube_url, $youtube_opt) = explode("/embed/", $video['video_url']);

        $vids = explode("?", $youtube_opt);

        $video['vid'] = $vids[0];

$video['is_shorts'] = false; // 일반 유튜브 영상

} else {

        // 일반 유튜브 URL 처리

        $video['vid'] = (isset($query['v']) && $query['v']) ? $query['v'] : '';

        $video['vlist'] = (isset($query['list']) && $query['list']) ? $query['list'] : '';

$video['is_shorts'] = false; // 일반 유튜브 영상

}

$query['autoplay'] = (isset($query['autoplay']) && $query['autoplay']) ? $query['autoplay'] : '';

$video['auto'] = (isset($option['auto']) && $option['auto']) ? $option['auto'] : $query['autoplay'];

$video['start'] = (isset($option['start']) && $option['start']) ? $option['start'] : (isset($query['t']) ? $query['t'] : $query['start']);

$video['s'] = (isset($option['s']) && $option['s']) ? $option['s'] : $query['s'];


=============================================





두번째로 볼곳이


//Show Video Player

function apms_video($vid, $opt='') {

global $autoplayvideo, $is_feedvideo;



이 함수안인데


switch($video['type']) {

case 'vimeo' : $video['width'] = 717; $video['height'] = 403; break;

case 'nate' : $video['width'] = 640; $video['height'] = 384; break;

case 'tagstory' : $video['width'] = 720; $video['height'] = 480; break;

case 'tvcast' : $video['width'] = 740; $video['height'] = 416; break;

case 'naver' : $video['width'] = 720; $video['height'] = 438; break;

case 'slideshare' : $video['width'] = 425; $video['height'] = 355; break;

case 'vid' : $video['width'] = 854; $video['height'] = 480; break;

case 'sendvid' : $video['width'] = 853; $video['height'] = 480; break;

case 'vine' : $video['width'] = 600; $video['height'] = 600; break;

case 'yinyuetai' : $video['width'] = 480; $video['height'] = 334; break;

case 'vlive' : $video['width'] = 544; $video['height'] = 306; break;

case 'srook' : $video['width'] = 720; $video['height'] = 480; break;

case 'twitch' : $video['width'] = 620; $video['height'] = 378; break;

case 'youtube' : if($video['s']) { $video['width'] = 480; $video['height'] = 880; $sero_size = ' style="max-width:400px !important;"'; break; }

default : $video['width'] = 640; $video['height'] = 360; break;

}


원코드에서


case 'youtube' 일때만


쇼츠와 나눴어요. 비율도 골드에서 업어옴


case 'youtube' : if($video['s']) { $video['width'] = 480; $video['height'] = 880; $sero_size = ' style="max-width:400px !important;"'; break; }


부분만 아래로 교체



case 'youtube':

    if ($video['is_shorts']) { 

        // 유튜브 쇼츠인 경우

        $video['width'] = 315;

        $video['height'] = 560;

        $sero_size = 'style="max-width:450px !important;"';

        break;

   

    if ($video['s']) { 

        $video['width'] = 480;

        $video['height'] = 880;

        $sero_size = 'style="max-width:400px !important;"';

        break;

    }


==============================================


썸네일은 그냥 쇼츠도 나오길래 얼쑤구나 하고 아무것도 손을 안봤고


모달창으로 보거나 하는건, 저는 안해서 쳐다도 안봤죠.


그리고 플레이어도 안쓰고 있어서, 플레이어 사용에 대해서도 생각을 안했어요.


또 어디를 더 해야하는지는 잘 모르겠어요


그냥 이렇게 해보니 저는 되더라..이정도에요

관련자료

댓글 0
등록된 댓글이 없습니다.
전체 1,963 / 3 페이지
번호
제목
이름

Favorites


최근글


새댓글


  • 댓글이 없습니다.
알림 0