download and play audio podcasts on raspberrypi [raspberrypi,android]

updated 16.3.17

based on:
http://strobelstefan.org/?p=4618
https://github.com/chessgriffin/mashpodder
http://www.linuxdoc.org/HOWTO/Bash-Prog-Intro-HOWTO.html
http://bingin.de/~bschiffner/bash2/content.html

requires a mpd installation:
https://fredfire1.wordpress.com/2013/08/16/install-mpd-raspberry-pi/

requires that you have installed git-core:
sudo apt install git-core -y

install podcastdownloader mashpodder:
mkdir -p /var/lib/mpd/music
cd /var/lib/mpd/music
git clone https://github.com/chessgriffin/mashpodder.git
cd ./mashpodder
nano mashpodder.sh

search with ctrl+w for “basedir=” and change it to:
BASEDIR=”/var/lib/mpd/music/mashpodder”
exit and save the file with pressing ctrl+x ->y ->enter

edit the mashpodder config file:
nano /var/lib/mpd/music/mashpodder/mp.conf
and paste your new feed at the end:

http://www1.wdr.de/radio/podcasts/1live/dennis126.podcast date 1
http://www1.wdr.de/radio/podcasts/1live/noobundnerd106.podcast date 1
http://www1.wdr.de/radio/podcasts/1live/otoncharts124.podcast date 1
http://www1.wdr.de/radio/podcasts/1live/tonymono102.podcast date 1
http://www1.wdr.de/radio/podcasts/1live/jesusineinslive100.podcast date 1
http://www1.wdr.de/radio/podcasts/1live/planbreportage100.podcast date 1
http://www1.wdr.de/radio/podcasts/wdr2/tipps_trends100.podcast date 1
http://www1.wdr.de/radio/podcasts/wdr2/quintessenz290.podcast date 1
http://www1.wdr.de/radio/podcasts/wdr2/klartext122.podcast date 1
http://www1.wdr.de/radio/podcasts/wdr4/zursache104.podcast date 1
http://www1.wdr.de/radio/podcasts/wdr5/dokfuenf140.podcast date 1
http://www1.wdr.de/radio/podcasts/wdr5/service_computer100.podcast date 1
http://www1.wdr.de/radio/podcasts/wdr5/mythen100.podcast date 1
http://www1.wdr.de/radio/podcasts/wdr5/leonardo302.podcast date 1
http://www1.wdr.de/radio/podcasts/wdr5/toene_texte_bilder102.podcast date 1
http://www1.wdr.de/radio/podcasts/wdr2/kabarett132.podcast date 1
http://www1.wdr.de/radio/podcasts/wdr2/zugabe150.podcast date 1

exit and save the file with pressing ctrl+x ->y ->enter

make a script for adding the downloaded files to the playlist:
nano /var/lib/mpd/music/mashpodder/add_musicpods.sh

#!/bin/bash
mpc add mashpodder/podcasts/$(( $(date +"%s") / 3600 / 24))

make the script executeable:
chmod +x /var/lib/mpd/music/mashpodder/add_musicpods.sh

you can manually test it with:
/var/lib/mpd/music/mashpodder/mashpodder.sh
mpc update
/var/lib/mpd/music/mashpodder/add_musicpods.sh

use an android phone with the mpdroid-app to remote control play your audio podcasts on the raspberrypi.
https://play.google.com/store/apps/details?id=com.namelessdev.mpdroid

edit the crontab to check automatic for new podcasts:
crontab -e
and add at the end the line:

0 7 * * * /var/lib/mpd/music/mashpodder/mashpodder.sh && mpc update --wait && /var/lib/mpd/music/mashpodder/add_musicpods.sh

Now mashpodder will check everyday at 7 o’clock in the morning for new podcasts, download and add them to the playlist.

clean old files by hand:
cd /var/lib/mpd/music/mashpodder/podcasts && rm -r xxx* && mpc update

Clean old podcasts automatic after a week

nano /var/lib/mpd/music/mashpodder/podcasts/clean_folders_older_than_7days.sh

#!/bin/bash
declare -i days_until_del
days_until_del=7
(clean up after a week)

declare -i today
today=$(( $(date +"%s") / 3600 / 24))

declare -i del_date
del_date=$(($today - $days_until_del))

function date_dif {
	if [ $1 -lt $del_date ]
#ยง1 < today -x
#folder_date < del_date
	then
		rm -r "/var/lib/mpd/music/mashpodder/podcasts/$1"
	fi
	}
find /var/lib/mpd/music/mashpodder/podcasts/ -mindepth 1 -maxdepth 1 -type d -printf '%f\n'  | sed 's|^\./||g' >> /var/lib/mpd/music/mashpodder/podcasts/log.txt #get foldernames
while read line; do date_dif  $line; done < /var/lib/mpd/music/mashpodder/podcasts/log.txt
rm /var/lib/mpd/music/mashpodder/podcasts/log.txt  

make the script executeable:
chmod +x /var/lib/mpd/music/mashpodder/podcasts/clean_folders_older_than_7days.sh

nano /var/lib/mpd/music/mashpodder/mashpodder.sh
replace $(date +$DATESTRING) with $(( $(date +”%s”) / 3600 / 24)) in the whole file

change the crontab-line:
crontab -e

0 7 * * * /var/lib/mpd/music/mashpodder/podcasts/clean_folders_older_than_7days.sh && /var/lib/mpd/music/mashpodder/mashpodder.sh && mpc update --wait && /var/lib/mpd/music/mashpodder/add_musicpods.sh
Advertisements

3 thoughts on “download and play audio podcasts on raspberrypi [raspberrypi,android]

  1. Not Pi related, but after using mashpodder for quite sometime, it no longer downloads any podcasts. When I run the script via CLI, each podcast checked has the same result (this being the last one in my list):

    Checking http://feeds.feedburner.com/thebuglefeed — last 1 episodes.
    ERROR: cannot parse any episodes in
    http://feeds.feedburner.com/thebuglefeed. Skipping.

    Cleaning up.
    Total downloads: 0
    All done.

    I’ve checked each download link and they’re all valid. I’m at a loss and can find virtually zero mention of this parsing error (or even what it means) online, hence my imposing on you for any insight.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s