Created
December 1, 2010 19:37
-
-
Save plindberg/724073 to your computer and use it in GitHub Desktop.
Rippa och bränn årets julkalender i Sveriges Radio (på Mac)
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
| #!/bin/bash | |
| BASE_URL=http://sverigesradio.se | |
| ASX_URL=$(curl -Ls ${BASE_URL}'/sida/default.aspx?programid=3023' \ | |
| | sed -e '/button-wrapper.*href=".*type=broadcast/!d' \ | |
| -e 's/^.*a href="//; s/".*$//' \ | |
| | ruby -rcgi -n -e 'puts CGI::unescapeHTML($_)') | |
| M4A_URL=$(curl -s ${BASE_URL}${ASX_URL} \ | |
| | sed -e '/<ref/!d' -e 's/^.*href="//; s/".*$//') | |
| M4A_FILE=/tmp/xmas.m4a | |
| curl -sLo ${M4A_FILE} ${M4A_URL} | |
| MP3_FILE=/tmp/xmas.mp3 | |
| ffmpeg -i ${M4A_FILE} -acodec libmp3lame -ac 2 -ab 128 ${MP3_FILE} \ | |
| -map_meta_data ${MP3_FILE}:${M4A_FILE} | |
| PLAYLIST="Julkalendern 2010" | |
| osascript -e 'on run argv | |
| set playlist_name to item 1 of argv | |
| set m4a_file to POSIX file (item 2 of argv) as alias | |
| tell application "iTunes" | |
| if not (exists playlist playlist_name) then | |
| make new user playlist with properties {name:playlist_name} | |
| end if | |
| add m4a_file to playlist playlist_name | |
| end tell | |
| end run' "${PLAYLIST}" "${MP3_FILE}" | |
| for disk in `diskutil list | egrep '^/dev'`; do | |
| if diskutil info $disk | egrep 'Media Type:.*CD-RW' > /dev/null; then | |
| diskutil eraseOptical quick $disk | |
| fi | |
| done | |
| osascript -e 'on run argv | |
| set playlist_name to item 1 of argv | |
| tell application "iTunes" | |
| activate | |
| set view of front browser window to playlist playlist_name | |
| end tell | |
| tell application "System Events" | |
| tell process "iTunes" | |
| tell menu "File" of menu bar 1 | |
| click menu item "Burn Playlist to Disc" | |
| end tell | |
| end tell | |
| end tell | |
| end run' "${PLAYLIST}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment