[grilo-plugins] thegamesdb: Fix setting multiple genres



commit 95f991c76d4bde6746336e949d0329c42fec6e22
Author: 1PunMan <saurabhsingh412 gmail com>
Date:   Thu May 17 16:04:42 2018 +0530

    thegamesdb: Fix setting multiple genres
    
    The _game.Genres_ table always contains a single _genre_ value. In
    case the Game contains multiple genres, we should iterate over the
    array in _game.Genres.genre_ which this patch does.
    
    Merge-request: !5
    https://bugzilla.gnome.org/show_bug.cgi?id=796231
    
    Signed-off-by: Victor Toso <victortoso redhat com>

 src/lua-factory/sources/grl-thegamesdb.lua | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/src/lua-factory/sources/grl-thegamesdb.lua b/src/lua-factory/sources/grl-thegamesdb.lua
index 5365f89..fd3fde2 100644
--- a/src/lua-factory/sources/grl-thegamesdb.lua
+++ b/src/lua-factory/sources/grl-thegamesdb.lua
@@ -165,8 +165,12 @@ function fetch_game_cb(results)
 
     if game.Genres then
       media.genre = {}
-      for index, genre in pairs(game.Genres) do
-        table.insert(media.genre, genre.xml)
+      if game.Genres.genre.xml then
+        table.insert(media.genre, game.Genres.genre.xml)
+      else
+        for _, genre in pairs(game.Genres.genre) do
+          table.insert(media.genre, genre.xml)
+        end
       end
     end
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]