[grilo-plugins] thegamesdb: Add support for Game Gear disambiguation



commit a4ab69de82564948f6b2bb3331081690cb4b9eb9
Author: Bastien Nocera <hadess hadess net>
Date:   Sun May 29 00:51:20 2016 +0200

    thegamesdb: Add support for Game Gear disambiguation
    
    We were expecting all suffixes to be 3 letters, they can be 2 in the
    case of the Game Gear suffix (*.gg).
    
    This also fixes the matching according to the review in:
    https://bugzilla.gnome.org/show_bug.cgi?id=766678#c18

 src/lua-factory/sources/grl-thegamesdb.lua  |    7 +-
 tests/games/Makefile.am                     |    4 +-
 tests/games/data/network-data.ini           |    6 +
 tests/games/data/resolve-getgame-sonic.data |   25 +++
 tests/games/data/resolve-sonic.data         |  274 +++++++++++++++++++++++++++
 tests/games/test_games.c                    |   13 ++
 6 files changed, 327 insertions(+), 2 deletions(-)
---
diff --git a/src/lua-factory/sources/grl-thegamesdb.lua b/src/lua-factory/sources/grl-thegamesdb.lua
index 045851f..8e5c4c5 100644
--- a/src/lua-factory/sources/grl-thegamesdb.lua
+++ b/src/lua-factory/sources/grl-thegamesdb.lua
@@ -111,7 +111,12 @@ end
 function get_suffix (url)
     if not url then return nil end
     -- Return a 3-letter suffix
-    return url:match('.-%.(...)$')
+    local ret = url:match('*-%.(...)$')
+    if not ret then
+      -- Try with a 2-letter suffix (Game Gear...)
+      ret = url:match('*-%.(..)$')
+    end
+    return ret
 end
 
 function get_title (title)
diff --git a/tests/games/Makefile.am b/tests/games/Makefile.am
index be421b3..fe73e23 100644
--- a/tests/games/Makefile.am
+++ b/tests/games/Makefile.am
@@ -36,7 +36,9 @@ dist_noinst_DATA =                    \
    data/resolve-getgame-sonic-sms.data\
    data/resolve-sonic-sms.data        \
    data/resolve-asterix.data          \
-   data/resolve-getgame-asterix.data
+   data/resolve-getgame-asterix.data  \
+   data/resolve-sonic.data            \
+   data/resolve-getgame-sonic.data
 
 noinst_PROGRAMS = $(TEST_PROGS)
 
diff --git a/tests/games/data/network-data.ini b/tests/games/data/network-data.ini
index 9c5f5b7..c6a9661 100644
--- a/tests/games/data/network-data.ini
+++ b/tests/games/data/network-data.ini
@@ -30,3 +30,9 @@ data=resolve-asterix.data
 
 [http://thegamesdb.net/api/GetGame.php?id=11837]
 data=resolve-getgame-asterix.data
+
+[http://thegamesdb.net/api/GetGamesList.php?name=Sonic%20the%20Hedgehog&platform=Sega%20Game%20Gear]
+data=resolve-sonic.data
+
+[http://thegamesdb.net/api/GetGame.php?id=5754]
+data=resolve-getgame-sonic.data
diff --git a/tests/games/data/resolve-getgame-sonic.data b/tests/games/data/resolve-getgame-sonic.data
new file mode 100644
index 0000000..6f3824e
--- /dev/null
+++ b/tests/games/data/resolve-getgame-sonic.data
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Data>
+<baseImgUrl>http://thegamesdb.net/banners/</baseImgUrl>
+<Game>
+<id>5754</id>
+<GameTitle>Sonic the Hedgehog</GameTitle>
+<AlternateTitles><title>Sonic the hedgehog (jue) (v1.1)</title></AlternateTitles><PlatformId>20</PlatformId>
+<Platform>Sega Game Gear</Platform>
+<ReleaseDate>06/23/1991</ReleaseDate>
+<Overview>It's Super Sonic!!! He's here! It's Sonic The Hedgehog on Game Gear! And he's busting the speed 
barrier wide open! Blaze by in a blur with his supersonic spin attack. Soar through the tingling rings for 
super scores. And dash past trouble with Sonic's power-sneakers. Smirk in the face of danger as you sail over 
glistening hills, scuttle over crumbling bridges and hops rocks in a raging waterfall. Swim through 
underwater passageways. And plummet down tunnels. Are you ready for life in the fast lane? Then get into 
gear... with Sonic The Hedgehog on Game Gear! Super pace! Super graphics! And Sonic's super attitude! Soar 
through BONUS LEVELS brimming with springs, bumpers, flippers, and more. 5 super challenging zones with 3 
acts in each zone.</Overview>
+<Genres><genre>Platform</genre></Genres><Players>1</Players><Co-op>No</Co-op>
+<Youtube>http://www.youtube.com/watch?v=-D00HFMfmro</Youtube>
+<Publisher>Sega</Publisher>
+<Developer>Sega</Developer>
+<Rating>7</Rating><Similar><SimilarCount>8</SimilarCount><Game><id>33733</id><PlatformId>23</PlatformId></Game><Game><id>7581</id><PlatformId>15</PlatformId></Game><Game><id>17073</id><PlatformId>1</PlatformId></Game><Game><id>114</id><PlatformId>18</PlatformId></Game><Game><id>3016</id><PlatformId>35</PlatformId></Game><Game><id>5544</id><PlatformId>36</PlatformId></Game><Game><id>16645</id><PlatformId>12</PlatformId></Game><Game><id>18802</id><PlatformId>6</PlatformId></Game></Similar><Images>
+<fanart>
+<original width="1280" height="720">fanart/original/5754-1.jpg</original>
+<thumb>fanart/thumb/5754-1.jpg</thumb>
+</fanart>
+<boxart side="back" width="1527" height="1370" 
thumb="boxart/thumb/original/back/5754-1.jpg">boxart/original/back/5754-1.jpg</boxart>
+<boxart side="front" width="490" height="684" 
thumb="boxart/thumb/original/front/5754-1.jpg">boxart/original/front/5754-1.jpg</boxart>
+<banner width="760" height="140">graphical/5754-g.jpg</banner><clearlogo width="400" 
height="183">clearlogo/5754.png</clearlogo></Images>
+</Game>
+</Data>
diff --git a/tests/games/data/resolve-sonic.data b/tests/games/data/resolve-sonic.data
new file mode 100644
index 0000000..a96ae89
--- /dev/null
+++ b/tests/games/data/resolve-sonic.data
@@ -0,0 +1,274 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+
+<Data>
+<Game>
+<id>5755</id>
+<GameTitle>Sonic the Hedgehog 2</GameTitle>
+<ReleaseDate>11/17/1992</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>5754</id>
+<GameTitle>Sonic the Hedgehog</GameTitle>
+<ReleaseDate>06/23/1991</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25213</id>
+<GameTitle>Sonic Blast</GameTitle>
+<ReleaseDate>01/01/1996</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25263</id>
+<GameTitle>Sonic &amp; Tails</GameTitle>
+<ReleaseDate>11/23/1993</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>26760</id>
+<GameTitle>Sonic Drift</GameTitle>
+<ReleaseDate>03/18/1994</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>11145</id>
+<GameTitle>Sonic Labyrinth</GameTitle>
+<ReleaseDate>01/01/1995</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25216</id>
+<GameTitle>Sonic 2 In 1: Sonic 2 + Sonic Spinball</GameTitle>
+<ReleaseDate>01/01/1995</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>19062</id>
+<GameTitle>Sonic Drift 2</GameTitle>
+<ReleaseDate>01/01/1995</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>19993</id>
+<GameTitle>The Ottifants</GameTitle>
+<ReleaseDate>01/01/1993</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25248</id>
+<GameTitle>The Terminator</GameTitle>
+<ReleaseDate>01/01/1992</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>24277</id>
+<GameTitle>The Chessmaster</GameTitle>
+<ReleaseDate>01/01/1992</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25210</id>
+<GameTitle>The Smurfs</GameTitle>
+<ReleaseDate>01/01/1994</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>14106</id>
+<GameTitle>The Simpsons: Bart vs. the Space Mutants</GameTitle>
+<ReleaseDate>01/01/1991</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>19836</id>
+<GameTitle>The Simpsons: Bart vs. the World</GameTitle>
+<ReleaseDate>01/01/1993</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>5746</id>
+<GameTitle>The Lion King</GameTitle>
+<ReleaseDate>01/01/1995</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>11828</id>
+<GameTitle>The Addams Family</GameTitle>
+<ReleaseDate>01/01/1994</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25197</id>
+<GameTitle>Robocop versus The Terminator</GameTitle>
+<ReleaseDate>01/01/1993</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25117</id>
+<GameTitle>The Itchy &amp; Scratchy Game</GameTitle>
+<ReleaseDate>01/01/1995</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25244</id>
+<GameTitle>T2: The Arcade Game</GameTitle>
+<ReleaseDate>01/01/1993</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>14105</id>
+<GameTitle>The Majors Pro Baseball</GameTitle>
+<ReleaseDate>01/01/1992</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25114</id>
+<GameTitle>The Incredible Hulk</GameTitle>
+<ReleaseDate>01/01/1995</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25195</id>
+<GameTitle>Rise of the Robots</GameTitle>
+<ReleaseDate>01/01/1995</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25087</id>
+<GameTitle>The Excellent Dizzy Collection</GameTitle>
+<ReleaseDate>11/01/1993</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>5734</id>
+<GameTitle>Astérix and the Secret Mission</GameTitle>
+<ReleaseDate>01/01/1993</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>21771</id>
+<GameTitle>Dragon: The Bruce Lee Story</GameTitle>
+<ReleaseDate>08/20/1993</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>24275</id>
+<GameTitle>Captain America and the Avengers</GameTitle>
+<ReleaseDate>01/01/1993</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>11836</id>
+<GameTitle>Disney's Ariel: The Little Mermaid</GameTitle>
+<ReleaseDate>01/01/1992</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25091</id>
+<GameTitle>Garfield: Caught in the Act</GameTitle>
+<ReleaseDate>12/14/1995</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>11837</id>
+<GameTitle>Astérix and the Great Rescue</GameTitle>
+<ReleaseDate>01/01/1995</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>21759</id>
+<GameTitle>The Berenstain Bears: Camping Adventure</GameTitle>
+<ReleaseDate>01/01/1994</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25249</id>
+<GameTitle>Tom and Jerry: The Movie</GameTitle>
+<ReleaseDate>01/01/1993</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25321</id>
+<GameTitle>Superman: The Man of Steel</GameTitle>
+<ReleaseDate>01/01/1993</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>21321</id>
+<GameTitle>The Lost World: Jurassic Park</GameTitle>
+<ReleaseDate>01/01/1997</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>17762</id>
+<GameTitle>Greendog: The Beached Surfer Dude!</GameTitle>
+<ReleaseDate>08/18/1993</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25246</id>
+<GameTitle>Tarzan: Lord of the Jungle</GameTitle>
+<ReleaseDate>01/01/1994</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>5739</id>
+<GameTitle>The Lucky Dime Caper Starring Donald Duck</GameTitle>
+<ReleaseDate>01/01/1991</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>5760</id>
+<GameTitle>Super Star Wars: Return of the Jedi</GameTitle>
+<ReleaseDate>01/01/1994</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>21769</id>
+<GameTitle>Desert Strike: Return to the Gulf</GameTitle>
+<ReleaseDate>01/01/1994</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25115</id>
+<GameTitle>Indiana Jones and the Last Crusade</GameTitle>
+<ReleaseDate>01/01/1992</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>19049</id>
+<GameTitle>Shining Force II: The Sword of Hajya</GameTitle>
+<ReleaseDate>01/01/1994</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>24269</id>
+<GameTitle>The Simpsons: Bartman Meets Radioactive Man</GameTitle>
+<ReleaseDate>12/01/1992</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25138</id>
+<GameTitle>Mighty Morphin Power Rangers: The Movie</GameTitle>
+<ReleaseDate>01/01/1994</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25222</id>
+<GameTitle>Star Trek: Generations: Beyond the Nexus</GameTitle>
+<ReleaseDate>01/01/1995</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25223</id>
+<GameTitle>Star Trek: The Next Generation: Advanced Holodeck Tutorial</GameTitle>
+<ReleaseDate>01/01/1995</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+<Game>
+<id>25193</id>
+<GameTitle>Quest for the Shaven Yak starring Ren Hoek &amp; Stimpy</GameTitle>
+<ReleaseDate>01/01/1994</ReleaseDate>
+<Platform>Sega Game Gear</Platform>
+</Game>
+</Data>
diff --git a/tests/games/test_games.c b/tests/games/test_games.c
index e02d354..4220ab5 100644
--- a/tests/games/test_games.c
+++ b/tests/games/test_games.c
@@ -115,6 +115,7 @@ test_resolve_thumbnail_found (GrlSource *source,
                               GrlOperationOptions *options,
                               const gchar *title,
                               const gchar *mime,
+                              const gchar *url,
                               guint expected_thumbnail_index,
                               const gchar *expected_thumbnail_url)
 {
@@ -124,6 +125,7 @@ test_resolve_thumbnail_found (GrlSource *source,
 
   media = build_game_media (title);
   grl_media_set_mime (media, mime);
+  grl_media_set_url (media, url);
 
   grl_operation_options_set_resolution_flags (options, GRL_RESOLVE_FULL);
 
@@ -162,24 +164,35 @@ test_resolve_thumbnails_found (void)
   test_resolve_thumbnail_found (source, keys, options,
                                 "Kirby & the Amazing Mirror",
                                 "application/x-gba-rom",
+                                NULL,
                                 0,
                                 "http://thegamesdb.net/banners/boxart/original/front/2336-1.png";);
 
   test_resolve_thumbnail_found (source, keys, options,
                                 "Kirby's Dream Land",
                                 "application/x-gameboy-rom",
+                                NULL,
                                 0,
                                 "http://thegamesdb.net/banners/boxart/original/front/8706-1.jpg";);
 
   test_resolve_thumbnail_found (source, keys, options,
                                 "Sonic the Hedgehog",
                                 "application/x-sms-rom",
+                                NULL,
                                 0,
                                 "http://thegamesdb.net/banners/boxart/original/front/3016-1.jpg";);
+ 
+  test_resolve_thumbnail_found (source, keys, options,
+                                "Sonic the Hedgehog",
+                                "application/x-sms-rom",
+                                "sonic.gg",
+                                0,
+                                "http://thegamesdb.net/banners/boxart/original/front/5754-1.jpg";);
 
   test_resolve_thumbnail_found (source, keys, options,
                                 "Astérix",
                                 "",
+                                NULL,
                                 0,
                                 "http://thegamesdb.net/banners/boxart/original/front/11837-1.jpg";);
 


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