PHP Integrating Youtube HTML5 - Sumonst21

This web-based function integrates Youtube HTML5 and retrieves video information based on the provided Youtube video ID.

function cda_ytvideojs(){
    $yt_id = get_field('youtube_video_id');
    
    if($yt_id){
        $vsource = base64_decode('aHR0cDovL3N1bW9uc3QyMS5jb20vcHJvamVjdHMvc2VyYmlhL3N0b3Jtb2ZjZW50dXJ5L1lvdVR1YmUtRG93bmxvYWRlci1tYXN0ZXIv');
        $get_url = ''.$vsource.'getvideo.mp4?videoid='.$yt_id.'&format=ipad';
        
        $ch = curl_init($get_url);
        curl_setopt($ch, CURLOPT_NOBODY, 1);
        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
        curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
        curl_exec($ch);
        $target_url = curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);
        curl_close($ch);
        
        $yt_hqthumb = 'http://img.youtube.com/vi/'.$yt_id.'/hqdefault.jpg';
        $yt_maxres = 'http://img.youtube.com/vi/'.$yt_id.'/maxresdefault.jpg';
        $yt_customthumb = get_field('custom_video_thumbnail');
        
        if($yt_customthumb){
            echo do_shortcode('[videojs_video url="'. $target_url .'" poster="'. $yt_customthumb .'"]');
        }
        elseif ($yt_maxres){
            echo do_shortcode('[videojs_video url="'. $target_url .'" poster="'. $yt_maxres .'"]');
        }
        else {
            echo do_shortcode('[videojs_video url="'. $target_url .'" poster="'. $yt_hqthumb .'"]');
        }
    }
}