Skip to content

Instantly share code, notes, and snippets.

@brad426
Last active August 29, 2015 13:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save brad426/10583873 to your computer and use it in GitHub Desktop.
Save brad426/10583873 to your computer and use it in GitHub Desktop.
Download videos from http://theberrics.com
var urlBase = 'http://berrics.vo.llnwd.net/o45/';
var url, videoName;
// Video listing pages
var videoListingPageEl = $('div[data-media-file-id]').each(function(){
var videoContainerDiv = $(this);
videoName = videoContainerDiv.data('media-file-id');
url = urlBase + videoName + '.mp4';
buildDownlodBtn( url, videoContainerDiv.parent() );
});
// Single video page
if(videoListingPageEl.length === 0) {
var key = 'media-file-div-';
var videoContainer = $('div[id^="' + key + '"]').first();
var videoContainerID = videoContainer.attr('id');
var wrapperIndex = videoContainerID.indexOf('_wrapper');
videoName = videoContainerID.substr(key.length, wrapperIndex - key.length);
url = urlBase + videoName + '.mp4';
buildDownlodBtn( url, videoContainer.parent() );
}
function buildDownlodBtn( url, container ) {
var downloadBtn = $('<a>')
.attr('href', url)
.attr('style', 'font-family:Helvetica; font-weight:bold; font-size:12px;')
.addClass('btn download-btn')
.html('download')
.appendTo( container );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment