YouTube 嵌入不更新和抛出 net::ERR_BLOCKED_BY_CLIENT

YouTube embeds not updating and throwing net::ERR_BLOCKED_BY_CLIENT

完整的控制台日志是:

base.js:1053 POST https://www.youtube.com/youtubei/v1/log_event?alt=json&key=... net::ERR_BLOCKED_BY_CLIENT.

这是我用来提取最新上传的视频以嵌入的功能。 似乎不是最新的旧视频仍然被缓存和嵌入,即使我 包含用于刷新缓存的元标记。

这是 HTML 嵌入:

  <div class="frame">
    <iframe class="latestVideoEmbed" vnum='0' cid="UC2_qY3K5w_BPM4uxeBzbuPw" width="600" height="340" frameborder="0"allowfullscreen="allowfullscreen"></iframe>
    <iframe class="latestVideoEmbed" vnum='1' cid="UC2_qY3K5w_BPM4uxeBzbuPw" width="600" height="340" frameborder="0"allowfullscreen="allowfullscreen"></iframe>
    <iframe class="latestVideoEmbed" vnum='2' cid="UC2_qY3K5w_BPM4uxeBzbuPw" width="600" height="340" frameborder="0"allowfullscreen="allowfullscreen"></iframe>
    <iframe class="latestVideoEmbed" vnum='3' cid="UC2_qY3K5w_BPM4uxeBzbuPw" width="600" height="340" frameborder="0"allowfullscreen="allowfullscreen"></iframe>
    <iframe class="latestVideoEmbed" vnum='4' cid="UC2_qY3K5w_BPM4uxeBzbuPw" width="600" height="340" frameborder="0"allowfullscreen="allowfullscreen"></iframe>
    <iframe class="latestVideoEmbed" vnum='5' cid="UC2_qY3K5w_BPM4uxeBzbuPw" width="600" height="340" frameborder="0"allowfullscreen="allowfullscreen"></iframe>
    </div>
</div>

这是Javascript:

$(window).load(function(){
  new WOW().init();
  var reqURL = "https://api.rss2json.com/v1/api.json?rss_url=" + encodeURIComponent("https://www.youtube.com/feeds/videos.xml?channel_id=");
function loadVideo(iframe) {
  $.getJSON(reqURL + iframe.getAttribute('cid'),
    function(data) {
      var videoNumber = (iframe.getAttribute('vnum') ? Number(iframe.getAttribute('vnum')) : 0);
      console.log(videoNumber);
      var link = data.items[videoNumber].link;
      id = link.substr(link.indexOf("=") + 1);
      iframe.setAttribute("src", "https://youtube.com/embed/" + id + "?modestbranding=0&autohide=0&showinfo=1controls=1&autoplay=0");
    }
  );
}
var iframes = document.getElementsByClassName('latestVideoEmbed');
for (var i = 0, len = iframes.length; i < len; i++) {
  loadVideo(iframes[i]);
}
  setTimeout(function(){

  $('#preloader').fadeOut(); // set duration in brackets
}, 4000);
});
    $(function() {
      $('body').vegas({

        slides: [
          { src: 'images/bg02.jpg' },
          { src: 'images/bg03.jpg' },
          { src: 'images/first.jpg' }

        ],
        overlay: 'images/07.png',
        timer: false,
        transition: [ 'fade' ]
      });
    });

因此,对于遇到类似问题的任何人,我找到了一些解决方案。
在我的例子中,用不同的名称重命名一个新的 js 文件可以强制页面将 js 重新加载到新实例。