From e90c00d4878c367d5f91339beb0d5929b3bd05f9 Mon Sep 17 00:00:00 2001 From: Toni Gundogdu Date: Mon, 4 Nov 2013 22:14:48 +0200 Subject: [PATCH] FIX: website/tcmag.lua: Media stream URL pattern Other notable changes: * Try to determine self-hosted/affiliate content from the stream URL * Parse thumbnail URL Signed-off-by: Toni Gundogdu --- share/lua/website/tcmag.lua | 44 +++++++++++++++----------------------------- 1 file changed, 15 insertions(+), 29 deletions(-) diff --git a/share/lua/website/tcmag.lua b/share/lua/website/tcmag.lua index d897eed..1fb0aa0 100644 --- a/share/lua/website/tcmag.lua +++ b/share/lua/website/tcmag.lua @@ -1,5 +1,6 @@ -- libquvi-scripts +-- Copyright (C) 2013 Toni Gundogdu -- Copyright (C) 2011 quvi project -- -- This file is part of libquvi-scripts . @@ -52,38 +53,23 @@ end -- function TCMag.check_external_content(self) - local page = quvi.fetch(self.page_url) - - local article = page:match('
(.-)
') - or error("no match: article") - - local s = article:match('http://.*youtube.com/embed/([^/]-)"') - if s then -- Hand over to youtube.lua - self.redirect_url = 'http://youtube.com/watch?v=' .. s - return self - end - - local s = article:match('http://.*vimeo.com/video/([0-9]+)') - if s then -- Hand over to vimeo.lua - self.redirect_url = 'http://vimeo.com/video/' .. s + local p = quvi.fetch(self.page_url) + + self.url = {p:match("file: '(.-)'") + or error("no match: media stream URL")} + + if self.url[1]:match('%.%w+$') then + -- Self-hosted content. + self.title = p:match('

(.-)

') + or error ("no match: media title") + self.id = self.url[1]:match("/%d+/%d+/(.-)/sizes/") + or error ("no match: media id") + self.thumbnail_url = p:match('"og:image" content="(.-)"') or '' + else -- Affiliate content. + self.redirect_url = self.url[1] return self end - local s = article:match('http://.*liveleak.com/e/([%w_]+)') - if s then -- Hand over to liveleak.lua - self.redirect_url = 'http://liveleak.com/e/' .. s - return self - end - - self.title = article:match('

(.-)

') - or error ("no match: media title") - - self.url = {article:match("'file': '(.-)',") - or error("no match: media url")} - - self.id = self.url[1]:match("/%d+/%d+/(.-)/sizes/") - or error ("no match: media id") - return self end -- 2.11.4.GIT