lappend auto_path ~/tcl/tdom/bin; package re tdom; package re http; wm withdraw .; wm withdraw .output; wm geom .konsola 868x570+144+139; kons_font 13 ## dostep do youtube z poziomy Tcl... # # ... # wyciaganie tytulu filmu na podstawie ID # + https://www.youtube.com/watch?v=0cq7isloJj8 # + czy wymaga pakietu https ??? w tym wypadku nie... # set h1 [http::geturl "http://gdata.youtube.com/feeds/api/videos/0cq7isloJj8"] set d1 [dom parse -html [http::data $h1]] #$d1 delete http::cleanup $h1 #% set d2 [$d1 selectNodes {//title}] $d2 text #% Space 1999 S01E01 - Breakaway.avi set d3 [$d1 selectNodes {//content}] string map {\r {}} [$d3 text] #% Old series but goodies...ask for more if interested... set d4 [$d1 selectNodes {/entry/*}] set _ {} foreach x $d4 {lappend _ [$x nodeName]} set _ #% id published updated category category title content link link link link author set d5 [$d1 selectNodes {/entry/author/*}] #% domNode0x82aaa74 domNode0x82aaaa0 [lindex $d5 0] nodeName #% name [lindex $d5 0] text #% Dany Van Mickael [lindex $d5 1] nodeName #% uri [lindex $d5 1] text #% http://gdata.youtube.com/feeds/api/users/MrDanyNervous # ... # jak znalezc kolejne odcinki Pana Wolodyjowskiego ??? (z. dla PZR420 ?!?!?!?!) # + problem z utf-8 ? # + dodac wyszukiwarke yt do mojej strony z filmami ?!?!?!?! # + docs: https://developers.google.com/youtube/2.0/developers_guide_protocol_api_query_parameters#Searching_for_Videos # set h1 [http::geturl "http://gdata.youtube.com/feeds/api/videos?q=Wolodyjowski"] set d1 [dom parse -html [http::data $h1]] http::cleanup $h1 set d2 [$d1 selectNodes {/feed/entry}] #% domNode0x83547b0 domNode0x8354a44 domNode0x8354cac domNode0x8354f40 domNode0x83551d4 domNode0x8355468 domNode0x83556fc domNode0x8355990 domNode0x8355c24 domNode0x8355eb8 domNode0x835614c domNode0x83563e0 domNode0x8356674 domNode0x8356908 domNode0x8356b9c domNode0x8356e30 domNode0x83570c4 domNode0x8357358 domNode0x83575ec domNode0x8357880 domNode0x8357b14 domNode0x8357da8 domNode0x835803c domNode0x83582d0 domNode0x8358564 set e [lindex $d2 0] #% domNode0x83547b0 encoding convertfrom utf-8 [[$e selectNodes title] text] #% PAN WOŁODYJOWSKI cz.1 wm deiconify .output; .output.t delete 1.0 end foreach e $d2 { set title [[$e selectNodes title] text] set title [encoding convertfrom utf-8 $title] set url [[$e selectNodes id] text] _puts "$title\n $url" } # ... # wyszukiwanie info o filmach # + klopot z powodu braku konsekwencji w tytulach itp... # #set q [http::formatQuery q "Woody Allen"] #set q [http::formatQuery q "Woody Allen Sleeper"] set q [http::formatQuery q "Woody|Allen Sleeper"] set h1 [http::geturl "http://gdata.youtube.com/feeds/api/videos?$q"] set d1 [dom parse -html [http::data $h1]] http::cleanup $h1 set d2 [$d1 selectNodes {/feed/entry}] #% domNode0x8358ab8 domNode0x8358d4c domNode0x8358fe0 domNode0x8359274 domNode0x8359508 domNode0x835979c domNode0x8359a30 domNode0x8359cc4 domNode0x8359f58 domNode0x835a1ec domNode0x835a480 domNode0x835a714 domNode0x835a9a8 domNode0x83dbe64 domNode0x83dc0f8 domNode0x83dc38c domNode0x83dc620 domNode0x83dc8b4 domNode0x83dcb48 domNode0x83dcddc domNode0x83dd070 domNode0x83dd304 domNode0x83dd598 domNode0x83dd82c domNode0x83ddac0 wm deiconify .output; .output.t delete 1.0 end array unset film foreach e $d2 { set title [[$e selectNodes title] text] set title [encoding convertfrom utf-8 $title] set url [[$e selectNodes id] text] _puts "$title\n $url" if {[regexp {^Sleeper part *([0-9]+) *} $title x1 x2]} { _puts "*** $title ($x2)\n $url" set film($x2) [list $title $url] } } # ...