media/guardian.lua: Also support "old" domain name
authorBastien Nocera <hadess@hadess.net>
Sat, 24 Aug 2013 03:45:57 +0000 (24 05:45 +0200)
committerToni Gundogdu <legatvs@gmail.com>
Mon, 26 Aug 2013 05:10:40 +0000 (26 08:10 +0300)
The old "guardian.co.uk" domain name still works, so
detect older URLs as working too, without the need to access
the network, or check for redirects.

Signed-off-by: Bastien Nocera <hadess@hadess.net>
share/media/guardian.lua

index 52405ca..c42f72c 100644 (file)
@@ -24,7 +24,7 @@ local Guardian = {} -- Utility functions unique to this script
 function ident(qargs)
   return {
     can_parse_url = Guardian.can_parse_url(qargs),
-    domains = table.concat({'theguardian.com'}, ',')
+    domains = table.concat({'theguardian.com', 'guardian.co.uk'}, ',')
   }
 end
 
@@ -56,7 +56,8 @@ function Guardian.can_parse_url(qargs)
   local U = require 'socket.url'
   local t = U.parse(qargs.input_url)
   if t and t.scheme and t.scheme:lower():match('^https?$')
-       and t.host   and t.host:lower():match('theguardian%.com$')
+       and t.host   and (t.host:lower():match('theguardian%.com$')
+                         or t.host:lower():match('guardian%.co%.uk$'))
        and t.path   and (t.path:lower():match('/video/')
                          or t.path:lower():match('/audio/'))
   then