However, we need to watch our ISP data quota. We're on a plan with a generous off peak quota, but the off peak period is 1am to 7am. Since iTunes has no scheduling facility this generally involves me getting up in the middle of the night at some point. I've seen a few recipes on the net to work around this, but they all seem cumbersome and/or baroque. Now I have a better way.
I wrote a small helper script called itunes which can tell an open iTunes app to commence a download. It also has a command to fetch a list of the currently selected media items from an open iTunes.
Combined, my workflow is now as follows:
- Open iTunes.
- Locate the items to download and select them, or some of them.
- From a shell, issue the command:
itunes download selected
- Check back in the morning.
The nitty gritty:
The scheduling: my laptop's crontab includes these lines:
30 1 * * * . $HOME/.profile; flag ISP_OFF_PEAK 1
30 6 * * * . $HOME/.profile; flag ISP_OFF_PEAK 0
which turn on and off the ISP_OFF_PEAK
flag, a persistent boolean value maintained by my flag script.
The itunes
helper script waits for a particular flag state before issuing the download request: the defaults are ROUTE_DEFAULT ISP_OFF_PEAK !DOWNLOAD_DISABLE
.
The ROUTE_DEFAULT
flag is maintained by some other automation I run, and is true when the laptop has a default route, which I use to infer that it is online, with access to the internet.
The ISP_OFF_PEAK
is maintained by cron as described above.
The DOWNLOAD_DISABLE
flag is entirely notional; I could set it to true to prevent downloads happening during the night.
No comments:
Post a Comment