Podcast download last programs
RADIO FM -> SUCCHIARE I PODCAST ALTRUI
Vi piace un podcast e lo volete rimandare sulla vostra radio locale fm? Tutti i giorni state a scaricare il file e a sistemarlo in palinsesto? Da oggi non più.
Podcast Download Last Programs (PDLP) è uno script in bash pensato come utility aggiuntiva per Soma (www.somasuite.org).
Questo programma serve alle radio che trasmettono in fm e vogliono rimandare delle trasmissioni che trovano su internet. In sostanza permette di scaricare in modo automatico gli mp3 che vengono via via aggiunti nel feed di un podcast.
Ogni volta che viene lanciato PDLP verifica se sono stati aggiunti dei nuovi link mp3 e in questo caso li scarica.
La prima volta che controlla un determinato feed scarica soltanto il file mp3 più recente, crea un archivio locale di sincronizzazione e da quel momento aggiorna i dati locali. Per ogni feed PDLP tiene un archivio locale di sincronizzazione separato.
In linea di massima PDLP è pensato per essere lanciato una volta al giorno (pianificato con crontab), in modo che ogni giorno vengano scaricate le nuove trasmissioni linkate.
Per facilitare questo processo, insieme a PDLP è rilasciato anche Podcast Daily Update, uno script nel quale è possibile indicare una serie di fonti (e per ciascuna la directory di destinazione degli mp3). Pianificato una volta al giorno con crontab (crontab -e, si inserisce qualcosa come "* 14 * * * /percorso/podcast_daily_update" per lanciare il programma tutti i giorni alle 14), il pogramma ogni giorno cancella i vecchi mp3 scaricati e li sostituisce con quelli nuovi.
Configurando opportunamente soma, è possibile mettere in onda in modo automatico le trasmissioni rilasciate in podcast.
per infoz fabio.deponte@gmail.com
PODCAST DOWNLOAD LAST PROGRAMS:
#!/bin/bash
# PODCAST RSS FEED EXTRACTOR
# Released on 06/14/2006 by Fabio De Ponte (fabio.deponte@gmail.com) under GPL license.
#This script extracts from a remote file (normally a feed rss) the new mp3 links
#added in the text since the previous source and downloads them to the destination
#directory.
#
#Example:
# ./podcast_download_last_programs http://downloads.bbc.co.uk/rmhttp/downloadtrial/radio4/today/rss.xml download
#That is the feed of bbc today, the bbc news program of the morning.
#You will get the last mp3s contained in the feed in the "download" directory.
#The first time you run the script you will get the last mp3 added to the podcast
#
#Hope you will enjoy this script.
if test "$1" == ''
then
echo ""
echo "************"
echo "Podcast Download Last Programs"
echo "************"
echo ""
echo "This program checks a rss feed and downloads the most recent mp3 files:"
echo "this means all new mp3 files added since the previous check."
echo "In other words, at every check it synchronizes to remote source."
echo "The first time it downloads only one mp3, the most recent."
echo ""
echo "Usage: podcast_download_last_programs [source [destination dir]] [options]"
echo ""
echo "Available opsions:"
echo "-R Deletes local synchronization data with source. It can be applied"
echo " either to one source or to all source at once"
echo ""
echo "Examples:"
echo ""
echo "podcast_download_last_programs http://www.site.com/rss.xml"
echo " will check this feed and download the latest updates to current dir"
echo "podcast_download_last_programs http://www.site.com/rss.xml download"
echo " will check this feed and download the latest updates to 'download' dir"
echo " podcast_download_last_programs http://www.site.com/rss.xml -R"
echo " will delete all information for this source"
echo " podcast_download_last_programs -R"
echo " will delete all informations for every source"
echo ""
echo "Released on the 14th of june 2006 by Fabio De Ponte (fabio.deponte@gmail.com)"
echo "under the GPL license."
exit 0
fi
echo ""
echo "**************"
echo "-----------> DATE/TIME: `date | sed -e 's/ CEST//g'` --- Start"
if test "$1" == '-R'
then
if rm ~/.podcast_download -R
then
echo "-----------> Local synchronization data for all sources has been removed"
echo "-----------> DATE/TIME: `date | sed -e 's/ CEST//g'` --- Stop"
echo ""
exit 0
else
echo "-----------> No local synchronization data to delete:"
echo "directory $HOME/.podcast_download does not exist."
echo ""
echo "-----------> DATE/TIME: `date | sed -e 's/ CEST//g'` --- Stop"
echo ""
exit 1
fi
fi
echo "-----------> FEED: $1"
#gets the name of the file without the rest of the link (in the example takes rss.xml and cuts the rest):
nomefile=`echo "$1" | sed -e 's/^.*[/]//g'`
nomefile_dir=`echo "$1" | sed -e 's/^.*[:][/][/]//g' | sed -e 's/[://].$//' -e 's/[/]/-/g'| sed -e 's/?.*$//g'`
if test "$2" == '-R'
then
if rm ~/.podcast_download/$nomefile_dir -R
then
echo "-----------> Local synchronization data for this feed has been removed"
echo "-----------> DATE/TIME: `date | sed -e 's/ CEST//g'` --- Stop"
echo ""
exit 0
else
echo "-----------> No local synchronization data to delete for this feed:"
echo "directory $HOME/.podcast_download/$nomefile_dir does not exist."
echo ""
echo "-----------> DATE/TIME: `date | sed -e 's/ CEST//g'` --- Stop"
echo ""
exit 1
fi
fi
if test "$2" == ''
then
eval dest_dir='.'
else
#Checks if the dir where it should put the mp3 exists:
if test -d $2
then
eval dest_dir=$2
else
echo "-----------> Error: directory $2 does not exist."
echo ""
echo "-----------> DATE/TIME: `date | sed -e 's/ CEST//g'` --- Stop"
echo ""
exit 1
fi
fi
if test "$dest_dir" == '.'
then
eval download_dir=$PWD
else
eval download_dir=$dest_dir
fi
echo "-----------> DOWNLOAD DESTINATION DIRECTORY: $download_dir"
#Checks if this is the first time the script runs and in this case creates its own hidden directory:
if test -d ~/.podcast_download
then
#echo "This is not first time you use this script"
eval a=1
else
mkdir ~/.podcast_download
echo "-----------> CREATING $HOME/.podcast_download directory"
fi
#Checks if the directory for this feed exists already and if not it creates it:
if test -d ~/.podcast_download/$nomefile_dir
then
echo "-----------> UPDATING local synchronization data for this feed"
#downloads the feed:
if wget $1 -P ~/.podcast_download/$nomefile_dir -t 3 -T 60 --dns-timeout=60
then
echo "-----------> FEED correctly downloaded"
else
echo "-----------> ERROR: the feed was not correctly downloaded."
echo "The problem could be that either:"
echo "1. the rss feed address is uncorrect"
echo "2. you have not enough space on $HOME"
echo "exiting program"
echo ""
echo "-----------> DATE/TIME: `date | sed -e 's/ CEST//g'` --- Stop"
echo ""
exit 0
fi
#saves the old mp3 list:
cp ~/.podcast_download/$nomefile_dir/mp3list.txt ~/.podcast_download/$nomefile_dir/oldmp3list.txt
#gets from the file all mp3 links:
cat ~/.podcast_download/$nomefile_dir/$nomefile |grep mp3|grep http:|sed -e 's/^.*http[:][/][/]/http:\/\//g' -e 's/.mp3.*/.mp3/g'|uniq > ~/.podcast_download/$nomefile_dir/mp3list.txt
#checks and gets even the ftp mp3 links:
cat ~/.podcast_download/$nomefile_dir/$nomefile |grep mp3|grep ftp:|sed -e 's/^.*ftp[:][/][/]/ftp:\/\//g' -e 's/.mp3.*/.mp3/g'|uniq >> ~/.podcast_download/$nomefile_dir/mp3list.txt
#compares the two files and gets only the new mp3, storing the list in mp3list2download.txt
diff ~/.podcast_download/$nomefile_dir/mp3list.txt ~/.podcast_download/$nomefile_dir/oldmp3list.txt |grep "<"|sed -e 's/[< ]//g' > ~/.podcast_download/$nomefile_dir/mp3list2download.txt
else
echo "-----------> GENERATING local synchronization data for this feed"
#creates the feed directory:
mkdir ~/.podcast_download/$nomefile_dir
#downloads the feed:
if wget $1 -P ~/.podcast_download/$nomefile_dir -t 3 -T 60 --dns-timeout=60
then
echo "-----------> FEED downloaded correctly"
else
echo "-----------> ERROR: the feed file was not correctly downloaded."
echo "The problem could be that either:"
echo "1. the rss feed address is uncorrect"
echo "2. you have not enough space on $HOME"
echo "exiting program"
echo ""
rm ~/.podcast_download/$nomefile_dir -R
echo "-----------> DATE/TIME: `date | sed -e 's/ CEST//g'` --- Stop"
echo ""
exit 0
fi
#gets from the file all mp3 links:
cat ~/.podcast_download/$nomefile_dir/$nomefile |grep mp3|grep http:|sed -e 's/^.*http[:][/][/]/http:\/\//g' -e 's/.mp3.*/.mp3/g' |uniq > ~/.podcast_download/$nomefile_dir/mp3list.txt
#checks and gets even the ftp mp3 links:
cat ~/.podcast_download/$nomefile_dir/$nomefile |grep mp3|grep ftp:|sed -e 's/^.*ftp[:][/][/]/ftp:\/\//g' -e 's/.mp3.*/.mp3/g' |uniq >> ~/.podcast_download/$nomefile_dir/mp3list.txt
#takes only the first mp3 link and puts it in mp3list2download.txt:
sed '2,$d' ~/.podcast_download/$nomefile_dir/mp3list.txt > ~/.podcast_download/$nomefile_dir/mp3list2download.txt
fi
if test -s ~/.podcast_download/$nomefile_dir/mp3list2download.txt
then
echo "-----------> MP3 LIST to download:"
cat ~/.podcast_download/$nomefile_dir/mp3list2download.txt
echo ""
if wget -i ~/.podcast_download/$nomefile_dir/mp3list2download.txt -P $dest_dir -t 3 -T 60 --dns-timeout=60
then
echo "-----------> SUCCESS: the mp3 files were correctly downloaded"
else
echo "-----------> ERROR: unable to download one or more of the mp3 files reported in the feed."
echo "The problem could be that either:"
echo "1. The mp3 links reported in the feed are not correct"
echo "2. You have not enough space on $HOME"
echo ""
fi
else
echo "-----------> NO NEW MP3 files to download"
fi
#removes the downloaded feed:
rm ~/.podcast_download/$nomefile_dir/$nomefile
echo "-----------> DATE/TIME: `date | sed -e 's/ CEST//g'` --- Stop"
echo ""
PODCAST_DAILY_UPDATE:
(qui c'è da cambiare le prime tre variabili e i riferimenti per ciascun feed)
#!/bin/bash
#directory di base all'interno della quale vengono create le directory di destinazione per ciascun feed:
eval podcast_dir="~/podcast"
#link all'eseguibile del pdlp:
eval pdlp="~/pdlp/podcast_download_last_programs"
#file di log
eval logfile="~/pdlp/log.txt"
echo "">>$logfile
echo "">>$logfile
echo "">>$logfile
echo "">>$logfile
echo "****** NEW PODCAST UPDATE ROUND: `date | sed -e 's/ CEST//g'` START ******">>$logfile
echo "">>$logfile
echo "">>$logfile
echo "">>$logfile
#il blocco che segue scarica il programma quotidiano di approfondimento della bbc:
#BBC - today
#scarica gli mp3 in podcast/bbc/today (nb: la cartella bbc deve già essere creata)
eval dest_dir="bbc/today"
#feed source:
eval feedsource="http://downloads.bbc.co.uk/rmhttp/downloadtrial/radio4/today/rss.xml"
#ad ogni esecuzione cancella la vecchia dir today e ne crea una nuova con i nuovi mp3:
if test -d $podcast_dir/$dest_dir ; then
rm $podcast_dir/$dest_dir -R
fi
mkdir $podcast_dir/$dest_dir
$pdlp $feedsource $podcast_dir/$dest_dir >> $logfile
#questi sono una serie di altri esempi. per aggiungere una fonte basta aggiungere un blocco
#BBC - world select
eval dest_dir="bbc/worldselect"
eval feedsource="http://downloads.bbc.co.uk/rmhttp/downloadtrial/worldservice/worldtodayselect/rss.xml"
if test -d $podcast_dir/$dest_dir ; then
rm $podcast_dir/$dest_dir -R
fi
mkdir $podcast_dir/$dest_dir
$pdlp $feedsource $podcast_dir/$dest_dir >> $logfile
#Journal Afrique
eval dest_dir="vari/journalafrique"
eval feedsource="http://www.rfi.fr/radiofr/podcast/journalAfrique.asp"
if test -d $podcast_dir/$dest_dir ; then
rm $podcast_dir/$dest_dir -R
fi
mkdir $podcast_dir/$dest_dir
$pdlp $feedsource $podcast_dir/$dest_dir >> $logfile
#radio.indymedia.org
eval dest_dir="vari/radioindymedia"
eval feedsource="http://radio.indymedia.org/syn/audio.rss"
if test -d $podcast_dir/$dest_dir ; then
rm $podcast_dir/$dest_dir -R
fi
mkdir $podcast_dir/$dest_dir
$pdlp $feedsource $podcast_dir/$dest_dir >> $logfile
#Indymedia Argentina
eval dest_dir="vari/indymedia-argentina"
eval feedsource="http://argentina.indymedia.org/news/xml.php?medium=audio"
if test -d $podcast_dir/$dest_dir ; then
rm $podcast_dir/$dest_dir -R
fi
mkdir $podcast_dir/$dest_dir
$pdlp $feedsource $podcast_dir/$dest_dir >> $logfile
#Amisnet
eval dest_dir="amis/amisnet"
eval feedsource="http://feed.amisnet.org/ita-mainpage-pod.xml"
if test -d $podcast_dir/$dest_dir ; then
rm $podcast_dir/$dest_dir -R
fi
mkdir $podcast_dir/$dest_dir
$pdlp $feedsource $podcast_dir/$dest_dir >> $logfile
#Indymedia Italia
eval dest_dir="vari/indymedia-italia"
eval feedsource="http://italy.indymedia.org/news/xml.php?medium=audio"
if test -d $podcast_dir/$dest_dir ; then
rm $podcast_dir/$dest_dir -R
fi
mkdir $podcast_dir/$dest_dir
$pdlp $feedsource $podcast_dir/$dest_dir >> $logfile
#Indymedia UK
eval dest_dir="vari/indymedia-uk"
eval feedsource="http://www.indymedia.org.uk/en/audio.rss"
if test -d $podcast_dir/$dest_dir ; then
rm $podcast_dir/$dest_dir -R
fi
mkdir $podcast_dir/$dest_dir
$pdlp $feedsource $podcast_dir/$dest_dir >> $logfile
#Radio Antifascista San Diego
eval dest_dir="sandiego/radioantifascista"
eval feedsource="http://feeds.feedburner.com/radioAntifascista"
if test -d $podcast_dir/$dest_dir ; then
rm $podcast_dir/$dest_dir -R
fi
mkdir $podcast_dir/$dest_dir
$pdlp $feedsource $podcast_dir/$dest_dir >> $logfile
#Indymedia Mexico
eval dest_dir="vari/indymedia-mexico"
eval feedsource="http://feeds.feedburner.com/comun"
if test -d $podcast_dir/$dest_dir ; then
rm $podcast_dir/$dest_dir -R
fi
mkdir $podcast_dir/$dest_dir
$pdlp $feedsource $podcast_dir/$dest_dir >> $logfile
#Au bout du fil - free music | DANCE HALL
eval dest_dir="dance-hall/AuBoutDuFil"
eval feedsource="http://www.auboutdufil.com/podcast.php"
if test -d $podcast_dir/$dest_dir ; then
rm $podcast_dir/$dest_dir -R
fi
mkdir $podcast_dir/$dest_dir
$pdlp $feedsource $podcast_dir/$dest_dir >> $logfile
#cole distribution reggae show
eval dest_dir="dance-hall/coledistribution"
eval feedsource="http://mookie1510.podomatic.com/rss2.xml"
if test -d $podcast_dir/$dest_dir ; then
rm $podcast_dir/$dest_dir -R
fi
mkdir $podcast_dir/$dest_dir
$pdlp $feedsource $podcast_dir/$dest_dir >> $logfile
#Dub Session
eval dest_dir="dance-hall/dubsession"
eval feedsource="http://www.dubsession.com/dubsession/rss/dubsession.xml"
if test -d $podcast_dir/$dest_dir ; then
rm $podcast_dir/$dest_dir -R
fi
mkdir $podcast_dir/$dest_dir
$pdlp $feedsource $podcast_dir/$dest_dir >> $logfile
#ACIDplanet Electronica Podcast
eval dest_dir="elettronica/acdiplanet"
eval feedsource="http://www.acidplanet.com/podcasts/rss.asp"
if test -d $podcast_dir/$dest_dir ; then
rm $podcast_dir/$dest_dir -R
fi
mkdir $podcast_dir/$dest_dir
$pdlp $feedsource $podcast_dir/$dest_dir >> $logfile
echo "">>$logfile
echo "">>$logfile
echo "">>$logfile
echo "">>$logfile
echo "****** NEW PODCAST UPDATE ROUND: `date | sed -e 's/ CEST//g'` STOP ******">>$logfile
echo "">>$logfile
echo "">>$logfile
echo "">>$logfile
0 Comments:
Posta un commento
<< Home