From c7f5fc0e63eb49969870c1eb4dfb2631fa1db087 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Tue, 17 Mar 2009 19:09:13 -0400 Subject: [PATCH] Added the ability to download FuckedTube (http://www.fuckedtube.com/) videos. --- src/websites/fuckedtube.rb | 64 +++++++++++++++ test/fixtures/fuckedtube/3.html | 133 ++++++++++++++++++++++++++++++++ test/fuckedtube_remote_test.rb | 32 ++++++++ test/fuckedtube_test.rb | 57 ++++++++++++++ test/remote_test_suite.rb | 1 + test/test_suite.rb | 1 + 6 files changed, 288 insertions(+) create mode 100644 src/websites/fuckedtube.rb create mode 100644 test/fixtures/fuckedtube/3.html create mode 100644 test/fuckedtube_remote_test.rb create mode 100644 test/fuckedtube_test.rb diff --git a/src/websites/fuckedtube.rb b/src/websites/fuckedtube.rb new file mode 100644 index 0000000..dfde083 --- /dev/null +++ b/src/websites/fuckedtube.rb @@ -0,0 +1,64 @@ +# +# Copyright Michael Orlitzky +# +# http://michael.orlitzky.com/ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# http://www.fsf.org/licensing/licenses/gpl.html +# + +require 'src/website' + +class Fuckedtube < Website + + VALID_FUCKEDTUBE_URL_REGEX = /^(http:\/\/)?(www\.)?fuckedtube\.com\/video\/\d+\/(.+)$/ + + def self.owns_url?(url) + return url =~ VALID_FUCKEDTUBE_URL_REGEX + end + + + def get_video_url() + page_data = self.get_page_data(@url) + video_url = self.parse_video_url(page_data) + return video_url + end + + + protected; + + # Get the FLV file URL from the HTML page for this movie. + # It's stored in some Flash variable. + def parse_video_url(page_data) + video_url_regex = /\?movie=([a-z0-9\-_]+\.flv)&/i + matches = video_url_regex.match(page_data) + + if (matches.nil? || matches.length < 2) + raise StandardError.new('Could not find the "movie" flash variable on the page.'); + end + + return "http://www.fuckedtube.com/videos/br_#{matches[1]}" + 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/test/fixtures/fuckedtube/3.html b/test/fixtures/fuckedtube/3.html new file mode 100644 index 0000000..b008bdb --- /dev/null +++ b/test/fixtures/fuckedtube/3.html @@ -0,0 +1,133 @@ + + + +A Different Kind Of Breast Exam | Fucked Tube - porn you shouldnt watch, ever + + + + + + + + + + + + +
+ + +
+
+
+
+
+

A Different Kind Of Breast Exam

+ FREE Signup! +

+

[Humorous] Girl goes into a store and scans her breasts and ass on the photocopier. Lucky day for the store attendant.

+
+ +
+
+
+ +
+

Our Porn Friends

+ +
+ + +
+

More Great Sites

+
+
    +
+
+
+
+

Video Categories

+ +

Random Videos

+
    +
  • Absexing
  • +
  • Creepy Old Fondler
  • +
  • Quick And Dark Anal Ravaging
  • +
  • Stumped About Anal
  • +
+
Signup FREE!
+
+
+
+
+ +
Fucked Tube nasty videos, bizarre porn, fucked porn
+
+ + + + diff --git a/test/fuckedtube_remote_test.rb b/test/fuckedtube_remote_test.rb new file mode 100644 index 0000000..eeca066 --- /dev/null +++ b/test/fuckedtube_remote_test.rb @@ -0,0 +1,32 @@ +# +# Copyright Michael Orlitzky +# +# http://michael.orlitzky.com/ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# http://www.fsf.org/licensing/licenses/gpl.html +# + +require 'test/unit' +require 'src/websites/fuckedtube' + + +class FuckedtubeRemoteTest < Test::Unit::TestCase + + def test_get_video_filename_works_on_good_urls + ft = Fuckedtube.new('http://www.fuckedtube.com/video/161/Pumped-Pussy/') + expected_filename = 'br_pumpedpussy.flv' + actual_filename = ft.get_video_filename() + assert_equal(expected_filename, actual_filename) + end + +end diff --git a/test/fuckedtube_test.rb b/test/fuckedtube_test.rb new file mode 100644 index 0000000..21d4319 --- /dev/null +++ b/test/fuckedtube_test.rb @@ -0,0 +1,57 @@ +# +# Copyright Michael Orlitzky +# +# http://michael.orlitzky.com/ +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# http://www.fsf.org/licensing/licenses/gpl.html +# + +require 'test/unit' +require 'src/websites/fuckedtube' + + +class FuckedtubeTest < Test::Unit::TestCase + + def test_owns_fuckedtube_urls + assert(Fuckedtube.owns_url?('http://www.fuckedtube.com/video/161/Pumped-Pussy/')) + assert(Fuckedtube.owns_url?('http://www.fuckedtube.com/video/152/Hits-From-The-Pong')) + assert(Fuckedtube.owns_url?('http://www.fuckedtube.com/video/143/Hot-n-Spicy-Jizz/')) + assert(Fuckedtube.owns_url?('http://www.fuckedtube.com/video/4/I-Spy-A-Cervix')) + end + + + def test_doesnt_own_infoq_urls + assert(!Fuckedtube.owns_url?('http://www.infoq.com/interviews/jim-weirich-discusses-rake')) + end + + + def test_doesnt_own_efukt_urls + assert(!Fuckedtube.owns_url?('http://www.efukt.com/2308_How_To_Fuck_Like_A_King.html')) + assert(!Fuckedtube.owns_url?('http://www.efukt.com/2304_The_Dumbest_Porno_Ever_Made.html')) + end + + + def test_parse_video_url + ft = Fuckedtube.new(nil) + + page_data = nil + + File.open('test/fixtures/fuckedtube/3.html') do |f| + page_data = f.read + end + + test_result = ft.send('parse_video_url', page_data) + assert_equal('http://www.fuckedtube.com/videos/br_scan.flv', test_result) + end + +end diff --git a/test/remote_test_suite.rb b/test/remote_test_suite.rb index 46c75a5..5068cf1 100644 --- a/test/remote_test_suite.rb +++ b/test/remote_test_suite.rb @@ -16,6 +16,7 @@ # http://www.fsf.org/licensing/licenses/gpl.html # +require 'test/fuckedtube_remote_test' require 'test/infoq_remote_test' require 'test/uri_utilities_remote_test' require 'test/youporn_remote_test' diff --git a/test/test_suite.rb b/test/test_suite.rb index 41f1f8c..a1a4390 100644 --- a/test/test_suite.rb +++ b/test/test_suite.rb @@ -17,6 +17,7 @@ # require 'test/efukt_test' +require 'test/fuckedtube_test' require 'test/howcast_test' require 'test/infoq_test' require 'test/redtube_test' -- 2.43.2