mirror of
https://github.com/p-stream/backend.git
synced 2026-04-21 16:52:21 +00:00
added results
This commit is contained in:
parent
9bd5ce3fcd
commit
9ccdf8c8c7
2 changed files with 10 additions and 16 deletions
6
package-lock.json
generated
6
package-lock.json
generated
|
|
@ -1,11 +1,11 @@
|
||||||
{
|
{
|
||||||
"name": "backend",
|
"name": "open-backend",
|
||||||
"version": "2.0.1",
|
"version": "2.0.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"version": "2.0.1",
|
"version": "2.0.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@prisma/client": "^6.4.1",
|
"@prisma/client": "^6.4.1",
|
||||||
"cheerio": "^1.0.0",
|
"cheerio": "^1.0.0",
|
||||||
|
|
|
||||||
|
|
@ -88,15 +88,15 @@ export default defineCachedEventHandler(async (event) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const tmdbIds = [];
|
const tmdbMovies = [];
|
||||||
|
|
||||||
for (const film of films) {
|
for (const film of films) {
|
||||||
try {
|
try {
|
||||||
const searchResult = await tmdb.search.movies({ query: film.name });
|
const searchResult = await tmdb.search.movies({ query: film.name });
|
||||||
|
|
||||||
if (searchResult.results && searchResult.results.length > 0) {
|
if (searchResult.results && searchResult.results.length > 0) {
|
||||||
const tmdbId = searchResult.results[0].id;
|
const tmdbMovie = searchResult.results[0];
|
||||||
tmdbIds.push(tmdbId);
|
tmdbMovies.push(tmdbMovie);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -106,23 +106,17 @@ export default defineCachedEventHandler(async (event) => {
|
||||||
allLists.push({
|
allLists.push({
|
||||||
listName: listName,
|
listName: listName,
|
||||||
listUrl: listUrl,
|
listUrl: listUrl,
|
||||||
tmdbIds,
|
tmdbMovies
|
||||||
metadata: {
|
|
||||||
originalFilmCount: films.length,
|
|
||||||
foundTmdbIds: tmdbIds.length,
|
|
||||||
expectedItemCount: expectedItemCount,
|
|
||||||
workingSelector
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
allLists.push({
|
allLists.push({
|
||||||
listName: listItem.title,
|
listName: listItem.title,
|
||||||
listUrl: `https://letterboxd.com${listItem.href}`,
|
listUrl: `https://letterboxd.com${listItem.href}`,
|
||||||
tmdbIds: [],
|
tmdbMovies: [],
|
||||||
metadata: {
|
metadata: {
|
||||||
originalFilmCount: 0,
|
originalFilmCount: 0,
|
||||||
foundTmdbIds: 0,
|
foundTmdbMovies: 0,
|
||||||
expectedItemCount: null,
|
expectedItemCount: null,
|
||||||
error: 'Failed to process list'
|
error: 'Failed to process list'
|
||||||
}
|
}
|
||||||
|
|
@ -134,7 +128,7 @@ export default defineCachedEventHandler(async (event) => {
|
||||||
lists: allLists,
|
lists: allLists,
|
||||||
totalLists: allLists.length,
|
totalLists: allLists.length,
|
||||||
summary: {
|
summary: {
|
||||||
totalTmdbIds: allLists.reduce((sum, list) => sum + list.tmdbIds.length, 0),
|
totalTmdbMovies: allLists.reduce((sum, list) => sum + list.tmdbMovies.length, 0),
|
||||||
totalExpectedItems: allLists.reduce((sum, list) => sum + (list.metadata.expectedItemCount || 0), 0)
|
totalExpectedItems: allLists.reduce((sum, list) => sum + (list.metadata.expectedItemCount || 0), 0)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue