danieltanfh95 / btapi

baka tsuki api clean up
http://btapi-shadowys.rhcloud.com/
8 stars 5 forks source link

[Feature] Provide the cover image on each novel (and optionally for each volume). #3

Closed Nandaka closed 9 years ago

Nandaka commented 9 years ago

As in the title.

You can get main cover image from the first image, usually with css class="thumbinner"

{  
   "title":"Zero no Tsukaima",
   "sections":{  },
   "status":"idle",
   "author":"Noboru Yamaguchi",
   "synopsis":"The Zero no Tsukaima series is also available in the following languages:\nIt is with sadness that we report that Noboru Yamaguchi, the author of Zero no Tsukaima passed away from cancer on April 4, 2013. As such, the series remains incomplete at 20 volumes and it is unlikely that there will be any further material published after this.\nTranslators are requested to mark all the chapters they are translating on the Registration Page according to Translation Management section of Zero no Tsukaima Project Specific Guidelines.\n",
   "cover" : "//www.baka-tsuki.org/project/images/f/fb/Znt_novel_cover.jpg"
}

as for each volumes, this might be tricky because the listing is not in standardized structure.

  1. After the h2 element (by), but before the h3 element (book title) http://www.baka-tsuki.org/project/index.php?title=Kino_no_Tabi http://www.baka-tsuki.org/project/index.php?title=Toaru_Majutsu_no_Index http://www.baka-tsuki.org/project/index.php?title=CubexCursedxCurious http://www.baka-tsuki.org/project/index.php?title=Kara_no_Kyoukai http://www.baka-tsuki.org/project/index.php?title=Hyouka
  2. After the h2 element (by) and the h3 element (book title), but before ul (the chapter list) http://www.baka-tsuki.org/project/index.php?title=Sekai_Ichi_no_Imouto-sama http://www.baka-tsuki.org/project/index.php?title=Gakusen_Toshi_Asterisk
  3. On the end of the chapter list http://baka-tsuki.org/project/index.php?title=Boku_wa_Tomodachi_ga_Sukunai
  4. this one uses tables.... http://www.baka-tsuki.org/project/index.php?title=My_Youth_Romantic_Comedy_Is_Wrong_As_I_Expected
  5. and some doesn't have cover.

Maybe for starter, we just parse the number 1 first and ask the translator to standardized the layout.

as for the structure for individual book cover (I changed field name for volume to sections):

"sections":[  
      {  
         "title":"The Toaru Majutsu no Index: New Testament series by Kazuma Kamachi",
         "books":[  
            {  
               "title":"NT Volume 1 (Full Text)",
               "cover":"//www.baka-tsuki.org/project/images/thumb/6/62/NT_To_Aru_Majutsu_no_Index_cover.jpg/145px-NT_To_Aru_Majutsu_no_Index_cover.jpg",
               "chapters":[  
                  {  
                     "title":"Full Text",
                     "page":"Toaru_Majutsu_no_Index:NT_Volume1"
                  },
                  {  
                     "title":"Illustrations",
                     "page":"Toaru_Majutsu_no_Index:NT_Volume1_Illustrations"
                  },
                  {  
                     "title":"Prologue: The People Who Became the Protagonists By Some Kind of Mistake — War?",
                     "page":"Toaru_Majutsu_no_Index:NT_Volume1_Prologue"
                  },
                  {  
                     "title":"Chapter 1: A Peaceful Academy City Without \"Him\" — City.",
                     "page":"Toaru_Majutsu_no_Index:NT_Volume1_Chapter1"
                  }
               ]
            },
            {  
               "title":"NT Volume 2 (Full Text)",
               "cover":"//www.baka-tsuki.org/project/images/thumb/e/e9/NT_vol_2.jpg/140px-NT_vol_2.jpg",
               "chapters":[  
                  {  
                     "title":"Full Text",
                     "page":"Toaru_Majutsu_no_Index:NT_Volume2"
                  },
                  {  
                     "title":"Prologue: Unknown Purpose, but Still a Threat — Radiosonde_Castle.",
                     "page":"Toaru_Majutsu_no_Index:NT_Volume2_Illustrations"
                  },
                  {  
                     "title":"Chapter 1: A New Territory, Magic Afterwards — Lecture_One.",
                     "page":"Toaru_Majutsu_no_Index:NT_Volume2_Prologue"
                  }
               ]
            }
         ]
      },
      {  
         "title":"Side Stories",
         "books":[  
            {  
               "title":"Toaru Majutsu no Index SP (Full Text)",
               "cover":"//www.baka-tsuki.org/project/images/thumb/e/e6/SP.jpg/142px-SP.jpg",
               "chapters":[  
                  {  
                     "title":"Full Text",
                     "page":"Toaru_Majutsu_no_Index:Volume_SP"
                  },
                  {  
                     "title":"Illustrations",
                     "page":"Toaru_Majutsu_no_Index:NT_Volume1_Illustrations"
                  },
                  {  
                     "title":"Prologue: The People Who Became the Protagonists By Some Kind of Mistake — War?",
                     "page":"Toaru_Majutsu_no_Index:NT_Volume1_Prologue"
                  },
                  {  
                     "title":"Chapter 1: A Peaceful Academy City Without \"Him\" — City.",
                     "page":"Toaru_Majutsu_no_Index:NT_Volume1_Chapter1"
                  }
               ]
            },
            {  
               "title":"Toaru Kagaku no Railgun SS: Liberal Arts City (Full Text)",
               "cover":"//www.baka-tsuki.org/project/images/thumb/e/e9/NT_vol_2.jpg/140px-NT_vol_2.jpg",
               "chapters":[  
                  {  
                     "title":"Full Text",
                     "page":"Toaru_Majutsu_no_Index:RailgunSS1"
                  },
                  {  
                     "title":"Prologue: Unknown Purpose, but Still a Threat — Radiosonde_Castle.",
                     "page":"Toaru_Majutsu_no_Index:NT_Volume2_Illustrations"
                  },
                  {  
                     "title":"Chapter 1: A New Territory, Magic Afterwards — Lecture_One.",
                     "page":"Toaru_Majutsu_no_Index:NT_Volume2_Prologue"
                  }
               ]
            }
         ]
      }
   ]

try to parse the layout from http://www.baka-tsuki.org/project/index.php?title=Toaru_Majutsu_no_Index:_New_Testament as they have better structure.

danieltanfh95 commented 9 years ago

Please check out the new JSON structure and the cover image parsing. Example is Kino no tabi

Also the special case of Oregairu

Nandaka commented 9 years ago

should be ok for internal, but maybe you need to expand the selection for text for the external link, e.g. take the whole <li /> text value.

Kino no Tabi volume 12 image

image

Oregairu image

image

danieltanfh95 commented 9 years ago

I don't really get what you mean. Can you provide an example JSON using Knt vol 12?

For the title: here, it's not in a

  • though

    image

  • Nandaka commented 9 years ago

    The external link title for KnT only says "here", because you only get the link text,

    What I'm propose is to expand the text selection to the parent level, so it became "[Completely translated by Untuned-Strings here]".

    danieltanfh95 commented 9 years ago

    Amended to include full text if link title is not found. This should be reflected the newest version of the API. https://baka-tsuki-api.herokuapp.com/api?title=Kino_no_Tabi

    Nandaka commented 9 years ago

    still got issue with https://baka-tsuki-api.herokuapp.com/api?title=My_Youth_Romantic_Comedy_Is_Wrong_As_I_Expected

                   "title":"Volume 1",
                   "chapters":[  
                      {  
                         "title":"My youth romantic comedy is wrong as I expected v1 Illustrations",
                         "page":"My_youth_romantic_comedy_is_wrong_as_I_expected_v1_Illustrations",
                         "linktype":"internal",
                         "link":"http://www.baka-tsuki.org/project/index.php?title=My_youth_romantic_comedy_is_wrong_as_I_expected_v1_Illustrations"
                      },
                      {  
                         "title":"Also on NDNovel Illustrations Also on ND\n\nNovel Illustrations Also on ND\n\nPrologue Also on ND\n\nChapter 1: Basically, Hachiman Hikigaya is rotten Also on ND\n\nChapter 2 Also on ND\n\nChapter 3 Also on ND\n\nChapter 4 Also on ND\n\nChapter 5Also on ND\n\nChapter 6Also on ND\n\nChapter 7 (incomplete)Also on ND\n\nChapter 8Also on ND\n\nAuthor's NotesAlso on ND\n\n\nNovel Illustrations Also on ND\n\nPrologue Also on ND\n\nChapter 1: Basically, Hachiman Hikigaya is rotten Also on ND\n\nChapter 2 Also on ND\n\nChapter 3 Also on ND\n\nChapter 4 Also on ND\n\nChapter 5Also on ND\n\nChapter 6Also on ND\n\nChapter 7 (incomplete)Also on ND\n\nChapter 8Also on ND\n\nAuthor's NotesAlso on ND\n\n\n\n\nNovel Illustrations Also on ND\n\nPrologue Also on ND\n\nChapter 1: Basically, Hachiman Hikigaya is rotten Also on ND\n\nChapter 2 Also on ND\n\nChapter 3 Also on ND\n\nChapter 4 Also on ND\n\nChapter 5Also on ND\n\nChapter 6Also on ND\n\nChapter 7 (incomplete)Also on ND\n\nChapter 8Also on ND\n\nAuthor's NotesAlso on ND\n\n\n\n\n\nNovel Illustrations Also on ND\n\nPrologue Also on ND\n\nChapter 1: Basically, Hachiman Hikigaya is rotten Also on ND\n\nChapter 2 Also on ND\n\nChapter 3 Also on ND\n\nChapter 4 Also on ND\n\nChapter 5Also on ND\n\nChapter 6Also on ND\n\nChapter 7 (incomplete)Also on ND\n\nChapter 8Also on ND\n\nAuthor's NotesAlso on ND\n\n\n\n\n\n\n\nNovel Illustrations Also on ND\n\nPrologue Also on ND\n\nChapter 1: Basically, Hachiman Hikigaya is rotten Also on ND\n\nChapter 2 Also on ND\n\nChapter 3 Also on ND\n\nChapter 4 Also on ND\n\nChapter 5Also on ND\n\nChapter 6Also on ND\n\nChapter 7 (incomplete)Also on ND\n\nChapter 8Also on ND\n\nAuthor's NotesAlso on ND\n\n\n\n\n\n\nVolume 1[edit]\n\n\n\nNovel Illustrations Also on ND\n\nPrologue Also on ND\n\nChapter 1: Basically, Hachiman Hikigaya is rotten Also on ND\n\nChapter 2 Also on ND\n\nChapter 3 Also on ND\n\nChapter 4 Also on ND\n\nChapter 5Also on ND\n\nChapter 6Also on ND\n\nChapter 7 (incomplete)Also on ND\n\nChapter 8Also on ND\n\nAuthor's NotesAlso on ND\n\n\n\n\n\n\n\n\nVolume 1[edit]\n\n\n\nNovel Illustrations Also on ND\n\nPrologue Also on ND\n\nChapter 1: Basically, Hachiman Hikigaya is rotten Also on ND\n\nChapter 2 Also on ND\n\nChapter 3 Also on ND\n\nChapter 4 Also on ND\n\nChapter 5Also on ND\n\nChapter 6Also on ND\n\nChapter 7 (incomplete)Also on ND\n\nChapter 8Also on ND\n\nAuthor's NotesAlso on ND\n\n\n\n\n\n\n\n\n\n \n\n\n\n\nVolume 1[edit]\n\n\n\nNovel Illustrations Also on ND\n\nPrologue Also on ND\n\nChapter 1: Basically, Hachiman Hikigaya is rotten Also on ND\n\nChapter 2 Also on ND\n\nChapter 3 Also on ND\n\nChapter 4 Also on ND\n\nChapter 5Also on ND\n\nChapter 6Also on ND\n\nChapter 7 (incomplete)Also on ND\n\nChapter 8Also on ND\n\nAuthor's NotesAlso on ND\n\n\n\n\n\n\n\n\n\n\n\n\n \n\n\n\n\nVolume 1[edit]\n\n\n\nNovel Illustrations Also on ND\n\nPrologue Also on ND\n\nChapter 1: Basically, Hachiman Hikigaya is rotten Also on ND\n\nChapter 2 Also on ND\n\nChapter 3 Also on ND\n\nChapter 4 Also on ND\n\nChapter 5Also on ND\n\nChapter 6Also on ND\n\nChapter 7 (incomplete)Also on ND\n\nChapter 8Also on ND\n\nAuthor's NotesAlso on ND\n\n\n\n\n\n\n\n\n",
                         "page":"http://oregairuthetranslation.wordpress.com/volume-1/color-illustrations/",
                         "linktype":"external",
                         "link":"http://oregairuthetranslation.wordpress.com/volume-1/color-illustrations/"
                      }]
    

    for some reason, the external chapter 1 title is appended too much

    danieltanfh95 commented 9 years ago

    Fixed. @@ The level of inconsistency in BT is astonishing. lol