Git Product home page Git Product logo

nintendo-switch-eshop's People

Contributors

bvanzile avatar dependabot-preview[bot] avatar dependabot[bot] avatar depfu[bot] avatar favna avatar junyeonglee avatar lililiuliu avatar lmmfranco avatar mmakarios avatar revolter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nintendo-switch-eshop's Issues

Get game by id

Is there a way to get a specific game data by id (fs_id or product code) ?

[QUESTION] eshop update time

Hi, nice lib you have here, thanks for your hard work.
Is there a fixed time when Nintendo update the eShop's content like discount and new games? If yes then does it vary between regions?

GET_GAMES_US_URL: No Longer Valid

The GET_GAMES_US_URL is no longer valid. Do you all know if there is a new endpoint to the US eshop json api?

The GET_GAMES_EU_URL is still valid!

DLCs

Will it be supported?

Getting VideoURL and VideoThumbnailURL

I've noticed there is a video_link in the USGames object. Doing a little research i found out that is only and ID and the corresponding URL are given by

thumbnailURL = http://cf.c.ooyala.com/{video_link}/PE3O6Z9ojHeNSk7H4xMDoxOjA1O37pTB
videoURL = http://cf.c.ooyala.com/{video_link}/DOcJ-FxaFrRg4gtDEwOjFmZzowczE7F2

I dont have setup anything to make a PR so if you want to go ahead, or just leave it here for future developers to find it out

[BUG] getGamesAmerica({ shop: 'unfiltered' }) not returning all games

Please describe the problem you are having in as much detail as possible:

Some games are not returning from the API using the 'unfiltered' option on getGamesAmerica, but are returning with the 'all' option. For instance: OKAMI HD, Armello, Cosmic Star Heroine.

Include a reproducible code sample here, if possible:

getGamesAmerica({ shop: 'unfiltered' }) ...

Further details:

  • version: 2.2.8
  • Node.js version: v13.3.0
  • Operating system: macOS Mojave 10.14.6
  • Priority this issue should have – please be realistic and elaborate if possible: High
  • I have also tested the issue on latest master, commit hash:

[QUESTION] GetGamesAmerica and games with no price

Hi all,

I've been using the library with no issues lately and I wanted to say thank you for maintaining and sharing this repository with all of us. It's been fantastic!

Recently, I noticed some of the "Coming Soon" games from Nintendo.com weren't showing up in the final games list from a successful GetGamesAmerica call.

In the screenshot below, it can be deduced that there are 53 games in the Coming Soon category for the Nintendo Switch that have a set price and there are also 66 games that have no price set at the moment.

image

Looking at the code comments and a few responses in some of the other issues, I thought that this might be due to the way Price Range is used to break up the API calls (if I even understood that correctly) and possibly the intended functionality since one of the library's main intents is price/sale related, which is fair.

However, when I made a GetGamesAmerica call earlier today to test this theory, it returned 55 games with "Coming Soon" Availability instead of the expected 53. It retrieved all 53 games that are Coming Soon and have a set price. The 2 extra were games titled Fuser and Quantum League, which both returned with a null msrp, null priceRange, and no specific release date, with the Fuser output in the below screenshot.

Screen Shot 2020-05-15 at 7 26 28 PM

Now, I was intending to figure out a way to get all of these 66 games that are unpriced (and usually with vague release date strings) to be included in the GetGamesAmerica result array but, now that 2 of these games seem to be present in the GetGamesAmerica API response, I was wondering if someone could shed some light on the expected results. Is the intent to include all games or just those with a set price? How did these 2 unpriced games slip through without the other 64? Is there an obvious way I can modify some configurations to include games with no price and a future release date?

Thanks for taking a look!

Getting EshopError while fetching prices

Hi Guys

It seems the update you committed yesterday broke my setup for reliably fetching the full price list.

This used to work perfectly because I chunked the array into smaller arrays of 40 nsuids.
However, since updating today, I receive the dreaded 'EshopError' again.

I noticed a commit that targeted the getPrices code, not sure if that could be the cause?

This is the function I've been using:

