Add support for selecting Amazon region in metadata settings
This commit is contained in:
committed by
Aditya Chandel
parent
a181c72a85
commit
25e59323f3
+1
@@ -13,6 +13,7 @@ public class MetadataProviderSettings {
|
|||||||
public static class Amazon {
|
public static class Amazon {
|
||||||
private boolean enabled;
|
private boolean enabled;
|
||||||
private String cookie;
|
private String cookie;
|
||||||
|
private String domain;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Data
|
@Data
|
||||||
|
|||||||
+1
@@ -65,6 +65,7 @@ public class SettingPersistenceHelper {
|
|||||||
MetadataProviderSettings.Amazon defaultAmazon = new MetadataProviderSettings.Amazon();
|
MetadataProviderSettings.Amazon defaultAmazon = new MetadataProviderSettings.Amazon();
|
||||||
defaultAmazon.setEnabled(true);
|
defaultAmazon.setEnabled(true);
|
||||||
defaultAmazon.setCookie(null);
|
defaultAmazon.setCookie(null);
|
||||||
|
defaultAmazon.setDomain("com");
|
||||||
|
|
||||||
MetadataProviderSettings.Google defaultGoogle = new MetadataProviderSettings.Google();
|
MetadataProviderSettings.Google defaultGoogle = new MetadataProviderSettings.Google();
|
||||||
defaultGoogle.setEnabled(true);
|
defaultGoogle.setEnabled(true);
|
||||||
|
|||||||
+1
-2
@@ -209,8 +209,7 @@ public class AmazonBookParser implements BookParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String encodedSearchTerm = searchTerm.toString().replace(" ", "+");
|
String encodedSearchTerm = searchTerm.toString().replace(" ", "+");
|
||||||
String url = "https://www.amazon.com/s?k=" + encodedSearchTerm;
|
String url = "https://www.amazon." + appSettingService.getAppSettings().getMetadataProviderSettings().getAmazon().getDomain() + "/s?k=" + encodedSearchTerm;
|
||||||
|
|
||||||
log.info("Query URL: {}", url);
|
log.info("Query URL: {}", url);
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ export interface MetadataProviderSettings {
|
|||||||
export interface Amazon {
|
export interface Amazon {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
cookie: string;
|
cookie: string;
|
||||||
|
domain: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface Google {
|
export interface Google {
|
||||||
|
|||||||
+34
-21
@@ -1,5 +1,5 @@
|
|||||||
<p class="text-lg flex items-center gap-2">
|
<p class="text-lg flex items-center gap-2">
|
||||||
Enabled Metadata Providers:
|
Enabled Metadata Providers:
|
||||||
<i
|
<i
|
||||||
class="pi pi-info-circle text-sky-600"
|
class="pi pi-info-circle text-sky-600"
|
||||||
pTooltip="Enable or configure third-party metadata sources for enhanced book information."
|
pTooltip="Enable or configure third-party metadata sources for enhanced book information."
|
||||||
@@ -13,32 +13,44 @@
|
|||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
<div class="flex items-center gap-4">
|
<div class="flex items-center gap-4">
|
||||||
<p-checkbox [(ngModel)]="amazonEnabled" [binary]="true"></p-checkbox>
|
<p-checkbox [(ngModel)]="amazonEnabled" [binary]="true"></p-checkbox>
|
||||||
<label>Amazon</label>
|
<label class="font-medium">Amazon</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-4 pl-6">
|
|
||||||
<input
|
<div class="flex flex-col gap-2 pl-9 pt-1">
|
||||||
type="text"
|
<label class="font-medium text-sm">Region</label>
|
||||||
pInputText
|
<p-select
|
||||||
placeholder="Amazon Cookie (Optional)"
|
[options]="amazonDomains"
|
||||||
class="w-full max-w-3xl"
|
[(ngModel)]="selectedAmazonDomain"
|
||||||
[(ngModel)]="amazonCookie" />
|
placeholder="Select Domain"
|
||||||
<i
|
class="w-full max-w-52">
|
||||||
class="pi pi-info-circle text-sky-600"
|
</p-select>
|
||||||
pTooltip="Providing your Amazon session cookie allows the app to access richer book metadata and bypass rate limits. Optional but recommended for best results."
|
|
||||||
tooltipPosition="right"
|
<label class="font-medium text-sm">Cookie (Optional)</label>
|
||||||
style="cursor: pointer;">
|
<div class="flex items-center gap-2">
|
||||||
</i>
|
<input
|
||||||
|
type="text"
|
||||||
|
pInputText
|
||||||
|
placeholder="Paste your Amazon cookie"
|
||||||
|
class="w-full max-w-3xl"
|
||||||
|
[(ngModel)]="amazonCookie" />
|
||||||
|
<i
|
||||||
|
class="pi pi-info-circle text-sky-600"
|
||||||
|
pTooltip="Providing your Amazon session cookie allows the app to access richer book metadata and bypass rate limits. Optional but recommended for best results."
|
||||||
|
tooltipPosition="right"
|
||||||
|
style="cursor: pointer;">
|
||||||
|
</i>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center gap-4">
|
<div class="flex items-center gap-4">
|
||||||
<p-checkbox [(ngModel)]="goodreadsEnabled" [binary]="true"></p-checkbox>
|
<p-checkbox [(ngModel)]="goodreadsEnabled" [binary]="true"></p-checkbox>
|
||||||
<label>Goodreads</label>
|
<label class="font-medium">Goodreads</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex items-center gap-4">
|
<div class="flex items-center gap-4">
|
||||||
<p-checkbox [(ngModel)]="googleEnabled" [binary]="true"></p-checkbox>
|
<p-checkbox [(ngModel)]="googleEnabled" [binary]="true"></p-checkbox>
|
||||||
<label>Google</label>
|
<label class="font-medium">Google</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex flex-col gap-2">
|
<div class="flex flex-col gap-2">
|
||||||
@@ -48,20 +60,21 @@
|
|||||||
[(ngModel)]="hardcoverEnabled"
|
[(ngModel)]="hardcoverEnabled"
|
||||||
[disabled]="!hardcoverToken">
|
[disabled]="!hardcoverToken">
|
||||||
</p-checkbox>
|
</p-checkbox>
|
||||||
<label>Hardcover</label>
|
<label class="font-medium">Hardcover</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="flex items-center gap-4 pl-6">
|
<div class="flex flex-col gap-2 pl-9 pt-1">
|
||||||
|
<label class="font-medium text-sm">API Token</label>
|
||||||
<input
|
<input
|
||||||
type="text"
|
type="text"
|
||||||
pInputText
|
pInputText
|
||||||
placeholder="API Token"
|
placeholder="Enter Hardcover API token"
|
||||||
class="w-full max-w-3xl"
|
class="w-full max-w-3xl"
|
||||||
[(ngModel)]="hardcoverToken"
|
[(ngModel)]="hardcoverToken"
|
||||||
(ngModelChange)="onTokenChange($event)" />
|
(ngModelChange)="onTokenChange($event)" />
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="flex justify-start px-4">
|
<div class="flex justify-start px-4">
|
||||||
<p-button label="Save" icon="pi pi-save" [outlined]="true" (click)="saveSettings()"></p-button>
|
<p-button label="Save" icon="pi pi-save" [outlined]="true" (click)="saveSettings()"></p-button>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
+31
-2
@@ -9,6 +9,7 @@ import {AppSettingsService} from '../../../core/service/app-settings.service';
|
|||||||
import {filter, take} from 'rxjs/operators';
|
import {filter, take} from 'rxjs/operators';
|
||||||
import {MessageService} from 'primeng/api';
|
import {MessageService} from 'primeng/api';
|
||||||
import {AppSettingKey} from '../../../core/model/app-settings.model';
|
import {AppSettingKey} from '../../../core/model/app-settings.model';
|
||||||
|
import {Select} from 'primeng/select';
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'app-metadata-provider-settings',
|
selector: 'app-metadata-provider-settings',
|
||||||
@@ -19,12 +20,38 @@ import {AppSettingKey} from '../../../core/model/app-settings.model';
|
|||||||
Checkbox,
|
Checkbox,
|
||||||
InputText,
|
InputText,
|
||||||
Button,
|
Button,
|
||||||
FormsModule
|
FormsModule,
|
||||||
|
Select
|
||||||
],
|
],
|
||||||
templateUrl: './metadata-provider-settings.component.html',
|
templateUrl: './metadata-provider-settings.component.html',
|
||||||
styleUrl: './metadata-provider-settings.component.scss'
|
styleUrl: './metadata-provider-settings.component.scss'
|
||||||
})
|
})
|
||||||
export class MetadataProviderSettingsComponent implements OnInit {
|
export class MetadataProviderSettingsComponent implements OnInit {
|
||||||
|
|
||||||
|
amazonDomains = [
|
||||||
|
{label: 'amazon.com', value: 'com'},
|
||||||
|
{label: 'amazon.de', value: 'de'},
|
||||||
|
{label: 'amazon.co.uk', value: 'co.uk'},
|
||||||
|
{label: 'amazon.co.jp', value: 'co.jp'},
|
||||||
|
{label: 'amazon.ca', value: 'ca'},
|
||||||
|
{label: 'amazon.in', value: 'in'},
|
||||||
|
{label: 'amazon.com.au', value: 'com.au'},
|
||||||
|
{label: 'amazon.fr', value: 'fr'},
|
||||||
|
{label: 'amazon.it', value: 'it'},
|
||||||
|
{label: 'amazon.es', value: 'es'},
|
||||||
|
{label: 'amazon.nl', value: 'nl'},
|
||||||
|
{label: 'amazon.se', value: 'se'},
|
||||||
|
{label: 'amazon.com.br', value: 'com.br'},
|
||||||
|
{label: 'amazon.sg', value: 'sg'},
|
||||||
|
{label: 'amazon.com.mx', value: 'com.mx'},
|
||||||
|
{label: 'amazon.pl', value: 'pl'},
|
||||||
|
{label: 'amazon.ae', value: 'ae'},
|
||||||
|
{label: 'amazon.sa', value: 'sa'},
|
||||||
|
{label: 'amazon.tr', value: 'tr'}
|
||||||
|
];
|
||||||
|
|
||||||
|
selectedAmazonDomain = 'com';
|
||||||
|
|
||||||
hardcoverToken: string = '';
|
hardcoverToken: string = '';
|
||||||
amazonCookie: string = '';
|
amazonCookie: string = '';
|
||||||
hardcoverEnabled: boolean = false;
|
hardcoverEnabled: boolean = false;
|
||||||
@@ -47,6 +74,7 @@ export class MetadataProviderSettingsComponent implements OnInit {
|
|||||||
const metadataProviderSettings = settings!.metadataProviderSettings;
|
const metadataProviderSettings = settings!.metadataProviderSettings;
|
||||||
this.amazonEnabled = metadataProviderSettings?.amazon?.enabled ?? false;
|
this.amazonEnabled = metadataProviderSettings?.amazon?.enabled ?? false;
|
||||||
this.amazonCookie = metadataProviderSettings?.amazon?.cookie ?? "";
|
this.amazonCookie = metadataProviderSettings?.amazon?.cookie ?? "";
|
||||||
|
this.selectedAmazonDomain = metadataProviderSettings?.amazon?.domain ?? 'com';
|
||||||
this.goodreadsEnabled = metadataProviderSettings?.goodReads?.enabled ?? false;
|
this.goodreadsEnabled = metadataProviderSettings?.goodReads?.enabled ?? false;
|
||||||
this.googleEnabled = metadataProviderSettings?.google?.enabled ?? false;
|
this.googleEnabled = metadataProviderSettings?.google?.enabled ?? false;
|
||||||
this.hardcoverToken = metadataProviderSettings?.hardcover?.apiKey ?? '';
|
this.hardcoverToken = metadataProviderSettings?.hardcover?.apiKey ?? '';
|
||||||
@@ -68,7 +96,8 @@ export class MetadataProviderSettingsComponent implements OnInit {
|
|||||||
newValue: {
|
newValue: {
|
||||||
amazon: {
|
amazon: {
|
||||||
enabled: this.amazonEnabled,
|
enabled: this.amazonEnabled,
|
||||||
cookie: this.amazonCookie
|
cookie: this.amazonCookie,
|
||||||
|
domain: this.selectedAmazonDomain
|
||||||
},
|
},
|
||||||
goodReads: {enabled: this.goodreadsEnabled},
|
goodReads: {enabled: this.goodreadsEnabled},
|
||||||
google: {enabled: this.googleEnabled},
|
google: {enabled: this.googleEnabled},
|
||||||
|
|||||||
Reference in New Issue
Block a user