Last active
July 20, 2020 10:11
-
-
Save JavierCane/4901f43de90c9e05224a76f24b602238 to your computer and use it in GitHub Desktop.
JavaScript statement to copy all Vimeo video titles and links while in the managing page
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
{ | |
// 👍 Videos folder in grid view (with video duration) | |
const videosInGridView = Array.from(document.querySelectorAll(".sc-jWBwVP")).reverse(); | |
const videoSummaries = videosInGridView.map(function (video) { | |
const videoLink = video.querySelector("h4 > a"); | |
const videoTitle = videoLink.getAttribute("title"); | |
const videoUrl = 'https://vimeo.com' + videoLink.getAttribute("href").replace('/settings', ''); | |
const videoDuration = video.querySelector("p.sc-brqgnP").innerHTML; | |
return videoTitle + ' (' + videoDuration + ')' + ': ' + videoUrl; | |
}); | |
copy(videoSummaries.sort().join("\r\n")); | |
console.log("🎉 Summary of video titles, duration, and URLs copied to your clipboard."); | |
const videoDurationsInMinutes = videosInGridView.map(function (video) { | |
const videoDuration = video.querySelector("p.sc-brqgnP").innerHTML; | |
const videoDurationSplit = videoDuration.split(':'); | |
const videoDurationMinutes = parseInt(videoDurationSplit[0]); | |
const videoDurationSeconds = parseInt(videoDurationSplit[1]); | |
return videoDurationMinutes + (videoDurationSeconds / 60); | |
}); | |
const videoIds = videosInGridView.map(function (video) { | |
const videoLink = video.querySelector("h4 > a"); | |
return videoLink.getAttribute("href").replace("/settings", "").replace("/", ""); | |
}); | |
const totalMinutes = videoDurationsInMinutes.reduce((a, b) => a + b); | |
const totalTime = Math.floor(totalMinutes / 60) + ':' + Math.ceil(totalMinutes % 60); | |
console.log("Course total time (hours:minutes): "); | |
console.log(totalTime); | |
console.log("Course total vídeos: "); | |
console.log(videosInGridView.length); | |
console.log("Command to generate the thumbnails: "); | |
console.log("./subscribe/app/bin/console generate-vimeo-thumbnails " + videoIds.join(" ")); | |
} |
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
{ | |
// 👎 Videos folder in list view (without video duration) | |
const videosInListView = $($('a.l-ellipsis').get().reverse()) | |
.map(function () { | |
return $(this).attr('title') + ': https://vimeo.com' + $(this).attr('href').replace('/settings', '') | |
}) | |
.get() | |
.join("\r\n") | |
copy(videosInListView) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment