f-log

just another web log

24 Apr 2012 21:00
Continuing my TV recipe
So I had a text file for channels with over 400 entries, many I new were unrelated to my interests.
I could have manually removed any channels I did not like but then what about when I refreshed the data?
No I needed to keep all the channels and mark which ones were interesting.
There were many many ways to do this but for the minimal about of coding I opted for ...
First time; import all the channels into the database, then unselect the ones I was not interested in.
All further imports; import into channels into a comparison table, figure out any new or deleted channels then add/delete new/obsolete channels.
The key was how to unselect the channels ...
sqlite3 database/tv.db "select id,selected,name from channel;" | sed -e "s/|+|/|checked=\"checked\"|/gi" | sed -e "s/\(^[0-9]*\)|\(.*\)|\(.*\)/<input type=\"checkbox\" name=\"id\" value=\"\1\" \2 \/>\3<br \/>/gi" > c.html
I then topped and tailed the c.html file to include a FORM BODY HTML tags.
Ran it in a browser and had a looong list of checkbox and channel names.
What I knew from the Computer-O quiz was that submitting the form using the GET method would put all the form data (i.e. selected channels) in the query string.
Its a bit mad but very easy, then it was a matter of taking that query string and running it by ...
echo QUERYSTRING | sed -e "s/\(^.*?id.\)/update channel set selected = '+' where id in (/" | sed -e "s/&id=/,/g" | sed -e "s/$/);/" | sqlite3 database/tv.db
echo QUERYSTRING | sed -e "s/\(^.*?id.\)/update channel set selected = '' where id not in (/" | sed -e "s/&id=/,/g" | sed -e "s/$/);/" | sqlite3 database/tv.db

Where QUERYSTRING is the query string from submitting my form to itself.
This sets the selected flag for included values and clears it (second command) where the are not included.
I love bash and sqlite scripting !
Next time importing the programmes and the tracker table...
24 Apr 2012 20:39
I DO plan on continuing the TV Recipe, but before we get back to that I just need to add this fix to my archive

I have a number of projects on the go at any one time and some seem to have been going on forever. One such project involves DVDs and when running the carefully considered memcoder command line X crashed.
X crashing is not a common occurrence and as I just wanted to be up and running email etc I forgot the issue and moved on. Then a few days later tried the same thing and it crashed X again, no obvious log messages, again forgot about it then the other day I tried to use Xine to watch a DVD and ... yep crashed again.
This time I decided to look into the problem a bit more deeply. It was my own fault for not updating the linux kernel and the video drivers. So I rebuilt the kernel using .config and meld, surprisingly no issues and rebooted and started X.
Something was wrong. The XFCE desktop seemed to be there(the panels were appearing) and my last running apps were loading but none of them had any window decoration, so no close/minimise etc. The mouse would not click on things and had the classic monochrome cursor.
After a lot of digging found the fix was to shut X and delete
rm ~/.cache/sessions/*
Then everything worked flawlessly again!
loading results, please wait loading animateloading animateloading animate
[More tags]
rss feed

email

root

flog archives


Disclaimer:
This page is by me for me, if you are not me then please be aware of the following
I am not responsible for anything that works or does not work including files and pages made available at www.jumpstation.co.uk I am also not responsible for any information(or what you or others do with it) available at www.jumpstation.co.uk
In fact I'm not responsible for anything ever, so there!

[Pay4Foss banner long]