<commit_before>class RubyTubeNoAuth
	attr_accessor :client
	
	def initialize(dev_key="")
		@client = GData::Client::YouTube.new
		@client.source = "RubyTube"
		if dev_key
			@client.developer_key = dev_key
		end
	end
	
	def find(id)
		res = @client.get("http://gdata.youtube.com/feeds/api/videos/#{id}")
		xml = Hpricot.XML(res.body)
		entry = xml.at("entry")
		vid = YTVideo.new({
			:id => (entry/"yt:videoid").text,
			:title => (entry/"title").text,
			:description => (entry/"media:description").text,
			:keywords => (entry/"media:keywords").text,
			:duration => (entry/"yt:duration").attr("seconds").to_i,
			:player_uri => (entry/"link[@rel='alternate']").attr("href"),
			:ratings_uri => (entry/"link[@rel$='ratings']").attr("href"),
			:comments_uri => (entry/"gd:comments").search("gd:feedlink").attr("href"),
			:comment_count => (entry/"gd:comments").search("gd:feedlink").attr("countHint").to_i,
			:published_at => Time.parse((entry/"published").text),
			:updated_at => Time.parse((entry/"updated").text),
			:view_count => (entry/"yt:statistics").empty? ? 0 : (entry/"yt:statistics").attr("viewCount"),
			:favorite_count => (entry/"yt:statistics").empty? ? 0 : (entry/"yt:statistics").attr("favoriteCount"),
			:comments => comments((entry/"yt:videoid").text),
			:ratings => ratings((entry/"yt:videoid").text),
			:status => status,
			:thumbnails => process_thumbnail_urls(entry)
		})
		vid
	end
	
	def comments(id)
		res = @client.get("http://gdata.youtube.com/feeds/api/videos/#{id}/comments")
		xml = Hpricot.XML(res.body)
		comments = Array.new
		if (xml/"entry").nitems > 0
			(xml/"entry").each do |entry|
				cmt = YTComment.new({
					:title => (entry/"title").text,
					:content => (entry/"content").text,
					:author => (entry/"author").search("name").text,
					:author_uri => (entry/"author").search("uri").text,
					:video_uri => (entry/"link[@rel='related']").attr("href")
				})
				comments << cmt
			end<commit_msg>check for nil instead of empty<commit_after>class RubyTubeNoAuth
	attr_accessor :client
	
	def initialize(dev_key="")
		@client = GData::Client::YouTube.new
		@client.source = "RubyTube"
		if dev_key
			@client.developer_key = dev_key
		end
	end
	
	def find(id)
		res = @client.get("http://gdata.youtube.com/feeds/api/videos/#{id}")
		xml = Hpricot.XML(res.body)
		entry = xml.at("entry")
		vid = YTVideo.new({
			:id => (entry/"yt:videoid").text,
			:title => (entry/"title").text,
			:description => (entry/"media:description").text,
			:keywords => (entry/"media:keywords").text,
			:duration => (entry/"yt:duration").attr("seconds").to_i,
			:player_uri => (entry/"link[@rel='alternate']").attr("href"),
			:ratings_uri => (entry/"link[@rel$='ratings']").attr("href"),
			:comments_uri => (entry/"gd:comments").search("gd:feedlink").attr("href"),
			:comment_count => (entry/"gd:comments").search("gd:feedlink").attr("countHint").to_i,
			:published_at => Time.parse((entry/"published").text),
			:updated_at => Time.parse((entry/"updated").text),
			:view_count => (entry/"yt:statistics").nil? ? 0 : (entry/"yt:statistics").attr("viewCount"),
			:favorite_count => (entry/"yt:statistics").nil? ? 0 : (entry/"yt:statistics").attr("favoriteCount"),
			:comments => comments((entry/"yt:videoid").text),
			:ratings => ratings((entry/"yt:videoid").text),
			:status => status,
			:thumbnails => process_thumbnail_urls(entry)
		})
		vid
	end
	
	def comments(id)
		res = @client.get("http://gdata.youtube.com/feeds/api/videos/#{id}/comments")
		xml = Hpricot.XML(res.body)
		comments = Array.new
		if (xml/"entry").nitems > 0
			(xml/"entry").each do |entry|
				cmt = YTComment.new({
					:title => (entry/"title").text,
					:content => (entry/"content").text,
					:author => (entry/"author").search("name").text,
					:author_uri => (entry/"author").search("uri").text,
					:video_uri => (entry/"link[@rel='related']").attr("href")
				})
				comments << cmt
			end
{'fraction_non_alphanumeric': 0.2226751592356688, 'fraction_numerical': 0.0015286624203821656, 'mean_word_length': 4.437673130193906, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 49, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 10}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3066876', 'n_tokens_mistral': 1570, 'n_tokens_neox': 1371, 'n_words': 194}