Browse Source

всякое

p.kushnir 5 years ago
parent
commit
afe2e4e39c
9 changed files with 378 additions and 213 deletions
  1. 2 0
      .gitignore
  2. 2 2
      cli.js
  3. 5 0
      get.sh
  4. 4 3
      package.json
  5. 9 5
      src/crawler.js
  6. 1 1
      src/index.html
  7. 1 1
      src/root.js
  8. 7 1
      src/settings.js
  9. 347 200
      yarn.lock

+ 2 - 0
.gitignore

@@ -41,3 +41,5 @@ jspm_packages
 /nginx
 /bower_components
 /build
+/.ideaDataSources
+/dataSources

+ 2 - 2
cli.js

@@ -4,9 +4,9 @@ const electron = require('electron');
 
 const proc = require('child_process');
 
-const child = proc.spawn(electron, ['.', '--inspect-brk=' + '14888'], {stdio: 'inherit'});
+const child = proc.spawn(electron, ['--inspect=51488', '.'], {stdio: 'inherit'});
 
-console.log(process.argv);
+console.dir(process.argv);
 
 child.on('close', function (code) {
     process.exit(code)

+ 5 - 0
get.sh

@@ -0,0 +1,5 @@
+for f in dl_*; do cat $f; echo; done > dl
+export http_proxy=http://roof:8118/
+export https_proxy=http://roof:8118/
+export no_proxy=roof
+wget -c -i dl

+ 4 - 3
package.json

@@ -5,6 +5,7 @@
   "main": "backend.js",
   "scripts": {
     "start": "electron .",
+    "console": "node cli.js",
     "build": "electron-packager . kisybi --overwrite --asar=true --platform=win32 --arch=ia32 --icon=src/favicon.ico --prune=true --out=build --version-string.CompanyName=pk --version-string.FileDescription=pk --version-string.ProductName=\"KISYBI\""
   },
   "dependencies": {
@@ -18,7 +19,7 @@
     "angular-messages": "^1.6.9",
     "angular-moment": "^1.2.0",
     "angular-sanitize": "^1.6.9",
-    "angular-ui-router": "^0.4.3",
+    "angular-ui-router": "0.4.3",
     "cheerio": "^1.0.0-rc.2",
     "common-prefix": "^1.1.0",
     "electron-ipc-broadcast": "^0.1.0",
@@ -33,7 +34,7 @@
     "underscore.string": "^3.3.4"
   },
   "devDependencies": {
-    "electron": "^1.8.2",
-    "electron-packager": "^11.0.1"
+    "electron": "^2.0.0",
+    "electron-packager": "^12.0.0"
   }
 }

+ 9 - 5
src/crawler.js

@@ -2,6 +2,7 @@ let moment = require('moment');
 let _ = require('underscore');
 let path = require('path');
 let S = require('underscore.string');
+let fs = require('fs');
 
 require('electron-ipc-broadcast').mainBroadcastListener();
 let ipb = require('electron-ipc-broadcast').default;
@@ -17,7 +18,7 @@ let common_prefix = require('common-prefix');
 
 if (settings().get('crawl') === undefined) settings().set('crawl', {});
 
-const baseUrl = 'http://freedom-tor.org/browse/';
+const baseUrl = 'http://rutorc6mqdinc4cz.onion/browse';
 
 let defaults = {
     category: {
@@ -27,7 +28,8 @@ let defaults = {
         science: 12,
         series: 4,
         music: 2,
-        books: 11
+        books: 11,
+        ru_series: 16
     },
     sort: {
         asc: 1,
@@ -106,7 +108,7 @@ function doGrouping(rs, rj) {
 
 let getUrlDay = function (date, cat, page) {
     if (_.isUndefined(page)) page = 0;
-    return `${baseUrl}${page}/${cat}/${defaults.user}/${(defaults.order.date + defaults.sort.asc)};${moment(date).format('DD.MM.YYYY')};${moment(date).format('DD.MM.YYYY')}`;
+    return `${baseUrl}/${page}/${cat}/${defaults.user}/${(defaults.order.date + defaults.sort.asc)};${moment(date).format('DD.MM.YYYY')};${moment(date).format('DD.MM.YYYY')}`;
 };
 
 function extractRows_v_0_1(fn) {
@@ -136,7 +138,7 @@ function doCrawl(cat, force) {
 
         var lastDates = settings().get('crawl').lastDates;
         if (_.isUndefined(lastDates)) lastDates = {};
-        var lastDate = _.has(lastDates, cat) ? lastDates[cat] : '2018-01-01';
+        var lastDate = _.has(lastDates, cat) ? lastDates[cat] : '2019-01-01';
 
         let date = moment(lastDate, 'YYYY-MM-DD').endOf('day');
         if (date.isBefore(moment())) date.add(1, 'day');
@@ -164,6 +166,8 @@ function doCrawl(cat, force) {
                     extractRows(r => {
                         r.date = parseInt(date.clone().startOf('day').format('x'));
                         r.category = cat;
+                        if (cat === 2) fs.writeFileSync(`ml_${r.id}`, `${S(baseUrl).replace('/browse', '').value()}${r.dl}\n`);
+                        if (cat === 11) fs.writeFileSync(`bl_${r.id}`, `${S(baseUrl).replace('/browse', '').value()}${r.dl}\n`);
                         ret.push(r)
                     })($);
                     rs(ret);
@@ -198,7 +202,7 @@ function doCrawl(cat, force) {
                 if (date.isBefore(moment().endOf('day'))) {
                     setTimeout(function () {
                         doCrawl(cat).then(rs, rj)
-                    }, 1000);
+                    }, 300);
                 } else {
                     setTimeout(function () {
                         rs();

+ 1 - 1
src/index.html

@@ -7,7 +7,7 @@
     <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
 </head>
 <body ui-view ng-cloak>
-<script>
+<script type="module">
     require('./frontend.js');
     require('../node_modules/angular-i18n/angular-locale_ru-ru.js');
     require('../node_modules/angular-material-badge/angular-material-badge.min.js');

+ 1 - 1
src/root.js

@@ -12,7 +12,7 @@ require('angular').module('Ks').constant('baseUrl', 'http://freedom-tor.org/torr
 
     let tabCats = {
         0: [1, 5],
-        1: [4],
+        1: [4, 16],
         2: [12],
         3: [2],
         4: [11],

+ 7 - 1
src/settings.js

@@ -9,7 +9,13 @@ let settings = {
     userPath: app.getPath('userData'),
     userConfigFile: 'config.json',
     userDbFile: 'data.sqlite',
-    userConfig: {}
+    userConfig: {
+        proxy: {
+            host: 'roof',
+            port: 8118,
+            active: false
+        }
+    }
 };
 
 function initConfig() {

File diff suppressed because it is too large
+ 347 - 200
yarn.lock


Some files were not shown because too many files changed in this diff