export async function getGamePrices({ games, region }: GetGamePricesVariables) {
  try {
    const gamesArrayChunks: GameEU[][] | GameUS[][] = chunkArray(games, 40);
    const gamesWithPriceData = [];

    const shops = region === Region.AMERICAS ? SHOPS_US : SHOPS_EU;

    for (const gamesArrayChunk of gamesArrayChunks) {
      const gamesPriceData = {};
      const nsuids = [];

      gamesArrayChunk.forEach((game: GameEU | GameUS) => {
        const nsuid = region === Region.AMERICAS ? (game as GameUS).nsuid : (game as GameEU).nsuid_txt[0];
        nsuids.push(nsuid);
      });

      for (const shop of shops) {
        const { prices } = await getPrices(shop, nsuids);
        console.log(prices);

        prices.forEach(price => {
          gamesPriceData[price.title_id] = gamesPriceData[price.title_id] || {};
          gamesPriceData[`${price.title_id}`][shop] = price;
        });
      }

      gamesArrayChunk.forEach((game: GameEU | GameUS) => {
        const nsuid = region === Region.AMERICAS ? (game as GameUS).nsuid : (game as GameEU).nsuid_txt[0];

        gamesWithPriceData.push({
          ...game,
          priceData: gamesPriceData[nsuid],
        });
      });
    }

    return gamesWithPriceData;
  } catch (err) {
    console.log('ERROR', err);
  }
}

[Question]: Not getting all games from `getGamesAmerica`

Please describe the problem you are having in as much detail as possible:

getGamesAmerica() doesn't return games beyond 'c'

Hi guys thank you for maintaining this project. I'm using a for loop to handle pagination but it stopped at

CAN ANDROIDS PRAY:BLUE \n Candle: The Power of the Flame \n Candleman \n Candy Hoarder \n Candy Match 3 \n Candy, Please! \n Cannibal Cuisine \n Capcom Beat 'Em Up Bundle \n Captain America: Super Soldier \n Captain Cat \n Captain StarONE \n Captain Toad: Treasure Tracker \n Captain Toad: Treasure Tracker \n Captain Toad: Treasure Tracker \n Car Battler Joe \n Car Mayhem \n Car Mechanic Manager \n Car Mechanic Simulator

No games after 'Car Mechanic Simulator' is returned. Any suggestions?

Further details:

  • version:
  • Node.js version:
  • Operating system:
  • Priority this issue should have – please be realistic and elaborate if possible:
  • I have also tested the issue on latest master, commit hash:

[Question] How does games / prices data fetching works?

Hi! :)
Thanks for publishing your app. It looks really nice! :) I was wondering what are the data sources you use for fetching games info and prices?
In case of EU and Japan I see some Big N related endpoints but for the US there is this Algolia thing. Did you create this service on your own or is publicallt available? If it's your's then how did you manage to get access to Nintendo data?

Sorry guys for many questions but after doing some research directly on Nintendo sites it was hard to find any reasonable API documentation.

export const US_GET_GAMES_URL = `https://${US_ALGOLIA_ID}-dsn.algolia.net/1/indexes/*/queries`;

Does getGamesAmerica returns unreleased games?

Hi everyone, I'm trying to get a list of nintendo switch games on sale but the count is different from mine and from nintendo's website. Not sure if this is related to the paging or if the function only returns released games.

Nintendo
image

Mine (filtered by salePrice != null && platform = 'Nintendo Switch')
image

Thanks in advance!

How to get all the games and the price of the game in each country eshop

Hi, thank you so much for developing such a great program. I plan to get all the games and their selling price in each country eshop, is this possible? I have found that the data obtained in different regions do not have a common unique id, so there is no way to merge the data, any ideas on how to do this? Very much looking forward to your reply.

How to get sale price for Canada and other regions?

Hi there,

Great package, thanks for your work!

I'm trying to get the sale price for games in the Canada eStore, the only way I can see (and I'm probably wrong) is to use .getPrices() but when I do so I get an object like this:

{
  personalized: false,
  country: 'CA',
  prices:
    [ {
      title_id: 70010000004550,
      sales_status: 'onsale',
      regular_price: {
        amount: '$9.87',
        currency: 'CAD',
        raw_value: '9.87'
      }
    } ] 

Any idea how, or if it's even possible, to get the sale price of games not in the US/EU/JP stores? I see in your docs there is an optional discount_price in the TitleData object but how do I get it? Ultimately I'm just trying to figure out how to get the sale prices for other regions.

Refactor JP game retrieval

Nintendo japanese API has changed. It no longer uses XML however some of the parsing and documenting must be refactored.

[BUG] Package requires tslib which is not on dependencies list

Please describe the problem you are having in as much detail as possible:

The package requires tslib to run (dist/index.js, line 3), but it is not listed in the dependencies section of package.json. So it is not installed and require('nintendo-switch-eshop') throws an error.

tslib is included in built js file due to importHelpers option of tsconfig.json which is enabled not directly in this project, but in another one through the extends option.

Either importHelpers should be disabled or tslib should be listed as a dependency.

Include a reproducible code sample here, if possible:

Requires clean environment without typescript installed globally

$ npm install nintendo-switch-eshop
$ node -r nintendo-switch-eshop -e ''
internal/modules/cjs/loader.js:797
    throw err;
    ^

Error: Cannot find module 'tslib'
Require stack:
- /tmp/test/node_modules/nintendo-switch-eshop/dist/index.js
- internal/preload
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/tmp/test/node_modules/nintendo-switch-eshop/dist/index.js:3:17)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/tmp/test/node_modules/nintendo-switch-eshop/dist/index.js',
    'internal/preload'
  ]
}

Further details:

  • version: 2.2.5
  • Node.js version: 12.13.0
  • Operating system: openSUSE Tumbleweed 20191124
  • Priority this issue should have – please be realistic and elaborate if possible: High, package not usable in clean environments, eg. docker container
  • I have also tested the issue on latest master, commit hash:

TypeError: Failed to execute 'fetch' on 'Window'

core.js:6014 ERROR Error: Uncaught (in promise): TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
TypeError: Failed to execute 'fetch' on 'Window': Illegal invocation
    at Object.default (zone-evergreen.js:1042)
    at nintendo-switch-eshop.js:136
    at Generator.next (<anonymous>)
    at tslib.es6.js:73
    at new ZoneAwarePromise (zone-evergreen.js:876)
    at Module.__awaiter (tslib.es6.js:69)
    at push../node_modules/nintendo-switch-eshop/dist/nintendo-switch-eshop.js.exports.getGamesAmerica (nintendo-switch-eshop.js:54)
    at AppComponent.ngOnInit (app.component.ts:13)
    at checkAndUpdateDirectiveInline (core.js:31910)
    at checkAndUpdateNodeInline (core.js:44367)
    at resolvePromise (zone-evergreen.js:797)
    at resolvePromise (zone-evergreen.js:754)
    at zone-evergreen.js:858
    at ZoneDelegate.invokeTask (zone-evergreen.js:391)
    at Object.onInvokeTask (core.js:39680)
    at ZoneDelegate.invokeTask (zone-evergreen.js:390)
    at Zone.runTask (zone-evergreen.js:168)
    at drainMicroTaskQueue (zone-evergreen.js:559)

This is the line
const gamesToCount = yield node_fetch_1.default(constants.US_GET_GAMES_URL, categoriesRequestOptions);

[API]

Please describe the problem you are having in as much detail as possible:
getQueriedGamesAmerica() throws a 403 Forbidden error, no matter what query I put.
Code:
eshop.getQueriedGamesAmerica('mario')

Response:
Response { size: 0, timeout: 0, [Symbol(Body internals)]: { body: PassThrough { _readableState: [ReadableState], _events: [Object: null prototype], _eventsCount: 2, _maxListeners: undefined, _writableState: [WritableState], allowHalfOpen: true, [Symbol(kCapture)]: false, [Symbol(kTransformState)]: [Object] }, disturbed: false, error: null }, [Symbol(Response internals)]: { url: 'https://u3b6gr4ua3-dsn.algolia.net/1/indexes/*/queries', status: 403, statusText: 'Forbidden', headers: Headers { [Symbol(map)]: [Object: null prototype] }, counter: 0 } }

Further details:

  • version: 4.0.0
  • Node.js version: 14.16.0
  • Operating system: Windows 10 Pro 10.0.19042 Build 19042
  • Priority this issue should have – please be realistic and elaborate if possible:
  • I have also tested the issue on latest master, commit hash:

Thoughts on converting to TypeScript?

Hey,

Would there be an interest in converting this project to TypeScript? It would allow for a simplification of the jsdocs and no longer needing to maintain the separate .d.ts file since that would be auto-generated.

