Module: TedTalk

Defined in:
lib/ted_talk.rb,
lib/ted_talk/version.rb

Defined Under Namespace

Classes: Converter

Constant Summary collapse

VERSION =
"0.0.50"

Class Method Summary collapse

Class Method Details

.delete_cacheObject



33
34
35
36
37
# File 'lib/ted_talk.rb', line 33

def self.delete_cache
  UnixTools.delete_dir(CACHE_DIR)
  puts "Cache folder has been deleted"
  return true
end

.desc_talks_rss(lang, num = 12) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/ted_talk.rb', line 39

def self.desc_talks_rss(lang, num = 12)
  if lang != "en"
    html = DownloadUtils.get_html("http://www.ted.com/translate/languages/#{lang}", true)
    html_doc = Nokogiri::HTML(html)  
    puts "--------------------------------------------------"  
    html_doc.xpath("//div[@id='list']//dd//a[1]").each do |link|
      puts link.attribute("title")
      puts link.attribute("href").text.sub(/\A\//, "http://www.ted.com/")
      puts "--------------------------------------------------"  
    end
  else
    rss_html = DownloadUtils.get_html("http://feeds.feedburner.com/tedtalks_video", true)
    rss_doc = Nokogiri::XML(rss_html)  
    talks = rss_doc.xpath("//item")
    puts "--------------------------------------------------"  
    talks.each_with_index do |talk, index|      
      puts title = talk.xpath("title").text
      puts pubdate = talk.xpath("pubDate").text
      puts category = talk.xpath("category").text      
      # puts source_url = DownloadUtils.get_final_location(talk.xpath("link").text).sub(/\?.+\z/, "")
      puts source_url = talk.xpath("feedburner:origLink").text
      puts description = talk.xpath("description").text      
      puts "--------------------------------------------------"  
      break if index + 1 == num
    end
  end
end