summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenjamin Franzke <benjaminfranzke@googlemail.com>2014-02-07 13:40:57 +0100
committerBenjamin Franzke <benjaminfranzke@googlemail.com>2014-02-07 13:40:57 +0100
commitd57d4653c97393925903358b23357f86f96e4831 (patch)
treeeb39df9e748224ffbce1f8098a2c2369d0b119ca
parentec64ea9653f5537b573578667953245b070514e6 (diff)
downloaddotfiles-d57d4653c97393925903358b23357f86f96e4831.tar.gz
dotfiles-d57d4653c97393925903358b23357f86f96e4831.tar.bz2
dotfiles-d57d4653c97393925903358b23357f86f96e4831.zip
uvi 0.9: Add script for flashx.tv
-rw-r--r--.local/share/libquvi-scripts/media/flashxtv.lua53
1 files changed, 53 insertions, 0 deletions
diff --git a/.local/share/libquvi-scripts/media/flashxtv.lua b/.local/share/libquvi-scripts/media/flashxtv.lua
new file mode 100644
index 0000000..f766894
--- /dev/null
+++ b/.local/share/libquvi-scripts/media/flashxtv.lua
@@ -0,0 +1,53 @@
+-- libquvi-scripts
+
+local Flashx = {}
+
+-- Identify the script.
+function ident(qargs)
+ return {
+ domains = table.concat({'flashx.tv'}, ','),
+ can_parse_url = Flashx.can_parse_url(qargs)
+ }
+end
+
+-- Parse media URL.
+function parse(qargs)
+ local c = quvi.http.fetch(qargs.input_url).data
+ qargs.title = c:match('<div class="video_title">(.-)</div>')
+ local iframe_url = c:match('<iframe[^>]+src="(http://play.flashx.tv/.-)"')
+
+ c = quvi.http.fetch(iframe_url).data
+ local p = { yes = c:match('name="yes"[^>]+value="(.-)"'),
+ sec = c:match('name="sec"[^>]+value="(.-)"') }
+ local R = require 'soup_request'
+ c = R.request("http://play.flashx.tv/player/player.php", "POST", p)
+ local data_url = c:match('data="[^"]+config=(.-)"')
+ c = quvi.http.fetch(data_url).data
+
+ qargs.id = qargs.input_url:match('video/([A-Z0-9]+)')
+ qargs.thumb_url = c:match('<image>(.-)</image>')
+ qargs.streams = Flashx.iter_streams(c, qargs)
+
+ return qargs
+end
+
+function Flashx.iter_streams(c, qargs)
+ local S = require 'quvi/stream'
+
+ url = c:match('<file>(.-)</file>')
+ local s = S.stream_new(url)
+ s.container = "flv"
+ return { s }
+end
+
+function Flashx.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('flashx%.tv$')
+ and t.path and t.path:match("^/video/[A-Z0-9]+")
+ and true or false
+end
+
+-- vim: set ts=2 sw=2 tw=72 expandtab: