4chan-list-webm
Advanced tools
Comparing version 1.3.0 to 2.0.0
const axios = require('axios') | ||
function getWebmList (url, callback, options) { | ||
function getWebmList (board, threadNo, callback, options) { | ||
options = options || {} | ||
const protocol = options.https ? 'https' : 'http' | ||
const parsedUrl = /http:\/\/boards.4chan.org\/(.*)\/thread\/(.*)\.json/.exec(url) | ||
const [, board, threadNo] = parsedUrl | ||
const apiUrl = `${protocol}://a.4cdn.org/${board}/thread/${threadNo}.json` | ||
@@ -11,0 +8,0 @@ |
{ | ||
"name": "4chan-list-webm", | ||
"version": "1.3.0", | ||
"version": "2.0.0", | ||
"description": "List all webms within a 4chan thread", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
# 4chan-list-webm | ||
Given a thread URL, returns an array of objects containing the filename and URL of every webm. | ||
Given a board and thread number, returns an array of objects containing the filename and URL of every webm. | ||
Because CORS [is only supported](https://github.com/4chan/4chan-API/issues/35) with an origin of `http(s)://boards.4chan.org`, | ||
this module **does not work in the browser; it only works with Node.js** | ||
this module **does not work in the browser; it only works with Node.js**. | ||
### Update 2.0.0 | ||
Breaking changes: | ||
* Now requires arguments `board` and `threadNo` (thread number) instead of `url` | ||
## Installation | ||
@@ -26,6 +32,7 @@ | ||
// Consider the following URL: http://boards.4chan.org/wsg/thread/2045456 | ||
// The board is 'wsg' and the thread number is 2045456 | ||
// Note: This thread will likely 404 by the time you see this | ||
const threadUrl = 'http://boards.4chan.org/wsg/thread/1959335' | ||
listWebms(threadUrl, function (webms) { | ||
listWebms('wsg', 2045456, function (webms) { | ||
console.log(webms) | ||
@@ -32,0 +39,0 @@ }) |
@@ -6,5 +6,4 @@ const listWebms = require('../') | ||
.then(function (res) { | ||
const url = 'http://boards.4chan.org/wsg/thread/' + res.data[0].threads[1].no + '.json' | ||
console.log(url) | ||
listWebms(url, function(data) { | ||
const threadNo = res.data[0].threads[1].no | ||
listWebms('wsg', threadNo, function(data) { | ||
console.log(data) | ||
@@ -11,0 +10,0 @@ }) |
3761
61
29