Skip to content

Commit

Permalink
feat: Persist last used JAVR scraper (xbapps#1646)
Browse files Browse the repository at this point in the history
Co-authored-by: Alderamin <alderamin49ly@gmail.com>
  • Loading branch information
Alderamin49ly and Alderamin authored Apr 2, 2024
1 parent f4c9c85 commit d9c16a2
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 76 deletions.
3 changes: 3 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
}

Expand Down
3 changes: 3 additions & 0 deletions pkg/tasks/content.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
165 changes: 89 additions & 76 deletions ui/src/views/options/sections/OptionsSceneCreate.vue
Original file line number Diff line number Diff line change
@@ -1,87 +1,89 @@
<template>
<div class="content">
<h3 class="title">{{$t('Import Japanese Adult VR (JAVR) Scene')}}</h3>
<div class="card">
<div class="card-content content">
<b-field grouped>
<b-select placeholder="Select scraper" v-model="javrScraper">
<option value="javdatabase">javdatabase.com</option>
<option value="r18d">r18.dev</option>
<option value="javlibrary">javlibrary.com</option>
<option value="javland">jav.land</option>
</b-select>
<b-input v-model="javrQuery" placeholder="ID (xxxx-001)" type="search"></b-input>
<b-button class="button is-primary" v-on:click="scrapeJAVR()">{{$t('Go')}}</b-button>
</b-field>
<span>R18.dev scraper works best with FANZA content ID, e.g. 84vrkm00139, but DVD-ID works too when maintained.</span>
<div class="container">
<b-loading :is-full-page="false" :active.sync="isLoading"></b-loading>
<div class="content">
<h3 class="title">{{$t('Import Japanese Adult VR (JAVR) Scene')}}</h3>
<div class="card">
<div class="card-content content">
<b-field grouped>
<b-select placeholder="Select scraper" v-model="javrScraper">
<option value="javdatabase">javdatabase.com</option>
<option value="r18d">r18.dev</option>
<option value="javlibrary">javlibrary.com</option>
<option value="javland">jav.land</option>
</b-select>
<b-input v-model="javrQuery" placeholder="ID (xxxx-001)" type="search"></b-input>
<b-button class="button is-primary" v-on:click="scrapeJAVR()">{{$t('Go')}}</b-button>
</b-field>
<span>R18.dev scraper works best with FANZA content ID, e.g. 84vrkm00139, but DVD-ID works too when maintained.</span>
</div>
</div>
</div>

<h3 class="title">{{$t('Import scene from TPDB')}}</h3>
<div class="card">
<div class="card-content content">
<h5 class="title">API Token</h5>
<b-field label="TPDB API Token" label-position="on-border" grouped>
<b-input v-model="tpdbApiToken" placeholder="TPDB API Token" type="search"></b-input>
</b-field>
<br>
<b-field label="TPDB Scene URL" label-position="on-border" grouped>
<b-input v-model="tpdbSceneUrl" placeholder="TPDB URL" type="search"></b-input>
<b-button class="button is-primary" v-on:click="scrapeTPDB()">{{$t('Go')}}</b-button>
</b-field>
<h3 class="title">{{$t('Import scene from TPDB')}}</h3>
<div class="card">
<div class="card-content content">
<h5 class="title">API Token</h5>
<b-field label="TPDB API Token" label-position="on-border" grouped>
<b-input v-model="tpdbApiToken" placeholder="TPDB API Token" type="search"></b-input>
</b-field>
<br>
<b-field label="TPDB Scene URL" label-position="on-border" grouped>
<b-input v-model="tpdbSceneUrl" placeholder="TPDB URL" type="search"></b-input>
<b-button class="button is-primary" v-on:click="scrapeTPDB()">{{$t('Go')}}</b-button>
</b-field>
</div>
</div>
</div>

<h3 class="title">{{$t('Create custom scene')}}</h3>
<div class="card">
<div class="card-content content">
<b-field label="Scene title" label-position="on-border">
<b-input v-model="customSceneTitle" placeholder="Stepsis stuck in washing machine" type="search"></b-input>
</b-field>
<b-field label="Scene ID" label-position="on-border" grouped>
<b-input v-model="customSceneID" placeholder="Can be empty" type="search"></b-input>
<b-button class="button is-primary" v-on:click="addScene(false)">{{$t('Create')}}</b-button>
<b-button class="button is-primary" v-on:click="addScene(true)" style="margin-left:0.2em">{{$t('Create and Edit')}}</b-button>
</b-field>
</div>
</div>

<h3 class="title">{{$t('Scrape a scene')}}</h3>
<div class="card">
<div class="card-content content">
<b-field label="Scene URL" label-position="on-border">
<b-input v-model="scrapeUrl" placeholder="Scene Url - do not use links requiring a login" type="url"></b-input>
</b-field>
<b-tooltip :label="$t(`Warning: Ensure you are entering a link to a scene (best taken from viewing the scene). Links to something like a Category or Studio list may result in a corrupt scene you cannot delete. DO NOT USE links requiring logons. Use with caution`)" :delay="50" multilined type="is-danger">
<b-button class="button is-primary" v-on:click="scrapeSingleScene()">{{$t('Scrape')}}</b-button>
</b-tooltip>
<h3 class="title">{{$t('Create custom scene')}}</h3>
<div class="card">
<div class="card-content content">
<b-field label="Scene title" label-position="on-border">
<b-input v-model="customSceneTitle" placeholder="Stepsis stuck in washing machine" type="search"></b-input>
</b-field>
<b-field label="Scene ID" label-position="on-border" grouped>
<b-input v-model="customSceneID" placeholder="Can be empty" type="search"></b-input>
<b-button class="button is-primary" v-on:click="addScene(false)">{{$t('Create')}}</b-button>
<b-button class="button is-primary" v-on:click="addScene(true)" style="margin-left:0.2em">{{$t('Create and Edit')}}</b-button>
</b-field>
</div>
</div>
</div>

<b-modal :active.sync="isSingleScrapeModalActive"
has-modal-card
trap-focus
aria-role="dialog"
aria-modal>
<div class="modal-card" style="width: auto">
<header class="modal-card-head">
<p class="modal-card-title">{{$t('Scene Id Required')}}</p>
</header>
<section class="modal-card-body">
<b-field label="Scene Id">
<b-input
v-model='singleScrapeId'
placeholder="eg 12345 (excl site prefix)"
>
</b-input>
<h3 class="title">{{$t('Scrape a scene')}}</h3>
<div class="card">
<div class="card-content content">
<b-field label="Scene URL" label-position="on-border">
<b-input v-model="scrapeUrl" placeholder="Scene Url - do not use links requiring a login" type="url"></b-input>
</b-field>
</section>
<footer class="modal-card-foot">
<button class="button is-primary" :disabled="this.singleScrapeId == ''" @click="scrapeSingleScene()">Continue</button>
</footer>
<b-tooltip :label="$t(`Warning: Ensure you are entering a link to a scene (best taken from viewing the scene). Links to something like a Category or Studio list may result in a corrupt scene you cannot delete. DO NOT USE links requiring logons. Use with caution`)" :delay="50" multilined type="is-danger">
<b-button class="button is-primary" v-on:click="scrapeSingleScene()">{{$t('Scrape')}}</b-button>
</b-tooltip>
</div>
</div>
</b-modal>


<b-modal :active.sync="isSingleScrapeModalActive"
has-modal-card
trap-focus
aria-role="dialog"
aria-modal>
<div class="modal-card" style="width: auto">
<header class="modal-card-head">
<p class="modal-card-title">{{$t('Scene Id Required')}}</p>
</header>
<section class="modal-card-body">
<b-field label="Scene Id">
<b-input
v-model='singleScrapeId'
placeholder="eg 12345 (excl site prefix)"
>
</b-input>
</b-field>
</section>
<footer class="modal-card-foot">
<button class="button is-primary" :disabled="this.singleScrapeId == ''" @click="scrapeSingleScene()">Continue</button>
</footer>
</div>
</b-modal>
</div>
</div>
</template>

Expand All @@ -92,6 +94,7 @@ export default {
name: 'OptionsCreateScene',
data () {
return {
isLoading: true,
javrScraper: 'javdatabase',
javrQuery: '',
tpdbSceneUrl: '',
Expand All @@ -103,7 +106,8 @@ export default {
additionalInfo: [],
}
},
mounted () {
async mounted () {
await this.loadState()
this.$store.dispatch('optionsVendor/load')
if (this.$store.state.optionsSceneCreate.scrapeScene!='') {
Expand All @@ -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 } })
Expand Down

0 comments on commit d9c16a2

Please sign in to comment.