lib/scraperd/activity.rb in scraperd-0.0.2 vs lib/scraperd/activity.rb in scraperd-0.0.3
- old
+ new
@@ -7,10 +7,11 @@
def initialize(item)
super(Hashie::Mash.new({
id: item[:guid].force_encoding("UTF-8"),
title: title_from_title(item[:title]),
+ year: year_from_title(item[:title]),
score: score_from_title(item[:title]),
link: item[:link].force_encoding("UTF-8"),
film_link: "http://letterboxd.com/film/#{nicetitle_from_url(item[:link])}/".force_encoding("UTF-8"),
watched_at: watched_at_from_description(item[:description]),
added_at: item[:pubDate]
@@ -26,10 +27,20 @@
string_date = description.match(/<p>Watched on (.*)<\/p>/)[1]
Time.parse string_date
end
def title_from_title(title)
- title.split(' - ')[0..-2].join(' - ').force_encoding("UTF-8")
+ title.split(' - ')[0..-2].join(' - ')
+ .split(',')[0..-2].join(',')
+ .strip
+ .force_encoding("UTF-8")
+ end
+
+ def year_from_title(title)
+ title.split(' - ')[0..-2].join(' - ')
+ .split(',').last
+ .strip
+ .force_encoding("UTF-8")
end
def score_from_title(title)
html_score = title.split(' - ').last
html_score.force_encoding("UTF-8")
\ No newline at end of file