[gnome-games] tools: Add psxdatacenter-gameinfo.py



commit 1236fdf8e662687d7948b83fa6d2cbd9111ea573
Author: Adrien Plazas <kekun plazas laposte net>
Date:   Sun Jul 31 00:57:16 2016 +0200

    tools: Add psxdatacenter-gameinfo.py
    
    Add the PlayStation DataCenter scrapper.
    
    This will be used in a next commit to generate a PlayStation gameinfo
    file.

 tools/gameinfo/psxdatacenter-gameinfo.py |   20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)
---
diff --git a/tools/gameinfo/psxdatacenter-gameinfo.py b/tools/gameinfo/psxdatacenter-gameinfo.py
index 4953318..349fdca 100755
--- a/tools/gameinfo/psxdatacenter-gameinfo.py
+++ b/tools/gameinfo/psxdatacenter-gameinfo.py
@@ -30,7 +30,7 @@ def _fetch_page(url):
     return response.text
 
 class GamesListScrapper:
-    def _parse_game_list_page(page, gameinfo, verbose=True):
+    def _parse_game_list_page(page, gameinfo, verbose=False):
         skip = '.*?'
         grab = '(.*?)'
 
@@ -46,24 +46,20 @@ class GamesListScrapper:
         domain = 'http://psxdatacenter.com/'
 
         for match in re.finditer(game_expr, page, re.DOTALL):
-            comments = {
-                'info': domain + match.group(1),
-            }
-
-            disc_ids = [disc_id.lower() for disc_id in match.group(2).split("<br>")]
+            disc_ids = match.group(2).split("<br>")
 
             title = match.group(3).split('<br>')[0]
             title = title.split('&nbsp; -&nbsp;')[0]
+            if verbose:
+                print("Adding " + " ".join(disc_ids) + ": " + title)
+
+            discs_node = gameinfo.add_game_discs(title, disc_ids)
 
+            discs_node.set('info', domain + match.group(1))
             if '<u>Includes:</u>' in match.group(3):
                 includes = match.group(3).split('<u>Includes:</u>')[1].replace('\n', ' ').replace('&nbsp;', 
' ').replace('</span>', '')
                 includes = re.sub('<span.*?>', '', includes)
-                comments['includes'] = includes.strip()
-
-            if verbose:
-                print("Adding " + " ".join(disc_ids).upper() + ": " + title)
-
-            gameinfo.add_game_discs(title, disc_ids, comments)
+                discs_node.set('includes', includes.strip())
 
     def fetch_tmp_gameinfo():
         gameinfo = Gameinfo()


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