Last active
August 29, 2015 13:59
-
-
Save brad426/10583873 to your computer and use it in GitHub Desktop.
Download videos from http://theberrics.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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