Esempio n. 1
0
def getNsuIds(titleIds, type='title', region='US', language='en', shop_id=4):
    j = ids(titleIds, type, region, language, shop_id)
    lst = {}
    try:
        for i in j['id_pairs']:
            titleId = i['title_id'].upper()
            nsuId = int(i['id'])
            lst[titleId] = nsuId

            title = Titles.getNsuid(nsuId, region, language)
            title.setId(titleId)

            try:
                pass
                if title.isDLC:
                    title.parseShogunJson(
                        getTitleByNsuid(nsuId, region, language), region,
                        language, True)
                elif not title.isUpdate:
                    title.parseShogunJson(
                        getTitleByNsuid(nsuId, region, language), region,
                        language, True)
            except:
                Print.error(str(e))
                pass

    except BaseException as e:
        Print.error(str(e))
    return lst
Esempio n. 2
0
def scrapeTitle(nsuid, region='US', language='en', shop_id=3):
    title = Titles.getNsuid(nsuid, region, language)
    n = getTitleByNsuid(nsuid, region, language)

    title.parseShogunJson(n, region, language, True)

    try:
        if n and "applications" in n and len(n["applications"]) > 0:
            titleId = n["applications"][0]["id"].upper()

            if titleId:
                title.setId(titleId)

                for x in cdn.Superfly.getAddOns(titleId):
                    if not x.endswith('800'):
                        getNsuIds(x, 'aoc', region, language)

                scrapeDlc(nsuid, region, language)
            else:
                print('Could not get title json!')
        else:
            #print('no title id found in json!')
            pass

        if n and "demos" in n:
            for d in n["demos"]:
                if "id" in d:
                    scrapeTitle(d["id"], region, language, shop_id)
        return title
    except Exception as e:
        print(str(e))
        raise
        return None
Esempio n. 3
0
def scrapeDlc(baseNsuid, region='US', language='en', shop_id=3):

    pageSize = 50
    offset = 0
    total = 1
    while offset < total:
        url = 'https://bugyo.hac.%s.eshop.nintendo.net/shogun/v1/titles/%d/aocs?shop_id=%d&lang=%s&country=%s' % (
            Config.cdn.environment, baseNsuid, shop_id, language, region)
        #print(url)
        #exit(0)
        j = makeJsonRequest(
            'GET', url, {}, '%d/%s/%s/titles/aocs/%d.json' %
            (shop_id, language, region, baseNsuid))

        if not j:
            break

        total = int(j['total'])

        if total == 0:
            break

        try:
            for i in j['contents']:
                title = Titles.getNsuid(i['id'], region, language)
                n = getDlcByNsuid(i['id'], region, language)

                if n and "applications" in n and len(n["applications"]) > 0:
                    title.setId(n["applications"][0]["id"].upper())

                title.parseShogunJson(n, region, language, True)

        except Exception as e:
            print(str(e))
            raise
            break

        offset = offset + len(j['contents'])
Esempio n. 4
0
    def parseShogunJson(self,
                        _json,
                        region=None,
                        language=None,
                        canGrabFromShogun=False):
        if not _json:
            return None

        if 'hero_banner_url' in _json:
            self.bannerUrl = _json['hero_banner_url']

        if "release_date_on_eshop" in _json:
            try:
                self.releaseDate = int(_json["release_date_on_eshop"].replace(
                    '-', ''))
            except:
                pass
        '''
		if "id" in _json:
			try:
				self.setNsuId("%s" % _json["id"])
			except BaseException as e:
				Print.info('error setting nsuid: ' + str(e))
				pass
		'''

        if "formal_name" in _json:
            self.name = _json["formal_name"].strip()

        if 'screenshots' in _json:
            self.screenshots = []
            for i, k in enumerate(_json["screenshots"]):
                self.screenshots.append(k["images"][0]["url"])

        if "languages" in _json:
            self.languages = []
            for language in _json["languages"]:
                self.languages.append(language['iso_code'])

        if "genre" in _json:
            self.category = _json["genre"].split(' / ')

        if "total_rom_size" in _json:
            self.size = _json["total_rom_size"]

        if "rating_info" in _json:
            if "rating" in _json["rating_info"]:
                if "age" in _json["rating_info"]['rating']:
                    self.rating = _json["rating_info"]['rating']['age']

            if "content_descriptors" in _json["rating_info"]:
                content = []
                for descriptor in _json["rating_info"]["content_descriptors"]:
                    content.append(descriptor['name'])
                self.ratingContent = content

        if "player_number" in _json:
            if 'local_max' in _json["player_number"]:
                self.numberOfPlayers = _json["player_number"]["local_max"]

            if 'offline_max' in _json["player_number"]:
                self.numberOfPlayers = _json["player_number"]["offline_max"]

        if "publisher" in _json:
            if 'name' in _json["publisher"]:
                self.publisher = _json["publisher"]["name"]
            if 'title' in _json["publisher"]:
                self.publisher = _json["publisher"]["title"]

        if "applications" in _json and isinstance(_json["applications"], list):
            for a in _json["applications"]:
                '''
				if "id" in a:
					self.setId(a['id'])
				'''

                if "image_url" in a:
                    self.iconUrl = a['image_url']
                break

        if "applications" in _json and "image_url" in _json["applications"]:
            self.iconUrl = _json["applications"]['image_url']

        if "catch_copy" in _json:
            #self.intro = htmlToText(_json["catch_copy"])
            self.intro = _json["catch_copy"]

        if "description" in _json:
            #self.description = htmlToText(_json["description"])
            self.description = _json["description"]

        try:
            if "target_titles" in _json:
                for nsu in _json["target_titles"]:
                    if not Titles.hasNsuid(nsu["id"], region, language):
                        if canGrabFromShogun:
                            baseTitle = Titles.getNsuid(
                                nsu["id"], region, language)
                            baseTitle.parseShogunJson(
                                cdn.Shogun.getTitleByNsuid(
                                    nsu["id"], region, language), region,
                                language, True)
                            #Titles.saveRegion(region, language)
                    else:
                        baseTitle = Titles.getNsuid(nsu["id"], region,
                                                    language)
                        if baseTitle.id:
                            pass
                            #self.setId(baseTitle.id)
                            #Print.info("setting appid " + str(baseTitle.id))
                        #else:
                        #	Print.error("Could not find title for " + str(nsu["id"]))
        except:
            Print.error('target titles error')
            raise