def test_GameDetails_MobyGames_Atari5200(self):

        from descriptionparserfactory import DescriptionParserFactory

        parseInstruction = self.get_scraper_xml_path ('04.02 - mobygames - details.xml')
        descFile = "http://www.mobygames.com/game/atari-5200/gyruss"

        parser = DescriptionParserFactory().getParser(parseInstruction)
        results = parser.parseDescription(descFile, 'utf-8')
        pprint (results)
    def test_LocalNFO(self):
        from descriptionparserfactory import DescriptionParserFactory

        parseInstruction = self.get_scraper_xml_path ('00 - local nfo.xml')
        descFile = os.path.join(self.get_testdata_path(), 'psx', 'Bushido Blade [SCUS-94180].nfo')

        parser = DescriptionParserFactory().getParser(parseInstruction)
        results = parser.parseDescription(descFile, 'utf-8')
        pprint (results)
        self.assertEqual(results[0].get('Game')[0], "Bushido Blade", "Expected game title to be Bushido Blade from .nfo")
    def test_SearchWithMultipleMatches(self):
        from descriptionparserflatfile import DescriptionParserFlatFile
        from descriptionparserfactory import DescriptionParserFactory

        parseInstruction = self.get_scraper_xml_path ('04.01 - mobygames - gamesearch.xml')
        descFile = "http://www.mobygames.com/search/quick?game=Actraiser&p=15"

        parser = DescriptionParserFactory().getParser(parseInstruction)
        results = parser.parseDescription(descFile, 'utf-8')

        self.assertTrue(len(results) == 2)
    def test_PublisherWithNumericName(self):
        from descriptionparserflatfile import DescriptionParserFlatFile
        from descriptionparserfactory import DescriptionParserFactory

        parseInstruction = self.get_scraper_xml_path ('02 - thegamesdb.xml')
        descFile = "http://thegamesdb.net/api/GetGame.php?name=Syphon%20Filter&platform=Sony%20Playstation"

        parser = DescriptionParserFactory().getParser(parseInstruction)
        results = parser.parseDescription(descFile, 'utf-8')

        self.assertEqual(results[0].get('Publisher')[0], "989", 'Expected publisher with numeric name to be a string')
    def test_TheGamesDB_SearchByNameWithApostropheAndPlatform(self):
        from descriptionparserflatfile import DescriptionParserFlatFile
        from descriptionparserfactory import DescriptionParserFactory

        parseInstruction = self.get_scraper_xml_path ('02 - thegamesdb.xml')
        descFile = "http://thegamesdb.net/api/GetGame.php?name=NBA%20Live%20%2798&platform=Super%20Nintendo%20%28SNES%29"

        parser = DescriptionParserFactory().getParser(parseInstruction)
        results = parser.parseDescription(descFile, 'utf-8')
        pprint (results)

        self.assertEqual(results[0].get('Game')[0], "NBA Live 98")
        self.assertEqual(results[0].get('Platform')[0], "Super Nintendo (SNES)")
        self.assertEqual(results[0].get('Publisher')[0], "THQ")
        self.assertEqual(results[0].get('Developer')[0], "EA Sports")
    def test_ArtworkDetail_CoverFront_MobyGames(self):
        from descriptionparserflatfile import DescriptionParserFlatFile
        from descriptionparserfactory import DescriptionParserFactory

        parseInstruction = self.get_scraper_xml_path ('04.04 - mobygames - coverdetail front.xml')
        descFile = "http://www.mobygames.com/game/snes/actraiser/cover-art/gameCoverId,170207"

        parser = DescriptionParserFactory().getParser(parseInstruction)
        results = parser.parseDescription(descFile, 'utf-8')

        filetype_boxfront_url = results[0].get('Filetypeboxfront')[0]
        # Mobygames parser extracts filename as /images/covers...; we prefix this with the domain name
        self.assertTrue(filetype_boxfront_url.startswith("http://www.mobygames.com"),
                        "Expected mobygames URL prefix to be added due to appendTo clause")
        self.assertEqual(filetype_boxfront_url, 'http://www.mobygames.com/images/covers/l/170207-actraiser-snes-front-cover.jpg')
    def test_GameDetails_MobyGames_Sega(self):

        from descriptionparserfactory import DescriptionParserFactory

        #descFile = "http://www.mobygames.com/game/sega-32x/blackthorne"
        #parseInstruction = "C:\\Users\\lom\\AppData\\Roaming\\XBMC\\scripts\\Rom Collection Browser\\resources\\scraper\\04.02 - mobygames - details.xml"

        parseInstruction = self.get_scraper_xml_path ('04.02 - mobygames - details.xml')
        descFile = "http://www.mobygames.com/game/sega-32x/metal-head"

        parser = DescriptionParserFactory().getParser(parseInstruction)
        results = parser.parseDescription(descFile, 'utf-8')

        self.assertEqual(results[0].get('Game')[0], "Metal Head")
        self.assertEqual(results[0].get('Developer')[0], "SEGA Enterprises Ltd.")
        self.assertEqual(results[0].get('ReleaseYear')[0], "1994")
        self.assertEqual(results[0].get('Publisher')[0], "SEGA of America, Inc.")
    def test_ArtworkLink_Screenshot_MobyGames(self):
        from descriptionparserfactory import DescriptionParserFactory

        parseInstruction = self.get_scraper_xml_path ('04.09 - mobygames - screenshotlink.xml')
        descFile = "http://www.mobygames.com/game/snes/actraiser/screenshots"

        parser = DescriptionParserFactory().getParser(parseInstruction)
        results = None
        try:
            results = parser.parseDescription(descFile, 'utf-8')
        except ParseException as e:
            print e
        except NameError as n:
            print n

        self.assertFalse(results is None)
        self.assertTrue(len(results) == 29, "Expected 29 screenshots from Mobygames")
    def test_TheGamesDB_RetrieveByIdWithMultipleGenres(self):
        from descriptionparserflatfile import DescriptionParserFlatFile
        from descriptionparserfactory import DescriptionParserFactory

        parseInstruction = self.get_scraper_xml_path ('02 - thegamesdb.xml')
        #descFile = "http://www.thegamesdb.net/game/7808/"   # Syphon Filter, Publisher 989
        descFile = "http://thegamesdb.net/api/GetGame.php?id=7808"  # Syphon Filter, Publisher 989

        parser = DescriptionParserFactory().getParser(parseInstruction)
        results = parser.parseDescription(descFile, 'utf-8')
        pprint (results)

        self.assertEqual(results[0].get('Game')[0], "Syphon Filter")
        self.assertEqual(results[0].get('Genre')[0], "Action")
        self.assertEqual(results[0].get('Genre')[1], "Stealth")
        self.assertTrue(type (results[0].get('ReleaseYear')[0]) is datetime.date,
                        "Expected type of ReleaseYear to be date, is {}".format (type (results[0].get('ReleaseYear')[0])))
    def test_GiantBomb_GameDetails(self):
        from descriptionparserfactory import DescriptionParserFactory

        parseInstruction = self.get_scraper_xml_path ('03.02 - giantbomb - detail.xml')
        descFile = "http://www.giantbomb.com/api/game/3030-17123/?api_key=279442d60999f92c5e5f693b4d23bd3b6fd8e868&resources=game&format=xml"

        parser = DescriptionParserFactory().getParser(parseInstruction)
        results = parser.parseDescription(descFile, 'utf-8')
        pprint (results)

        self.assertFalse(results is None)
        self.assertTrue(len (results) == 1, "Expected 1 result for GiantBomb Game Details")
        self.assertEqual(results[0].get('Publisher')[0], "989")
        self.assertTrue(len(results[0].get('Publisher') == 2), "Expected 2 publishers for GiantBomb Game Details for ActRaiser 2")
        self.assertTrue(len(results[0].get('Genre') == 2), "Expected 2 genres for GiantBomb Game Details for ActRaiser 2")


        pprint (results)
    def test_GiantBomb_Search(self):
        from descriptionparserfactory import DescriptionParserFactory

        parseInstruction = self.get_scraper_xml_path ('03.01 - giantbomb - search.xml')
        descFile = "http://api.giantbomb.com/search/?api_key=279442d60999f92c5e5f693b4d23bd3b6fd8e868&query=Actraiser&resources=game&format=xml"

        parser = DescriptionParserFactory().getParser(parseInstruction)
        results = parser.parseDescription(descFile, 'utf-8')
        pprint (results)

        self.assertFalse(results is None)
        self.assertTrue(len(results) == 2, 'Expected 2 results for Giantbomb search criteria')
        self.assertTrue(results[0])
        self.assertEqual(results[0].get('SearchKey')[0], "ActRaiser 2", "Expected ActRaiser 2 to be the first SearchKey in the results")
        self.assertEqual(results[1].get('SearchKey')[0], "ActRaiser", "Expected ActRaiser 2 to be the second SearchKey in the results")

        self.assertTrue('api_key=%GIANTBOMBAPIKey%' in str (results[1].get('url')[0]), "Expected %GIANTBOMBAPIKey% in URL link")

        pprint (results)
