[mythtv] My small (and very bash) contibution to mythtv...
Martin Moeller
martin at martinm-76.dk
Tue Mar 11 19:56:10 EST 2003
I haven't gotten much extra work done on it and it may not be necessary
for American feeds and certain others, but it certainly help on
tv_grab_sn to give some form of categorizing.
Please note that there are plenty of things that could be better but
it's good enough that I can usually guess what's what.
mythfilldatabasecron is somewhat modified. It works better this way for
me, except every other day except from tomorrow gets lost?!
mythfilldatabase never fetches them. I've tried to find the location of
this problem, but I haven't been able to as yet...
--
Martin Moeller <martin at martinm-76.dk>
-------------- next part --------------
#!/bin/sh
# (C)2003 Martin Moeller - Licensed under the GNU GPL.
# See www.gnu.org/copyleft/gpl.html for the details.
#
# Purpose: To add categorization to feeds without them
# using comments and titles.
#
# I'm sure it can be done better, but it works pretty well..
#
# Possible improvements:
# * Priority inserts (e.g. typical film categories last (drama, sci-fi, etc..)
# * More keywords, possibly in more languages. Kind of coved now is:
# Danish, Swedish, partly Norwegian and English.
# * Speedups? It isn't too bad, but it might be better.
# * Improved accuracy. We don't test for being part of a word so, e.g.
# Some of the Search terms could probably do with some narrowing, as well.
# E.g. : Talk ends up marking things talk-shows that aren't. No biggie, though.
# A documentary about homosexuals would end up classified as Erotica.
#
export TERM=xterm
cat /tmp/program.sql | sed s#"\\\'"#"½§"#g | cut -d\' -f6 > /tmp/description.txt
cat /tmp/program.sql | sed s#"\\\'"#"½§"#g | cut -d\' -f2 > /tmp/title.txt
if [ -e /tmp/categories ] ; then
rm -rf /tmp/categories
fi
mkdir /tmp/categories
# Find matching lines
function get_type() {
echo -n "."
cat /tmp/description.txt | grep -ni $1 > /tmp/categories/$1.match02
cat /tmp/title.txt | grep -ni $1 > /tmp/categories/$1.match01
}
# Reinsert found categories into database.
# Process title before description : Description can override title.
# Two arguments: Type and Category (e.g. insert_desc krimi Crime)
function insert_desc() {
for a in /tmp/categories/$1.match* ; do
if [ -s $a ] ; then
for a in $(cat $a | cut -d: -f1) ; do
LINE=$(head -$a /tmp/program.sql | tail -1 | sed s#"\\\'"#"½§"#g)
NEWLINE1=$(echo $LINE | cut -d\' -f1-8)
NEWLINE2=$(echo $LINE | cut -d\' -f9-)
NEWLINE="${NEWLINE1}${2}'${NEWLINE2}"
echo $NEWLINE | sed s#"½§"#"\\\'"#g >> /tmp/categories/$2.sql
done
mysql -umythtv -pmythtv mythconverg < /tmp/categories/$2.sql
rm /tmp/categories/$2.sql
echo -n "."
fi
done
}
echo -n "Searching for categories : "
for a in Drama News Cook Sex Eroti Kultur Culture Special ; do
get_type $a
done
for a in Episode Serie Avsnit Afsnit ; do # Series
get_type $a
done
for a in Film Movie Action Adventure Thriller Sci-Fi Science ; do
get_type $a
done
for a in Tegnefilm Cartoon Tecknad Animerad Animeret CGI ; do
get_type $a
done
for a in Komedi Comedy Humor Nyhed Nyhet ; do
get_type $a
done
for a in Sport Badminton Tennis Fodbold Fotboll Football Volley Ridning Riding League ; do
get_type $a
done
for a in Musik Music ; do
get_type $a
done
for a in Krimi Crime Document Dokument; do # Crime
get_type $a
done
for a in Familje Familie Family Underhold ; do # * -> Family
get_type $a
done
for a in Talk Prat Snakke ; do
get_type $a
done
for a in Natur Debat Debate Repris Rerun Genudsendelse ; do
get_type $a
done
echo " - done."
# Cook -> Cooking
# Sex & Eroti -> Erotica
# Nyheter & Nyheder -> News, Kultur -> Culture
# Komedi -> Comedy
echo -n "Importing categories : "
insert_desc Film Movie
insert_desc Movie Movie
for a in /tmp/categories/*.match* ; do
NAME=$(basename $a)
NAME=$(echo $NAME | cut -d\. -f1)
case $NAME in
Action|Adventure|Thriller|Sci-Fi|Drama|News ) insert_desc $NAME $NAME ;;
Nyhet|Nyhed ) insert_desc $NAME News ;;
Cook ) insert_desc $NAME Cooking ;;
Tegnefilm|Cartoon|Tecknad|Animerad|Animeret|CGI ) insert_desc $NAME Cartoon ;;
Komedi|Comedy|Humor ) insert_desc $NAME Comedy ;;
Musik|Music ) insert_desc $NAME Music ;;
Krimi|Crime ) insert_desc $NAME Crime ;;
Dokument|Document ) insert_desc $NAME Documentary ;;
Debat|Debate ) insert_desc $NAME Debate ;;
Episode|Serie|Avsnit|Afsnit ) insert_desc $NAME Series ;;
Sex|Eroti ) insert_desc $NAME Erotica ;;
Kultur|Culture ) insert_desc $NAME Culture ;;
Special|Science ) insert_desc $NAME $NAME ;;
Familje|Familie|Family|Underhold ) insert_desc $NAME Family ;;
Talk|Prat|Snakke ) insert_desc $NAME Talk-show ;;
Natur ) insert_desc $NAME Nature ;;
Repris|Rerun|Genudsendelse ) insert_desc $NAME Rerun ;;
Sport|Badminton|Tennis|Fodbold|Fotboll|Football|Volley|Ridning|Riding|League ) insert_desc $NAME Sports ;;
esac
done
echo " - done."
-------------- next part --------------
#!/bin/bash
export TERM=xterm
export QTDIR=/usr/lib/qt3
# Choose one of the two modes below.
# Mode 1: Start from scratch.
#mysql -uroot mythconverg -e 'delete from program;'
# Mode 2: Keep old records (start with today) - Not tested.
START=$(date -d 'yesterday' +%Y%m%d235959)
mysql -uroot mythconverg -e "delete from program where starttime>$START;"
/usr/local/bin/mythfilldatabase
mysql -uroot mythconverg < /home/martin/mythtv/Extras/channel.sql
mysqldump -uroot mythconverg program | sed s#INSERT#REPLACE#g > /tmp/program.sql
/usr/local/sbin/myth_categorize
More information about the mythtv-dev
mailing list