From d9c16a2426ddf237cd6ebd38c05e0d33b03d5205 Mon Sep 17 00:00:00 2001 From: Alderamin <126297468+Alderamin49ly@users.noreply.github.com> Date: Tue, 2 Apr 2024 10:59:00 -0400 Subject: [PATCH] feat: Persist last used JAVR scraper (#1646) Co-authored-by: Alderamin --- pkg/config/config.go | 3 + pkg/tasks/content.go | 3 + .../options/sections/OptionsSceneCreate.vue | 165 ++++++++++-------- 3 files changed, 95 insertions(+), 76 deletions(-) diff --git a/pkg/config/config.go b/pkg/config/config.go index 3b8bfa2ea..f96f3b5f3 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -174,6 +174,9 @@ type ObjectConfig struct { TMWVRNet struct { TmwMembersDomain string `default:"members.tmwvrnet.com" json:"tmwMembersDomain"` } `json:"tmwvrnet"` + Javr struct { + JavrScraper string `default:"javdatabase" json:"javrScraper"` + } `json:"javr"` } `json:"scraper_settings"` } diff --git a/pkg/tasks/content.go b/pkg/tasks/content.go index 3a7e920ff..0355a7d92 100644 --- a/pkg/tasks/content.go +++ b/pkg/tasks/content.go @@ -366,6 +366,9 @@ func ScrapeJAVR(queryString string, scraper string) { tlog := log.WithField("task", "scrape") tlog.Infof("Scraping started at %s", t0.Format("Mon Jan _2 15:04:05 2006")) + config.Config.ScraperSettings.Javr.JavrScraper = scraper + config.SaveConfig() + // Start scraping var collectedScenes []models.ScrapedScene diff --git a/ui/src/views/options/sections/OptionsSceneCreate.vue b/ui/src/views/options/sections/OptionsSceneCreate.vue index 81806bc09..6b7f686df 100644 --- a/ui/src/views/options/sections/OptionsSceneCreate.vue +++ b/ui/src/views/options/sections/OptionsSceneCreate.vue @@ -1,87 +1,89 @@ @@ -92,6 +94,7 @@ export default { name: 'OptionsCreateScene', data () { return { + isLoading: true, javrScraper: 'javdatabase', javrQuery: '', tpdbSceneUrl: '', @@ -103,7 +106,8 @@ export default { additionalInfo: [], } }, - mounted () { + async mounted () { + await this.loadState() this.$store.dispatch('optionsVendor/load') if (this.$store.state.optionsSceneCreate.scrapeScene!='') { @@ -113,6 +117,15 @@ export default { } }, methods: { + async loadState () { + this.isLoading = true + await ky.get('/api/options/state') + .json() + .then(data => { + this.javrScraper = data.config.scraper_settings.javr.javrScraper + this.isLoading = false + }) + }, addScene(showEdit) { if (this.customSceneTitle !== '') { ky.post('/api/scene/create', { json: { title: this.customSceneTitle, id: this.customSceneID } })