[grilo-plugins] thegamesdb: Handle situation with only one result
- From: Bastien Nocera <hadess src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [grilo-plugins] thegamesdb: Handle situation with only one result
- Date: Wed, 18 Apr 2018 16:15:29 +0000 (UTC)
commit 2d1ec6776a1e1746f3c75ddaba161de755c0cdb8
Author: Exalm <exalm7659 gmail com>
Date: Wed Apr 18 20:31:32 2018 +0500
thegamesdb: Handle situation with only one result
In that case, results_table.Data.Game would contain GameTitle, id and
other keys directly and #results_table.Data.Game would return 0.
All thegamesdb tests should pass now.
https://bugzilla.gnome.org/show_bug.cgi?id=794504
src/lua-factory/sources/grl-thegamesdb.lua | 4 ++++
1 files changed, 4 insertions(+), 0 deletions(-)
---
diff --git a/src/lua-factory/sources/grl-thegamesdb.lua b/src/lua-factory/sources/grl-thegamesdb.lua
index f492f87..3d285b4 100644
--- a/src/lua-factory/sources/grl-thegamesdb.lua
+++ b/src/lua-factory/sources/grl-thegamesdb.lua
@@ -84,6 +84,10 @@ function get_id(results, title)
not results_table.Data.Game then
return nil
end
+ -- If there's only a single match, just return it
+ if results_table.Data.Game.id then
+ return results_table.Data.Game.id.xml
+ end
for index, game in pairs(results_table.Data.Game) do
if game.GameTitle and
string.lower(game.GameTitle.xml) == string.lower(title) then
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]