Posted to tcl by mjanssen at Thu Oct 19 22:41:59 GMT 2006view raw

  1. package require http
  2. package require sqlite3
  3. set data [set [http::geturl http://tvrage.com/quickschedule.php](body)]
  4.  
  5. sqlite3 db {}
  6. db eval {CREATE TABLE shows(date text, time text, name text)}
  7.  
  8.  
  9.  
  10. set lines [split $data \n]
  11. foreach line $lines {
  12. set type {}
  13. regexp {\[(.*)?\](.*)\[.*\]} $line -> type value
  14. switch $type {
  15. DAY {set current_day $value }
  16. TIME {set show_time $value ; set show_nr 0}
  17. SHOW {db eval {INSERT INTO shows VALUES($current_day,$show_time, $value)}}
  18. default {continue}
  19. }
  20. }
  21.  
  22. db eval {SELECT * from shows WHERE date="Wednesday, 25 Oct 2006" ORDER BY time } {
  23. puts "$time: $name"
  24. }
  25.  
  26. db close