Created
June 24, 2022 18:16
-
-
Save edgardleal/7bccf44bffe1eaf73edf1d602b6ab0d4 to your computer and use it in GitHub Desktop.
Download gravatar user images from a git repository folder to be used with gource
This file contains hidden or 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
const fs = require('fs'); | |
const path = require('path'); | |
const shelljs = require('shelljs'); | |
const crypto = require('crypto'); | |
const size = 90; | |
const output_dir = '.git/avatar'; | |
shelljs.mkdir('-p', output_dir); | |
const log_command = 'git log --pretty=format:"%ae|%an"'; | |
const logResult = shelljs.exec(log_command, { silent: true }); | |
const logs = Array.from(new Set(logResult.stdout.split(/[\n\r]/).sort())); | |
console.log('Found %d users', logs.length); // eslint-disable-line | |
for (let i = 0; i < logs.length; i += 1) { | |
const item = logs[i]; | |
const [email, name] = item.split('|'); | |
const imagePath = path.join(__dirname, output_dir, `${name}.png`); | |
if (fs.existsSync(imagePath)) { | |
continue; | |
} | |
const emailHash = crypto.createHash('md5').update(email).digest('hex'); | |
const grav_url = `http://www.gravatar.com/avatar/${emailHash}?d=404&size=${size}`; | |
console.log('Downloading %s', email); // eslint-disable-line | |
const result = shelljs.exec(`wget --output-document='${imagePath}' ${grav_url}`, { silent: true }); | |
if (result.stderr.indexOf('ERROR 404') > -1) { | |
shelljs.exec(`rm '${imagePath}'`); | |
} | |
shelljs.exec('sleep 1'); | |
} | |
const gourceCommand = `gource \ | |
-s 2 \ | |
-1280x720 \ | |
--auto-skip-seconds .1 \ | |
--multi-sampling \ | |
--stop-at-end \ | |
--key \ | |
--highlight-users \ | |
--date-format "%d/%m/%y" \ | |
--hide mouse,filenames \ | |
--file-idle-time 0 \ | |
--max-files 0 \ | |
--background-colour 000000 \ | |
--font-size 25 --user-image-dir ${output_dir} | |
` | |
console.log('%s', gourceCommand); // eslint-disable-line |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Based on this pearl script: https://code.google.com/archive/p/gource/wikis/GravatarExample.wiki