|
1 | | -# Most possible unattended rip workflow |
| 1 | +# Most Possible Unattended Rip Workflow |
2 | 2 |
|
3 | | -This is a script that allows you to quickly rip a large collection of audio cd's only with the minimum of manual intervention: __insert cd - remove cd__! |
| 3 | +This project allows you to quickly rip a large collection of audio CD's only with the minimum of manual intervention: __insert cd - remove cd__ |
4 | 4 |
|
5 | 5 | ## Structure |
6 | 6 |
|
7 | | -This project comprises three parts: |
| 7 | +This project comprises two components: |
8 | 8 |
|
9 | | -1. A __shell script__: |
10 | | - - rip a cd with [whipper](https://github.com/JoeLametta/whipper) (fka. morituri) with a very low cpu and storage usage priority |
11 | | - - fall back to abcde if that fails |
12 | | - - automatic atgging and naming |
13 | | - - grab the cover art |
14 | | - - eject the cd |
| 9 | +1. A shell script for the actual process: |
15 | 10 |
|
16 | | -2. (optional) A __udev rule__ to automatically run the shell script when a cd is being inserted. |
| 11 | + - riping, tagging and naming a CD using [whipper](https://github.com/JoeLametta/whipper) |
| 12 | + - grab the cover art using [beets](http://beets.io/) |
| 13 | + - eject the CD |
17 | 14 |
|
18 | | -3. (optional) A __config file__ which lets you do some decision regarding the shell script. |
19 | | - |
20 | | -All steps within the script are well documented which makes it easy to customize it to any special needs. Furthermore this makes it easy for beginners to understand each step. |
| 15 | +2. (optional) __UDEV Integration__: A UDEV rule to automatically run the shell script when a CD is being inserted. |
21 | 16 |
|
22 | 17 | ## Installation |
23 | 18 |
|
24 | | -1. Simply download the shell script and give it the executable flag: |
25 | | - |
26 | | - `wget https://github.com/thomas-mc-work/most-possible-unattended-rip/auto-rip-audio-cd.sh && chmod +x auto-rip-audio-cd.sh` |
27 | | - |
28 | | - 1b. If you like to use have the script grabbing the cover for you then you need to install [beets](http://beets.io/) (`pip install beets`) and place a special config only for the cover grabbing process into `$HOME/.config/beets/config.albums-cover.yaml`: |
29 | | - |
30 | | - import: |
31 | | - copy: no |
32 | | - write: no |
33 | | - |
34 | | - plugins: fetchart |
| 19 | +First you need to download and extract the project: |
| 20 | + |
| 21 | + curl -L https://github.com/thomas-mc-work/most-possible-unattended-rip/archive/master.tar.gz | tar xz |
| 22 | + cd most-possible-unattended-rip-master |
| 23 | + |
| 24 | +### Docker |
| 25 | + |
| 26 | +At the moment it's required to build the whipper image yourself as the official Docker support is not yet integrated (https://github.com/JoeLametta/whipper/pull/237). |
| 27 | + |
| 28 | + git clone https://github.com/thomas-mc-work/whipper.git |
| 29 | + cd whipper |
| 30 | + git checkout -b dockerfile |
| 31 | + docker build -t whipper/whipper . |
| 32 | + # remove the sources again |
| 33 | + cd .. |
| 34 | + rm -rf whipper |
| 35 | + |
| 36 | +#### Build The Image |
| 37 | + |
| 38 | + docker build -t tmcw/mpur . |
| 39 | + |
| 40 | +#### Run The Container |
| 41 | + |
| 42 | + [ ! -d config ] && mkdir config |
| 43 | + [ ! -d logs ] && mkdir logs |
| 44 | + [ ! -d output ] && mkdir output |
| 45 | + |
| 46 | + docker run --rm \ |
| 47 | + --device=/dev/cdrom \ |
| 48 | + -v "${PWD}/config":/home/worker/.config/whipper \ |
| 49 | + -v "${PWD}/logs":/logs \ |
| 50 | + -v "${PWD}/output":/output \ |
| 51 | + tmcw/mpur |
| 52 | + |
| 53 | +### Native |
| 54 | + |
| 55 | + # Mark the script executable |
| 56 | + chmod +x auto-rip-audio-cd.sh |
| 57 | + # Install beets via pip |
| 58 | + pip install --user beets |
| 59 | + # Add the beets configuration |
| 60 | + curl -Lo "${HOME}/.config/beets/config.albums-cover.yaml https://raw.githubusercontent.com/thomas-mc-work/most-possible-unattended-rip/master/beets.yml |
| 61 | + |
| 62 | +Now you can simply execute the script after inserting th audio CD: |
| 63 | + |
| 64 | + ./auto-rip-audio-cd.sh |
35 | 65 |
|
36 | | -2. (optional) Add a udev rule to automatically trigger the script: |
| 66 | +### UDEV Integration |
37 | 67 |
|
38 | | - `echo "SUBSYSTEM==\"block\", SUBSYSTEMS==\"scsi\", KERNEL==\"sr?\", ENV{ID_TYPE}==\"cd\", ENV{ID_CDROM}==\"?*\", ENV{ID_CDROM_MEDIA_TRACK_COUNT_AUDIO}==\"?*\", ACTION==\"change\", RUN+=\"/bin/su -lc '<path-to-script>/auto-rip-audio-cd.sh' <username>\"" | sudo tee 80-audio-cd.rules` |
| 68 | +Add a UDEV rule to automatically trigger the script: |
39 | 69 |
|
40 | | - It's important here to replace `<username>` and `<path-to-script>` with the appropriate values. The script will be run with the according user permissions. This is important to get the correct locale settings in the environment. |
| 70 | + echo "SUBSYSTEM==\"block\", SUBSYSTEMS==\"scsi\", KERNEL==\"sr?\", ENV{ID_TYPE}==\"cd\", ENV{ID_CDROM}==\"?*\", ENV{ID_CDROM_MEDIA_TRACK_COUNT_AUDIO}==\"?*\", ACTION==\"change\", RUN+=\"/bin/su -lc '<path-to-script>/auto-rip-audio-cd.sh' <username>\"" | sudo tee 80-audio-cd.rules |
41 | 71 |
|
42 | | -3. (optional) Download the config file template into your profiles config (`$HOME/.config`) folder: |
| 72 | +Just be sure to substitude the placeholders `<username>` and `<path-to-script>` by the appropriate values. The script will be run with the according user permissions. This is important to get the correct locale settings in the environment. |
43 | 73 |
|
44 | | - `wget https://github.com/thomas-mc-work/most-possible-unattended-rip/auto-rip.cfg -O $HOME/.config/auto-rip.cfg` |
| 74 | +**Config File To Control The UDEV Automatism** |
45 | 75 |
|
46 | | - These options are available: |
| 76 | +Create a config file in your profiles config (`$HOME/.config`) folder: |
| 77 | + |
| 78 | +If you want to use a config file then you're required to create an intermediate shell script that is invoked by the UDEV rule: |
| 79 | + |
| 80 | + #!/usr/bin/env bash |
| 81 | + |
| 82 | + # end previous shutdown if one is active |
| 83 | + sudo shutdown -c |
| 84 | + |
| 85 | + # marker file for skipping the automated ripping |
| 86 | + CONFIG_FILE="${HOME}/.config/auto-rip.cfg" |
| 87 | + |
| 88 | + # include config file |
| 89 | + if [ -f "$CONFIG_FILE" ]; then |
| 90 | + . "$CONFIG_FILE" |
| 91 | + fi |
| 92 | + |
| 93 | + # optionally omit the process by config setting |
| 94 | + if [ "$DISABLED" = 1 ]; then |
| 95 | + echo "# omitting auto rip due to config setting" |
| 96 | + exit 0 |
| 97 | + fi |
| 98 | + |
| 99 | + nice -n 19 ionice -c 3 /path/to/auto-rip-audio-cd.sh |
| 100 | + |
| 101 | + # reread the config file to include a late shutdown decision |
| 102 | + if [ -f "$CONFIG_FILE" ]; then |
| 103 | + . "$CONFIG_FILE" |
| 104 | + fi |
| 105 | + |
| 106 | + # optionally shutdown after a short delay |
| 107 | + if [ "$SHUTDOWN" = 1 ]; then |
| 108 | + echo "# shutting down the system" |
| 109 | + if ! [[ $SHUTDOWN_TIMEOUT =~ ^[0-9]+$ ]]; then SHUTDOWN_TIMEOUT=3; fi |
| 110 | + sudo shutdown -h $SHUTDOWN_TIMEOUT |
| 111 | + fi |
| 112 | + |
| 113 | + |
| 114 | +The config file: |
| 115 | + |
| 116 | + # disable auto ripping? |
| 117 | + DISABLED=0 |
| 118 | + # shutdown after finish? |
| 119 | + SHUTDOWN=0 |
| 120 | + # shutdown timeout in minutes |
| 121 | + SHUTDOWN_TIMEOUT=3 |
| 122 | + |
| 123 | +These options are available: |
47 | 124 |
|
48 | 125 | - `DISABLED={0,1}`: Disable the script. Good if you like listen to some music CDs without instantly ripping them |
49 | 126 | - `SHUTDOWN={0,1}`: You can choose whether to automatically shutdown the system ofter the rip process has finished. This is good e.g. when going to bed and letting the system finish the last CD by itself. For using this you need to have the permission to shutdown the system via the command line. You can achieve this by inserting `%sudo ALL = NOPASSWD: /sbin/shutdown` into `/etc/sudoers`. |
50 | | - - `SHUTDOWN_TIMEOUT=3`: Lets you define the shutdown timeout |
| 127 | + - `SHUTDOWN_TIMEOUT=<value>`: Lets you define the shutdown timeout |
51 | 128 |
|
52 | 129 | ## Links |
53 | 130 |
|
54 | 131 | - [whipper](https://github.com/JoeLametta/whipper) |
55 | 132 | - [good explanations and debug help with udev on arch wiki](https://wiki.archlinux.org/index.php/udev) |
56 | 133 | - [beets](http://beets.io/) |
57 | | -- [abcde best of breed configuration](http://www.andrews-corner.org/linux/abcde/index.html) |
58 | | -- [let abcde grab album art](http://www.andrews-corner.org/linux/abcde/getalbumart.html) |
59 | 134 |
|
60 | | -Any comments, questions or PRs are very welcome! |
| 135 | +--- |
| 136 | + |
| 137 | +**Any comments, questions or PRs are very welcome!** |
0 commit comments