@xriss/weerss 0.0.23 → 0.0.25

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 +16 -11
  2. package/db.js +18 -7
  3. package/package.json +1 -1
  4. package/weerss.js +36 -27
package/cmd.js CHANGED
@@ -35,34 +35,34 @@ if( arg1=="help" )
35
35
 
36
36
  options:
37
37
 
38
- Load config file, you should always load your custom config for all
38
+ Load config file, you should always load your custom config for all
39
39
  of the following commands...
40
40
 
41
41
  --config=weerss.config
42
42
 
43
- environment variables can also set options with the prefix WEERSS_
43
+ environment variables can also set options with the prefix WEERSS_
44
44
  and the option name in all uppercase. eg:
45
45
 
46
46
  export WEERSS_CONFIG=/home/dave/weerss.config
47
47
 
48
- All options are loaded into this config structure with . used as an
48
+ All options are loaded into this config structure with . used as an
49
49
  object seperator and the value parsed as json.
50
50
 
51
- EG To choose the number of items in your rss feed from the command line
51
+ EG To choose the number of items in your rss feed from the command line
52
52
  and thus overide the config file setting.
53
53
 
54
54
  --rss.length=100
55
55
  or
56
56
  --rss='{length:100}'
57
57
 
58
- With the later removing any other values in the rss object while the
58
+ With the later removing any other values in the rss object while the
59
59
  former just changes the legth value.
60
60
 
61
61
  commands:
62
62
 
63
63
  weerss config
64
- Create a default to config file if we do not already have one and
65
- then print the current config. I recomend reading the default
64
+ Create a default to config file if we do not already have one and
65
+ then print the current config. I recomend reading the default
66
66
  config file for comments about how to configure weerss.
67
67
 
68
68
  weerss config --force
@@ -78,12 +78,12 @@ weerss rss
78
78
  Save torrents as rss.
79
79
 
80
80
  weerss move
81
- Move downloaded chaotic files to an organised jellyfin style
81
+ Move downloaded chaotic files to an organised jellyfin style
82
82
  directory.
83
83
 
84
84
  weerss dirs
85
- Create a script to cleanup TV dirs using tvmaze. This does not do
86
- any cleanup just prints bash commands that you may wish to run
85
+ Create a script to cleanup TV dirs using tvmaze. This does not do
86
+ any cleanup just prints bash commands that you may wish to run
87
87
  later.
88
88
 
89
89
  weerss help
@@ -123,13 +123,18 @@ if( arg1=="dirs" )
123
123
  await weerss.dirs(args)
124
124
  }
125
125
  else
126
+ if( arg1=="clean" )
127
+ {
128
+ await weerss.clean(args)
129
+ }
130
+ else
126
131
  {
127
132
  console.log(` Unknown weerss command "${arg1}" `)
128
133
  }
129
134
 
130
135
  if(args.wtf)
131
136
  {
132
- console.log(` Forcing exit `)
137
+ console.log(` Forcing exit `)
133
138
  wtf.dump()
134
139
  process.exit(0)
135
140
  }
package/db.js CHANGED
@@ -166,6 +166,23 @@ db.delete=async function(table,key)
166
166
  `,{$key:key})
167
167
  }
168
168
 
169
+ db.clean=async function(table)
170
+ {
171
+ await db.handle.each(`
172
+
173
+ SELECT * FROM ${table}
174
+
175
+ `,{},function(row)
176
+ {
177
+ try{
178
+ JSON.parse(row.value)
179
+ }catch(e){
180
+ console.log("removing broken json for "+row.key)
181
+ db.delete(table,row.key)
182
+ }
183
+ })
184
+ }
185
+
169
186
  db.list=async function(table,filter)
170
187
  {
171
188
  table=table||"keyval"
@@ -248,13 +265,7 @@ db.list=async function(table,filter)
248
265
 
249
266
  `,{},function(row)
250
267
  {
251
- try{
252
- rs.push(JSON.parse(row.value))
253
- }catch(e){
254
- console.log("BROKEN SQLITE JSON")
255
- console.log(row.value)
256
- console.log(e)
257
- }
268
+ rs.push(JSON.parse(row.value))
258
269
  })
259
270
 
260
271
  return rs // filtered only, sorted by date
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xriss/weerss",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "source": "weerss.js",
5
5
  "type": "module",
