Autotag scraper (#1817)

* Refactor scraper structures
* Move matching code into new package
* Add autotag scraper
* Always check first letter of auto-tag names
* Account for nulls

Co-authored-by: Kermie <kermie@isinthe.house>
This commit is contained in:
WithoutPants
2021-10-11 23:06:06 +11:00
committed by GitHub
parent b5381ff071
commit e9d48683f8
22 changed files with 1023 additions and 660 deletions

View File

@@ -19,7 +19,7 @@ func (e scraperAction) IsValid() bool {
return false
}
type scraper interface {
type scraperActionImpl interface {
scrapePerformersByName(name string) ([]*models.ScrapedPerformer, error)
scrapePerformerByFragment(scrapedPerformer models.ScrapedPerformerInput) (*models.ScrapedPerformer, error)
scrapePerformerByURL(url string) (*models.ScrapedPerformer, error)
@@ -36,16 +36,16 @@ type scraper interface {
scrapeMovieByURL(url string) (*models.ScrapedMovie, error)
}
func getScraper(scraper scraperTypeConfig, txnManager models.TransactionManager, config config, globalConfig GlobalConfig) scraper {
func (c config) getScraper(scraper scraperTypeConfig, txnManager models.TransactionManager, globalConfig GlobalConfig) scraperActionImpl {
switch scraper.Action {
case scraperActionScript:
return newScriptScraper(scraper, config, globalConfig)
return newScriptScraper(scraper, c, globalConfig)
case scraperActionStash:
return newStashScraper(scraper, txnManager, config, globalConfig)
return newStashScraper(scraper, txnManager, c, globalConfig)
case scraperActionXPath:
return newXpathScraper(scraper, txnManager, config, globalConfig)
return newXpathScraper(scraper, txnManager, c, globalConfig)
case scraperActionJson:
return newJsonScraper(scraper, txnManager, config, globalConfig)
return newJsonScraper(scraper, txnManager, c, globalConfig)
}
panic("unknown scraper action: " + scraper.Action)