# 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

    def get_game_information(self, nvapp):
        request_name = nvapp.title.replace(" ", "+").replace(":", "")
        response = self._gather_information(nvapp, request_name)
        response.name = nvapp.title
        return response

    def return_paths(self):
        return [self.cover_cache, self.fanart_cache, self.api_cache]

    def is_enabled(self):
        return self.core.get_setting('enable_tgdb', bool)

    def _gather_information(self, nvapp, game):
        game_cover_path = self._set_up_path(os.path.join(self.cover_cache, nvapp.id))
        game_fanart_path = self._set_up_path(os.path.join(self.fanart_cache, nvapp.id))

        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)


# 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


    def get_game_information(self, nvapp):
        request_name = nvapp.title.replace(" ", "+").replace(":", "")
        response = self._gather_information(nvapp, request_name)
        response.name = nvapp.title
        return response

    def return_paths(self):
        return [self.cover_cache, self.fanart_cache, self.api_cache]

    def is_enabled(self):
        return self.core.get_setting('enable_tgdb', bool)

    def _gather_information(self, nvapp, game):
        game_cover_path = self._set_up_path(os.path.join(self.cover_cache, nvapp.id))
        game_fanart_path = self._set_up_path(os.path.join(self.fanart_cache, nvapp.id))

        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()