예제 #1
0
파일: psn.py 프로젝트: Finikun/psnprices
    def _item_to_game_offer(self, game):
        if not game:
            raise Exception("Item is empty")

        return GameOffer(
            id=game["id"],
            cid=game["id"],
            url=game["url"],
            type=game['gameContentTypesList'][0][
                'key'] if 'gameContentTypesList' in game else None,
            name=game["name"],
            # prices=[game['default_sku']['price']/100],
            prices=[
                Price(
                    value=_get_normal_price(game),
                    currency=_get_currency_symbol(self.country),
                    offer_type="NORMAL"
                ),
                Price(
                    value=_get_playstation_plus_price(game),
                    currency=_get_currency_symbol(self.country),
                    offer_type="PS+"
                ),
            ],
            platforms=game['playable_platform'] if 'playable_platform' in game else "",
            picture_url=_get_image(game)
        )
예제 #2
0
파일: eshop.py 프로젝트: Finikun/psnprices
    def search(self, name):
        url = "https://search.nintendo-europe.com/" + country + "/select?q=" + urllib.parse.quote(name) + "&fq=type%3A*%20AND%20*%3A*&start=0&rows=24&wt=json&group=true&group.field=pg_s&group.limit=" + \
            str(limit) + "&group.sort=score%20desc,%20date_from%20desc&sort=score%20desc,%20date_from%20desc"

        payload = utils.get_json_response(url)

        return_offers = []

        for group in payload['grouped']['pg_s']['groups']:
            if group['groupValue'] == "GAME":
                for game in group['doclist']['docs']:
                    price = game['price_lowest_f']
                    return_offers.append(
                        GameOffer(
                            id=game["fs_id"],
                            cid=self._encode_id(id=game["fs_id"],
                                                name=game["title"]),
                            url=game["url"],
                            name=game["title"],
                            type=game["type"],
                            prices=[
                                Price(
                                    value=price if price > 0 else None,
                                    # TODO add currency
                                    currency="",
                                    offer_type="LOWEST"),
                            ],
                            platforms=game['system_names_txt'],
                            picture_url=game['image_url']
                            if 'image_url' in game else None))

        return return_offers
예제 #3
0
파일: psn.py 프로젝트: snipem/psnprices
    def _item_to_game_offer(self, game):
        if not game:
            raise Exception("Item is empty")

        normal_price = _get_normal_price(game)
        plus_price = _get_playstation_plus_price_reduction(game)
        non_plus_price = _get_non_playstation_plus_price_reduction(game)

        prices = []

        if normal_price != None:
            prices.append(Price(
                value=normal_price,
                offer_type="NORMAL",
            ))

        if plus_price != None:
            prices.append(Price(
                value=plus_price,
                offer_type="PS+",
            ))

        if non_plus_price != None:
            prices.append(
                Price(
                    value=non_plus_price,
                    offer_type="Without PS+",
                ))

        # Make lowest price first in list
        prices.sort(key=lambda x: x.value)

        return GameOffer(
            id=game["id"],
            cid=game["id"],
            url=game["url"],
            type=game["gameContentTypesList"][0]["key"]
            if "gameContentTypesList" in game else None,
            name=game["name"],
            prices=prices,
            platforms=game["playable_platform"]
            if "playable_platform" in game else "",
            picture_url=_get_image(game),
        )
예제 #4
0
    def search(self, name):
        url = "https://search.nintendo-europe.com/" + country + "/select?q=" + urllib.parse.quote(
            name
        ) + "&fq=type%3A*%20AND%20*%3A*&start=0&rows=24&wt=json&group=true&group.field=pg_s&group.limit=" + str(
            limit
        ) + "&group.sort=score%20desc,%20date_from%20desc&sort=score%20desc,%20date_from%20desc"

        payload = utils.get_json_response(url)

        return_offers = []

        for group in payload["grouped"]["pg_s"]["groups"]:
            if group["groupValue"] == "GAME":
                for game in group["doclist"]["docs"]:
                    price = game["price_lowest_f"]
                    return_offers.append(
                        GameOffer(
                            id=game["fs_id"],
                            cid=self._encode_id(encode_id=game["fs_id"],
                                                name=game["title"]),
                            url=game["url"],
                            name=game["title"],
                            type=game["type"],
                            prices=[
                                Price(
                                    value=price,
                                    offer_type="OFFER",
                                ) if price > 0 else Price(value=-1,
                                                          offer_type="NONE"),
                            ],
                            platforms=game["system_names_txt"],
                            picture_url=game["image_url"]
                            if "image_url" in game else None,
                        ))

        return return_offers