forked from magicknight/javlibrary-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.hbs
107 lines (84 loc) · 2.44 KB
/
README.hbs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
![Hero](https://i.imgur.com/ymnsyVQ.gif)
<p align="center">
🐝 This repo name is fully encapsulated.
</p>
<p align="center">
<a href="https://travis-ci.org/ken113/javlibrary-api"><img src="https://img.shields.io/travis/ken113/javlibrary-api/master.svg?style=flat-square"></a>
<a href="https://david-dm.org/ken113/javlibrary-api"><img src="https://david-dm.org/trazyn/ieaseMusic/status.svg?style=flat-square"></a>
<a href="https://david-dm.org/ken113/javlibrary-api?type=dev"><img src="https://david-dm.org/trazyn/ieaseMusic/dev-status.svg?style=flat-square"></a>
</p>
> This is a universal wrapper/scraper for the [javlibrary.com](http://javlibrary.com/) that runs on Nodejs.
- [Installation](#installation)
- [Usage](#usage)
- [Sample](#sample)
- [Session](#session)
## Installation
```
npm i ken113/javlibrary-api
```
## Usage
The first thing is bypass Cloudflare's anti-bot page, all the content access need with [session](#session).
```javascript
import jav from 'javlibrary-api';
jav.config(
{
headers: {
'User-Agent': 'required'
'Cookie': 'required'
}
}
);
(
async() => {
var res = await jav.getVideoDetail('javliida3q');
console.log(res);
}
)();
```
## Sample
There are a lot of [samples](https://github.com/ken113/javlibrary-api/tree/master/sample) 🤗 If you're trying to figure out how to use an API, look there first!
```
npm run sample -- ./sample/search.js
```
## Session
Run the command generate a session file:
```
npm run session
```
There has a example how to keep a fresh session:
```python
import time
import cfscrape
import schedule
def job():
tokens, user_agent = cfscrape.get_cookie_string('http://www.javlibrary.com/') # noqa
with open('../session.txt', 'w') as file:
file.write('{}+{} \r\n'.format(tokens, user_agent))
job()
schedule.every(30).minutes.do(job)
while 1:
schedule.run_pending()
time.sleep(1)
```
Use the session file:
```javascript
var jav = require('../index');
var fs = require('fs');
var path = require('path');
module.exports = () => {
var session = fs.readFileSync(path.resolve(__dirname, '../session.txt'), { encoding: 'utf-8' });
var [cookie, userAgent] = session.split('+');
jav.config(
{
headers: {
'User-Agent': userAgent.trim(),
'Cookie': cookie.trim()
}
}
);
return jav;
};
```
# API Reference
{{>main-index~}}
{{>all-docs~}}