Last active
October 16, 2017 23:17
-
-
Save Andersama/a534ce641758c164b5ee97101ddbb220 to your computer and use it in GitHub Desktop.
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
/*Takes an array of hh:mm:ss formatted text and returns a floating point value where 1.0 represents a full day*/ | |
function durationToFloat(durations){ | |
return durations.map(function(t){ | |
/*hh:mm:ss*/ | |
var segments = t.split(":"); | |
//24:60:60 | |
//24:1440:86400 | |
return (parseInt(segments[0],10) / 24) + (parseInt(segments[1],10) / (1440) ) + (parseInt(segments[2],10) / (86400)); | |
}); | |
} | |
/*If for some reason floating point values aren't allowed represent the duration as a number of seconds 86400 represents a full day*/ | |
function durationToInt(durations){ | |
return durations.map(function(t){ | |
/*hh:mm:ss*/ | |
var segments = t.split(":"); | |
//24:60:60 | |
return (parseInt(segments[0],10) * 3600) + (parseInt(segments[1],10) * 60 ) + (parseInt(segments[2],10) * 1); | |
}); | |
} |
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
/*Grabs duration of videos from youtube, for statistical analysis if you're so inclined (tested on channel pages video tab)*/ | |
/*Select elements*/ | |
var times = document.querySelectorAll(".video-time span"); | |
var vtimes = []; | |
var i = 0; | |
/*Create an array from the particular property which actually has the time*/ | |
for ( t of times ) { | |
vtimes[i] = t.innerHTML; | |
i++; | |
}; | |
var formatted = vtimes.map(function(t){ | |
if(t.split(":").length-1 == 1){ | |
return "00:"+t; | |
} else { | |
return t; | |
} | |
}); | |
/*Output so we can copy/paste into excel*/ | |
/*Formatted as rows?*/ | |
var excelcol = formatted.join("\n"); | |
/*Formatted as columns?*/ | |
var excelrow = formatted.join("\t"); | |
/*Doing this through console so this will spit out the text*/ | |
excelcol; | |
excelrow; | |
/*Copy Paste As Required*/ |
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
/*Grabs titles of videos from youtube (tested on channel pages video tab)*/ | |
/*Select elements*/ | |
var titles = document.querySelectorAll(".yt-lockup-title a"); | |
var vtitles = []; | |
var i = 0; | |
/*Create an array from the particular property which actually has the time*/ | |
for ( t of titles ) { | |
vtitles[i] = t.innerHTML; | |
i++; | |
}; | |
/*...we don't need to do any weird formatting, we've already got the title...*/ | |
var formatted = vtitles.map(function(t){ | |
return t; | |
}); | |
/*Output so we can copy/paste into excel*/ | |
/*Formatted as rows?*/ | |
var excelcol = formatted.join("\n"); | |
/*Formatted as columns?*/ | |
var excelrow = formatted.join("\t"); | |
/*Doing this through console so this will spit out the text*/ | |
excelcol; | |
excelrow; | |
/*Copy Paste As Required*/ |
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
/*Grabs view count of videos from youtube, for statistical analysis if you're so inclined (tested on channel pages video tab)*/ | |
/*Select elements*/ | |
var views = document.querySelectorAll(".yt-lockup-meta-info li:nth-child(2)"); | |
var vviews = []; | |
var i = 0; | |
/*Create an array from the particular property which actually has the time*/ | |
for ( v of views ) { | |
vviews[i] = v.innerHTML; | |
i++; | |
}; | |
var formatted = vviews.map(function(v){ | |
return parseInt(v,10); | |
}); | |
/*Output so we can copy/paste into excel*/ | |
/*Formatted as rows?*/ | |
var excelcol = formatted.join("\n"); | |
/*Formatted as columns?*/ | |
var excelrow = formatted.join("\t"); | |
/*Doing this through console so this will spit out the text*/ | |
excelcol; | |
excelrow; | |
/*Copy Paste As Required*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment