lib/jekyll-import/importers/tumblr.rb in jekyll-import-0.10.0 vs lib/jekyll-import/importers/tumblr.rb in jekyll-import-0.11.0
- old
+ new
@@ -39,10 +39,13 @@
begin
current_page = (current_page || -1) + 1
feed_url = url + "?num=#{per_page}&start=#{current_page * per_page}"
puts "Fetching #{feed_url}"
feed = open(feed_url)
- json = feed.readlines.join("\n")[21...-2] # Strip Tumblr's JSONP chars.
+ contents = feed.readlines.join("\n")
+ beginning = contents.index("{")
+ ending = contents.rindex("}")
+ json = contents[beginning..ending] # Strip Tumblr's JSONP chars.
blog = JSON.parse(json)
puts "Page: #{current_page + 1} - Posts: #{blog["posts"].size}"
batch = blog["posts"].map { |post| post_to_hash(post, format) }
# If we're rewriting, save the posts for later. Otherwise, go ahead and