This would also allow for using more modern javascript styles like async/await. TypeScript could be leaned on for transpiling that code back to non-async/await code (if you're trying to support versions of node <10.) Along with other benefits of having a compiler catch errors and other things.

I'm just curious for what the general thoughts behind this would be. I work in TS for a living and would be interested in doing this. Just wanted to gauge support before I dove into it.

Cheers.

[API]

Please describe the problem you are having in as much detail as possible:

the type USGame seems to be out of sync with the results that are coming back from the API

{
            "lastModified": 1614328337443,
            "title": "Hollow Knight",
            "description": "Hollow Knight is a classically s...",
            "url": "/games/detail/hollow-knight-switch/",
            "nsuid": "70010000003208",
            "slug": "hollow-knight-switch",
            "boxart": "https://assets.nintendo.com/image/upload/ncom/en_US/games/switch/h/hollow-knight-switch/boxart",
            "horizontalHeaderImage": "https://assets.nintendo.com/image/upload/ncom/en_US/games/switch/h/hollow-knight-switch/hero",
            "platform": "Nintendo Switch",
            "releaseDateDisplay": "2018-06-12T07:00:00.000Z",
            "esrbRating": "Everyone 10+",
            "numOfPlayers": "1 player",
            "featured": false,
            "freeToStart": false,
            "esrbDescriptors": [
                "Fantasy Violence",
                "Mild Blood"
            ],
            "franchises": [],
            "genres": [
                "Indie",
                "Adventure",
                "Platformer",
                "Action"
            ],
            "publishers": [
                "Team Cherry"
            ],
            "developers": [
                "Team Cherry"
            ],
            "generalFilters": [
                "Nintendo Switch Online compatible"
            ],
            "howToShop": [
                "On Nintendo.com"
            ],
            "playerFilters": [
                "1+"
            ],
            "priceRange": "$10 - $19.99",
            "msrp": 15,
            "salePrice": null,
            "lowestPrice": 15,
            "availability": [
                "Available now"
            ],
            "objectID": "6e82b0de-b57b-4e76-af5a-50211a2d82e0",
            "_highlightResult": {
                "title": {
                    "value": "Hollow Knight",
                    "matchLevel": "none",
                    "matchedWords": []
                },
                "nsuid": {
                    "value": "70010000003208",
                    "matchLevel": "none",
                    "matchedWords": []
                }
            }
        },

[BUG] yarn build fails

Please describe the problem you are having in as much detail as possible:

running yarn build fails with the following error

Using @sveltejs/adapter-vercel
 > node_modules/nintendo-switch-eshop/dist/index.mjs:15:13: error: The export name "__esModule" is reserved and cannot be used (it's needed as an export marker when converting ES module syntax to CommonJS)
    15 │ export const __esModule = mod.__esModule;
       ╵              ~~~~~~~~~~

> Build failed with 1 error:
node_modules/nintendo-switch-eshop/dist/index.mjs:15:13: error: The export name "__esModule" is reserved and cannot be used (it's needed as an export marker when converting ES module syntax to CommonJS)
Error: Build failed with 1 error:
node_modules/nintendo-switch-eshop/dist/index.mjs:15:13: error: The export name "__esModule" is reserved and cannot be used (it's needed as an export marker when converting ES module syntax to CommonJS)
    at failureErrorWithLog (/Users/jmsunseri/dev/code/n-buddy/node_modules/esbuild/lib/main.js:1449:15)
    at /Users/jmsunseri/dev/code/n-buddy/node_modules/esbuild/lib/main.js:1131:28
    at runOnEndCallbacks (/Users/jmsunseri/dev/code/n-buddy/node_modules/esbuild/lib/main.js:1049:65)
    at buildResponseToResult (/Users/jmsunseri/dev/code/n-buddy/node_modules/esbuild/lib/main.js:1129:7)
    at /Users/jmsunseri/dev/code/n-buddy/node_modules/esbuild/lib/main.js:1236:14
    at /Users/jmsunseri/dev/code/n-buddy/node_modules/esbuild/lib/main.js:609:9
    at handleIncomingPacket (/Users/jmsunseri/dev/code/n-buddy/node_modules/esbuild/lib/main.js:706:9)
    at Socket.readFromStdout (/Users/jmsunseri/dev/code/n-buddy/node_modules/esbuild/lib/main.js:576:7)
    at Socket.emit (events.js:315:20)
    at addChunk (_stream_readable.js:309:12)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
~/dev/code/n-buddy(master) » 

[BUG]

Please describe the problem you are having in as much detail as possible:

getting: "EshopError: Fetching of US Games failed" on calling
getGamesUS();
and
getGamesUS({shop: 'unfiltered'});

{ EshopError: Fetching of US Games failed
at new e (...\node_modules\nintendo-switch-eshop\dist\index.js:1:156866)
at ...\node_modules\nintendo-switch-eshop\dist\index.js:1:160490
at ...\node_modules\nintendo-switch-eshop\dist\index.js:1:2156
at Object.throw (...\node_modules\nintendo-switch-eshop\dist\index.js:1:2261)
at o (...\node_modules\nintendo-switch-eshop\dist\index.js:1:1070)
at process._tickCallback (internal/process/next_tick.js:68:7) name: 'EshopError' }

getGamesEurope() seems unaffected.

Include a reproducible code sample here, if possible:

module.exports = {
    setAllGames: async () => {
        console.log("searching getGamesAmerica");
        allGames = await getGamesAmerica({shop: 'unfiltered'});
        console.log("Total games: " + allGames.length);
    },
}
// Place your code here

Further details:

  • version: 2.2.4
  • Node.js version: 10.16.3
  • Operating system: Windows 10 - 64 bit
  • Priority this issue should have – please be realistic and elaborate if possible: Fairly high if getGamesUS is actually broken, fairly low if user error
  • I have also tested the issue on latest master, commit hash:

[QUESTION] Module is returning less than total NA eShop games

Quick suggestion. I believe the reason why the "getGamesAmerica" function returns less than the actual total is that the "hitsPerPage:" attribute is set to 100. This caps the number of results per individual query.

For example, category: "Action" and priceRange: "$0 - $4.99" has 346 results at the time of this posting. But the module only returns 100 and never creates a new request for the rest.

A quick fix is to change the "hitsPerPage" to something like 800 (that worked for me). Or allow users to set this as an option.

In my case, I'm using "priceRange" and "esrb" facets to pull all games, this creates fewer requests.

Regards,
Izay

[QUESTION] Getting all games and a specific game

Hey guys!

I've been reading the documentation and all the issue post in this repo.

First of all I think the maintainers of this repo are true rockstars as they've been very helpful and present in the maintenance of this lib.

Now to the actual question.

I'm getting a combine response of +5000 games when fetching all games using getGamesAmericaand getGamesEurope, but still I believe there are games missing... or perhaps not. The problem is that looking for a specific game seems quite hard (at least I've been bashing my head for a couple of hours now with no real results)

So to give a bit of context, I'm using RAWG video game API and exposing it through a GraphQL interface. I'm able to get Steam, Xbox and PSN IDs from the store urls given to me by RAWG. Unfortunately, Nintendo do not put their game IDS (NSUID) as URL params in their store.

So, for example when querying for Fire Emblem: Three Houses, I get a url like: https://www.nintendo.com/games/detail/fire-emblem-three-houses-switch

For PSN it would be: https://store.playstation.com/en-us/product/UP4497-CUSA00527_00-0000000000000002where UP4497-CUSA00527_00-0000000000000002is the game's unique ID. Basically the equivalent of 'NSUID` for Playstation Store.

Unless there's a way to query by slug or something I'm missing, the only thing I though that could be the same across all APIs is the game's name.

So, I ended up doing some blasphemous things like:

  const games = await Promise.all([eshop.getGamesAmerica(), eshop.getGamesEurope()])
  const rawData = games.flat().filter((g) => g.title === title)
  const { price_regular_f: usPrice, msrp: euPrice } = rawData.flat()
  return {
    // eslint-disable-next-line no-nested-ternary
    usPrice: usPrice ? usPrice * 100 : 0,
    euPrice: euPrice ? euPrice * 100 : 0,
    rawData,
  }

I'm trying to get prices for a game in all stores. Let's take as an example The Witcher 3, one of the few true Multiplatform titles out there. It's available in all modern platforms.

However, when title === 'The Witcher 3: Wild Hunt' I'm not getting a response. Still when title === 'Fire Emblem: Three Houses' it does work.

Now, I'm truly curious about the discord bot @favna has, because for what I've seen he gives them a simple string like Pokemon sword and the bot is capable of matching the actual game and returning it's pricing data.

If I find a robust way of searching a specific game I'm planning to have the result of await Promise.all([eshop.getGamesAmerica(), eshop.getGamesEurope()]) to be stored in a DB, and refreshing it once every few hours, just to make querying a lot faster.

Any ideas?

Thanks!

Still fetches only 200 even with limit set to 10000

As the title says, regardless of setting the limit to way higher than 200 the lib still only returns 200 results, at least when using getGamesAmerica. In the getGamesAmerica function I added some console logs to check why this could be happening, specifically after the let accumulatedGames

console.log(limit); // outputs 10000
console.log(!hasProp(options, "limit")); // outputs false ??
console.log(filteredResponse.games.game.length + offset); // outputs 200
console.log(filteredResponse.filter.total); // outputs 596
console.log('=========================');

As is evident from the latter two numbers, that part of the IF statement on line 199 resolves to true, however the statement is skipped because the !hasProp(options, "limit") resolves to false due to the ! swapping the condition. I tried changing this by removing the ! but then I get thrown this error:

E:\UserFiles\DevProjects\ribbon\node_modules\array-unique-x\index.js:10
        var key = property ? item[property] : item;
                                 ^

TypeError: Cannot read property 'slug' of undefined
    at E:\UserFiles\DevProjects\ribbon\node_modules\array-unique-x\index.js:10:34
    at Array.filter (<anonymous>)
    at module.exports (E:\UserFiles\DevProjects\ribbon\node_modules\array-unique-x\index.js:9:18)
    at Request.request.get [as _callback] (E:\UserFiles\DevProjects\ribbon\node_modules\nintendo-switch-eshop\index.js:197:36)
    at Request.self.callback (E:\UserFiles\DevProjects\ribbon\node_modules\request\request.js:186:22)
    at emitTwo (events.js:126:13)
    at Request.emit (events.js:214:7)
    at Request.<anonymous> (E:\UserFiles\DevProjects\ribbon\node_modules\request\request.js:1163:10)
    at emitOne (events.js:116:13)
    at Request.emit (events.js:211:7)
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

So basically it is useless to specify our own limit and simply flipping the condition breaks the parsing.


I use the lib sort of as follows (but in a Discord bot):

const eshop = require('nintendo-switch-eshop'),
  fs = require('fs'),
  path = require('path');

async function run() {
  fs.writeFileSync(path.join(__dirname, '../../data/databases/eshop.json'), JSON.stringify(await eshop.getGamesAmerica({
    limit: 10000
  })), 'utf8');
}

run();

p.s. I know that omitting the limit altogether will have the lib fetch all possible entries, however I want to stipulate here that setting a limit far higher than the amount should also do this.

How to know the API url

Hello, I saw that there are API urls for each region in the code. How do I get the request on which page of the official website? Thank you.

[BUG] Cannot run tests

Please describe the problem you are having in as much detail as possible:

After a clean configuration of the repository following the instructions in the contribution guideline, I am unable to run the automated tests. After running yarn lint && yarn test, the terminal stops at nintendo-switch-eshop: $ jest and nothing happens, even if I make changes to the files.

Include a reproducible code sample here, if possible:

Terminal sample:

 nintendo-switch-eshop ➤ yarn lint && yarn test

yarn run v1.19.1
$ lerna run lint --parallel
lerna notice cli v3.16.4
lerna info Executing command in 1 package: "yarn run lint"
nintendo-switch-eshop: $ eslint src __tests__ --ext js,ts --fix
lerna success run Ran npm script 'lint' in 1 package in 4.3s:
lerna success - nintendo-switch-eshop
✨  Done in 6.41s.
yarn run v1.19.1
$ lerna run test --parallel
lerna notice cli v3.16.4
lerna info Executing command in 1 package: "yarn run test"
nintendo-switch-eshop: $ jest

Further details:

  • version: 2.2.3
  • Node.js version: 12.11.1
  • Operating system: macOS 10.14.6
  • Priority this issue should have – please be realistic and elaborate if possible: High
  • I have also tested the issue on latest master, commit hash: 9405bb3

[QUESTION] Offset not working on getGamesAmerica

I was trying out the latest version of the package.

When I just do

async function getAmericanGames() {
  const result = await getGamesAmerica();

  console.log(result.length)
}

getAmericanGames();

The resulting amount of games returned is 972. This is a bit confusing since this is not the entire collection of US Switch eShop games but the documentation states that if you don't pass in any options to the function, you get the entire collection.

On the US eshop, the max limit is 100. Leave empty to get all the games.

Promise containing all the games

So I tried adding an offset:

async function getAmericanGames() {
  const result = await getGamesAmerica({}, 900);

  console.log(result.length)
}

getAmericanGames();

And I got the exact same result back. 972 games.

I tried using any offset from 1000 to 10000 but the result is always the same.

Am I doing something wrong? How can I reliably get the entire list of US eShop games?

[QUESTION]

Hey there,

Hi, I have stumbled upon an issue regarding your Switch e-shop module. I'm not sure if it's a bug or the lack of my understanding.
At the end result, some games were missing (like Worms W.M.D), so I have checked your implementation, and seen that you overcame a 100 page limit(?) by querying first by category, then by price range. What was the reasoning behind choosing this path instead of iterating through pages without any filtering applied? Looking at the requests on the Nintendo website, it seems that there is a "page" property in the Algolia API which could just be increased (and I'm concerned that the current method might be flawed in some way that it doesn't fetch all games).

Thank you very much,
Gergely Morva

getGamesAmerica only returns half of actual games list

Hey guys,

For some reason, when I use getGamesEurope, I get back 1733 games but when I use getGamesAmerica and use the offset to progress to the list, I get back 949 games. Even when I set the shop option to 'all'.

This is my current implementation:

import { getGamesAmerica, getGamesEurope } from 'nintendo-switch-eshop';
import { GameEU, GameUS } from 'nintendo-switch-eshop/dist/interfaces';

const gamesAmerica: GameUS[] = [];
const gamesEurope: GameEU[] = [];

async function getGamesUS(offset = 0) {
  const response = await getGamesAmerica({ shop: 'all' }, offset);
  gamesAmerica.push(...response);

  if (response.length === 200) {
    getGamesUS(gamesAmerica.length);
  } else {
    console.log('WE ARE FINISHED', gamesAmerica.length);
  }
}

async function getGamesEU(offset = 0) {
  const response = await getGamesEurope();
  gamesEurope.push(...response);
  console.log('REPONSE LENGTH', response.length);
}

getGamesUS();
getGamesEU();

You don't have permission to access "http://api.ec.nintendo.com/v1/price?" on this server.

<HTML><HEAD>
<TITLE>Access Denied</TITLE>
</HEAD><BODY>
<H1>Access Denied</H1>

You don't have permission to access "http://api.ec.nintendo.com/v1/price?" on this server.<P>
Reference #18.5402a46e.1521957632.26bea562
</BODY>
</HTML>

Error at

SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse (<anonymous>)
    at Request.request.get [as _callback] (C:\Users\GitHub.com\co.consolegamer\node_modules\nintendo-switch-eshop\index.js:367:37)
    at Request.self.callback (C:\Users\GitHub.com\co.consolegamer\node_modules\request\request.js:186:22)
    at Request.emit (events.js:160:13)
    at Request.<anonymous> (C:\Users\GitHub.com\co.consolegamer\node_modules\request\request.js:1163:10)
    at Request.emit (events.js:160:13)
    at IncomingMessage.<anonymous> (C:\Users\GitHub.com\co.consolegamer\node_modules\request\request.js:1085:12)
    at Object.onceWrapper (events.js:255:19)
    at IncomingMessage.emit (events.js:165:20)
    at endReadableNT (_stream_readable.js:1101:12)
    at process._tickCallback (internal/process/next_tick.js:152:19)

[API] Stopped getting new updates since last month from getGamesAmerica

Hey all,

I've noticed that my getGamesAmerica calls have stopped returning any lastModified values after Sept 14, 2020 (unix timestamp 1600099408951 specifically).

For example, the code below gets all games from getGamesAmerica and pulls out the most recent lastModified value and prints it.

const { getGamesAmerica } = require('nintendo-switch-eshop');

(async () => {
    try {
        const games = await getGamesAmerica();
      
        console.log(games.length);

        var latest = 0;

        for (let i = 0; i < games.length; ++i) {
            if (games[i].lastModified > latest) {
                latest = games[i].lastModified;
            }
        }

        console.log(latest);
    } catch (error) {
        console.error(error);
    }
})();

For me, that returns:

2858                                      // all games I get from the api call
1600099408951                  // latest lastModified timestamp found

I see 24 games with this timestamp for lastModified. Anyone run into an issue like this? I've updated to the latest and, in the process of trying to figure this out, lost some custom changes that was returning ~3800 games, but the issue remains. The 2858 on a fresh install is kind of problematic since the eshop shows 4792 for me, but that's another issue.

Anyone experiencing similar? What does the above code give you guys?

Regards,
Bryan

[BUG] parseNSUID returns null for GameJP objects and their properties are not arrays

Please describe the problem you are having in as much detail as possible:

For Japanese games parseNSUID extracts nsuid from the first element of LinkURL property with a regex . However this property is actually a string and not an array. So regex tests not the whole link, but the first letter of it, does not match and the function returns null.

Further investigation showed, that all other properties of GameJP are not arrays, contrary to what documentations says.

This might look like an API issue but I don't know how did the Japanese eShop API look like before so I can't say for sure. I personally think that it could be an issue with the XML parser (version changed and introduced breaking changes?), did not dive deep into this though.

Include a reproducible code sample here, if possible:

// Not 100% reproducible as it depends on the external API
// but should be good enough to illustrate this issue

const { getGamesJapan, parseNSUID, Region } = require('nintendo-switch-eshop');

getGamesJapan()
  .then(games => {
    for (const game of games) {
      if (/\d{14}$/.test(game.LinkURL)) {
        console.log(game.LinkURL, parseNSUID(game, Region.ASIA))
        break;
      }
    }
  });

Output:

LinkURL is a string, parseNSUID returned null

https://ec.nintendo.com/JP/ja/titles/70010000002204 null

Expected output:

LinkURL is a single item array, parseNSUID parses correctly

[ 'https://ec.nintendo.com/JP/ja/titles/70010000002204' ] 70010000002204

Further details:

  • version: 2.2.5
  • Node.js version: 12.13.0
  • Operating system: openSUSE Tumbleweed 20191124
  • Priority this issue should have – please be realistic and elaborate if possible: High, as the function does not work, as expected, and game object structure differs from what is described in the documentation
  • I have also tested the issue on latest master, commit hash:

Help with asia game_code

Hi, I'm trying to understand how you get the asia's game_code from games that the ScreenshotImgURL does not have the code, for example:

<TitleInfo>
<LinkURL>/switch/aacca/index.html</LinkURL>
<ScreenshotImgURL>/software/switch/img/launch_panel_12switch.jpg</ScreenshotImgURL></>
<TitleName>1-2-Switch(ワンツースイッチ)</TitleName>
...
</TitleInfo>

or

<LinkURL>https://ec.nintendo.com/JP/ja/titles/70010000000851</LinkURL><ScreenshotImgURL>https://img-eshop.cdn.nintendo.net/i/1cc0ef1e0236180092465f05b455d588b9da361418b92b1be36f58f6f59fcb82.jpg</ScreenshotImgURL>
<TitleName>ポッ拳 POKKÉN TOURNAMENT DX</TitleName>

Can you help me?

Fetching of Games failed

Hi i get always this error:
Fetching of EU Games failed
Fetching of US Games failed
Fetching of JP Games failed

from these requests:
getGamesEurope()
getGamesAmerica()
getGamesJapan()

[API] game_code in US region data is not found

Please describe the problem you are having in as much detail as possible:

Can not find game_code in us region data.

image

Further details:

  • version:
  • Node.js version:
  • Operating system:
  • Priority this issue should have – please be realistic and elaborate if possible:
  • I have also tested the issue on latest master, commit hash:

Is the pagination work ?

GAME_LIST_LIMIT is assigned 200 ref

GAME_LIST_LIMIT is used in getGamesAmerica() ref

My test case

const SwitchEshop = require('nintendo-switch-eshop');
const us = SwitchEshop.getGamesAmerica();
us.then(data => console.log(data.length));

Test case output (25 JAN 2018)

433

a

a

Duplicate game codes

There are two games which return the same game code after parsing it with the /HAC\w(\w{4})/ regex from lib/constants.ts#L4.

The (US and EU) regex to parse the game codes like HACXXXXX return the same game code for two different games.

Ludomania - released Aug 31, 2018

https://www.nintendo.com/games/detail/ludomania-switch
US game API returns code HACNAQVMA.
After applying the regex, this results in AQVM

Flowlines VS - Released Jan 25, 2019

https://www.nintendo.com/games/detail/flowlines-vs-switch
US game API returns code HACNAQVMB.
After applying the regex, this results in AQVM

These now have the same parsed game code. The difference in the original code is the A and B at the end.

The Flowlines game has only been released a few weeks ago, but this looks to me that this might occur more often.

I'm working on something similar and wondered if you have encountered something like this before Looks like the regex might need an update.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.