-
Notifications
You must be signed in to change notification settings - Fork 265
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
MyAnimeList Importer #734
MyAnimeList Importer #734
Conversation
@@ -0,0 +1,43 @@ | |||
module DataImport | |||
class MyAnimeList | |||
MDL_HOST = "https://hbv3-mal-api.herokuapp.com/2.1" # 2.1 is the api version, MAYBE add graceful decay to check from v1 if it can't find? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we need a decay. We should be very clear which version we need, and since we have our own instance this isn't a problem. If anything, this number should only ever increase.
Great start |
end | ||
|
||
def get_media(external_id) # anime/1234 or manga/1234 | ||
media = Mapping.lookup('myanimelist', external_id) || external_id.split('/').first.classify.constantize.new # should return Anime.new or Manga.new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line is a bit long. I'd suggest splitting it into three: one to lookup the Mapping, one to identify the class, and one to create the new instance with a ||=
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will do!
7faeee4
to
a7d7919
Compare
end | ||
end | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra blank line detected.
Extra empty line detected at block body end.
…ge everything into a Media object
…mit might have an issue
…v test... no idea how
caebfaf
to
1dbc9d5
Compare
next unless node.text? | ||
t = node.content.split(/: ?/).map { |x| x.split(' ') } | ||
if t.length >= 2 | ||
if t[0].length <= 3 && t[1].length <= 20 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Favor modifier if
usage when having a single-line body. Another good alternative is the usage of control flow &&
/||
. (https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
not even touching that @NuckChorris you can deal with it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fair, I can handle these
# manga | ||
when 'manga' then :manga | ||
when 'novel' then :novel | ||
when 'manuha' then :manuha |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's manhua
not manuha
. Also is there a reason why you don't just use else data['type'].downcase.to_sym
for most of these cases?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops.. sorry bout that you are correct (actually when have you ever been wrong?)
Actually this is god damn brilliant lol.
reference #710 (need to still add manga)