]> gitweb.michael.orlitzky.com - dead/whatever-dl.git/commitdiff
Add support for deviantclip.com.
authorMichael Orlitzky <michael@orlitzky.com>
Wed, 5 Jan 2011 02:22:00 +0000 (21:22 -0500)
committerMichael Orlitzky <michael@orlitzky.com>
Wed, 5 Jan 2011 02:22:00 +0000 (21:22 -0500)
src/websites/deviantclip.rb [new file with mode: 0644]

diff --git a/src/websites/deviantclip.rb b/src/websites/deviantclip.rb
new file mode 100644 (file)
index 0000000..60f4fc3
--- /dev/null
@@ -0,0 +1,52 @@
+#
+# 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'
+require 'cgi'
+
+class Deviantclip < Website
+
+  VALID_DEVIANTCLIP_URL_REGEX = /^(http:\/\/)?(www.)?deviantclip\.com\/[a-z0-9\-_\.]+$/i
+
+  def self.owns_url?(url)
+    return url =~ VALID_DEVIANTCLIP_URL_REGEX
+  end
+
+
+  def get_video_url()
+    page_data = get_page_data(@url)
+    filepath = parse_video_url(page_data)
+
+    return CGI::unescape(filepath)
+  end
+
+
+  protected;
+
+  def parse_video_url(page_data)
+    video_url_regex = /"file":"([^"]+)"/i
+    matches = video_url_regex.match(page_data)
+
+    if matches.nil? or (matches.length < 2)
+      raise StandardError.new("Couldn't parse the 'file' JSON parameter.")
+    else
+      return matches[1]
+    end
+  end
+
+end