@xriss/weerss 0.0.43 → 0.0.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/cmd.js +0 -5
  2. package/db.js +32 -31
  3. package/package.json +1 -3
  4. package/weerss.js +3 -10
package/cmd.js CHANGED
@@ -126,11 +126,6 @@ if( arg1=="dirs" )
126
126
  await weerss.dirs(args)
127
127
  }
128
128
  else
129
- if( arg1=="clean" )
130
- {
131
- await weerss.clean(args)
132
- }
133
- else
134
129
  if( arg1=="purge" )
135
130
  {
136
131
  await weerss.purge(args)
package/db.js CHANGED
@@ -3,7 +3,7 @@ let db={}
3
3
  export default db
4
4
 
5
5
 
6
- import { AsyncDatabase } from "promised-sqlite3"
6
+ import { DatabaseSync } from 'node:sqlite';
7
7
 
8
8
  import { configure } from 'safe-stable-stringify'
9
9
  const stringify = configure({})
@@ -29,18 +29,18 @@ db.name="weerss"
29
29
  db.setup=async function()
30
30
  {
31
31
 
32
- db.handle = await AsyncDatabase.open( weerss.get_config_path("sqlite") );
32
+ db.handle = new DatabaseSync( weerss.get_config_path("sqlite") );
33
33
 
34
34
  // db.handle.inner.on("trace", (sql) => console.log("[TRACE]", sql));
35
35
 
36
- await db.handle.run("PRAGMA synchronous = 0 ;");
37
- await db.handle.run("PRAGMA encoding = \"UTF-8\" ;");
38
- await db.handle.run("PRAGMA journal_mode=WAL;");
39
- await db.handle.run("PRAGMA mmap_size=268435456;");
40
- await db.handle.run("PRAGMA temp_store=2;");
36
+ db.handle.exec("PRAGMA synchronous = 0 ;");
37
+ db.handle.exec("PRAGMA encoding = \"UTF-8\" ;");
38
+ db.handle.exec("PRAGMA journal_mode=WAL;");
39
+ db.handle.exec("PRAGMA mmap_size=268435456;");
40
+ db.handle.exec("PRAGMA temp_store=2;");
41
41
 
42
42
 
43
- await db.handle.run(`
43
+ db.handle.exec(`
44
44
 
45
45
  CREATE TABLE IF NOT EXISTS keyval
46
46
  (
@@ -50,7 +50,7 @@ db.setup=async function()
50
50
 
51
51
  `);
52
52
 
53
- await db.handle.run(`
53
+ db.handle.exec(`
54
54
 
55
55
  CREATE TABLE IF NOT EXISTS hoard
56
56
  (
@@ -60,7 +60,7 @@ db.setup=async function()
60
60
 
61
61
  `);
62
62
 
63
- await db.handle.run(`
63
+ db.handle.exec(`
64
64
 
65
65
  CREATE TABLE IF NOT EXISTS feeds
66
66
  (
@@ -70,7 +70,7 @@ db.setup=async function()
70
70
 
71
71
  `);
72
72
 
73
- await db.handle.run(`
73
+ db.handle.exec(`
74
74
 
75
75
  CREATE TABLE IF NOT EXISTS items
76
76
  (
@@ -80,7 +80,7 @@ db.setup=async function()
80
80
 
81
81
  `);
82
82
 
83
- await db.handle.run(`
83
+ db.handle.exec(`
84
84
 
85
85
  CREATE TABLE IF NOT EXISTS torrents
86
86
  (
@@ -90,7 +90,7 @@ db.setup=async function()
90
90
 
91
91
  `);
92
92
 
93
- await db.handle.run(`
93
+ db.handle.exec(`
94
94
 
95
95
  CREATE TABLE IF NOT EXISTS shows
96
96
  (
@@ -123,56 +123,57 @@ db.get=async function(table,key)
123
123
  db.set=async function(table,key,value)
124
124
  {
125
125
  table=table||"keyval"
126
- await db.handle.run(`
126
+ value=stringify(value)
127
+ db.handle.exec(`
127
128
 
128
129
  INSERT INTO ${table} (key,value)
129
- VALUES ($key,$value)
130
+ VALUES (${key},${value})
130
131
  ON CONFLICT (key)
131
132
  DO
132
- UPDATE SET value = $value
133
- WHERE key = $key;
133
+ UPDATE SET value = ${value}
134
+ WHERE key = ${key};
134
135
 
135
- `,{$key:key,$value:stringify(value)})
136
+ `)
136
137
  }
137
138
 
138
139
 
139
140
  db.clear=async function(table)
140
141
  {
141
142
  table=table||"keyval"
142
- await db.handle.run(`
143
+ db.handle.exec(`
143
144
 
144
145
  DELETE FROM ${table};
145
146
 
146
- `,{})
147
+ `)
147
148
 
148
149
  }
149
150
 
150
151
  db.vacuum=async function()
151
152
  {
152
- await db.handle.run(`
153
+ db.handle.exec(`
153
154
 
154
155
  VACUUM;
155
156
 
156
- `,{})
157
+ `)
157
158
  }
158
159
 
159
160
  db.delete=async function(table,key)
160
161
  {
161
162
  table=table||"keyval"
162
- await db.handle.run(`
163
+ db.handle.exec(`
163
164
 
164
- DELETE FROM ${table} WHERE key=$key;
165
+ DELETE FROM ${table} WHERE key=${key};
165
166
 
166
- `,{$key:key})
167
+ `)
167
168
  }
168
169
 
169
170
  db.clean=async function(table)
170
171
  {
171
- await db.handle.each(`
172
+ for ( const row of db.handle.prepare(`
172
173
 
173
174
  SELECT * FROM ${table}
174
175
 
175
- `,{},function(row)
176
+ `).iterate({}) )
176
177
  {
177
178
  try{
178
179
  JSON.parse(row.value)
@@ -180,7 +181,7 @@ db.clean=async function(table)
180
181
  console.log("removing broken json for "+row.key)
181
182
  db.delete(table,row.key)
182
183
  }
183
- })
184
+ }
184
185
  }
185
186
 
186
187
  db.list=async function(table,filter,cb)
@@ -258,19 +259,19 @@ db.list=async function(table,filter,cb)
258
259
  }
259
260
  // console.log(filters)
260
261
 
261
- await db.handle.each(`
262
+ for ( const row of db.handle.prepare(`
262
263
 
263
264
  SELECT * FROM ${table}
264
265
  ${filters}
265
266
 
266
- `,{},function(row)
267
+ `).iterate({}) )
267
268
  {
268
269
  let v=JSON.parse(row.value)
269
270
  if((!cb)||(cb(row.key,v)))
270
271
  {
271
272
  rs.push(v)
272
273
  }
273
- })
274
+ }
274
275
 
275
276
  return rs // filtered only, sorted by date
276
277
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xriss/weerss",
3
- "version": "0.0.43",
3
+ "version": "0.0.45",
4
4
  "source": "weerss.js",
5
5
  "type": "module",
6
6
  "repository": {
@@ -22,11 +22,9 @@
22
22
  "mri": "^1.2.0",
23
23
  "parse-torrent": "^11.0.17",
24
24
  "path-browserify": "^1.0.1",
25
- "promised-sqlite3": "^2.1.0",
26
25
  "safe-stable-stringify": "^2.5.0",
27
26
  "sanitize-filename": "^1.6.3",
28
27
  "sax": "^1.4.1",
29
- "sqlite3": "^5.1.7",
30
28
  "stream-browserify": "^3.0.0",
31
29
  "webpack": "^5.94.0",
32
30
  "webtorrent": "^2.5.1",
package/weerss.js CHANGED
@@ -320,7 +320,9 @@ weerss.getlist=async function(filters)
320
320
  }
321
321
  }
322
322
  list.sort( function(a,b){
323
- return new Date(b.date) - new Date(a.date)
323
+ // sort by date of episode ?
324
+ // return new Date(b.show.date || 0) - new Date(a.show.date || 0)
325
+ return new Date(b.date || 0) - new Date(a.date || 0)
324
326
  })
325
327
  return list
326
328
  }
@@ -413,15 +415,6 @@ weerss.save_rss=async function(args)
413
415
  }
414
416
 
415
417
 
416
- weerss.clean=async function(args)
417
- {
418
- await db.setup()
419
-
420
- await db.clean("items")
421
-
422
- await db.close()
423
- }
424
-
425
418
  weerss.move=async function(args)
426
419
  {
427
420