Sha256: 8613ce4ab79d81fafe0c27084df739be0289367ec193431a5ccb63f2bbe027d2

Contents?: true

Size: 785 Bytes

Versions: 4

Compression:

Stored size: 785 Bytes

Contents

class Knj::YouTube
	def self.all_videos(data, params = {}, opts = {})
		params[:per_page] = 50
		
		ret_arr = []
		go_through_pages = true
		page = 1
		while go_through_pages
			print "Getting page #{page.to_s}\n"
			
			newparams = Marshal.load(Marshal.dump(params))
			newparams[:page] = page
			videos = data["youtube"].videos_by(newparams)
			
			videos.videos.each do |video|
				if data["check_stop"] and data["check_stop"].respond_to?("check_stop_parsing")
					if data["check_stop"].check_stop_parsing(video)
						go_through_pages = false
						break
					end
				end
				
				ret_arr << video
			end
			
			status = videos.next_page
			break if !status
			
			page += 1
			
			if data["pages"] and page > data["pages"].to_i
				break
			end
		end
		
		return ret_arr
	end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
knjrbfw-0.0.8 lib/knj/youtube.rb
knjrbfw-0.0.7 lib/knj/youtube.rb
knjrbfw-0.0.4 lib/knj/youtube.rb
knjrbfw-0.0.3 lib/knj/youtube.rb