コード例 #1
0
ファイル: omdbscraper.py プロジェクト: Tommassino/luna
    def _gather_information(self, game):
        game_cover_path = self._set_up_path(os.path.join(self.cover_cache, game))
        game_cache_path = self._set_up_path(os.path.join(self.api_cache, game))

        json_file = self._get_json_data(game_cache_path, game)
        try:
            json_data = json.load(open(json_file))
        except:
            xbmcgui.Dialog().notification(
                self.core().string('name'),
                self.core().string('scraper_failed') % (game, self.name())
            )

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

            return ApiResponse()

        if json_data['Response'] != 'False':
            json_data['posters'] = []
            cover_path = self._dump_image(game_cover_path, json_data['Poster'])
            if cover_path is not None:
                json_data['posters'].append(cover_path)
            del json_data['Poster']
            response = dict((k.lower(), v) for k, v in json_data.iteritems())
            if 'genre' in response:
                response['genre'] = response.get('genre').split(',')
                response['genre'] = [str(v).strip() for v in response.get('genre')]

            return ApiResponse.from_dict(**response)
        else:

            return ApiResponse()
コード例 #2
0
ファイル: tgdbscraper.py プロジェクト: Tommassino/luna
    def _gather_information(self, game):
        game_cover_path = self._set_up_path(os.path.join(self.cover_cache, game))
        game_fanart_path = self._set_up_path(os.path.join(self.fanart_cache, game))

        xml_response_file = self._get_xml_data(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)
コード例 #3
0
ファイル: omdbscraper.py プロジェクト: witzatom/luna
    def _gather_information(self, game):
        game_cover_path = self._set_up_path(
            os.path.join(self.cover_cache, game))
        game_cache_path = self._set_up_path(os.path.join(self.api_cache, game))

        json_file = self._get_json_data(game_cache_path, game)
        try:
            json_data = json.load(open(json_file))
        except:
            xbmcgui.Dialog().notification(
                self.core().string('name'),
                self.core().string('scraper_failed') % (game, self.name()))

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

            return ApiResponse()

        if json_data['Response'] != 'False':
            json_data['posters'] = []
            cover_path = self._dump_image(game_cover_path, json_data['Poster'])
            if cover_path is not None:
                json_data['posters'].append(cover_path)
            del json_data['Poster']
            response = dict((k.lower(), v) for k, v in json_data.iteritems())
            if 'genre' in response:
                response['genre'] = response.get('genre').split(',')
                response['genre'] = [
                    str(v).strip() for v in response.get('genre')
                ]

            return ApiResponse.from_dict(**response)
        else:

            return ApiResponse()
コード例 #4
0
    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()

        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)