Frank Fiumara
Frank Fiumara

Reputation: 120

YouTube embeds not updating and throwing net::ERR_BLOCKED_BY_CLIENT

The full console log is:

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

This is the function I'm using to pull the latest videos uploaded to embed. It seems like old videos that aren't the latest are still cached and embedded even though I Included the metatags to refresh the cache.

Here's the HTML embedding:

  <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>

Here's the 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' ]
      });
    });

Upvotes: 1

Views: 2973

Answers (1)

Frank Fiumara
Frank Fiumara

Reputation: 120

So for anyone having similar problems, I found somewhat of a solution.
In my case, renaming a new js file with a different name did the trick to force the page to reload js to the new instance.

Upvotes: 1

Related Questions