Skip to content

Instantly share code, notes, and snippets.

@njbotkin
Last active January 25, 2018 04:46
Show Gist options
  • Save njbotkin/6d75061226b351e506b95cc9bbbd3bcf to your computer and use it in GitHub Desktop.
Save njbotkin/6d75061226b351e506b95cc9bbbd3bcf to your computer and use it in GitHub Desktop.
Download DCC sermons in bulk

DCC bulk download bookmarklet

Limitations

Doesn't work in Firefox. Use in Chrome.

Instructions

Create a bookmark with the contents of DCC-bulk-download-bookmarklet.js

Whenever you want to download some or all of a sermon series:

  1. Open http://www.dominioncovenantchurch.com/sermons/
  2. Click [Show Filter], and choose the series
  3. Look in the URL. In the query string you will see ?series=[series_number]
  4. Go to http://www.dominioncovenantchurch.com/?podcast&series=[series_number]
  5. Click the bookmarklet. It'll open up a window where you can select the sermons you want to download. When you click 'download', your browser will ask you if you want to allow the site to download multiple files. Say yes.

Credits

Heavily inspired by ArtskydJ

Bookmarklet generated at https://jadengore.github.io/bookmarkleter/ (ES6 compatible!)

javascript:%22use%20strict%22;(function(){function%20e(e){var%20t=document.createElement(%22textarea%22);return%20t.innerHTML=e,t.value}var%20t=document.body.innerText.match(/%3Citem%3E[\s\S]*%3F%3C\/item%3E/g).reverse().reduce(function(t,c,n){var%20l=(%2200%22+(n+1)).slice(-3),a=e(c.match(/%3Ctitle%3E(%3F:[^%3C]+)%3F%3C\/title%3E/g).pop().slice(7,-8)),o=c.match(/%3Cenclosure%20url=%22([^%22]+)%22/).pop().replace(%22%26amp;%22,%22%26%22),i=new%20Date(c.match(/%3CpubDate%3E([^%3C]+)%3C\/pubDate%3E/g).pop().slice(9,-10)).toISOString().split(%22T%22)[0],r=l+%22_%22+i+%22_%22+a;return%20t+='%3Cdiv%3E%3Cinput%20type=%22checkbox%22%20checked%3E%26nbsp;%26nbsp;%3Ca%20href=%22'+o+'%22%20download=%22'+r+'.mp3%22%3E'+r+%22%3C/a%3E%3C/div%3E%22},%22%22),c=document.createElement(%22script%22);c.innerHTML='function%20setAll(bool)%20{Array.prototype.slice.call(document.getElementsByTagName(%22input%22)).forEach(e%20=%3E%20{e.checked%20=%20bool})}function%20clickAll()%20{Array.prototype.slice.call(document.getElementsByTagName(%22div%22)).forEach(e%20=%3E%20{if(e.getElementsByTagName(%22input%22)[0].checked)%20{var%20a%20=%20e.getElementsByTagName(%22a%22)[0];a.click()}})}',document.head.appendChild(c),document.body.innerHTML='%3Cbutton%20onclick=%22setAll(true)%22%3ESelect%20all%3C/button%3E%20%3Cbutton%20onclick=%22setAll(false)%22%3EDeselect%20all%3C/button%3E%20%3Cbutton%20onclick=%22clickAll()%22%3EDownload%3C/button%3E%3Cbr/%3E%3Cbr/%3E'+t})();
(()=> {
function decodeHtml(html) {
var txt = document.createElement("textarea");
txt.innerHTML = html;
return txt.value;
}
var links = document.body.innerText.match(/<item>[\s\S]*?<\/item>/g).reverse().reduce((l,m,i)=>{
var number = ('00' + (i+1)).slice(-3)
var title = decodeHtml(m.match(/<title>(?:[^<]+)?<\/title>/g).pop().slice(7,-8))
var url = m.match(/<enclosure url="([^"]+)"/).pop().replace('&amp;', '&')
var date = new Date(m.match(/<pubDate>([^<]+)<\/pubDate>/g).pop().slice(9,-10)).toISOString().split('T')[0]
var name = number + '_' + date + '_' + title
return l += '<div><input type="checkbox" checked>&nbsp;&nbsp;<a href="'+url+'" download="'+name+'.mp3">'+ name +'</a></div>'
}, '')
var script = document.createElement("script");
script.innerHTML = ''+
'function setAll(bool) {'+
'Array.prototype.slice.call(document.getElementsByTagName("input")).forEach(e => {'+
'e.checked = bool'+
'})'+
'}'+
'function clickAll() {'+
'Array.prototype.slice.call(document.getElementsByTagName("div")).forEach(e => {'+
'if(e.getElementsByTagName("input")[0].checked) {'+
'var a = e.getElementsByTagName("a")[0];'+
'a.click()'+
'}'+
'})'+
'}'
document.head.appendChild(script)
document.body.innerHTML = '<button onclick="setAll(true)">Select all</button> <button onclick="setAll(false)">Deselect all</button> <button onclick="clickAll()">Download</button><br/><br/>'+links
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment