How to use the plugin as a scanlation team

View previous topic View next topic Go down

How to use the plugin as a scanlation team

Post  Doonge on Thu Jul 12, 2012 5:32 pm

Introduction


The plugin allows users to manage and follow scanlation teams' feeds (through HTML5's localStorage feature), and automatically accesses them (through CORS request) while browsing webtoons that your team translate. If you want to distribute your work through users' plugin, you'll have to provide a feed that gives appropriate information (in JSON) about your work.



3 key parameters


When accessing your feed, a plugin user gives you three pieces of information :
- the identifier of the webtoon he's reading.
- the identifier of the publication (the chapter sortof) aswell.
- the duration in minutes since last visit.

What are these identifiers?
http //comic.naver.com/webtoon/detail.nhn?titleId=186811&no=50 leads us to Cheese in the trap, Season 2 Chapter 1. "Cheese in the trap" webtoon's identifier is 186811, and "CITT Season 2 chapter 1" publication's identifier is 50. Note that [ this url ] works too. Sometimes an ID is invalid, for instance [ Publication #95 of Cheese in the Trap ] does not exist, and you will just see the most recent publication/chapter when accessing it.

If an user just added your feed, or if it has been a while he didn't check your feed, he will just ask for the status of your projects. Both given identifiers will be set to 0. And if it's the first time, duration will also be set to 0 (minimum given duration is always 1 otherwise, even if the user is spamming).

Technically, supposing that your feed's url is feedURL, the plugin will access

http :// {feedURL} / {webtoon's id} / {publication's id} . json ? {duration}

For instance http://feedURL/186811/50.json?60 for Cheese in the Trap Season 2 Chapter 1 (last visit one hour ago).
Or http://feedURL/0/0.json?0 the first time the user poke your feed.

*note : in a previous version of the addon, the time parameter was a date in YYYYMMDD (GMT) format. One year is approx. 525000 minutes. So if higher than that, assume it's maybe a date and not a duration in minutes.*



Hosting the feed

If you want to distribute your work through simple, flat, JSON files neatly stored in your website (in case you are not allowed to use dynamic langage like php on your website), it works okay but the automated tracking of your new projects is less smooth (so you'll have to work around).

If you want to distribute your work through a dynamic script (php for instance), this works fine. If you use a php file, like feed.php, the plugin would access http://feedURL/feed.php/186811/50.json?60, and you could retrieve the identifiers through $_SERVER['PATH_INFO'] and $_SERVER['QUERY_STRING']. Never forget to verify malicious input.
You may even simplify the feed's URL and hide the .php (or whatever) extension with URL rewriting (.htaccess file).
Note that when using dynamic scripts, you must specify that you return a JSON file, and send the correct header. In php, the line
Code:
header("content-type: application/json");
does the trick.

If you want to change the default behaviour, and have a custom URL format, you may provide a generic URL with the parameters in curly brackets ({id} for webtoon's identifier, {no} for publication's identifier, and {time} for duration).
For instance someURL/feed.php?webtoon={id}&chapter={no}&last_visit={time}
It will change the default behavior, which is feedURL/{id}/{no}.json?{time}



In all cases, you'll have to validate the CORS requests for comic.naver.com by sending an additionnal header; setting Access-Control-Allow-Origin to http://comic.naver.com
This can be done with an .htaccess file in the feed directory, containing the line
Code:
Header set Access-Control-Allow-Origin http://comic.naver.com
, or within the feed dynamic script (if you use one). For instance, in php the line
Code:
header("Access-Control-Allow-Origin: http://comic.naver.com");
works as well.




What should the feed provide ?

A JSON file. ( http://www.json.org/ )
This is a simple text message (text file) between two curly brackets, that links parameters names and parameters values, comma-separated. Array are "[ ]" and objects are "{ }".
content of a json file wrote:{"parameterName" : "parameterValue", "otherParameterName" : "otherParameterValue"}


By accessing http://lmsodd.x10.mx/feed/186811/50.json?60, here would be the result:
{
"chapterName":"Season 2 Chapter 1",
"first":"26",
"previous":"49",
"next":"51",
"last":"51",
"generalUrl":"http://lmsodd.x10.mx/oddsquad/citt/no50/no50p{imgNumber}.png"
}



Here's the list of variables names, and what they do if contained in the JSON file:

General
"teamName" : your team's name. Give only if it changes, or when the user is performing his first visit (minute parameter will be set as 0).
"teamLogo" : optionnal, url of your logo. Give only if it changes, or when the user is performing his first visit (minute parameter will be set as 0).
"teamURL" : optionnal, your team's website. Give only if it changes, or when the user is performing his first visit (minute parameter will be set as 0).

"add" : [{"id": , "category": , "title": , "author": , "blurb": , "thumbnail": , "smallThumbnail": }, {} , ...] "Most complicated" command. Object or Array of objects. Add (or update) webtoons to the team's pool. All the property must be correctly given :
- id is the webtoon's id
- category is the type of the webtoon : it's either "webtoon", or "challenge", or "best challenge". You can just send "w" "c" or "b".
- title is the title of the webtoon
- author the name of the author
- blurb the little synopsis of the webtoon (you can use the token {endl} to force an endline).
- thumbnail is the filename of the logo (218x120 webtoons or 98x79 challenges) ( title_thumbnail_20110615184135_t218x120.jpg for citt) for webtoons, or the path to the filename for challenges 2010/08/11/mir2030s/thumbnail_title_mir2030s_092631_98x79.jpg for Because I Love You
- smallThumbnail is the FILENAME of the thumbnail (83x90) ( title_thumbnail_20110615184135_t83x90.jpg for citt) ro the path to the filename for challenges 2010/08/11/mir2030s/thumbnail_title_mir2030s_092631_83x90.jpg for Because I Love You

"remove" : [ , , ,] ID or Array of ID. Removes the corresponding webtoons from the team. (in case project dropped, or "falsely added").


Used by the mini navigation bar (Only if your team is translating this webtoon)
"chapterName": specify the current publication/chapter name,
"first": specify the first chapter translated by the team (don't give it if it's >= to the current chapter),
"previous": specify the previous chapter translated by the team (don't give if there's none, or same than current),
"next": specify the next chapter translated by the team (don't give if there's none, or same than current),
"last": specify the last chapter translated by the team (don't give it if it's <= to the current chapter),

Used by the layers loader (Only if your team has effectively translated that chapter)
"generalUrl": general form of the layers' URL. The {imgNumber} token MUST be present. This confirms the current chapter has been translated, don't give if not translated.
"urls": [ , , , ... ] array of URLs. The size must match with the number of layers required. This confirms the current chapter has been translated, don't give if not translated. If most of the URLs fit with the generalURL parameter, just write 0 or the number of the image, in that case the URL will be judged wrong and the generalURL, if exists, will be used.
"split": integer value indicating you have split the layers (OSS did that with earlier chapters of CITT, because they were way too big), and give the size of the split. It is 1400 for the first chapters of CITT (all cut images are 1400px tall, except the last splits).



Check http://lmsodd.x10.mx/feed/186811/30.json?60 (publication #30 of Cheese in the Trap).
Or http://lmsodd.x10.mx/feed/0/0.json?0 (first visit).
Or even http://lmsodd.x10.mx/feed/99/0.json?1 (unknown project).

Doonge
Expert
Expert

Posts: 104
Join date: 2012-01-18

View user profile

Back to top Go down

View previous topic View next topic Back to top

- Similar topics

Permissions in this forum:
You cannot reply to topics in this forum