summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2014-02-07 18:07:58 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2014-02-07 18:07:58 +0100
commit8abf288264d0119eb85009fb77c055088aef038f (patch)
tree3f09e710ea341c48db4e9a606c520e02bc89c21f
parentd5e91aa3847e6dc1a1d625c6a0cb9f9dd5fc8255 (diff)
downloaddotfiles-8abf288264d0119eb85009fb77c055088aef038f.tar.gz
dotfiles-8abf288264d0119eb85009fb77c055088aef038f.tar.bz2
dotfiles-8abf288264d0119eb85009fb77c055088aef038f.zip
quvi 0.9: Add script for putlocker
-rw-r--r--.local/share/libquvi-scripts/media/putlocker.lua51
1 files changed, 51 insertions, 0 deletions
diff --git a/.local/share/libquvi-scripts/media/putlocker.lua b/.local/share/libquvi-scripts/media/putlocker.lua
new file mode 100644
index 0000000..f3abebc
--- /dev/null
+++ b/.local/share/libquvi-scripts/media/putlocker.lua
@@ -0,0 +1,51 @@
+-- libquvi-scripts
+
+local Putlocker = {}
+
+-- Identify the script.
+function ident(qargs)
+ return {
+ domains = table.concat({'putlocker.com'}, ','),
+ can_parse_url = Putlocker.can_parse_url(qargs)
+ }
+end
+
+-- Parse media URL.
+function parse(qargs)
+ local R = require 'soup_request'
+ local c = quvi.http.fetch(qargs.input_url).data
+ local p = { confirm = "Continue as Free User",
+ hash = c:match('value="([^"]+)" name="hash"') }
+ c = R.request(qargs.input_url, "POST", p)
+
+ qargs.id = qargs.input_url:match("file/([A-Z0-9]+)")
+ qargs.title = c:match('<div class="site-content">%s*<h1>(.-)<strong>')
+ --qargs.thumb_url = c:match('property="og:image"%s+content="(.-)"')
+ --qargs.duration_ms = tonumber(c:match('duration:%s*"(%d+)"') or 0) * 1000
+ qargs.streams = Putlocker.iter_streams(c, qargs)
+
+ return qargs
+end
+
+function Putlocker.iter_streams(c, qargs)
+ local S = require 'quvi/stream'
+
+ url = c:match('<a href="([^"]+)" class="download_file_link"')
+
+ -- url,container = c:match('file:%s*"(.-/)v%.(.-)"')
+ local s = S.stream_new(table.concat({"http://www.putlocker.com", url}))
+ --s.container = container
+ return { s }
+end
+
+function Putlocker.can_parse_url(qargs)
+ local U = require 'socket.url'
+ local t = U.parse(qargs.input_url)
+
+ return t and t.scheme and t.scheme:lower():match('^http$')
+ and t.host and t.host:lower():match('putlocker%.com$')
+ and t.path and t.path:match("^/file/[A-Z0-9]+")
+ and true or false
+end
+
+-- vim: set ts=2 sw=2 tw=72 expandtab: