Blame SOURCES/0001-guardian.lua-Update-for-website-changes.patch

779037
From 1622a28581e2c4afa9061b72a05dc1c171e891f2 Mon Sep 17 00:00:00 2001
779037
From: Bastien Nocera <hadess@hadess.net>
779037
Date: Tue, 17 Feb 2015 14:25:38 +0100
779037
Subject: [PATCH] guardian.lua: Update for website changes
779037
779037
See https://bugzilla.redhat.com/show_bug.cgi?id=1134853
779037
---
779037
 share/media/guardian.lua | 20 ++++++++++++++------
779037
 1 file changed, 14 insertions(+), 6 deletions(-)
779037
779037
diff --git a/share/media/guardian.lua b/share/media/guardian.lua
779037
index 454971c..7435204 100644
779037
--- a/share/media/guardian.lua
779037
+++ b/share/media/guardian.lua
779037
@@ -35,13 +35,17 @@ function parse(qargs)
779037
   qargs.duration_ms = Guardian.parse_duration(p)
779037
 
779037
   qargs.title = (p:match('"og:title" content="(.-)"') or '')
779037
-                  :gsub('%s+%-%s+video','')
779037
+  qargs.title = qargs.title:gsub('%s+%-%s+video','')
779037
+  qargs.title = qargs.title:gsub('%s+%–%s+video','')
779037
+
779037
+  -- FIXME this should be more generic
779037
+  qargs.title = qargs.title:gsub(''', "'")
779037
 
779037
   qargs.id = (p:match('prop8%s+=%s+["\'](.-)["\']') or '')
779037
               :match('(%d+)') or ''
779037
 
779037
-  qargs.thumb_url = p:match('"thumbnail" content="(.-)"')
779037
-                      or p:match('"og:image" content="(.-)"') or ''
779037
+  qargs.thumb_url = p:match('"og:image" content="(.-)"')
779037
+                      or p:match('"thumbnail" content="(.-)"') or ''
779037
 
779037
   qargs.streams = Guardian.iter_streams(p)
779037
 
779037
@@ -75,7 +79,7 @@ function Guardian.fetch(qargs)
779037
 end
779037
 
779037
 function Guardian.iter_streams(p)
779037
-  local u = p:match("%s+file.-:%s+'(.-)'")
779037
+  local u = p:match('&file=(.-)&poster')
779037
               or error('no match: media stream URL')
779037
   local S = require 'quvi/stream'
779037
   local s = S.stream_new(u)
779037
@@ -86,9 +90,13 @@ end
779037
 
779037
 function Guardian.parse_duration(p)
779037
   local n = tonumber(p:match('duration%:%s+"?(%d+)"?') or 0) * 1000
779037
-  if n ==0 then
779037
+  if n == 0 then
779037
     local m,s = p:match('T(%d+)M(%d+)S')
779037
-    n = (tonumber(m)*60 + tonumber(s)) * 1000
779037
+    n = ((tonumber(m) or 0) *60 + (tonumber(s) or 0)) * 1000
779037
+  end
779037
+  if n == 0 then
779037
+    local s = p:match('content="PT(%d+)S"')
779037
+    n = (tonumber(s) or 0) * 1000
779037
   end
779037
   return n
779037
 end
779037
-- 
779037
2.1.0
779037