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

  1. package require http
  2. set data [set [http::geturl http://tvrage.com/quickschedule.php](body)]
  3.  
  4. set shows {}
  5. set show_nr 0
  6.  
  7. set lines [split $data \n]
  8. foreach line $lines {
  9. set type {}
  10. regexp {\[(.*)?\](.*)\[.*\]} $line -> type value
  11. switch $type {
  12. DAY {set current_day $value }
  13. TIME {set show_time $value ; set show_nr 0}
  14. SHOW {dict set shows $current_day $show_time [incr show_nr] $value}
  15. default {continue}
  16. }
  17. }
  18.  
  19. set dates [dict keys $shows]
  20.  
  21. foreach date [lsort $dates] {
  22. puts --------
  23. puts "Date: $date"
  24. set times [lsort [dict keys [dict get $shows $date]]]
  25. foreach time $times {
  26. puts "$time"
  27. foreach show [dict values [dict get $shows $date $time]] {
  28. puts "\t$show"
  29. }
  30. }
  31. }