From 037a1b4adafaa44419ffb2f593901ade86181ae6 Mon Sep 17 00:00:00 2001 From: Asparghus <147214977+Asparghus@users.noreply.github.com> Date: Mon, 5 Aug 2024 19:36:15 +0100 Subject: [PATCH] feat: add Has Image Filter * Update RescrapeButton.vue Updated the Rescrape Scene function to work with scenes that have scrape_id and belong to a configured scraper. By toggling it's needs_update and running that scraper. It can be useful in case of single scenes without images. I've had to add a small delay (200ms) as it was not triggering the forceUpdate when making the API call, even when checking if this.item.needs_update was true. * Replaced github.com/cosmtrek/air with github.com/air-verse/air The repo github.com/cosmtrek/air doesn't exist anymore. When running Gitpod, it suggests using github.com/air-verse/air instead. * Replaced github.com/cosmtrek/air with github.com/air-verse/air The repo github.com/cosmtrek/air doesn't exist anymore. When running Gitpod, it suggests using github.com/air-verse/air instead. * Added the missing Has Image case --- .gitpod.dockerfile | 2 +- .gitpod.yml | 2 +- pkg/models/model_scene.go | 2 + ui/src/components/RescrapeButton.vue | 71 ++++++++++++++++------------ 4 files changed, 44 insertions(+), 33 deletions(-) diff --git a/.gitpod.dockerfile b/.gitpod.dockerfile index 1c3f74c3e..292dddf90 100644 --- a/.gitpod.dockerfile +++ b/.gitpod.dockerfile @@ -11,7 +11,7 @@ RUN export PATH=$(echo "$PATH" | sed -e 's|:/workspace/go/bin||' -e 's|:/home/gi ENV PATH=$GOROOT/bin:$GOPATH/bin:$PATH RUN go install -v \ - github.com/cosmtrek/air@latest && \ + github.com/air-verse/air@latest && \ sudo rm -rf $GOPATH/src && \ sudo rm -rf $GOPATH/pkg # user Go packages diff --git a/.gitpod.yml b/.gitpod.yml index 9a99bf403..762737219 100644 --- a/.gitpod.yml +++ b/.gitpod.yml @@ -2,7 +2,7 @@ image: file: .gitpod.dockerfile tasks: - name: Continuous Build - command: yarn config set ignore-engines true && yarn global add concurrently && go install github.com/cosmtrek/air@latest && cd /workspace/xbvr && go generate && go get && yarn && yarn dev + command: yarn config set ignore-engines true && yarn global add concurrently && go install github.com/air-verse/air@latest && cd /workspace/xbvr && go generate && go get && yarn && yarn dev ports: - port: 9999 onOpen: open-preview diff --git a/pkg/models/model_scene.go b/pkg/models/model_scene.go index fd3ec0cdc..d1fd5bac5 100644 --- a/pkg/models/model_scene.go +++ b/pkg/models/model_scene.go @@ -885,6 +885,8 @@ func queryScenes(db *gorm.DB, r RequestSceneList) (*gorm.DB, *gorm.DB) { where = `scenes.scene_id like "povr-%"` case "SLR Scraper": where = `scenes.scene_id like "slr-%"` + case "Has Image": + where = "cover_url not in ('','http://localhost/dont_cause_errors')" case "VRPHub Scraper": where = `scenes.scene_id like "vrphub-%"` case "VRPorn Scraper": diff --git a/ui/src/components/RescrapeButton.vue b/ui/src/components/RescrapeButton.vue index dadc3e8e4..0bf3e7b7a 100644 --- a/ui/src/components/RescrapeButton.vue +++ b/ui/src/components/RescrapeButton.vue @@ -1,7 +1,7 @@ @@ -12,44 +12,53 @@ export default { name: 'RescrapeButton', props: { item: Object }, methods: { - async rescrapeSingleScene () { + delay(ms) { + return new Promise(resolve => setTimeout(resolve, ms)); + }, + async rescrapeScene () { let site = "" - if (this.item.scene_url.toLowerCase().includes("dmm.co.jp")) { - ky.post('/api/task/scrape-javr', { json: { s: "r18d", q: this.item.scene_id } }) + this.$store.commit('sceneList/toggleSceneList', {scene_id: this.item.scene_id, list: 'needs_update'}) + if (this.item.scraper_id && this.item.needs_update) { + await this.delay(200); + ky.get(`/api/task/scrape?site=${this.item.scraper_id}`) } else { + if (this.item.scene_url.toLowerCase().includes("dmm.co.jp")) { + ky.post('/api/task/scrape-javr', { json: { s: "r18d", q: this.item.scene_id } }) + } else { - const sites = await ky.get('/api/options/sites').json() - console.info(sites) + const sites = await ky.get('/api/options/sites').json() + console.info(sites) - for (const element of sites) { - if (this.item.scene_url.toLowerCase().includes(element.id)) { - site = element.id + for (const element of sites) { + if (this.item.scene_url.toLowerCase().includes(element.id)) { + site = element.id + } } - } - if (this.item.scene_url.toLowerCase().includes("sexlikereal.com")) { - site = "slr-single_scene" - } - if (this.item.scene_url.toLowerCase().includes("czechvrnetwork.com")) { - site = "czechvr-single_scene" - } - if (this.item.scene_url.toLowerCase().includes("povr.com")) { - site = "povr-single_scene" - } - if (this.item.scene_url.toLowerCase().includes("vrporn.com")) { - site = "vrporn-single_scene" - } - if (this.item.scene_url.toLowerCase().includes("vrphub.com")) { - site = "vrphub-single_scene" + if (this.item.scene_url.toLowerCase().includes("sexlikereal.com")) { + site = "slr-single_scene" + } + if (this.item.scene_url.toLowerCase().includes("czechvrnetwork.com")) { + site = "czechvr-single_scene" + } + if (this.item.scene_url.toLowerCase().includes("povr.com")) { + site = "povr-single_scene" + } + if (this.item.scene_url.toLowerCase().includes("vrporn.com")) { + site = "vrporn-single_scene" + } + if (this.item.scene_url.toLowerCase().includes("vrphub.com")) { + site = "vrphub-single_scene" + } + if (site == "") { + this.$buefy.toast.open({message: `No scrapers exist for this domain`, type: 'is-danger', duration: 5000}) + return + } + ky.post(`/api/task/singlescrape`, {timeout: false, json: { site: site, sceneurl: this.item.scene_url, additionalinfo:[] }}) } - if (site == "") { - this.$buefy.toast.open({message: `No scrapers exist for this domain`, type: 'is-danger', duration: 5000}) - return - } - ky.post(`/api/task/singlescrape`, {timeout: false, json: { site: site, sceneurl: this.item.scene_url, additionalinfo:[] }}) } } } } - \ No newline at end of file +