MythNewsGoogleReader
Author | Cowbutt |
Description | A simple bash script which imports news feeds from a Google Reader account into MythNews. |
Supports |
Contents
Export your Google Reader subscriptions to OPML
Login to your Google Reader account, then select Settings->Reader Settings->Import/Export, then "Export your subscriptions as an OPML file". Save the file somewhere.
Convert the OPML file to a SQL script
#!/bin/sh cat google-reader-subscriptions.xml | while read LINE do # echo "LINE=$LINE" echo $LINE | grep >/dev/null "xmlUrl=" RC=$? if [ $RC -eq 0 ]; then PODCAST=0 # echo "$LINE" | grep xmlUrl |awk -F"xmlUrl=\"" '{print $2}' | awk -F"\"" '{print $1}' RSSURL=`echo "$LINE" | awk -F"xmlUrl=\"" '{print $2}' | awk -F"\"" '{print $1}'` TITLE=`grep -B 2 "$RSSURL" google-reader-subscriptions.xml | grep title | tail -1| awk -F"title=\"" '{print $2}' | awk -F"\"" '{print $1}'` # grep -B 1 "$RSSURL" google-reader-subscriptions.xml | grep title #| awk -F"title=\"" '{print $2}' | awk -F"\"" '{print $1}' echo "$TITLE" | grep >/dev/null -i "podcast\|audio rss" TITLEISPODCAST=$? echo "$RSSURL" | grep >/dev/null -i "podcast" RSSURLISPODCAST=$? if [ $TITLEISPODCAST -eq 0 -o $RSSURLISPODCAST -eq 0 ]; then PODCAST=1 fi # echo "[${RSSURL}] [${TITLE}]" echo "INSERT INTO newssites (category, name, url, podcast) VALUES ('Google Reader', '"$TITLE"', '"$RSSURL"', $PODCAST);" fi done
Run it from the same directory as the OPML file you downloaded. Direct the output to a file, e.g. google-reader-to-MythNews.sh >google-reader-subscriptions.sql
Note that if the names include special characters (e.g. ', /, », « etc) then you probably want to manually edit the resultant SQL script. Failure to do so may confuse MythNews and/or result in illegal local feed filenames.
Import the edited SQL script into your MythTV database
Probably best to backup first (though any sites you add should be trivially removeable using DELETE FROM newssites WHERE category='Google Reader';
).
mysql -p mythconverg <google-reader-subscriptions.sql
Use a cron script to update all your feeds
MythNews seems to have a bug that prevents the updating of large numbers of feeds (I suspect it tries to kick off all the updates simultaneously and runs out of Qt slots), so I run this script from cron with a frequency greater than my NewsUpdateFrequency
setting (default of 30 minutes).
/etc/cron.hourly/update-MythNews.sh
#!/bin/sh MYTHDBUSER="mythtv" MYTHDBPASS="mythtv" MYTHUSER="mythtv" URLFILE=`mktemp /tmp/MythNews.XXXXXXXX` touch $URLFILE mysql -B -p${MYTHDBPASS} -u ${MYTHDBUSER} -e 'use mythconverg; select * from newssites;' | tail -n +2 >$URLFILE cat $URLFILE | while read LINE do # may need to fix path in awk statement below FILE=`echo "$LINE" | awk -F"\t" '{print "/var/lib/mythtv/.mythtv/MythNews/"$1}'` URL=`echo "$LINE" | awk -F"\t" '{print $3}'` # echo "Updating [$FILE] from [$URL]" wget --no-verbose -O "${FILE}" "${URL}" chown ${MYTHUSER}.%{MYTHUSER} "${FILE}" done NOW=`date +%s` echo "use mythconverg; update newssites set updated=$NOW;" | mysql -p${MYTHPASS} -u ${MYTHUSER} rm -f $URLFILE