@xriss/weerss 0.0.11 → 0.0.13
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/hoard.js +1 -1
- package/package.json +1 -1
- package/shows.js +19 -6
- package/weerss.js +14 -17
package/hoard.js
CHANGED
|
@@ -69,7 +69,7 @@ hoard.fetch_text=async function(url,refresh)
|
|
|
69
69
|
let timeout_id
|
|
70
70
|
let res=await Promise.race([
|
|
71
71
|
fetch(corsurl),
|
|
72
|
-
new Promise(function(_, reject){ timeout_id=setTimeout(function(){reject("timeout")},
|
|
72
|
+
new Promise(function(_, reject){ timeout_id=setTimeout(function(){reject("timeout")}, 10*1000) } ),
|
|
73
73
|
])
|
|
74
74
|
if(timeout_id) { clearTimeout(timeout_id) }
|
|
75
75
|
|
package/package.json
CHANGED
package/shows.js
CHANGED
|
@@ -41,6 +41,7 @@ shows.fetch=async function(url,force)
|
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
let data = await fetch(url).then(res => res.json())
|
|
44
|
+
data=data && data[0] && data[0].show // get first item from array returned from search
|
|
44
45
|
if(data)
|
|
45
46
|
{
|
|
46
47
|
await shows.set({url:url,data:data})
|
|
@@ -75,14 +76,14 @@ shows.get_tvmaze_episode=async function(showid,season,episode)
|
|
|
75
76
|
// lookup show on tvmaze
|
|
76
77
|
shows.get_tvmaze=async function(show,force)
|
|
77
78
|
{
|
|
78
|
-
await new Promise(resolve => setTimeout(resolve, 500)) // do not spam requests
|
|
79
79
|
|
|
80
80
|
try{ // on network errors, just return non tvmaze info
|
|
81
81
|
|
|
82
82
|
let show_year
|
|
83
83
|
let show_country
|
|
84
84
|
let show_name=show.name
|
|
85
|
-
let qurl="https://api.tvmaze.com/
|
|
85
|
+
let qurl="https://api.tvmaze.com/search/shows?q="+show_name.replaceAll(" ","+")
|
|
86
|
+
await new Promise(resolve => setTimeout(resolve, 500)) // do not spam requests
|
|
86
87
|
let tvmaze=await shows.fetch(qurl,force)
|
|
87
88
|
|
|
88
89
|
if(!tvmaze) // maybe try again
|
|
@@ -91,7 +92,8 @@ shows.get_tvmaze=async function(show,force)
|
|
|
91
92
|
{
|
|
92
93
|
show_year=show_name.substring(show_name.length-4)
|
|
93
94
|
show_name=show_name.substring(0,show_name.length-5)
|
|
94
|
-
qurl="https://api.tvmaze.com/
|
|
95
|
+
qurl="https://api.tvmaze.com/search/shows?q="+show_name.replaceAll(" ","+")
|
|
96
|
+
await new Promise(resolve => setTimeout(resolve, 500)) // do not spam requests
|
|
95
97
|
tvmaze=await shows.fetch(qurl,force)
|
|
96
98
|
if(tvmaze)
|
|
97
99
|
{
|
|
@@ -106,7 +108,8 @@ shows.get_tvmaze=async function(show,force)
|
|
|
106
108
|
{
|
|
107
109
|
show_country=show_name.substring(show_name.length-2)
|
|
108
110
|
show_name=show_name.substring(0,show_name.length-3)
|
|
109
|
-
qurl="https://api.tvmaze.com/
|
|
111
|
+
qurl="https://api.tvmaze.com/search/shows?q="+show_name.replaceAll(" ","+")
|
|
112
|
+
await new Promise(resolve => setTimeout(resolve, 500)) // do not spam requests
|
|
110
113
|
tvmaze=await shows.fetch(qurl,force)
|
|
111
114
|
if(tvmaze)
|
|
112
115
|
{
|
|
@@ -139,6 +142,8 @@ shows.get_show=async function(filename)
|
|
|
139
142
|
|
|
140
143
|
let name=filename
|
|
141
144
|
if(!name){return} // give up
|
|
145
|
+
|
|
146
|
+
item_tags=name.replace(/[^a-zA-Z0-9]/g," ").replace(/\s+/g," ").trim().toLowerCase().split(" ")
|
|
142
147
|
|
|
143
148
|
if(!item_name)
|
|
144
149
|
{
|
|
@@ -148,7 +153,6 @@ shows.get_show=async function(filename)
|
|
|
148
153
|
item_name=shows.clean_name(aa[1])
|
|
149
154
|
item_season=Number(aa[2])
|
|
150
155
|
item_episode=Number(aa[3])
|
|
151
|
-
item_tags=shows.clean_name(aa[4]).split(" ")
|
|
152
156
|
}
|
|
153
157
|
}
|
|
154
158
|
|
|
@@ -161,7 +165,6 @@ shows.get_show=async function(filename)
|
|
|
161
165
|
item_name=aa[1].replace(/[^a-zA-Z0-9]/g," ").replace(/\s+/g," ").trim().toLowerCase()
|
|
162
166
|
item_season=Number(aa[2]) // season is the year
|
|
163
167
|
item_episode=Number(aa[3]+aa[4]) // join month and day to make a 4 digit episode number
|
|
164
|
-
item_tags=aa[5].replace(/[^a-zA-Z0-9]/g," ").replace(/\s+/g," ").trim().toLowerCase().split(" ")
|
|
165
168
|
item_date=aa[2]+"-"+aa[3]+"-"+aa[4]
|
|
166
169
|
}
|
|
167
170
|
}
|
|
@@ -273,7 +276,17 @@ shows.good_episode=function(show,rules)
|
|
|
273
276
|
{
|
|
274
277
|
if( !rules ) { return true }
|
|
275
278
|
|
|
279
|
+
let tvmaze=show.tvmaze||{}
|
|
276
280
|
let flags={}
|
|
281
|
+
|
|
282
|
+
if( tvmaze.language ) { flags[ tvmaze.language.trim().toLowerCase() ]=true }
|
|
283
|
+
if( tvmaze.type ) { flags[ tvmaze.type.trim().toLowerCase() ]=true }
|
|
284
|
+
if( tvmaze.genres )
|
|
285
|
+
for( let genre of tvmaze.genres || [] )
|
|
286
|
+
{
|
|
287
|
+
flags[ genre.trim().toLowerCase() ]=true
|
|
288
|
+
}
|
|
289
|
+
|
|
277
290
|
for( let tag of show.tags || [] )
|
|
278
291
|
{
|
|
279
292
|
flags[ tag.trim().toLowerCase() ]=true
|
package/weerss.js
CHANGED
|
@@ -288,6 +288,19 @@ weerss.getlist=async function()
|
|
|
288
288
|
}
|
|
289
289
|
}
|
|
290
290
|
|
|
291
|
+
for( let idx=bucket.length-1 ; idx>0 ; idx-- ) // remove huge/small files
|
|
292
|
+
{
|
|
293
|
+
if( bucket[ idx ].torrent.file_length > weerss.config.episode.maxsize ) // 3GB
|
|
294
|
+
{
|
|
295
|
+
bucket.splice( idx , 1 )
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if( bucket[ idx ].torrent.file_length < weerss.config.episode.minsize ) // 3GB
|
|
299
|
+
{
|
|
300
|
+
bucket.splice( idx , 1 )
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
291
304
|
|
|
292
305
|
if( weerss.config.episode.best == "small" )
|
|
293
306
|
{
|
|
@@ -307,23 +320,7 @@ weerss.getlist=async function()
|
|
|
307
320
|
error("unknown config.episode.best option")
|
|
308
321
|
}
|
|
309
322
|
|
|
310
|
-
while( bucket.length>0 ) //
|
|
311
|
-
{
|
|
312
|
-
if( bucket[ bucket.length-1 ].torrent.file_length > weerss.config.episode.maxsize ) // 3GB
|
|
313
|
-
{
|
|
314
|
-
bucket.pop()
|
|
315
|
-
}
|
|
316
|
-
else
|
|
317
|
-
if( bucket[ 0 ].torrent.file_length < weerss.config.episode.minsize ) // 3GB
|
|
318
|
-
{
|
|
319
|
-
bucket.shift()
|
|
320
|
-
}
|
|
321
|
-
else
|
|
322
|
-
{
|
|
323
|
-
break
|
|
324
|
-
}
|
|
325
|
-
}
|
|
326
|
-
while( bucket.length>0 ) // check episode flags
|
|
323
|
+
while( bucket.length>0 ) // check episode flags ( uses words from filename + all the show flags )
|
|
327
324
|
{
|
|
328
325
|
if( ! shows.good_episode(bucket[ 0 ].show,weerss.config.episode.rules) ) // skip this episode?
|
|
329
326
|
{
|