jvc
Node.js jeuxvideo.com API client.
Caution
This library is in early beta, and not complete at all. I implemented only the methods I needed, and I'm not going to add support for other methods unless I need them too.
However, I happily accept pull requests; feel free to implement the features you need, and please get in touch with me if you need some advices on how to hack this library.
Usage
const jvc =
You can then call all the supported API methods on the jvc
object.
Some methods will require you to be logged in (like private
messages access and forums post), while others will
work anonymously.
Also, the jvc
object is fully overridable thanks to bind-late. Look
the source to see what you can customize!
All code examples that need a connected API will use connectedJvc
object, and anonymous methods will just use jvc
.
All the code examples assume to be run in an ES7 asynchronous function.
Login
// Need to handle captcha prompts.const handleCaptcha = async { if !errcaptcha throw err // Prompt the user to fill given captcha URL. const code = await return await err // Retry request. // Recursively ask for captcha.} const connectedJvc = await jvc // You can then call methods that require connection on `connectedJvc`.
Note: once you have a connectedJvc
object, you can find the
connection cookie in connectedJvc.user.cookie
. If you store it
permanently, you can restore it like this:
const connectedJvc = jvc
This way you avoid getting the captcha prompt everytime. Though, I have no idea how long the cookie will stay valid. Please tell me if you have more informations about this.
Private messages
List
// Get first page.const list = await connectedJvcpm // list:// count: Number// page: Number// unread: Number// threads:// - id: Number// subject: String// author: String// date: Date// isRead: Boolean// // Get second page.const next = await connectedJvcpm
Thread
// Get the last 5 messages of a thread (ID from previous list).const thread = await connectedJvcpm // thread:// id: Number// subject: String// members: [String]// count: Number// next: Number// messages:// - image: String// author: String// date: Date// post: String // Get next 10 messages.const next = await connectedJvcpm
Example
See the jvc-cli project for a concrete usage example. Or if you just want an interactive demo:
npm install -g jvc-clijvc loginjvc pm