Transferring podcasts automatically #podcast
I found that I often went through the same ritual:
- Plug the phone in
- Run hpodder
- Open ~/sound/podcasts/
- If there are any podcasts waiting to be transferred, open the phone's Podcast folder and move them there.
I wonder how people do this seamlessly.
The first thing I did, quite a while ago, was to avoid the "Run hpodder" step.
I set up downloading podcasts - with hpodder to ~/sound/podcasts/ - to happen automatically when my desktop machine is booted:
@reboot sleep 60s; (/usr/bin/hpodder > /dev/null)
And at regular times during the day, sort of before I expect to plug in my phone:
0 17,18,22 * * * /usr/bin/hpodder > /dev/null
Now today I got annoyed about the remaining two needlessly manual steps:
- Open ~/sound/podcasts/
- If there are any podcasts waiting to be transferred, open the phone's Podcast folder and move them there.
What to do... Hm, first I created a script that looks on the harddisk to see if there are any podcasts waiting to be moved to the phone. If there are, it checks to see if the phone happens to be connected, and if so, the podcasts are transferred and the playlist is updated.
First step then is to have that run after each invocation of hpodder. Easily done; have cron call run_hpodder which in turn just runs hpodder and then transfer_podcasts.
Fine, now every time the machine has fetched podcasts it checks for phone presence and moves them over.
But that only gives any benefit if the phone happens to be connected at one of those times...
If I could run transfer_podcasts when the phone is connected, then the combination would solve the problem.
The Gnome System → Preferences → Removable Drives and Media-thing allows you to configure programs to run when certain devices appear, but - alas - not when a new disk appears (which is what the phone looks like).
Enter incron - just adding a IN_CREATE watch on /media/ and then running transfer_podcasts ought to do the trick:
/media/ IN_CREATE /home/asjo/bin/transfer_podcasts
Hm. It does indeed run when a new folder appears in /media/, but the folder is created and then the phone is mounted - enough time for transfer_podcasts to win the race and not see the destination. Meh.
Okay, the ugly solution: add --sleep 2 to transfer_podcasts, so it'll just wait a little bit and hopefully avoid the race condition.
Et voilà .
Add comment
How to in excruciating detail…
To avoid spam many websites make you fill out a CAPTCHA, or log in via an account at a corporation such as Twitter, Facebook, Google or even Microsoft GitHub.
I have chosen to use a more old school method of spam prevention.
To post a comment here, you need to:
- Configure a newsreader¹ to connect to the server
- Open the newsgroup called
¹ Such as Thunderbird, Pan, slrn, tin or Gnus (part of Emacs).koldfront.dk
on port1119
using nntps (nntp over TLS).lantern.koldfront
and post a follow up to the article.Or, you can fill in this form: