Permalink
Browse files

improved the whole html summary processor

  • Loading branch information...
mattetti committed Dec 27, 2012
1 parent ec2593a commit d90aecf1f46cd262b4b0f3888c453a781fca1a9b
Showing with 28 additions and 4 deletions.
  1. +4 −0 .gitignore
  2. +14 −0 bin/console
  3. +7 −2 processors/episode_summary.rb
  4. +1 −1 runner.rb
  5. +2 −1 scrapers/pluzz_francetv_fr.rb
View
@@ -12,6 +12,10 @@ test/tmp
test/version_tmp
tmp
+# custom
+output
+tags
+
# YARD artifacts
.yardoc
_yardoc
View
@@ -0,0 +1,14 @@
+#!/usr/bin/env ruby
+require 'bundler'
+Bundler.require
+require 'irb'
+
+STDOUT.sync = true
+
+# Require all the scrapers & processors
+Dir.glob("./scrapers/*.rb"){|file| require file }
+Dir.glob("./processors/*.rb"){|file| require file }
+
+FileUtils.mkdir_p('output')
+
+IRB.start(__FILE__)
@@ -14,7 +14,7 @@ def process(items, format=:html)
self.items = items
if format == :html
html_header + "\n" + \
- items.map{|i| html_episode_summary(i)}.join("\n") + \
+ items.sort_by(&:show_name).map{|i| html_episode_summary(i)}.join("\n") + \
html_footer
elsif format == :json
items.map(&:to_json)
@@ -43,7 +43,12 @@ def html_episode_summary(item)
<<-EOS
<li>
<h2>#{item.show_name} - #{item.title}</h2>
- <a href="#{item.url}">Link (#{item.notes})</a>
+ #{("<div><img href='#{item.url}'
+ src='" + item.image_url +
+ "' /img></div>") if item.image_url}
+ <a href="#{item.url}">
+ #{(item.notes.nil? || item.notes == "") ? 'link' : item.notes }
+ </a>
</li>
EOS
end
View
@@ -4,7 +4,7 @@
STDOUT.sync = true
-# Require all the scrapers
+# Require all the scrapers & processors
Dir.glob("./scrapers/*.rb"){|file| require file }
Dir.glob("./processors/*.rb"){|file| require file }
@@ -21,6 +21,7 @@ def self.fetch_episodes(page)
episode.show_ref = episode.fetch(e, "span[data-prog]", ->(el){ el.first.attributes['data-prog'].value})
episode.title = episode.fetch(e, "div.rs-cell-details", ->(el){ el.first.search("a.ss-titre").text.strip})
episode.notes = episode.fetch(e, "div.rs-cell-details", ->(el){ el.first.search("a.rs-ep-ss").text.strip})
+ episode.image_url = episode.fetch(e, "figure.rs-cell-image img", ->(el){ el.first.attributes["src"].value})
episode
end
episodes
@@ -58,7 +59,7 @@ def to_json
end
def failed?
- if self.url.nil? || self.failures.size > 3
+ if self.url.nil? || !self.failures.empty?
true
else
false

0 comments on commit d90aecf

Please sign in to comment.