Last active
March 7, 2018 00:15
-
-
Save brikis98/c04ed582d888866cd0e82f455c5e899a to your computer and use it in GitHub Desktop.
Get course summary from Teachable
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 result = $('.section-item .item').get().reduce(function(total, item) { | |
var text = $(item).text().split("\n").join(" "); | |
var matches = /.+\((\d):(\d\d)\)/g.exec(text); | |
var minutes = parseInt(matches[1]); | |
var seconds = parseInt(matches[2]); | |
var totalMin = total[0] + minutes; | |
var totalSec = total[1] + seconds; | |
if (totalSec > 60) { | |
totalMin += 1; | |
totalSec -= 60; | |
} | |
return [totalMin, totalSec] | |
}, [0,0]); | |
console.log($('.section-item .item').size() + " micro videos, " + result[0] + " minutes, " + result[1] + " seconds"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I needed a way to quickly count the number of videos and the total course duration for courses on Teachable. There's no obvious way to find this info in the UI, so I wrote a very hacky JS script to calculate it.
Instructions: