Skip to content

Instantly share code, notes, and snippets.

@yohanboniface
Last active September 5, 2016 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yohanboniface/5527e1c1e3f0c45314c31f139a51729c to your computer and use it in GitHub Desktop.
Save yohanboniface/5527e1c1e3f0c45314c31f139a51729c to your computer and use it in GitHub Desktop.
Generating thumbnails for ideascube

Creating the pdf thumbnails:

for file in *.pdf; do evince-thumbnailer -s 400 $file $file.png; done

Creating the mp4 thumbnails:

for file in *.mp4; do totem-video-thumbnailer -rs 400 $file $file.png; done
# This adds the "preview" column to the CSV
# Plus do some cleaning I've needed last time.
import csv
with open('/path/to/source.csv') as source:
with open('/path/to/destination.csv', 'w') as dest:
rows = csv.DictReader(source)
dest = csv.DictWriter(dest, fieldnames=rows.fieldnames + ['preview'])
dest.writeheader()
for row in rows:
path = row['path']
path = path.split('\\')[-1]
path = path.replace(' ', '_')
path = path.replace('(', '')
path = path.replace(')', '')
path = path.replace(',', '')
path = path.replace('&', '')
path = path.replace('?', '')
path = path.replace('؟', '')
path = path.replace('’', '')
path = path.replace('#', '')
path = path.replace('–', '')
path = path.replace('ّ', '')
row['path'] = path
if row['kind'] == 'mp4':
row['kind'] = 'video'
if row['kind'] in ('pdf', 'video'):
row['preview'] = path + '.png'
dest.writerow(dict(row))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment