@xriss/weerss 0.0.24 → 0.0.26
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.
- package/cmd.js +16 -11
- package/db.js +18 -14
- package/feeds.js +1 -1
- package/package.json +1 -1
- package/weerss.js +49 -31
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"
|
|
@@ -241,8 +258,6 @@ db.list=async function(table,filter)
|
|
|
241
258
|
}
|
|
242
259
|
// console.log(filters)
|
|
243
260
|
|
|
244
|
-
try{
|
|
245
|
-
|
|
246
261
|
await db.handle.each(`
|
|
247
262
|
|
|
248
263
|
SELECT * FROM ${table}
|
|
@@ -250,19 +265,8 @@ try{
|
|
|
250
265
|
|
|
251
266
|
`,{},function(row)
|
|
252
267
|
{
|
|
253
|
-
|
|
254
|
-
rs.push(JSON.parse(row.value))
|
|
255
|
-
}catch(e){
|
|
256
|
-
console.log("BROKEN SQLITE RESULT")
|
|
257
|
-
console.log(row.value)
|
|
258
|
-
console.log(e)
|
|
259
|
-
}
|
|
268
|
+
rs.push(JSON.parse(row.value))
|
|
260
269
|
})
|
|
261
270
|
|
|
262
|
-
}catch(e){
|
|
263
|
-
console.log("BROKEN SQLITE QUERY")
|
|
264
|
-
console.log(e)
|
|
265
|
-
}
|
|
266
|
-
|
|
267
271
|
return rs // filtered only, sorted by date
|
|
268
272
|
}
|
package/feeds.js
CHANGED
|
@@ -206,7 +206,7 @@ feeds.fetch_all=async function()
|
|
|
206
206
|
return ( b.items_date || 0 ) - ( a.items_date || 0 )
|
|
207
207
|
})
|
|
208
208
|
|
|
209
|
-
let topitem=(await db.list("items",{},"date","prev",1))[0] ; topitem=topitem && topitem.uuid
|
|
209
|
+
// let topitem=(await db.list("items",{},"date","prev",1))[0] ; topitem=topitem && topitem.uuid
|
|
210
210
|
|
|
211
211
|
for(let feed of list )
|
|
212
212
|
{
|
package/package.json
CHANGED
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
|
|
|
@@ -226,14 +226,14 @@ weerss.fetch=async function()
|
|
|
226
226
|
await db.close()
|
|
227
227
|
}
|
|
228
228
|
|
|
229
|
-
weerss.getlist=async function()
|
|
229
|
+
weerss.getlist=async function(filters)
|
|
230
230
|
{
|
|
231
231
|
// all items then we sort and filter and list
|
|
232
|
-
let its=await db.list("items",{})
|
|
233
|
-
|
|
232
|
+
let its=await db.list("items",filters||{})
|
|
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?
|
|
@@ -360,9 +360,14 @@ weerss.getlist=async function()
|
|
|
360
360
|
|
|
361
361
|
weerss.list=async function(args)
|
|
362
362
|
{
|
|
363
|
+
let past=new Date()
|
|
364
|
+
past.setDate( past.getDate()-28 )
|
|
365
|
+
past=past.toISOString()
|
|
366
|
+
let filters={date_gt:past}
|
|
367
|
+
|
|
363
368
|
await db.setup()
|
|
364
369
|
|
|
365
|
-
let list=(await weerss.getlist()).slice(0,weerss.config.rss.length)
|
|
370
|
+
let list=(await weerss.getlist(filters)).slice(0,weerss.config.rss.length)
|
|
366
371
|
for(let item of list)
|
|
367
372
|
{
|
|
368
373
|
console.log( item_to_string(item))
|
|
@@ -397,7 +402,7 @@ weerss.save_rss=async function(args)
|
|
|
397
402
|
|
|
398
403
|
let dates=(new Date(item.date)).toUTCString()
|
|
399
404
|
let isodates=(new Date(item.date)).toISOString()
|
|
400
|
-
|
|
405
|
+
|
|
401
406
|
let it={
|
|
402
407
|
"/guid" : url ,
|
|
403
408
|
"/link" : url ,
|
|
@@ -416,7 +421,11 @@ weerss.save_rss=async function(args)
|
|
|
416
421
|
rss_items.push(it)
|
|
417
422
|
}
|
|
418
423
|
|
|
419
|
-
let
|
|
424
|
+
let past=new Date()
|
|
425
|
+
past.setDate( past.getDate()-28 )
|
|
426
|
+
past=past.toISOString()
|
|
427
|
+
let filters={date_gt:past}
|
|
428
|
+
let list=(await weerss.getlist(filters)).slice(0,weerss.config.rss.length)
|
|
420
429
|
for(let item of list)
|
|
421
430
|
{
|
|
422
431
|
push_item(item)
|
|
@@ -439,12 +448,21 @@ weerss.save_rss=async function(args)
|
|
|
439
448
|
}
|
|
440
449
|
|
|
441
450
|
|
|
451
|
+
weerss.clean=async function(args)
|
|
452
|
+
{
|
|
453
|
+
await db.setup()
|
|
454
|
+
|
|
455
|
+
await db.clean("items")
|
|
456
|
+
|
|
457
|
+
await db.close()
|
|
458
|
+
}
|
|
459
|
+
|
|
442
460
|
weerss.move=async function(args)
|
|
443
461
|
{
|
|
444
|
-
|
|
462
|
+
|
|
445
463
|
let from=weerss.get_config_path("download") //args._[2] // optional dest dir
|
|
446
464
|
let dest=weerss.get_config_path("tv") //args._[2] // optional dest dir
|
|
447
|
-
|
|
465
|
+
|
|
448
466
|
if(dest)
|
|
449
467
|
{
|
|
450
468
|
console.log( "Moving file from "+from+" to "+dest )
|
|
@@ -453,9 +471,9 @@ weerss.move=async function(args)
|
|
|
453
471
|
{
|
|
454
472
|
console.log( "Testing moving files from "+from )
|
|
455
473
|
}
|
|
456
|
-
|
|
474
|
+
|
|
457
475
|
await db.setup()
|
|
458
|
-
|
|
476
|
+
|
|
459
477
|
let getallfiles=function(dir, a)
|
|
460
478
|
{
|
|
461
479
|
a = a || []
|
|
@@ -485,7 +503,7 @@ weerss.move=async function(args)
|
|
|
485
503
|
for( let file of files )
|
|
486
504
|
{
|
|
487
505
|
try{ // continue if we get file errors?
|
|
488
|
-
|
|
506
|
+
|
|
489
507
|
let ext=path.extname(file).toLowerCase()
|
|
490
508
|
let base=path.basename(file)
|
|
491
509
|
if( exts[ext] )
|
|
@@ -515,7 +533,7 @@ weerss.move=async function(args)
|
|
|
515
533
|
|
|
516
534
|
let to = tvname+"/Season "+show.season+"/"+tvname+" "+SxxExx+ext
|
|
517
535
|
console.log(file)
|
|
518
|
-
|
|
536
|
+
|
|
519
537
|
if( dest )
|
|
520
538
|
{
|
|
521
539
|
to=path.join(dest , to)
|
|
@@ -539,12 +557,12 @@ weerss.move=async function(args)
|
|
|
539
557
|
|
|
540
558
|
|
|
541
559
|
weerss.dirs=async function(args)
|
|
542
|
-
{
|
|
543
|
-
let dest=weerss.get_config_path("tv")
|
|
560
|
+
{
|
|
561
|
+
let dest=weerss.get_config_path("tv")
|
|
562
|
+
|
|
544
563
|
|
|
545
|
-
|
|
546
564
|
await db.setup()
|
|
547
|
-
|
|
565
|
+
|
|
548
566
|
let getdirs=function(dir, a)
|
|
549
567
|
{
|
|
550
568
|
a = a || []
|
|
@@ -568,10 +586,10 @@ weerss.dirs=async function(args)
|
|
|
568
586
|
// if( ! file.match(/\((\d\d\d\d)\)/) ) { continue }
|
|
569
587
|
|
|
570
588
|
try{ // continue if we get file errors?
|
|
571
|
-
|
|
589
|
+
|
|
572
590
|
let escfiles=`'${file.replace(/'/g, `'\\''`)}/.'`
|
|
573
591
|
let escdir=`'${file.replace(/'/g, `'\\''`)}'`
|
|
574
|
-
|
|
592
|
+
|
|
575
593
|
// console.log(file)
|
|
576
594
|
let show={
|
|
577
595
|
name:shows.clean_name(file),
|
|
@@ -618,7 +636,7 @@ weerss.dirs=async function(args)
|
|
|
618
636
|
{
|
|
619
637
|
console.log(`rm -rf ${escdir}`)
|
|
620
638
|
}
|
|
621
|
-
|
|
639
|
+
|
|
622
640
|
// await new Promise(resolve => setTimeout(resolve, 500))
|
|
623
641
|
|
|
624
642
|
}catch(e){console.log(e)}
|