Skip to content

Instantly share code, notes, and snippets.

@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 / 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 / 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 / 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
#!/bin/sh
while read file;
do
touch -r "${file}" "${file%.flac}.mp3";
done < <(ls *.flac)
@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/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 / youtube-dl.sh
Last active November 8, 2024 14:24
youtube-dl
# audio
youtube-dl -x --audio-format mp3 --audio-quality 0 --embed-thumbnail --add-metadata -o "%(title)s-%(id)s.%(ext)s" -- URL
yt-dlp -x --audio-format mp3 --audio-quality 0 --embed-thumbnail --add-metadata --metadata-from-title "%(artist)s - %(title)s" -o "%(artist)s - %(title)s - %(id)s.%(ext)s" -- URL
# video
youtube-dl -f best -o "%(title)s-%(id)s.%(ext)s" -- URL
yt-dlp -f best -o "%(title)s-%(id)s.%(ext)s" -- URL