🔧 Debugging the 403 from CV
This commit is contained in:
@@ -191,6 +191,7 @@ export default class ComicVineService extends Service {
|
|||||||
rawFileDetails: object;
|
rawFileDetails: object;
|
||||||
}>
|
}>
|
||||||
) => {
|
) => {
|
||||||
|
try {
|
||||||
console.log(
|
console.log(
|
||||||
"Searching against: ",
|
"Searching against: ",
|
||||||
ctx.params.scorerConfiguration.searchParams
|
ctx.params.scorerConfiguration.searchParams
|
||||||
@@ -211,7 +212,10 @@ export default class ComicVineService extends Service {
|
|||||||
let volumeIdString = "volume:";
|
let volumeIdString = "volume:";
|
||||||
potentialVolumeMatches.map(
|
potentialVolumeMatches.map(
|
||||||
(volumeId: string, idx: number) => {
|
(volumeId: string, idx: number) => {
|
||||||
if (idx >= potentialVolumeMatches.length - 1) {
|
if (
|
||||||
|
idx >=
|
||||||
|
potentialVolumeMatches.length - 1
|
||||||
|
) {
|
||||||
volumeIdString += `${volumeId}`;
|
volumeIdString += `${volumeId}`;
|
||||||
return volumeIdString;
|
return volumeIdString;
|
||||||
}
|
}
|
||||||
@@ -223,7 +227,8 @@ export default class ComicVineService extends Service {
|
|||||||
let coverDateFilter = "";
|
let coverDateFilter = "";
|
||||||
if (
|
if (
|
||||||
!isNil(
|
!isNil(
|
||||||
ctx.params.scorerConfiguration.searchParams.year
|
ctx.params.scorerConfiguration.searchParams
|
||||||
|
.year
|
||||||
)
|
)
|
||||||
) {
|
) {
|
||||||
const issueYear = parseInt(
|
const issueYear = parseInt(
|
||||||
@@ -239,30 +244,29 @@ export default class ComicVineService extends Service {
|
|||||||
console.log(filterString);
|
console.log(filterString);
|
||||||
|
|
||||||
const issueMatches = await axios({
|
const issueMatches = await axios({
|
||||||
url: `https://comicvine.gamespot.com/api/issues?api_key=${process.env.COMICVINE_API_KEY}`,
|
url: `${CV_BASE_URL}issues?api_key=${process.env.COMICVINE_API_KEY}`,
|
||||||
method: "GET",
|
|
||||||
params: {
|
params: {
|
||||||
resources: "issues",
|
resources: "issues",
|
||||||
limit: "100",
|
limit: "100",
|
||||||
format: "json",
|
format: "json",
|
||||||
filter: filterString,
|
filter: filterString,
|
||||||
},
|
},
|
||||||
// headers: {
|
headers: {
|
||||||
// "User-Agent": "ThreeTwo",
|
Accept: "application/json",
|
||||||
// "Accept": "application/json",
|
},
|
||||||
// },
|
|
||||||
});
|
});
|
||||||
console.log(
|
console.log(
|
||||||
`Total issues matching the criteria: ${issueMatches.data.results.length}`
|
`Total issues matching the criteria: ${issueMatches.data.results.length}`
|
||||||
);
|
);
|
||||||
// 3. get volume information for the issue matches
|
// 3. get volume information for the issue matches
|
||||||
if (issueMatches.data.results.length === 1) {
|
if (issueMatches.data.results.length === 1) {
|
||||||
const volumeInformation = await this.broker.call(
|
const volumeInformation =
|
||||||
|
await this.broker.call(
|
||||||
"comicvine.getVolumes",
|
"comicvine.getVolumes",
|
||||||
{
|
{
|
||||||
volumeURI:
|
volumeURI:
|
||||||
issueMatches.data.results[0].volume
|
issueMatches.data.results[0]
|
||||||
.api_detail_url,
|
.volume.api_detail_url,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
issueMatches.data.results[0].volumeInformation =
|
issueMatches.data.results[0].volumeInformation =
|
||||||
@@ -271,15 +275,22 @@ export default class ComicVineService extends Service {
|
|||||||
}
|
}
|
||||||
const finalMatches = issueMatches.data.results.map(
|
const finalMatches = issueMatches.data.results.map(
|
||||||
async (issue: any) => {
|
async (issue: any) => {
|
||||||
const volumeDetails = await this.broker.call(
|
const volumeDetails =
|
||||||
|
await this.broker.call(
|
||||||
"comicvine.getVolumes",
|
"comicvine.getVolumes",
|
||||||
{ volumeURI: issue.volume.api_detail_url }
|
{
|
||||||
|
volumeURI:
|
||||||
|
issue.volume.api_detail_url,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
issue.volumeInformation = volumeDetails;
|
issue.volumeInformation = volumeDetails;
|
||||||
return issue;
|
return issue;
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
return Promise.all(finalMatches);
|
return Promise.all(finalMatches);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -287,13 +298,11 @@ export default class ComicVineService extends Service {
|
|||||||
fetchVolumesFromCV: async (params, output: any[] = []) => {
|
fetchVolumesFromCV: async (params, output: any[] = []) => {
|
||||||
let currentPage = parseInt(params.page, 10);
|
let currentPage = parseInt(params.page, 10);
|
||||||
const response = await axios.request({
|
const response = await axios.request({
|
||||||
url: `https://comicvine.gamespot.com/api/search?api_key=${process.env.COMICVINE_API_KEY}`,
|
url: `${CV_BASE_URL}search?api_key=${process.env.COMICVINE_API_KEY}`,
|
||||||
method: "GET",
|
|
||||||
params,
|
params,
|
||||||
// headers: {
|
headers: {
|
||||||
// "User-Agent": "ThreeTwo",
|
Accept: "application/json",
|
||||||
// "Accept": "application/json",
|
},
|
||||||
// },
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const { data } = response;
|
const { data } = response;
|
||||||
|
|||||||
Reference in New Issue
Block a user