2014-06-24 99 views
0

我正在尋找解決方案來編寫腳本,該腳本會在網站上的嵌入視頻已被刪除或在視頻提供商網站(如Youtube,Vimeo)上刪除時發出警告。在html網站上嵌入視頻鏈接檢查器腳本

我到處尋找,但我無法找到任何有關此主題的解決方案。

+2

您應該檢查API文檔爲每個視頻提供商。他們應該有一些處理代碼。 – Joseph

回答

0

檢查了這一點:

function isURLReal(fullyQualifiedURL) { 
    var URL = encodeURIComponent(fullyQualifiedURL), 
     dfd = $.Deferred(), 
     checkURLPromise = $.getJSON('http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20html%20where%20url%3D%22' + URL + '%22&format=json'); 

    checkURLPromise 
      .done(function(response) { 
       // results should be null if the page 404s or the domain doesn't work 
       if (response.query.results) { 
        dfd.resolve(true); 
       } else { 
        dfd.reject(false); 
       } 
      }) 
      .fail(function() { 
       dfd.reject('failed'); 
      }); 
    }); 

    return dfd.promise(); 
} 

// usage 
isURLReal('http://google.com') 
     .done(function(result) { 
      // yes 
     }) 
     .fail(function(result) { 
      // no, or request failed 
     }); 

全部細節在這裏:StackOverFlowLink

+0

所以,如果我得到它的權利,這是重定向如果URL訪問失敗。 – GABOCSA