Ejemplo n.º 12
0
    def test_ArtworkLink_Screenshot_MobyGames(self):
        from descriptionparserfactory import DescriptionParserFactory

        parseInstruction = self.get_scraper_xml_path(
            '04.09 - mobygames - screenshotlink.xml')
        descFile = "http://www.mobygames.com/game/snes/actraiser/screenshots"

        parser = DescriptionParserFactory().getParser(parseInstruction)
        results = None
        try:
            results = parser.parseDescription(descFile, 'utf-8')
        except ParseException as e:
            print e
        except NameError as n:
            print n

        self.assertFalse(results is None)
        self.assertTrue(
            len(results) == 29, "Expected 29 screenshots from Mobygames")
    def test_ArtworkLink_BackCover_MobyGames(self):
        from descriptionparserflatfile import DescriptionParserFlatFile
        from descriptionparserfactory import DescriptionParserFactory

        parseInstruction = self.get_scraper_xml_path ('04.05 - mobygames - coverlink back.xml')
        descFile = "http://www.mobygames.com/game/snes/actraiser/cover-art"

        parser = DescriptionParserFactory().getParser(parseInstruction)
        results = None
        try:
            results = parser.parseDescription(descFile, 'utf-8')
        except ParseException as e:
            print e
        except NameError as n:
            print n

        self.assertFalse(results is None)
        self.assertTrue(len(results) == 3, "Expected 3 back covers from Mobygames")
        self.assertTrue(results[0].get('url')[0].startswith("http://www.mobygames.com"),
                        "Expected mobygames URL prefix to be added due to appendTo clause")
    def test_ContentNotFound404_MAWS(self):
        from descriptionparserflatfile import DescriptionParserFlatFile
        from descriptionparserfactory import DescriptionParserFactory

        parseInstruction = self.get_scraper_xml_path ('06 - maws.xml')
        descFile = "http://maws.mameworld.info/maws/romset/88games"

        # This will throw a HTTPError which we need to handle (currently the code doesn't handle it)
        parser = DescriptionParserFactory().getParser(parseInstruction)
        self.assertRaises(HTTPError, parser.parseDescription, descFile, 'utf-8',
                          "Expected 404 response from unavailable site MAWS")
