stash/pkg/api
SmallCoccinelle 4089fcf1e2
Scraper refactor middle (#2043)
* Push scrapeByURL into scrapers

Replace ScrapePerfomerByURL, ScrapeMovie..., ... with ScrapeByURL in
the scraperActionImpl interface. This allows us to delete a lot of
repeated code in the scrapers and replace the central part with a
switch on the scraper type.

* Fold name scraping into one call

Follow up on scraper refactoring. Name scrapers use the same code path.
This allows us to restructure some code and kill some functions, adding
variance to the name scraping code. It allows us to remove some code
repetition as well.

* Do not export loop refs.

* Simplify fragment scraping

Generalize fragment scrapers into ScrapeByFragment. This simplifies
fragment code flows into a simpler pathing which should be easier
to handle in the future.

* Eliminate more context.TODO()

In a number of cases, we have a context now. Use the context rather than
TODO() for those cases in order to make those operations cancellable.

* Pass the context for the stashbox scraper

This removes all context.TODO() in the path of the stashbox scraper,
and replaces it with the context that's present on each of the paths.

* Pass the context into subscrapers

Mostly a mechanical update, where we pass in the context for
subscraping. This removes the final context.TODO() in the scraper
code.

* Warn on unknown fields from scripts

A common mistake for new script writers are that they return fields
not known to stash. For instance the name "description" is used rather
than "details".

Decode disallowing unknown fields. If this fails, use a tee-reader to
fall back to the old behavior, but print a warning for the user in this
case. Thus, we retain the old behavior, but print warnings for scripts
which fails the more strict unknown-fields detection.

* Nil-check before running the postprocessing chain

Fixes panics when scraping returns nil values.

* Lift nil-ness in post-postprocessing

If the struct we are trying to post-process is nil, we shouldn't
enter the postprocessing flow at all. Pass the struct as a value
rather than a pointer, eliminating nil-checks as we go. Use the
top-level postProcess call to make the nil-check and then abort there
if the object we are looking at is nil.

* Allow conversion routines to handle values

If we have a non-pointer type in the interface, we should also convert
those into ScrapedContent. Otherwise we get errors on deprecated
functions.
2021-11-26 11:20:06 +11:00
..
urlbuilders Generate screenshot images for markers (#1604) 2021-09-15 12:27:05 +10:00
authentication.go Errorlint sweep + minor linter tweaks (#1796) 2021-10-12 14:03:08 +11:00
changeset_translator.go Remove assignments to _ (#1685) 2021-09-07 13:18:32 +10:00
check_version.go Handle request cancellation more gracefully (#1877) 2021-10-25 10:09:20 +11:00
context_keys.go Remove unused (#1709) 2021-09-09 14:10:08 +10:00
images.go Only add image files to imageBox files slice (#2017) 2021-11-17 11:58:49 +11:00
locale.go French translation (fr-FR) (#1967) 2021-11-08 11:41:05 +11:00
resolver.go Refactor scraper top half (#1893) 2021-11-19 10:55:34 +11:00
resolver_model_gallery.go Add CreatedAt & UpdatedAt to all object resolvers (#1421) 2021-05-25 10:56:34 +10:00
resolver_model_image.go Add CreatedAt & UpdatedAt to all object resolvers (#1421) 2021-05-25 10:56:34 +10:00
resolver_model_movie.go Movie card visual consistency (#1758) 2021-09-26 13:52:08 +10:00
resolver_model_performer.go Add movie count to performer and studio card (#1760) 2021-09-27 11:31:49 +10:00
resolver_model_scene.go Move scene post update hook to outside Identify transaction (#1953) 2021-11-06 09:58:52 +11:00
resolver_model_scene_marker.go Generate screenshot images for markers (#1604) 2021-09-15 12:27:05 +10:00
resolver_model_studio.go Enable gocritic (#1848) 2021-10-18 14:12:40 +11:00
resolver_model_tag.go Tag hierarchy (#1519) 2021-09-09 14:58:43 +10:00
resolver_mutation_configure.go Tasks page refactor (#1949) 2021-11-24 09:09:47 +11:00
resolver_mutation_dlna.go DLNA (#1364) 2021-05-20 16:58:43 +10:00
resolver_mutation_gallery.go Fix deleting folder-based gallery file deleting (#1872) 2021-10-25 09:29:03 +11:00
resolver_mutation_image.go Plugin hooks (#1452) 2021-06-11 17:24:58 +10:00
resolver_mutation_job.go Job queueing (#1379) 2021-05-24 14:24:18 +10:00
resolver_mutation_metadata.go Identify task (#1839) 2021-10-28 14:25:17 +11:00
resolver_mutation_movie.go Toward better context handling (#1835) 2021-10-14 15:32:41 +11:00
resolver_mutation_performer.go Toward better context handling (#1835) 2021-10-14 15:32:41 +11:00
resolver_mutation_plugin.go Errcheck phase 1 (#1715) 2021-09-21 09:34:25 +10:00
resolver_mutation_saved_filter.go Saved filters (#1474) 2021-06-16 14:53:32 +10:00
resolver_mutation_scene.go Identify task (#1839) 2021-10-28 14:25:17 +11:00
resolver_mutation_scraper.go Refactor xpath scraper code. Add fixed and map (#616) 2020-07-21 14:06:25 +10:00
resolver_mutation_stash_box.go Scraper refactor middle (#2043) 2021-11-26 11:20:06 +11:00
resolver_mutation_studio.go Toward better context handling (#1835) 2021-10-14 15:32:41 +11:00
resolver_mutation_tag.go Add a TagMergePost post-hook (#2010) 2021-11-19 11:12:34 +11:00
resolver_mutation_tag_test.go Plugin hooks (#1452) 2021-06-11 17:24:58 +10:00
resolver_query_configuration.go Tasks page refactor (#1949) 2021-11-24 09:09:47 +11:00
resolver_query_dlna.go DLNA (#1364) 2021-05-20 16:58:43 +10:00
resolver_query_find_gallery.go Data layer restructuring (#997) 2021-01-18 12:23:20 +11:00
resolver_query_find_image.go Show duration and filesize in results (#1776) 2021-10-25 11:40:13 +11:00
resolver_query_find_movie.go Remove slim graphql endpoints (#1207) 2021-03-17 11:17:01 +11:00
resolver_query_find_performer.go Remove slim graphql endpoints (#1207) 2021-03-17 11:17:01 +11:00
resolver_query_find_saved_filter.go Saved filters (#1474) 2021-06-16 14:53:32 +10:00
resolver_query_find_scene.go Convert filesize to float64 for arm32 (#1895) 2021-10-27 11:55:11 +11:00
resolver_query_find_scene_marker.go Data layer restructuring (#997) 2021-01-18 12:23:20 +11:00
resolver_query_find_studio.go Remove slim graphql endpoints (#1207) 2021-03-17 11:17:01 +11:00
resolver_query_find_tag.go Remove slim graphql endpoints (#1207) 2021-03-17 11:17:01 +11:00
resolver_query_job.go Job queueing (#1379) 2021-05-24 14:24:18 +10:00
resolver_query_logs.go Change thumbnail default size and resize algorithm (#336) 2020-01-31 17:19:15 -05:00
resolver_query_metadata.go Job queueing (#1379) 2021-05-24 14:24:18 +10:00
resolver_query_plugin.go Add plugin tasks (#651) 2020-08-08 12:05:35 +10:00
resolver_query_scene.go Setup and migration UI refactor (#1190) 2021-04-12 09:31:33 +10:00
resolver_query_scraper.go Scraper refactor middle (#2043) 2021-11-26 11:20:06 +11:00
resolver_subscription_job.go Remove unused (#1709) 2021-09-09 14:10:08 +10:00
resolver_subscription_logging.go add missing trace loglevel (#2007) 2021-11-15 12:26:49 +11:00
routes_downloads.go Selective export (#770) 2020-09-15 17:28:53 +10:00
routes_image.go Scan refactor (#1816) 2021-10-15 10:39:48 +11:00
routes_movie.go Errcheck phase 1 (#1715) 2021-09-21 09:34:25 +10:00
routes_performer.go Errcheck phase 1 (#1715) 2021-09-21 09:34:25 +10:00
routes_scene.go Scan refactor (#1816) 2021-10-15 10:39:48 +11:00
routes_studio.go Suppress a benign warning (#1932) 2021-11-01 11:16:23 +11:00
routes_tag.go Errcheck phase 1 (#1715) 2021-09-21 09:34:25 +10:00
scraped_content.go Scraper refactor middle (#2043) 2021-11-26 11:20:06 +11:00
server.go Reenable gzipping, pull in statigz fix, fix proxy prefix (#2039) 2021-11-19 13:30:21 +11:00
session.go Errorlint sweep + minor linter tweaks (#1796) 2021-10-12 14:03:08 +11:00
types.go Fix inf values causing marshal error (#1607) 2021-08-03 14:29:57 +10:00