[grilo-plugins] guardianvideos: Fix parsing of metadata
- From: Victor Toso <victortoso src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] guardianvideos: Fix parsing of metadata
- Date: Tue, 17 Jul 2018 09:48:53 +0000 (UTC)
commit d9df3871d45a23b87dfe39ecc1c03661f0115f41
Author: veer <bveer428 gmail com>
Date: Mon Jun 4 02:01:20 2018 +0530
guardianvideos: Fix parsing of metadata
Closes #2
Signed-off-by: Victor Toso <victortoso redhat com>
src/lua-factory/sources/grl-guardianvideos.lua | 27 ++++++++++++++++++++++++--
1 file changed, 25 insertions(+), 2 deletions(-)
---
diff --git a/src/lua-factory/sources/grl-guardianvideos.lua b/src/lua-factory/sources/grl-guardianvideos.lua
index 9db333f..ca9ded2 100644
--- a/src/lua-factory/sources/grl-guardianvideos.lua
+++ b/src/lua-factory/sources/grl-guardianvideos.lua
@@ -105,9 +105,32 @@ function create_media(item)
media.type = "video"
media.id = item.id
- media.url = item.webUrl
media.title = grl.unescape(item.webTitle)
- media.thumbnail = item.fields.thumbnail
+
+ main = item.fields.main
+ -- Some entries rarely don't have a 'main' field. So, we bail out.
+ if not main then
+ grl.warning ("No media URL metadata found for: " .. media.title)
+ return media
+ end
+
+ media.url = main:match('src="(.-%.mp4)"')
+ media.thumbnail = main:match('poster="(.-%.jpg)"')
+
+ if not media.url then
+ grl.warning ("No media streaming URL found for: " .. media.title)
+ grl.debug ("Data from: " .. media.title .. "\n" .. grl.lua.inspect(item));
+ end
+
+ if not media.thumbnail then
+ -- Try to see if we have a 'thumbnail' field. This field seems
+ -- to exist for some entries, which don't have a 'poster' field
+ if item.fields.thumbnail then
+ media.thumbnail = item.fields.thumbnail
+ else
+ grl.debug ("No media thumbnail URL found for: " .. media.title)
+ end
+ end
return media
end
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]