<script type="text/javascript">
    var videoInp = $('#video_vid');
    videoInp.on("change", function(){
        console.log('change');
        if (videoInp.data("value") != videoInp.val() || videoInp.val().indexOf("https://") != -1) {
            var id = videoInp.val().replace("https://www.youtube.com/watch?v=", "").replace("https://youtu.be/", "").split("?");
            if (id[0].length == 0) {
                return;
            }
            var p = sOverlay($("#lui_scroller"));
            $.getJSON('https://www.googleapis.com/youtube/v3/videos?part=snippet,contentDetails&id=' + id[0] + '&key=AIzaSyBNZlUiTOGWeTzZL58mgL7MWFReluzbQM0', function(data){
                videoInp.data("value", videoInp.val());
                if (data.items != undefined && data.items.length) {
                    $.each(data.items, function(k, item) {
                        var snippet = item.snippet;
                        $('.lui_tab_links__item__ru input[type="checkbox"]').click();
                        $("#video_ru_title").val(snippet.title);
                        $.getJSON(sf_prefix + "/uploader?key=video&url=" + snippet.thumbnails.standard.url, function(response) {
                            var div = '<div class="uploader_preview__item test_item" data-val="' + response.filename + '"><span title="Удалить файл" class="uploader_preview__item_close" onclick="$(this).parent().remove();liteUploader_updateVal_news_events_image_(event);">×</span>' + response.preview.replace('<img', '<img onclick="ftm.init(\'item\', this);" height="100"') + '</div>';
                            $('#video_cover___uploader_preview').html(div).show();
                            $('#video_cover_').val(response.filename);
                        });
                    });
                }
            });
        }
    });
</script>