6
6
  "repository": {
package/weerss.js CHANGED
@@ -39,14 +39,14 @@ weerss.config_default=`
39
39
  // number of episodes to list in the rss files
40
40
  length = 100
41
41
  }
42
- // decide which shows we like ( data from tvmaze )
42
+ // decide which shows we like ( data from tvmaze )
43
43
  show = {
44
44
  rules = [
45
45
  [ TRUE ]
46
46
  [ "!english" FALSE ]
47
47
  ]
48
48
  }
49
- // decide which episode we like tags come from filename
49
+ // decide which episode we like tags come from filename
50
50
  episode = {
51
51
  best = "small"
52
52
  maxsize = 4000000000
@@ -76,7 +76,7 @@ weerss.load_config=async function(args)
76
76
  {
77
77
  console.log(` Loading config from `+args.config)
78
78
  weerss.config=djon.load_file(args.config)
79
-
79
+
80
80
  let def=djon.load(weerss.config_default)
81
81
  for(let n in def )
82
82
  {
@@ -145,7 +145,7 @@ weerss.get_config_path=function(name)
145
145
  {
146
146
  f=path.join( d , f )
147
147
  }
148
-
148
+
149
149
  return f
150
150
  }
151
151
 
@@ -205,9 +205,9 @@ weerss.fetch=async function()
205
205
  await torrents.fill_torrent(item)
206
206
  console.log(item.torrent)
207
207
  items.set(item)
208
- }
208
+ }
209
209
  }
210
-
210
+
211
211
  {
212
212
  let its=await db.list("items",{show_is_null:1,torrent_is_not_null:1})
213
213
  console.log("Checking shows : "+its.length)
@@ -218,7 +218,7 @@ weerss.fetch=async function()
218
218
  console.log( item_to_string(item) )
219
219
 
220
220
  items.set(item)
221
- }
221
+ }
222
222
  }
223
223
 
224
224
 
@@ -230,10 +230,10 @@ weerss.getlist=async function()
230
230
  {
231
231
  // all items then we sort and filter and list
232
232
  let its=await db.list("items",{})
233
-
233
+
234
234
  let buckets={}
235
235
  let itemshows={}
236
-
236
+
237
237
  for(let item of its)
238
238
  {
239
239
  if(!item.show) { continue }
@@ -245,18 +245,18 @@ weerss.getlist=async function()
245
245
  let SxxExx=("S"+item.show.season.toString().padStart(2, "0")+"E"+item.show.episode.toString().padStart(2, "0") )
246
246
 
247
247
  if(!buckets[item.show.id]){buckets[item.show.id]={}}
248
- if(!buckets[item.show.id][SxxExx]){buckets[item.show.id][SxxExx]=[]}
248
+ if(!buckets[item.show.id][SxxExx]){buckets[item.show.id][SxxExx]=[]}
249
249
 
250
250
  buckets[item.show.id][SxxExx].push(item)
251
251
 
252
252
  itemshows[item.show.id] = item.show
253
253
  }
254
-
254
+
255
255
  let list=[]
256
256
  for( let showid in itemshows )
257
257
  {
258
258
  let show=itemshows[showid]
259
-
259
+
260
260
  if( show.tvmaze )
261
261
  {
262
262
  if( ! shows.good_show(show,weerss.config.show.rules) ) // skip this show?
@@ -327,7 +327,7 @@ weerss.getlist=async function()
327
327
  {
328
328
  error("unknown config.episode.best option")
329
329
  }
330
-
330
+
331
331
  while( bucket.length>0 ) // check episode flags ( uses words from filename + all the show flags )
332
332
  {
333
333
  if( ! shows.good_episode(bucket[ 0 ].show,weerss.config.episode.rules) ) // skip this episode?
@@ -397,7 +397,7 @@ weerss.save_rss=async function(args)
397
397
 
398
398
  let dates=(new Date(item.date)).toUTCString()
399
399
  let isodates=(new Date(item.date)).toISOString()
400
-
400
+
401
401
  let it={
402
402
  "/guid" : url ,
403
403
  "/link" : url ,
@@ -439,12 +439,21 @@ weerss.save_rss=async function(args)
439
439
  }
440
440
 
441
441
 
442
+ weerss.clean=async function(args)
443
+ {
444
+ await db.setup()
445
+
446
+ await db.clean("items")
447
+
448
+ await db.close()
449
+ }
450
+
442
451
  weerss.move=async function(args)
443
452
  {
444
-
453
+
445
454
  let from=weerss.get_config_path("download") //args._[2] // optional dest dir
446
455
  let dest=weerss.get_config_path("tv") //args._[2] // optional dest dir
447
-
456
+
448
457
  if(dest)
449
458
  {
450
459
  console.log( "Moving file from "+from+" to "+dest )
@@ -453,9 +462,9 @@ weerss.move=async function(args)
453
462
  {
454
463
  console.log( "Testing moving files from "+from )
455
464
  }
456
-
465
+
457
466
  await db.setup()
458
-
467
+
459
468
  let getallfiles=function(dir, a)
460
469
  {
461
470
  a = a || []
@@ -485,7 +494,7 @@ weerss.move=async function(args)
485
494
  for( let file of files )
486
495
  {
487
496
  try{ // continue if we get file errors?
488
-
497
+
489
498
  let ext=path.extname(file).toLowerCase()
490
499
  let base=path.basename(file)
491
500
  if( exts[ext] )
@@ -515,7 +524,7 @@ weerss.move=async function(args)
515
524
 
516
525
  let to = tvname+"/Season "+show.season+"/"+tvname+" "+SxxExx+ext
517
526
  console.log(file)
518
-
527
+
519
528
  if( dest )
520
529
  {
521
530
  to=path.join(dest , to)
@@ -539,12 +548,12 @@ weerss.move=async function(args)
539
548
 
540
549
 
541
550
  weerss.dirs=async function(args)
542
- {
543
- let dest=weerss.get_config_path("tv")
551
+ {
552
+ let dest=weerss.get_config_path("tv")
553
+
544
554
 
545
-
546
555
  await db.setup()
547
-
556
+
548
557
  let getdirs=function(dir, a)
549
558
  {
550
559
  a = a || []
@@ -568,10 +577,10 @@ weerss.dirs=async function(args)
568
577
  // if( ! file.match(/\((\d\d\d\d)\)/) ) { continue }
569
578
 
570
579
  try{ // continue if we get file errors?
571
-
580
+
572
581
  let escfiles=`'${file.replace(/'/g, `'\\''`)}/.'`
573
582
  let escdir=`'${file.replace(/'/g, `'\\''`)}'`
574
-
583
+
575
584
  // console.log(file)
576
585
  let show={
577
586
  name:shows.clean_name(file),
@@ -618,7 +627,7 @@ weerss.dirs=async function(args)
618
627
  {
619
628
  console.log(`rm -rf ${escdir}`)
620
629
  }
621
-
630
+
622
631
  // await new Promise(resolve => setTimeout(resolve, 500))
623
632
 
624
633
  }catch(e){console.log(e)}