Ejemplo n.º 15
0
    def test_ArtworkDetail_CoverFront_MobyGames(self):
        from descriptionparserflatfile import DescriptionParserFlatFile
        from descriptionparserfactory import DescriptionParserFactory

        parseInstruction = self.get_scraper_xml_path(
            '04.04 - mobygames - coverdetail front.xml')
        descFile = "http://www.mobygames.com/game/snes/actraiser/cover-art/gameCoverId,170207"

        parser = DescriptionParserFactory().getParser(parseInstruction)
        results = parser.parseDescription(descFile, 'utf-8')

        filetype_boxfront_url = results[0].get('Filetypeboxfront')[0]
        # Mobygames parser extracts filename as /images/covers...; we prefix this with the domain name
        self.assertTrue(
            filetype_boxfront_url.startswith("http://www.mobygames.com"),
            "Expected mobygames URL prefix to be added due to appendTo clause")
        self.assertEqual(
            filetype_boxfront_url,
            'http://www.mobygames.com/images/covers/l/170207-actraiser-snes-front-cover.jpg'
        )
Ejemplo n.º 16
0
    def test_ArtworkLink_BackCover_MobyGames(self):
        from descriptionparserflatfile import DescriptionParserFlatFile
        from descriptionparserfactory import DescriptionParserFactory

        parseInstruction = self.get_scraper_xml_path(
            '04.05 - mobygames - coverlink back.xml')
        descFile = "http://www.mobygames.com/game/snes/actraiser/cover-art"

        parser = DescriptionParserFactory().getParser(parseInstruction)
        results = None
        try:
            results = parser.parseDescription(descFile, 'utf-8')
        except ParseException as e:
            print e
        except NameError as n:
            print n

        self.assertFalse(results is None)
        self.assertTrue(
            len(results) == 3, "Expected 3 back covers from Mobygames")
        self.assertTrue(
            results[0].get('url')[0].startswith("http://www.mobygames.com"),
            "Expected mobygames URL prefix to be added due to appendTo clause")
    def test_ContentNotFound404_ArchiveVG(self):
        from descriptionparserflatfile import DescriptionParserFlatFile
        from descriptionparserfactory import DescriptionParserFactory


        #descFile = "http://api.archive.vg/1.0/Game.getInfoByCRC/VT7RJ960FWD4CC71L0Z0K4KQYR4PJNW8/b710561b"
        #parseInstruction = "C:\\Users\\lom\\AppData\\Roaming\\XBMC\\addons\\script.games.rom.collection.browser.dev\\resources\\scraper\\05.01 - archive - search.xml"

        #descFile = "http://api.archive.vg/1.0/Archive.search/VT7RJ960FWD4CC71L0Z0K4KQYR4PJNW8/Alien+Breed"
        #http://api.archive.vg/1.0/Game.getInfoByID/VT7RJ960FWD4CC71L0Z0K4KQYR4PJNW8/19970

        #http://api.archive.vg/1.0/System.getGames/VT7RJ960FWD4CC71L0Z0K4KQYR4PJNW8/SYSTEM

        parseInstruction = self.get_scraper_xml_path ('05.01 - archive - search.xml')
        descFile = "http://api.archive.vg/1.0/Game.getInfoByCRC/VT7RJ960FWD4CC71L0Z0K4KQYR4PJNW8/b710561b"

        # This will throw a HTTPError which we need to handle (currently the code doesn't handle it)
        parser = DescriptionParserFactory().getParser(parseInstruction)
        self.assertRaises(HTTPError, parser.parseDescription, descFile, 'utf-8')
