Posted to tcl by superlinux-hp at Mon Feb 23 08:36:06 GMT 2015view raw

  1. #!/usr/bin/tclsh
  2.  
  3. package require http
  4. package require json
  5.  
  6. set youtube_playlist_url {https://www.youtube.com/playlist?list=PLsAEIIjTPIo_Ja5sHIb6H-Fpnh2-LAwmv}
  7.  
  8. set playlist_id [ lindex [ split $youtube_playlist_url "=" ] 1 ]
  9. set http_token [ ::http::geturl "http://gdata.youtube.com/feeds/api/playlists/$playlist_id/?v=2&alt=json&feature=plcp" -method GET ]
  10. set youtube_dictionary [ ::json::json2dict [ ::http::data $http_token ] ]
  11.  
  12. puts output:
  13. set video_entries [ dict get [ dict get $youtube_dictionary feed] entry]
  14. puts [ lsearch -inline -regexp {http://www\.youtube\.com/v/.*version} $video_entries]