roflmuffin / node-anime-scraper

Scrapes information from Gogoanime to get Anime, Episode & Video information & urls.
60 stars 14 forks source link

500 response code when Anime name contains ☆ #6

Closed Eligioo closed 9 years ago

Eligioo commented 9 years ago

Node will crash when using the Anime.fromName method when the Anime serie contains a '☆'. For example the Space☆Dandy serie on KissAnime.

Anime.fromName('Space☆Dandy').then(function(anime) {
    anime.getVideoUrls().then(function(results) {
        console.log('results');
    })
})
roflmuffin commented 9 years ago

Hi Eligioo,

I recently fixed this issue in a commit a couple of days ago but didn't get around to publishing it to the npm registry, so that is done now and should work with unicode characters (such as the star).

Secondly, Space☆Dandy won't retrieve an Anime as the actual name of the Anime is Space☆Dandy (Sub). To catch this error use the syntax seen below:

Anime.fromName('Space☆Dandy').then(function(anime) {
    anime.getVideoUrls().then(function(results) {
        console.log('results');
    })
}).catch(function(err) {   
    console.log(err) // Error: Exact match not found. See matches property.
    console.log(err.matches) // Outputs list of animes similar in name to one you searched.
})
{ [Error: Exact match not found. See matches property.]
  matches: 
   [ { name: 'Space☆Dandy (Dub)',
       url: 'http://kissanime.com/Anime/Space-Dandy-Dub' },
     { name: 'Space☆Dandy (Sub)',
       url: 'http://kissanime.com/Anime/Space-Dandy' },
     { name: 'Space☆Dandy 2nd Season (Dub)',
       url: 'http://kissanime.com/Anime/Space-Dandy-2nd-Season-Dub' },
     { name: 'Space☆Dandy 2nd Season (Sub)',
       url: 'http://kissanime.com/Anime/Space-Dandy-2nd-Season' },
     { name: 'Space☆Dandy Picture Drama',
       url: 'http://kissanime.com/Anime/Space-Dandy-Picture-Drama' } ] }

You can then use the information from the error (err.matches) to pick one and then Anime.fromUrl based on those results.

Hope this helps.