Browse Source

First version of Line Stickers Dump

Antoine Leroyer 8 years ago
commit
efced21467
3 changed files with 46 additions and 0 deletions
  1. 1 0
      .gitignore
  2. 30 0
      lsdump.js
  3. 15 0
      package.json

+ 1 - 0
.gitignore

@@ -0,0 +1 @@
+node_modules/

+ 30 - 0
lsdump.js

@@ -0,0 +1,30 @@
+let cheerio = require('cheerio')
+let request = require('request')
+let fs = require ('fs')
+
+var args = process.argv.slice(2);
+
+request(args[0], function (error, response, html) {
+  if (!error && response.statusCode == 200) {
+    var $ = cheerio.load(html);
+    // var script = $('script').get()[2].children[0].data;
+    //
+    // var jsonStr = script.substr(script.indexOf('OPTIONS.config.sticker = {'), script.lastIndexOf('}'));
+    //
+    // console.log(jsonStr);
+    // JSON.parse(jsonStr);
+
+    var dir = $('.mdCMN08Ttl').text();
+    fs.mkdirSync(dir);
+
+    $('.FnSticker_animation_list_img li div span').each(function(i, elem) {
+      var sticker = $(elem);
+      var url = sticker.css('background-image').substring(4);
+      var filename = url.substring(url.lastIndexOf('/') + 1);
+      var path = dir + '/' + filename;
+
+      console.log("Dumping " + filename + " to " + path);
+      request(url).pipe(fs.createWriteStream(path));
+    });
+  }
+});

+ 15 - 0
package.json

@@ -0,0 +1,15 @@
+{
+  "name": "line_stickers_dump",
+  "version": "1.0.0",
+  "description": "Dump Line stickers from a given URL",
+  "main": "lsdump.js",
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "author": "Tone",
+  "license": "ISC",
+  "dependencies": {
+    "cheerio": "^0.22.0",
+    "request": "^2.75.0"
+  }
+}