Sha256: 3c9e2846fa3cafb7cf35716b2ddc140a76f95fd94bf6fb235e712e01b1128d18

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

# encoding: utf-8
module Nokaya

  class TumblrAlbum < Basic

    def initialize args, options
      super(args, options)
      @type = :tumblr
      parsed = self.parse(args[0])
      @image_url = album(parsed)
      @file_name = name()
      @path = "#{@path}/tumblr-#{@workers.timed}"
    end

    private

    def album page
      refs = []
      queries = ['img.photo', '.post .photo a img', '.entry img', 'article img', '.image img', '.item_content img', 'img.post-image', '.box img', '#allposts img', '.media img', '.wide img', '.big img', '.large img', '.gallery img', '.photos img', '.content img', 'img']
      queries.each do |query|
        refs = page.css query
        next if refs.empty?
        break
      end
      links = []
      refs.each do |l|
        target = l['src']
        unless (target == 'reblog.png' || target =~ /statcounter/ || target =~ /impixu/ || target =~ /quantserve/ || target == 'like.png')
          links << target
        end
      end
      links
    end

    def name
      @image_url.map do |url|
        "#{@type.to_s}-#{File.basename(url).gsub('tumblr_', '')}"
      end
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
nokaya-0.1.1 lib/nokaya/tumblr_album.rb