X-Git-Url: http://gitweb.michael.orlitzky.com/?a=blobdiff_plain;f=lib%2Fwhatever-dl%2Fwebsites%2Ftnaflix.rb;fp=lib%2Fwhatever-dl%2Fwebsites%2Ftnaflix.rb;h=cc6bfd0d1ff069c506a441168274bc919f40b7b7;hb=6de408333ceb0d142f8fa0fef2571228e89c8fc1;hp=0000000000000000000000000000000000000000;hpb=8e886df259246365023322b78f58e4037cb536a4;p=dead%2Fwhatever-dl.git diff --git a/lib/whatever-dl/websites/tnaflix.rb b/lib/whatever-dl/websites/tnaflix.rb new file mode 100644 index 0000000..cc6bfd0 --- /dev/null +++ b/lib/whatever-dl/websites/tnaflix.rb @@ -0,0 +1,68 @@ +# +# 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() + # 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