From 898ac047794bd23c6a60929d484a7e898549752f Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Thu, 1 Oct 2009 22:45:37 -0400 Subject: [PATCH] Merged upstream branch (master). --- src/website.rb | 3 + src/websites/tnaflix.rb | 73 ++ .../tnaflix/86b08c10d3e25d277b68.html | 841 ++++++++++++++++++ .../tnaflix/c831fefc21b6bd58a012.html | 841 ++++++++++++++++++ test/test_suite.rb | 3 +- test/tnaflix_test.rb | 99 +++ 6 files changed, 1859 insertions(+), 1 deletion(-) create mode 100644 src/websites/tnaflix.rb create mode 100644 test/fixtures/tnaflix/86b08c10d3e25d277b68.html create mode 100644 test/fixtures/tnaflix/c831fefc21b6bd58a012.html create mode 100644 test/tnaflix_test.rb diff --git a/src/website.rb b/src/website.rb index ef96dc1..75f5aa8 100644 --- a/src/website.rb +++ b/src/website.rb @@ -16,6 +16,9 @@ # http://www.fsf.org/licensing/licenses/gpl.html # +# Needed for the default implementation of get_page_data. +require 'net/http' + # Necessary in a lot of subclasses; plus, we need it # to parse the server name out of our URL. require 'uri' diff --git a/src/websites/tnaflix.rb b/src/websites/tnaflix.rb new file mode 100644 index 0000000..7fd5f90 --- /dev/null +++ b/src/websites/tnaflix.rb @@ -0,0 +1,73 @@ +# +# 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 Tnaflix < Website + + VALID_TNAFLIX_URL_REGEX = /^(http:\/\/)?(www\.)?tnaflix\.com\/view_video\.php\?viewkey=([[:alnum:]]+)(&player=old)?$/ + + def self.owns_url?(url) + return url =~ VALID_TNAFLIX_URL_REGEX + end + + + def get_video_url() + # First, figure out the video id from the URL. + # Then we download the page, and parse the Flash + # variable that we need to construct the URL. + video_id = self.parse_video_id() + + # The old player page has the video URL conveniently + # stored in one variable. + old_player_url = @url + '&player=old' + old_player_page_data = get_page_data(old_player_url) + video_url = parse_video_url(old_player_page_data) + + return video_url + end + + + def get_video_filename() + return (self.parse_video_id() + '.flv') + end + + protected; + + def parse_video_id() + video_id_regex = /([[:alnum:]]+)(&player=old)?$/ + matches = video_id_regex.match(@url) + video_id = matches[1] if not (matches.nil? || matches.length < 2) + + return video_id + end + + + # The old player page has the video URL stored in a Flash + # variable called 'videoURL'. + def parse_video_url(page_data) + video_url_regex = /addVariable\(\'videoUrl\',\'([^\']+)/ + matches = video_url_regex.match(page_data) + video_url = matches[1] if not (matches.nil? || matches.length < 1) + + return video_url + end + + +end diff --git a/test/fixtures/tnaflix/86b08c10d3e25d277b68.html b/test/fixtures/tnaflix/86b08c10d3e25d277b68.html new file mode 100644 index 0000000..9e1144e --- /dev/null +++ b/test/fixtures/tnaflix/86b08c10d3e25d277b68.html @@ -0,0 +1,841 @@ + + + + Young vs Old - Skinny Guy with Hot Milf, Free Porn | Sex | Porno at Tnaflix + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Login to your TNAFlix account Login | Register +
+ +
+
+ +
+ +
+
+
+ Show Me: + Straight + Gay + Tranny +             Video Type: + Widescreen + Standard +             Thumbnails: + Video + Image +  
+
+
+ +
+ +

+
+ + + + +
+ + + + + + + + + + + + + + + + + + +
+ +

Young vs Old - Skinny Guy with Hot Milf

+
+
+
+
+

Flash Player 9 Required

+ Adobe Flash Player 9 or greater is required to view the movies on this website, You can get it for free from Adobe by clicking this link.

Sorry for the inconvienence. +

Get Adobe Flash player
+

Once installed please refresh the page and you will be able to enjoy the movie
+
+
+ + + +
+
+
+
    +
  • +
+
409 Votes
+
+
+ + +
+ Try out the new player +
+
+ + +
+ + Favorite +
+ + + +
+ Broken +
+ + +
+ + + + +
+
+
+
+ Added: 1 year ago
+ From: bonez
+ Categories: Hardcore Porn Videos, Oral Sex & Licking, Mature Sex, Huge Tits
+ Tags: Mature, Youngold, Milf, Skinny, Babe +
+
+
Great scene
+
+
Try out the Beta Tnaflix embedding, this allows you to put this video on your blog, website or forum! Just copy and paste the code and put it in your site's html!

+ Embed this movie copy & Paste: +
+ +
+
+
+ +
+ + +
+
+
+
+
+
+ + +
+ +
+
+

+
+ +
+
+
Related Videos
+
Users Videos
+
Comments (6)
+ +
+
+
+ + + +
+ +
+ + + +
+ + +
+ + + + + + + + +
+
+
+
+ + + + + +
+ + + +
+
+

Sites linking to this video:

+ +
+ To get on this list just link to this video from your site or blog and send at least 3 hits + +
+ +
+ +
+
+ + +
+ + +
+ + + + + + + +
+ + \ No newline at end of file diff --git a/test/fixtures/tnaflix/c831fefc21b6bd58a012.html b/test/fixtures/tnaflix/c831fefc21b6bd58a012.html new file mode 100644 index 0000000..f2cd303 --- /dev/null +++ b/test/fixtures/tnaflix/c831fefc21b6bd58a012.html @@ -0,0 +1,841 @@ + + + + Young girl Gives a Forceful Handjob on Tied Guy, Free Porn | Sex | Porno at Tnaflix + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ Login to your TNAFlix account Login | Register +
+ +
+
+ +
+ +
+
+
+ Show Me: + Straight + Gay + Tranny +             Video Type: + Widescreen + Standard +             Thumbnails: + Video + Image +  
+
+
+ +
+ +

