@xriss/weerss 0.0.11 → 0.0.12
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/package.json +1 -1
- package/shows.js +7 -4
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
|
{
|