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 {
|
||||
private boolean enabled;
|
||||
private String cookie;
|
||||
private String domain;
|
||||
}
|
||||
|
||||
@Data
|
||||
|
||||
+1
@@ -65,6 +65,7 @@ public class SettingPersistenceHelper {
|
||||
MetadataProviderSettings.Amazon defaultAmazon = new MetadataProviderSettings.Amazon();
|
||||
defaultAmazon.setEnabled(true);
|
||||
defaultAmazon.setCookie(null);
|
||||
defaultAmazon.setDomain("com");
|
||||
|
||||
MetadataProviderSettings.Google defaultGoogle = new MetadataProviderSettings.Google();
|
||||
defaultGoogle.setEnabled(true);
|
||||
|
||||
+1
-2
@@ -209,8 +209,7 @@ public class AmazonBookParser implements BookParser {
|
||||
}
|
||||
|
||||
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);
|
||||
return url;
|
||||
}
|
||||
|
||||
@@ -52,6 +52,7 @@ export interface MetadataProviderSettings {
|
||||
export interface Amazon {
|
||||
enabled: boolean;
|
||||
cookie: string;
|
||||
domain: string;
|
||||
}
|
||||
|
||||
export interface Google {
|
||||
|
||||
+34
-21
@@ -1,5 +1,5 @@
|
||||
<p class="text-lg flex items-center gap-2">
|
||||
Enabled Metadata Providers:
|
||||
Enabled Metadata Providers:
|
||||
<i
|
||||
class="pi pi-info-circle text-sky-600"
|
||||
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 items-center gap-4">
|
||||
<p-checkbox [(ngModel)]="amazonEnabled" [binary]="true"></p-checkbox>
|
||||
<label>Amazon</label>
|
||||
<label class="font-medium">Amazon</label>
|
||||
</div>
|
||||
<div class="flex items-center gap-4 pl-6">
|
||||
<input
|
||||
type="text"
|
||||
pInputText
|
||||
placeholder="Amazon Cookie (Optional)"
|
||||
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 class="flex flex-col gap-2 pl-9 pt-1">
|
||||
<label class="font-medium text-sm">Region</label>
|
||||
<p-select
|
||||
[options]="amazonDomains"
|
||||
[(ngModel)]="selectedAmazonDomain"
|
||||
placeholder="Select Domain"
|
||||
class="w-full max-w-52">
|
||||
</p-select>
|
||||
|
||||
<label class="font-medium text-sm">Cookie (Optional)</label>
|
||||
<div class="flex items-center gap-2">
|
||||
<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 class="flex items-center gap-4">
|
||||
<p-checkbox [(ngModel)]="goodreadsEnabled" [binary]="true"></p-checkbox>
|
||||
<label>Goodreads</label>
|
||||
<label class="font-medium">Goodreads</label>
|
||||
</div>
|
||||
|
||||
<div class="flex items-center gap-4">
|
||||
<p-checkbox [(ngModel)]="googleEnabled" [binary]="true"></p-checkbox>
|
||||
<label>Google</label>
|
||||
<label class="font-medium">Google</label>
|
||||
</div>
|
||||
|
||||
<div class="flex flex-col gap-2">
|
||||
@@ -48,20 +60,21 @@
|
||||
[(ngModel)]="hardcoverEnabled"
|
||||
[disabled]="!hardcoverToken">
|
||||
</p-checkbox>
|
||||
<label>Hardcover</label>
|
||||
<label class="font-medium">Hardcover</label>
|
||||
</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
|
||||
type="text"
|
||||
pInputText
|
||||
placeholder="API Token"
|
||||
placeholder="Enter Hardcover API token"
|
||||
class="w-full max-w-3xl"
|
||||
[(ngModel)]="hardcoverToken"
|
||||
(ngModelChange)="onTokenChange($event)" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="flex justify-start px-4">
|
||||
<p-button label="Save" icon="pi pi-save" [outlined]="true" (click)="saveSettings()"></p-button>
|
||||
</div>
|
||||
|
||||
+31
-2
@@ -9,6 +9,7 @@ import {AppSettingsService} from '../../../core/service/app-settings.service';
|
||||
import {filter, take} from 'rxjs/operators';
|
||||
import {MessageService} from 'primeng/api';
|
||||
import {AppSettingKey} from '../../../core/model/app-settings.model';
|
||||
import {Select} from 'primeng/select';
|
||||
|
||||
@Component({
|
||||
selector: 'app-metadata-provider-settings',
|
||||
@@ -19,12 +20,38 @@ import {AppSettingKey} from '../../../core/model/app-settings.model';
|
||||
Checkbox,
|
||||
InputText,
|
||||
Button,
|
||||
FormsModule
|
||||
FormsModule,
|
||||
Select
|
||||
],
|
||||
templateUrl: './metadata-provider-settings.component.html',
|
||||
styleUrl: './metadata-provider-settings.component.scss'
|
||||
})
|
||||
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 = '';
|
||||
amazonCookie: string = '';
|
||||
hardcoverEnabled: boolean = false;
|
||||
@@ -47,6 +74,7 @@ export class MetadataProviderSettingsComponent implements OnInit {
|
||||
const metadataProviderSettings = settings!.metadataProviderSettings;
|
||||
this.amazonEnabled = metadataProviderSettings?.amazon?.enabled ?? false;
|
||||
this.amazonCookie = metadataProviderSettings?.amazon?.cookie ?? "";
|
||||
this.selectedAmazonDomain = metadataProviderSettings?.amazon?.domain ?? 'com';
|
||||
this.goodreadsEnabled = metadataProviderSettings?.goodReads?.enabled ?? false;
|
||||
this.googleEnabled = metadataProviderSettings?.google?.enabled ?? false;
|
||||
this.hardcoverToken = metadataProviderSettings?.hardcover?.apiKey ?? '';
|
||||
@@ -68,7 +96,8 @@ export class MetadataProviderSettingsComponent implements OnInit {
|
||||
newValue: {
|
||||
amazon: {
|
||||
enabled: this.amazonEnabled,
|
||||
cookie: this.amazonCookie
|
||||
cookie: this.amazonCookie,
|
||||
domain: this.selectedAmazonDomain
|
||||
},
|
||||
goodReads: {enabled: this.goodreadsEnabled},
|
||||
google: {enabled: this.googleEnabled},
|
||||
|
||||
Reference in New Issue
Block a user