From 174589cd65cf32d4a54b9298953228f6094c7128 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Sat, 21 Mar 2009 00:35:54 -0400 Subject: [PATCH] Factored out the Youtube implementation of get_page_data into the Website superclass. --- src/website.rb | 15 +++++++++++++++ src/websites/efukt.rb | 11 ----------- src/websites/fuckedtube.rb | 11 ----------- src/websites/infoq.rb | 11 ----------- src/websites/veoh.rb | 10 ---------- src/websites/vimeo.rb | 10 ---------- src/websites/youtube.rb | 10 ---------- 7 files changed, 15 insertions(+), 63 deletions(-) diff --git a/src/website.rb b/src/website.rb index b5a501f..5e06479 100644 --- a/src/website.rb +++ b/src/website.rb @@ -48,6 +48,21 @@ class Website return uri.host end + + + def get_page_data(url) + # A naive implementation that just grabs the + # data from a page. + uri = URI.parse(url) + + response = Net::HTTP.start(uri.host, uri.port) do |http| + http.get(uri.request_uri) + end + + return response.body + end + + public; diff --git a/src/websites/efukt.rb b/src/websites/efukt.rb index f4cc58d..4d5d397 100644 --- a/src/websites/efukt.rb +++ b/src/websites/efukt.rb @@ -71,15 +71,4 @@ class Efukt < Website end - # Just make a normal HTTP "get" request. - def get_page_data(url) - uri = URI.parse(url) - - response = Net::HTTP.start(uri.host, uri.port) do |http| - http.get(uri.path) - end - - return response.body - end - end diff --git a/src/websites/fuckedtube.rb b/src/websites/fuckedtube.rb index dfde083..c8b6ca7 100644 --- a/src/websites/fuckedtube.rb +++ b/src/websites/fuckedtube.rb @@ -50,15 +50,4 @@ class Fuckedtube < Website end - # Just make a normal HTTP "get" request. - def get_page_data(url) - uri = URI.parse(url) - - response = Net::HTTP.start(uri.host, uri.port) do |http| - http.get(uri.path) - end - - return response.body - end - end diff --git a/src/websites/infoq.rb b/src/websites/infoq.rb index dca55fa..1829c8c 100644 --- a/src/websites/infoq.rb +++ b/src/websites/infoq.rb @@ -55,15 +55,4 @@ class Infoq < Website end - # Just make a normal HTTP "get" request. - def get_page_data(url) - uri = URI.parse(url) - - response = Net::HTTP.start(uri.host, uri.port) do |http| - http.get(uri.path) - end - - return response.body - end - end diff --git a/src/websites/veoh.rb b/src/websites/veoh.rb index c961d68..8978feb 100644 --- a/src/websites/veoh.rb +++ b/src/websites/veoh.rb @@ -77,14 +77,4 @@ class Veoh < Website end - def get_page_data(url) - uri = URI.parse(url) - - response = Net::HTTP.start(uri.host, uri.port) do |http| - http.get(uri.path) - end - - return response.body - end - end diff --git a/src/websites/vimeo.rb b/src/websites/vimeo.rb index 56243fa..b3dfe74 100644 --- a/src/websites/vimeo.rb +++ b/src/websites/vimeo.rb @@ -119,14 +119,4 @@ class Vimeo < Website end - def get_page_data(url) - uri = URI.parse(url) - - response = Net::HTTP.start(uri.host, uri.port) do |http| - http.get(uri.path) - end - - return response.body - end - end diff --git a/src/websites/youtube.rb b/src/websites/youtube.rb index cbda4e2..c124f53 100644 --- a/src/websites/youtube.rb +++ b/src/websites/youtube.rb @@ -97,16 +97,6 @@ class Youtube < Website return t_parameter end - - def get_page_data(url) - uri = URI.parse(url) - - response = Net::HTTP.start(uri.host, uri.port) do |http| - http.get(uri.request_uri) - end - - return response.body - end end -- 2.44.2