Ejemplo n.º 18
0
#http://api.archive.vg/1.0/Game.getInfoByID/VT7RJ960FWD4CC71L0Z0K4KQYR4PJNW8/19970

#http://api.archive.vg/1.0/System.getGames/VT7RJ960FWD4CC71L0Z0K4KQYR4PJNW8/SYSTEM

#descFile = "E:\\Games\\RCB TestDataBase\\Scraping\\V2 - Amiga - ff - descpergame\\synopsis\\Dogfight\\synopsis.txt"
#parseInstruction = "E:\\Games\\RCB TestDataBase\\Scraping\\V2 - Amiga - ff - descpergame\\parserConfig.xml"

#descFile = "F:\\Emulatoren\\data\\synopsis\\XTRAS-RCB\\NGPC.txt"
#parseInstruction = "F:\\Emulatoren\\data\\synopsis\\XTRAS-RCB\\_parserConfig.xml"

descFile = "E:\\XBMC\\RCB\\Support\\Tomkun\\info.txt"
parseInstruction = "E:\\XBMC\\RCB\\Support\\Tomkun\\parserconfig.xml"


from descriptionparserfactory import *
descParser = DescriptionParserFactory.getParser(parseInstruction)

results = descParser.parseDescription(str(descFile), '	iso-8859-15')
for result in results:
	print result
	
print len(results)




"""
import glob

def getFilesByWildcard(pathName):
		
Ejemplo n.º 19
0
#descFile = "http://api.archive.vg/1.0/Archive.search/VT7RJ960FWD4CC71L0Z0K4KQYR4PJNW8/Alien+Breed"
#http://api.archive.vg/1.0/Game.getInfoByID/VT7RJ960FWD4CC71L0Z0K4KQYR4PJNW8/19970

#http://api.archive.vg/1.0/System.getGames/VT7RJ960FWD4CC71L0Z0K4KQYR4PJNW8/SYSTEM

#descFile = "E:\\Games\\RCB TestDataBase\\Scraping\\V2 - Amiga - ff - descpergame\\synopsis\\Dogfight\\synopsis.txt"
#parseInstruction = "E:\\Games\\RCB TestDataBase\\Scraping\\V2 - Amiga - ff - descpergame\\parserConfig.xml"

#descFile = "F:\\Emulatoren\\data\\synopsis\\XTRAS-RCB\\NGPC.txt"
#parseInstruction = "F:\\Emulatoren\\data\\synopsis\\XTRAS-RCB\\_parserConfig.xml"

descFile = "E:\\XBMC\\RCB\\Support\\Tomkun\\info.txt"
parseInstruction = "E:\\XBMC\\RCB\\Support\\Tomkun\\parserconfig.xml"

from descriptionparserfactory import *
descParser = DescriptionParserFactory.getParser(parseInstruction)

results = descParser.parseDescription(str(descFile), '	iso-8859-15')
for result in results:
    print result

print len(results)
"""
import glob

def getFilesByWildcard(pathName):
		
	files = []
	
	try:
		# try glob with * wildcard