+
+ + + + +
+ + + + + + + + + + + + + + + + + + +
+ +

Young girl Gives a Forceful Handjob on Tied Guy

+
+
+
+
+

Flash Player 9 Required

+ Adobe Flash Player 9 or greater is required to view the movies on this website, You can get it for free from Adobe by clicking this link.

Sorry for the inconvienence. +

Get Adobe Flash player
+

Once installed please refresh the page and you will be able to enjoy the movie
+
+
+ + + +
+
+
+
    +
  • +
+
337 Votes
+
+
+ + +
+ Try out the new player +
+
+ + +
+ + Favorite +
+ + + +
+ Broken +
+ + +
+ + + + +
+
+
+
+ Added: 1 year ago
+ From: Bestflix
+ Categories: Teen Girls, Cumshots, Oral Sex & Licking, Porn Stars
+ Tags: Teen, Handjob, Veronique, Vega, Tied +
+
+
I like handjob videos as much as I like giving them. The guy shudders so hard as he cums and Veronique is not afraid to play with the cum afterwards. A great handjob video.
+
+
Try out the Beta Tnaflix embedding, this allows you to put this video on your blog, website or forum! Just copy and paste the code and put it in your site's html!

+ Embed this movie copy & Paste: +
+ +
+
+
+ +
+ + +
+
+
+
+
+
+ + +
+ +
+
+

+
+ +
+
+
Related Videos
+
Users Videos
+
Comments (3)
+ +
+
+
+ + + +
+ +
+ + + +
+ + +
+ + + + + + + + +
+
+
+
+ + + + + +
+ + + +
+
+

Sites linking to this video:

+ +
+ To get on this list just link to this video from your site or blog and send at least 3 hits + +
+ +
+ +
+
+ + +
+ + +
+ + + + + + + +
+ + \ No newline at end of file diff --git a/test/test_suite.rb b/test/test_suite.rb index 9312ab8..3cf8af3 100644 --- a/test/test_suite.rb +++ b/test/test_suite.rb @@ -22,8 +22,9 @@ require 'test/howcast_test' require 'test/infoq_test' require 'test/megaporn_test' require 'test/redtube_test' -require 'test/veoh_test' +require 'test/tnaflix_test' require 'test/uri_utilities_test' +require 'test/veoh_test' require 'test/vimeo_test' require 'test/website_test' require 'test/yikers_test' diff --git a/test/tnaflix_test.rb b/test/tnaflix_test.rb new file mode 100644 index 0000000..3bd42d0 --- /dev/null +++ b/test/tnaflix_test.rb @@ -0,0 +1,99 @@ +# +# 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/tnaflix' + +class TnaflixTest < Test::Unit::TestCase + + def test_parse_video_id + tna = Tnaflix.new('http://www.tnaflix.com/view_video.php?viewkey=c831fefc21b6bd58a012') + video_id = tna.send('parse_video_id') + assert_equal('c831fefc21b6bd58a012', video_id) + end + + + def test_parse_second_video_id + tna = Tnaflix.new('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68') + video_id = tna.send('parse_video_id') + assert_equal('86b08c10d3e25d277b68', video_id) + end + + + def test_parse_third_video_id + tna = Tnaflix.new('http://www.tnaflix.com/view_video.php?viewkey=c831fefc21b6bd58a012&player=old') + video_id = tna.send('parse_video_id') + assert_equal('c831fefc21b6bd58a012', video_id) + end + + + def test_parse_fourth_video_id + tna = Tnaflix.new('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68&player=old') + video_id = tna.send('parse_video_id') + assert_equal('86b08c10d3e25d277b68', video_id) + end + + + def test_parse_video_url + tna = Tnaflix.new(nil) + + page_data = nil + + File.open('test/fixtures/tnaflix/c831fefc21b6bd58a012.html') do |f| + page_data = f.read + end + + actual_result = tna.send('parse_video_url', page_data) + expected_result = 'http://cdnt.tnaflix.com/videos/c8/c831fefc21b6bd58a012.flv?key=af67396eb0d05897c13e396ce78da277' + + assert_equal(expected_result, actual_result) + end + + + def test_second_parse_video_url + tna = Tnaflix.new(nil) + + page_data = nil + + File.open('test/fixtures/tnaflix/86b08c10d3e25d277b68.html') do |f| + page_data = f.read + end + + actual_result = tna.send('parse_video_url', page_data) + expected_result = 'http://cdnt.tnaflix.com/videos/86/86b08c10d3e25d277b68.flv?key=157c6255df3296ff5cf06582e3b70273' + + assert_equal(expected_result, actual_result) + end + + + + def test_owns_tnaflix_urls + assert(Tnaflix.owns_url?('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68')) + assert(Tnaflix.owns_url?('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68&player=old')) + assert(Tnaflix.owns_url?('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68')) + assert(Tnaflix.owns_url?('http://www.tnaflix.com/view_video.php?viewkey=86b08c10d3e25d277b68&player=old')) + end + + + def test_doesnt_own_redtube_urls + assert(!Tnaflix.owns_url?('http://www.redtube.com/6807')) + assert(!Tnaflix.owns_url?('www.redtube.com/6807')) + assert(!Tnaflix.owns_url?('http://redtube.com/6807')) + assert(!Tnaflix.owns_url?('redtube.com/6807')) + end +end -- 2.44.2