Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Character info search #90

Open
kratosrog opened this issue Dec 2, 2022 · 9 comments
Open

Character info search #90

kratosrog opened this issue Dec 2, 2022 · 9 comments

Comments

@kratosrog
Copy link

maybe I'm missing something, I wanted to know if there is any way we can find character info using their name just like we do to find anime malScraper.getInfoFromName(query)
if there is no way currently see if you can add that feature.

@StavrosNik4
Copy link
Contributor

I don't think there is such feature. Also I'm not really sure how we are going to implement this because links of character pages have a specific ID before the name of the character as you can see in the screenshots below.
image
image
image

@LegendaryEmoji
Copy link

This feature is completely possible if you are wondering.

scraper.getInfoFromName(query...) function actually does two things when called:

  1. Send a GET request to https://myanimelist.net/search/prefix.json?type=anime&keyword={query} to get all the results of type anime.
  2. Find the best anime result (or the first anime result depending on getBestMatch parameter) and send another GET request to the selected anime result's URL and parse the raw HTML and return the anime data.

You could modify the function to add support for type parameter. So, instead of hardcoded type=anime, you could do the following and the code would change the type parameter (code location):

// New usage:
scraper.getInfoFromName(query, getBestMatch=true, type="anime");

scraper.getInfoFromName("Spy x Family");
// -> Using https://myanimelist.net/search/prefix.json?type=anime&keyword=Spy+x+Family
// -> If no type is provided, it would use `anime` as type by default.

scraper.getInfoFromName("Spy x Family", true, "anime");
// -> Using https://myanimelist.net/search/prefix.json?type=anime&keyword=Spy+x+Family
// -> If type is provided, it would use the provided type.

scraper.getInfoFromName("Forger", true, "character");
// -> Using https://myanimelist.net/search/prefix.json?type=character&keyword=Forger
// -> If type is provided, it would use the provided type.

Honestly, this whole type thing is a bit flawed, but without it, searching would become really difficult as most of the people only need anime results.

I would've made a PR (Pull Request) but seeing how the main developer is inactive, I doubt that it would get merged anytime soon.

@StavrosNik4
Copy link
Contributor

@LegendaryEmoji If you have the code ready then please make a PR. Kylart is not inactive on GitHub, he will see it anytime soon. I will also work on an implementation and we can discuss them in the PR.

@LegendaryEmoji
Copy link

I don't have the code ready yet. The reason is simple, if we decided to add character searching, we would also need to add parsing for the raw character HTML page and so on. This isn't a simple function change if you want detailed information. I would need some time (e.g. 3-5 days) to code this feature. I will definitely need help regarding TypeScript typing so you can help me in that in the pull request (@StavrosNik4).

@Kylart
Copy link
Owner

Kylart commented Feb 18, 2023

You have two solutions if you're willing to make a PR and are unsure it will get merge because of an inactive maintainer:

  1. fork the project and use your fork repo as your dependency in your project
  2. In this case, if I don't see your PR in a timely manner, feel free to send me an email and I will probably react quickly.

In the meantime, I greatly appreciate your contributions even though I don't have that much time to take care of these projects!

@LegendaryEmoji
Copy link

This would take a little longer. I am planning to add more things other than this single thing. I'll keep you updated.

@LegendaryEmoji
Copy link

@Kylart would it be fine if I make major changes like changes which will break the package for sure? Of course, this update of mine will be "3.0.0" instead of adding more to "2.x.x" version as this update would introduce many new functions, models, and things.

@LegendaryEmoji
Copy link

I am expecting this to take around solid 2-3 weeks of work. After this update, this package will be able to scrape everything literally. For example, you would be able to scrape all forum posts of user, users comments posted on the user page, clubs, badges, detailed biography and comments, reviews, recommendations, and so on. My initial plan was to just add this type and be done, but after digging, it seems like this package really needs some updates.

Don't worry, I'll let both of you know when it's done. Sorry for the constant delays, it's just that there are too many things.

@Kylart
Copy link
Owner

Kylart commented Feb 23, 2023

Sounds great to me!

This package is in dire needs of update. I planned on working on this whenever I got the chance so I'm looking forward to this. Please do not feel pressured by time or anything, it's already great 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants