stg-annon / stashapi

api wrapper
MIT License
14 stars 5 forks source link

stashid scraping crash #8

Open scruffynerf opened 5 months ago

scruffynerf commented 5 months ago

using:

# Fragment Scrape
    def scrape_scene(self, source, input):
        if isinstance(source, str):
            source = {"scraper_id": source}
        if isinstance(input, (str, int)):
            input = {"scene_id": input}

        if not isinstance(source, dict):
            self.log.warning(f'Unexpected Object passed to source {type(source)}{source}\n, expecting "ScraperSourceInput" or string of scraper_id')
            return None
        if not isinstance(input, dict):
            self.log.warning(f'Unexpected Object passed to input {type(input)}{input}\n, expecting "ScrapeSingleSceneInput" or string of scene_id')
            return None

        query = """query ScrapeSingleScene($source: ScraperSourceInput!, $input: ScrapeSingleSceneInput!) {
            scrapeSingleScene(source: $source, input: $input) {
              ...ScrapedScene
            }
          }
        """
        scraped_scene_list = self._callGraphQL(query, {"source": source, "input": input})["scrapeSingleScene"]
        if len(scraped_scene_list) == 0:
            return None
        else:
            return scraped_scene_list

I use:

stashresult = stash.scrape_scene(
                {"stash_box_index": stash_box_index}, 
                {"query": stash_id}
                )

and crash with error 120

If I do it directly, and avoid the Scraped Scene fragment:

query = """query ScrapeSingleScene($source: ScraperSourceInput!, $input: ScrapeSingleSceneInput!) {
            scrapeSingleScene(source: $source, input: $input) {
              title
              }
            }"""
        stashresult = stash._callGraphQL(query, {"source": {"stash_box_index": stash_box_index} , "input": {"query": stash_id}})

No error, and I get the title as expected result is {"scrapeSingleScene": [{"title": "whatever"}]}

Since I'm literally querying a stashid to a result from a stashbox, it's not a local issue.

solution: allow custom fragment but also need to figure out why it crashes on what should be a simple scraped result

stg-annon commented 5 months ago

any details in the error? I can't seem to reproduce this