# Path: resources/lib/model/apiresponse.py
# class ApiResponse:
#     def __init__(self, name=None, year=None, genre=None, plot=None, posters=None, fanarts=None):
#         if genre is None:
#             genre = []
#         if posters is None:
#             posters = []
#         if fanarts is None:
#             fanarts = {}
# 
#         self.name = name
#         self.year = year
#         self.genre = genre
#         self.plot = plot
#         self.posters = posters
#         self.fanarts = fanarts
# 
#     @classmethod
#     def from_dict(cls, name=None, year=None, genre=None, plot=None, posters=None, fanarts=None, **kwargs):
#         return cls(name, year, genre, plot, posters, fanarts)
# 
# Path: resources/lib/model/fanart.py
# class Fanart:
#     def __init__(self, original=None, thumb=None):
#         self.original = original
#         self.thumb = thumb
# 
#     def get_original(self):
#         return self.original
# 
#     def set_original(self, original):
#         self.original = original
# 
#     def get_thumb(self):
#         return self.thumb
# 
#     def set_thumb(self, thumb):
#         self.thumb = thumb


import os
import subprocess
    import xbmcgui
from xml.etree.ElementTree import ElementTree
from xml.etree.ElementTree import Element
    from xbmcswift2 import xbmcgui
from abcscraper import AbstractScraper
from resources.lib.model.apiresponse import ApiResponse
from resources.lib.model.fanart import Fanart

        xml_response_file = self._get_xml_data(nvapp.id, game)

        try:
            xml_root = ElementTree(file=xml_response_file).getroot()
        except:
            xbmcgui.Dialog().notification(
                self.core.string('name'),
                self.core.string('scraper_failed') % (game, self.name())
            )

            if xml_response_file is not None and os.path.isfile(xml_response_file):
                os.remove(xml_response_file)

            return ApiResponse()

        dict_response = self._parse_xml_to_dict(xml_root)

        if dict_response:
            posters = dict_response['posters']
            dict_response['posters'] = []
            for poster in posters:
                dict_response['posters'].append(self._dump_image(game_cover_path, poster))

            local_arts = {}
            for art in dict_response.get('fanarts'):
                art.set_thumb(self._dump_image(game_fanart_path, art.get_thumb()))
                local_arts[os.path.basename(art.get_thumb())] = art
            dict_response['fanarts'] = local_arts


# Path: resources/lib/model/apiresponse.py
# class ApiResponse:
#     def __init__(self, name=None, year=None, genre=None, plot=None, posters=None, fanarts=None):
#         if genre is None:
#             genre = []
#         if posters is None:
#             posters = []
#         if fanarts is None:
#             fanarts = {}
# 
#         self.name = name
#         self.year = year
#         self.genre = genre
#         self.plot = plot
#         self.posters = posters
#         self.fanarts = fanarts
# 
#     @classmethod
#     def from_dict(cls, name=None, year=None, genre=None, plot=None, posters=None, fanarts=None, **kwargs):
#         return cls(name, year, genre, plot, posters, fanarts)
# 
# Path: resources/lib/model/fanart.py
# class Fanart:
#     def __init__(self, original=None, thumb=None):
#         self.original = original
#         self.thumb = thumb
# 
#     def get_original(self):
#         return self.original
# 
#     def set_original(self, original):
#         self.original = original
# 
#     def get_thumb(self):
#         return self.thumb
# 
#     def set_thumb(self, thumb):
#         self.thumb = thumb


# Path: resources/lib/scraper/tgdbscraper.py
import os
import subprocess
    import xbmcgui
from xml.etree.ElementTree import ElementTree
from xml.etree.ElementTree import Element
    from xbmcswift2 import xbmcgui
from abcscraper import AbstractScraper
from resources.lib.model.apiresponse import ApiResponse
from resources.lib.model.fanart import Fanart


        xml_response_file = self._get_xml_data(nvapp.id, game)

        try:
            xml_root = ElementTree(file=xml_response_file).getroot()
        except:
            xbmcgui.Dialog().notification(
                self.core.string('name'),
                self.core.string('scraper_failed') % (game, self.name())
            )

            if xml_response_file is not None and os.path.isfile(xml_response_file):
                os.remove(xml_response_file)

            return ApiResponse()

        dict_response = self._parse_xml_to_dict(xml_root)

        if dict_response:
            posters = dict_response['posters']
            dict_response['posters'] = []
            for poster in posters:
                dict_response['posters'].append(self._dump_image(game_cover_path, poster))

            local_arts = {}
            for art in dict_response.get('fanarts'):
                art.set_thumb(self._dump_image(game_fanart_path, art.get_thumb()))
                local_arts[os.path.basename(art.get_thumb())] = art
            dict_response['fanarts'] = local_arts


            return ApiResponse.from_dict(**dict_response)