Skydrive direct link/hot link Hack

Skydrive is free excellent online storage disk from Microsoft, but has some limitation regarding Link sharing and hotlinking a file from the Skydrive, To download a file from Skydrive, you will have to visit Skydrive

To know more about skydrive, Click HereWL-SkyDrive_h_rgb

If you manage to get a direct download link from skydrive download page, It will stop working after one or two days. Because these download links are dynamic. Microsoft wants Skydrive users to visit their website so that they can keep making money from Ad Views and Clicks.

Good thing about this drive is, it is hosted on Microsoft’s Cloud, So it provides you almost 100% up time with unlimited download access i.e No Bandwidth limit and 25GB space.

People have made scripts to track download links, but most of these scripts are hosted on their own server with no service guarantee.

So I wanted to make a workaround to overcome this problem which is reliable and efficient.

I made a simple javascript code which tracks the download link with the help of Yahoo Query Language (YQL) API (A service from YAHOO).

This script is useful for web publishers and bloggers and can be installed on your website or blog in a minute.

Requirements:

  • JQuery
    JQuery is a very popular javascript library and a large number of sites are using it to enhance their site visibility and user Interface. If it is not installed on your blog/Webpage already, just add the below code in the header (i.e anywhere between <head> and </head> tag).
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.0/jquery.min.js"></script>



  • Link Tracker Code

    Below is the link tracker code, add this code anywhere in the head section of your page. If you are using blogger, you can paste this code in a HTML/Javascript Gadget.


<!--Code written by Waqar's Blog--><script type="text/javascript">
function loadLinks(newUrl,url){
$("a[href='"+url+"']").each(function(){
var text = $(this).text();
var replacedcode = '<a href="'+newUrl+'" target="_blank">'+text+'</a>'
$(this).replaceWith(replacedcode);
});}
function getJSONdata(){
$('a[href*="office.live.com"]').each(function(){
var url = $(this).attr('href');
var queryAPI = "http://query.yahooapis.com/v1/public/yql?q=";
var query = "select * from html where url=\""+url+"\" and xpath=\'//div[@id=\"spPreviewContainer\"]/a/@href\'"
var queryFinal = queryAPI+encodeURI(query+"&format=json&callback=");
$.getJSON(queryFinal, function(json){
if (json.query.results == null) newUrl = "http://skydlpage.blogspot.com/p/missing-link.html";
else newUrl = json.query.results.a.href;
loadLinks(newUrl,url);});});}
$(document).ready(function(){
getJSONdata();});
</script>

Well, here is a video to guide you through the installation. Though I have shown it on blogger blog, it can be used with any webpage, blog service or CMS.




Note: This code will not work for files having extensions doc, docx, ppt, xls or any MS Office file extesion. To use with such files, first zip it and then upload to Skydrive.



After installation, you can start posting Skydrive links on your Blog. Make sure that the link which you are copying from Skydrive is public and correct.


Your copied link will look something like this.

http://cid-xxxxxxxxxxxxxxxxxxx.office.live.com/self.aspx/path to your file/filename with extension


E.g Links


http://cid-d6d439ce1b0b8393.office.live.com/self.aspx/Waqar%5E4s%20Blog/Direct%20link%20demo%20files/demo.pdf

http://cid-d6d439ce1b0b8393.office.live.com/self.aspx/Waqar%5E4s%20Blog/Direct%20link%20demo%20files/demo.zip

If you post a wrong link, it will just redirect you to an error page.
Please let me know through your comments, if you find any bug or want to tell other modification/suggessions.

Here I list two blogs which are using this code to stream their MP3 files, directly from Skydrive. In next post, I’ll post a vide which will guide you to integrate Yahoo Media Player with Skydrive to play your Media Files on your page: