Ombi-app / Ombi

Want a Movie or TV Show on Plex/Emby/Jellyfin? Use Ombi!
http://ombi.io
GNU General Public License v2.0
3.73k stars 396 forks source link

The SPA default page middleware could not return the default page #4918

Closed strike84 closed 1 year ago

strike84 commented 1 year ago

Describe the bug I'm trying to run a script to pull the top items from the official trakt.tv list and send it to Ombi so it can request them.

But I get a 500 response from ombi with this in the ombi log (see logs)

To Reproduce Steps to reproduce the behavior:

  1. Set up an trakt.tv account and set up an app to get the API key
  2. Run the mentioned script listed under Additional context and replace the relevant values (API keys, ombi URL and user)
  3. See error in ombi logs

Expected behavior Pulls list from trakt.tv and send items to ombi to request them.

Logs (Logs directory where Ombi is located) Microsoft.AspNetCore.SpaServices.SpaDefaultPageMiddleware.<>c__DisplayClass0_0.b__1(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Ombi.ApiKeyMiddlewear.ValidateApiKey(HttpContext context, RequestDelegate next, String key) in /home/runner/work/Ombi/Ombi/src/Ombi/Middleware/ApiKeyMiddlewear.cs:line 135 at Ombi.ApiKeyMiddlewear.Invoke(HttpContext context) in /home/runner/work/Ombi/Ombi/src/Ombi/Middleware/ApiKeyMiddlewear.cs:line 58 at Ombi.ErrorHandlingMiddleware.Invoke(HttpContext context) in /home/runner/work/Ombi/Ombi/src/Ombi/Middleware/ErrorHandlingMiddlewear.cs:line 30 2023-05-02 17:47:16.318 +02:00 [ERR] Something bad happened, ErrorMiddleware caught this System.InvalidOperationException: The SPA default page middleware could not return the default page '/index.html' because it was not found, and no other middleware handled the request. Your application is running in Production mode, so make sure it has been published, or that you have built your SPA manually. Alternatively you may wish to switch to the Development environment.

at Microsoft.AspNetCore.SpaServices.SpaDefaultPageMiddleware.<>c__DisplayClass0_0.b__1(HttpContext context, RequestDelegate next) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Routing.EndpointMiddleware.Invoke(HttpContext httpContext) at Microsoft.AspNetCore.StaticFiles.StaticFileMiddleware.Invoke(HttpContext context) at Swashbuckle.AspNetCore.SwaggerUI.SwaggerUIMiddleware.Invoke(HttpContext httpContext) at Swashbuckle.AspNetCore.Swagger.SwaggerMiddleware.Invoke(HttpContext httpContext, ISwaggerProvider swaggerProvider) at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) at Ombi.ApiKeyMiddlewear.ValidateApiKey(HttpContext context, RequestDelegate next, String key) in /home/runner/work/Ombi/Ombi/src/Ombi/Middleware/ApiKeyMiddlewear.cs:line 135 at Ombi.ApiKeyMiddlewear.Invoke(HttpContext context) in /home/runner/work/Ombi/Ombi/src/Ombi/Middleware/ApiKeyMiddlewear.cs:line 58 at Ombi.ErrorHandlingMiddleware.Invoke(HttpContext context) in /home/runner/work/Ombi/Ombi/src/Ombi/Middleware/ErrorHandlingMiddlewear.cs:line 30

Desktop (please complete the following information):

Ombi Version (please complete the following information):

Additional context The relevant script I'm running is this:

import requests

# Set up the Trakt.tv API endpoint and headers
trakt_endpoint = "https://api.trakt.tv"
trakt_headers = {
"Content-Type": "application/json",
"trakt-api-key": "1234",
"trakt-api-version": "2",
}

# Set up the Ombi API endpoint and headers
ombi_endpoint = "https://my-ombi-url/api/v1"
ombi_headers = {
"Content-Type": "application/json",
"ApiKey": "1234",
"UserName": "user",
}

# Define the list names to pull from Trakt.tv
list_names = ["popular", "recommended", "anticipated", "trending"]

# Loop through each list and pull the top 100 movies and TV shows
for list_name in list_names:
# Construct the Trakt.tv API endpoint for the list
list_endpoint = "{}/movies/{}?extended=full&page=1&limit=100".format(trakt_endpoint, list_name)
if list_name == "trending":
    list_endpoint = "{}/shows/{}?extended=full&page=1&limit=100".format(trakt_endpoint, list_name)

# Make the API call to Trakt.tv and get the list of movies and TV shows
response = requests.get(list_endpoint, headers=trakt_headers).json()

# Loop through each movie/TV show and send a request to Ombi to request it
for item in response:
    if "movie" in item:
        # Construct the Ombi API endpoint for this movie, and send the request
        movie_id = item["movie"]["ids"]["imdb"]
        movie_endpoint = "{}/Request/movie/imdb/{}".format(ombi_endpoint, movie_id)
        response = requests.post(movie_endpoint, headers=ombi_headers)

    elif "show" in item:
        # Construct the Ombi API endpoint for this TV show, and send the request
        tv_id = item["show"]["ids"]["imdb"]
        tv_endpoint = "{}/Request/tv/imdb/{}".format(ombi_endpoint, tv_id)
        response = requests.post(tv_endpoint, headers=ombi_headers)
github-actions[bot] commented 1 year ago

Hi!
Thanks for the issue report. Before a real human comes by, please make sure you used our bug report format.
Have you looked at the wiki yet? https://docs.ombi.app/
Before posting make sure you also read our FAQ.
Make the title describe your issue. Having 'not working' or 'I get this bug' for 100 issues, isn't really helpful.
If we need more information or there is some progress we tag the issue or update the tag and keep you updated.
Thanks!
Ombi Bot.

sephrat commented 1 year ago

I'm not well versed in Python, what's the endpoint you're hitting? I'm reading /api/v1/Request/movie/imdb/xxx, this is not a valid endpoint according to the API documentation. https://docs.ombi.app/info/api-information/ You'll want to use POST /api/v1/Request/movie and pass the ID in the request body.

In case of doubt, the UI uses the API. Make the request in the UI and check your network tab to see the API call to make.

strike84 commented 1 year ago

You're completely right. The endpoint was wrong. I've successfully requested a movie with the script now. But I can't request a tv show yet, I think the endpoint for tv is correct this time tho. Working on debugging that. I guess I can close this issue and come back if I have some other issues.