@xriss/weerss 0.0.14 → 0.0.16

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 (2) hide show
  1. package/package.json +1 -1
  2. package/weerss.js +43 -22
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xriss/weerss",
3
- "version": "0.0.14",
3
+ "version": "0.0.16",
4
4
  "source": "weerss.js",
5
5
  "type": "module",
6
6
  "repository": {
package/weerss.js CHANGED
@@ -288,16 +288,20 @@ weerss.getlist=async function()
288
288
  }
289
289
  }
290
290
 
291
- for( let idx=bucket.length-1 ; idx>0 ; idx-- ) // remove huge/small files
291
+ for( let idx=bucket.length-1 ; idx>=0 ; idx-- ) // remove huge/small files
292
292
  {
293
- if( bucket[ idx ].torrent.file_length > weerss.config.episode.maxsize ) // 3GB
293
+ let it=bucket[ idx ]
294
+ if( it && it.torrent && it.torrent.file_length )
294
295
  {
295
- bucket.splice( idx , 1 )
296
- }
296
+ if( it.torrent.file_length > weerss.config.episode.maxsize ) // 3GB
297
+ {
298
+ bucket.splice( idx , 1 )
299
+ }
297
300
 
298
- if( bucket[ idx ].torrent.file_length < weerss.config.episode.minsize ) // 3GB
299
- {
300
- bucket.splice( idx , 1 )
301
+ if( it.torrent.file_length < weerss.config.episode.minsize ) // 3GB
302
+ {
303
+ bucket.splice( idx , 1 )
304
+ }
301
305
  }
302
306
  }
303
307
 
@@ -305,14 +309,18 @@ weerss.getlist=async function()
305
309
  if( weerss.config.episode.best == "small" )
306
310
  {
307
311
  bucket.sort(function(a,b){
308
- return a.torrent.file_length - b.torrent.file_length
312
+ let al=(a && a.torrent && a.torrent.file_length) || 0
313
+ let bl=(b && b.torrent && b.torrent.file_length) || 0
314
+ return al - bl
309
315
  })
310
316
  }
311
317
  else
312
318
  if( weerss.config.episode.best == "large" )
313
319
  {
314
320
  bucket.sort(function(a,b){
315
- return b.torrent.file_length - a.torrent.file_length
321
+ let al=(a && a.torrent && a.torrent.file_length) || 0
322
+ let bl=(b && b.torrent && b.torrent.file_length) || 0
323
+ return bl - al
316
324
  })
317
325
  }
318
326
  else
@@ -485,17 +493,25 @@ weerss.move=async function(args)
485
493
  let show=await shows.get_show(base+ext)
486
494
  if( show )
487
495
  {
488
- let xtra=""
489
- if(show.year)
490
- {
491
- xtra=xtra+" ("+show.year+")"
492
- }
493
-
494
496
  let SxxExx=("S"+show.season.toString().padStart(2, "0")+"E"+show.episode.toString().padStart(2, "0") )
495
497
 
496
498
  // console.log(base , show.tvmaze.name , show.season , show.episode)
497
- let showname=show.tvmaze.name.replace(/[/\\?%*:|"<>]/g, "-") // remove problematic chars
498
- let to = showname+xtra+"/Season "+show.season+"/"+showname+" "+SxxExx+ext
499
+ // let showname=show.tvmaze.name.replace(/[/\\?%*:|"<>]/g, "-") // remove problematic chars
500
+
501
+ let tvname=sanitize(show.tvmaze.name,{replacement:""})
502
+ let country=show.tvmaze.network && show.tvmaze.network.country && show.tvmaze.network.country.code
503
+ let year=show.tvmaze.premiered && show.tvmaze.premiered.substr(0,4)
504
+ if(country)
505
+ {
506
+ tvname=tvname+" ("+country+")" // put country in dirname
507
+ }
508
+ if(year)
509
+ {
510
+ tvname=tvname+" ("+year+")" // put year in dirname
511
+ }
512
+ let esctvname=`'${tvname.replace(/'/g, `'\\''`)}'`
513
+
514
+ let to = tvname+"/Season "+show.season+"/"+tvname+" "+SxxExx+ext
499
515
  console.log(file)
500
516
 
501
517
  if( dest )
@@ -566,12 +582,17 @@ weerss.dirs=async function(args)
566
582
  console.log(`echo ${escfile}`)
567
583
  if( show.tvmaze )
568
584
  {
569
- let tvname=sanitize(show.tvmaze.name)
570
- let year=file.match(/\((\d\d\d\d)\)/);
571
- year=year && year[1]
585
+ //console.log(show.tvmaze)
586
+ let tvname=sanitize(show.tvmaze.name,{replacement:""})
587
+ let country=show.tvmaze.network && show.tvmaze.network.country && show.tvmaze.network.country.code
588
+ let year=show.tvmaze.premiered && show.tvmaze.premiered.substr(0,4)
589
+ if(country)
590
+ {
591
+ tvname=tvname+" ("+country+")" // put country in dirname
592
+ }
572
593
  if(year)
573
594
  {
574
- tvname=tvname+" ("+year+")" // keep year in dirname
595
+ tvname=tvname+" ("+year+")" // put year in dirname
575
596
  }
576
597
  let esctvname=`'${tvname.replace(/'/g, `'\\''`)}'`
577
598
  let good=shows.good_show(show,weerss.config.show.rules)
@@ -593,7 +614,7 @@ weerss.dirs=async function(args)
593
614
  console.log(`rm -rf ${escfile}`)
594
615
  }
595
616
 
596
- await new Promise(resolve => setTimeout(resolve, 500))
617
+ // await new Promise(resolve => setTimeout(resolve, 500))
597
618
 
598
619
  }catch(e){console.log(e)}
599
620
  }