Last active
December 17, 2015 20:59
-
-
Save maop/5671780 to your computer and use it in GitHub Desktop.
Script para "grabar" los programas de "La Corneta" www.los40.com.mx/lacorneta/ y generar RSS para suscribirse como podcast
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# by maop <[email protected]> | |
# RSS: maop.gulegro.org/corneta/corneta.xml | |
# v0.1 29/05/2013 | |
# | |
# Install: | |
# Modify Paths, and create a crontab with: | |
# | |
# 0 13 * * 1-5 /home/maop/scripts/corneta.sh | |
# | |
# (program starts at 13:00 and ends at 15:00 | |
filename="corneta.$(date +'%Y-%m-%d')" | |
(sleep 2h;sleep 10m; killall wget) & | |
/usr/bin/wget "http://3653.live.streamtheworld.com/LOS40_MEXICOAAC?streamtheworld_user=1&nobuf=1369674816149" -O /home/maop/sites/maop.gulegro.org/corneta/$filename.flv -o /tmp/corneta.log | |
cd /home/maop/sites/maop.gulegro.org/corneta/ | |
#/usr/bin/ffmpeg -i $filename.flv -acodec libmp3lame -ab 128 $filename.mp3 | |
#cambiamos a m4a: ffmpeg -i corneta.2013-05-27.flv -acodec copy prueba.m4a | |
/usr/bin/ffmpeg -i $filename.flv -acodec copy $filename.m4a | |
# Listo el programa del dia ahora a actualizar el RSS | |
IFS='' read -r -d '' RSS <<EOF | |
<?xml version="1.0" encoding="UTF-8"?>\n | |
<rss version="2.0">\n | |
<channel>\n | |
<title>La Corneta</title>\n | |
<link>http://www.los40.com.mx/lacorneta/</link>\n | |
<description>Fan RSS suscription</description>\n | |
<language>es-mx</language> | |
EOF | |
last10=$(ls -lat *m4a|awk '{print $9}'|head -n10) | |
for i in $last10;do | |
title="La ${i%%.m4a}" | |
fileurl="http://maop.gulegro.org/corneta/$i" | |
link="$fileurl" | |
guid="$fileurl" | |
tmp="${i%%.m4a}" #extrae corneta.YYYY-MM-DD | |
date="${tmp##*.}" #extrae YYYY-MM-DD | |
timestamp="$(date -d $date +%s)" | |
timestamp=$(($timestamp+13*3600)) | |
pubdate="$(date -d @$timestamp +'%a, %d %b %Y %H:%M:%S %z')" | |
desc="La corneta $date | Archivo: $fileurl" | |
RSS="$RSS\n<item>\n <title>$title</title>\n <description>$desc</description>\n <link>$link</link>\n <pubDate>$pubdate</pubDate>\n <guid>$guid</guid>\n <enclosure url='$fileurl' type='audio/mp4'/>\n</item>" | |
done | |
RSS="${RSS}\n</channel></rss>" | |
echo -e $RSS > corneta.xml |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment