Skip to content

Instantly share code, notes, and snippets.

@sillage
sillage / youtube-dl.sh
Created January 8, 2019 22:26
youtube-dl
# audio
youtube-dl -x --audio-format mp3 --audio-quality 0 --embed-thumbnail --add-metadata -o "%(title)s-%(id)s.%(ext)s" -- URL
# video
youtube-dl -f best -o "%(title)s-%(id)s.%(ext)s" -- URL
#!/bin/bash
# source: https://superuser.com/a/764524
# Managed formats:
# <xmp:CreateDate>2017-07-19T08:53:29Z</xmp:CreateDate>
# <xmp:CreateDate>2017-10-16T12:07:43+02:00</xmp:CreateDate>
# xmp:CreateDate="2013-09-03T17:37:08+02:00"
for f in *.pdf
do
@sillage
sillage / pypi.sh
Last active November 2, 2019 21:40
Upgrade all PyPI packages
#!/bin/sh
for p in $(pip list --outdated | awk -F ' ' 'NR>2{print $1}')
do pip install --upgrade $p
done
#!/bin/sh
while read file;
do
touch -r "${file}" "${file%.flac}.mp3";
done < <(ls *.flac)
@sillage
sillage / flactags.sh
Last active December 23, 2023 18:44
flac tags with metaflac
#!/bin/bash
# file format: ARTIST/ALBUM/01-TITLE.flac
read -p "YEAR? " -n 4 YEAR
ALBUM="${PWD##*/}" # ALBUM=$(basename "${PWD}")
ARTIST=$(echo $(cd .. && echo "${PWD##*/}"))
# delete all
metaflac --preserve-modtime --remove-all-tags *.flac
# artist, album, year and cover
metaflac --preserve-modtime --set-tag=ARTIST="${ARTIST}" --set-tag=ALBUM="${ALBUM}" --set-tag=DATE=${YEAR} --import-picture-from=Folder.jpg *.flac
@sillage
sillage / mp3tags.sh
Last active January 11, 2019 20:25
MP3 tags with eyeD3
#!/bin/bash
# file format: ARTIST/ALBUM/01-TITLE.mp3
read -p "YEAR? " -n 4 YEAR
ALBUM="${PWD##*/}" # ALBUM=$(basename "${PWD}")
ARTIST=$(echo $(cd .. && echo "${PWD##*/}"))
# help: eyeD3 -h
# delete all
eyeD3 --preserve-file-times --remove-all *.mp3
# artist, album, year and cover
eyeD3 --preserve-file-times --v2 --artist "${ARTIST}" --album "${ALBUM}" --release-year ${YEAR} --add-image Folder.jpg:FRONT_COVER *.mp3
@sillage
sillage / jpg2pdf.sh
Last active August 29, 2015 14:19
Convert multiple files to one PDF
#! /bin/sh
brew install imagemagick
convert *.jpg output.pdf
@sillage
sillage / gist:492efe63c553fababa7d
Created April 25, 2015 18:13
curl multiple files with cookies
# "#1" and "#2"are like sed groups
curl url{foo,bar}_[1-42] --output "#1_#2.jpg" --cookie "NAME1=VALUE1;NAME2=VALUE2"
# or
curl url{foo,bar}_[1-42] -o "#1_#2.jpg" -b "NAME1=VALUE1;NAME2=VALUE2"
@sillage
sillage / exifdate.sh
Last active April 7, 2017 20:57
Rename pictures with Exif DateTimeOriginal prefix
#! /bin/sh
# Rename pictures with Exif DateTimeOriginal prefix
# format: YYYYmmdd_HHMMSS_:basename:
exiv2 -r '%Y%m%d_%H%M%S_:basename:' rename $(ls *.JPG *.jpg 2>/dev/null)
# format (Dropbox like): YYYY-mm-dd HH.MM.SS_:basename:
# exiv2 -r '%Y-%m-%d %H.%M.%S_:basename:' rename $(ls *.JPG *.jpg 2>/dev/null)

Creating a two way sync between a Github repository and Subversion

Another git <> svn post?

As many of you know I have been on a quest to get Jetpack core development moved from the WordPress.org Subversion (svn) repository to Github (git). As part of this process I setup an experimental Jetpack repository to see how synchronization works between git and svn. Lets just clear the air right now and say not well, not well at all. This is due to how git and svn each store their respective histories. But! I think I finally have it figure out.

Backfill

I wrote an article a couple months ago entitled Creating a synchronized Github fork of a WordPress.org Subversion plugin repository. This article is great (and still a recommended read) if you are only doing synchronization b