Added media type passed along with the apis to query and the title
This commit is contained in:
parent
5a8feca561
commit
0157c0adf9
2 changed files with 6 additions and 6 deletions
|
|
@ -18,12 +18,12 @@ export class APIManager {
|
||||||
* @param query
|
* @param query
|
||||||
* @param apisToQuery
|
* @param apisToQuery
|
||||||
*/
|
*/
|
||||||
async query(query: string, apisToQuery: string[]): Promise<MediaTypeModel[]> {
|
async query(query: string, apisToQuery: string[], mediaType: string): Promise<MediaTypeModel[]> {
|
||||||
console.debug(`MDB | api manager queried with "${query}"`);
|
console.debug(`MDB | api manager queried with "${query}"`);
|
||||||
|
|
||||||
let res: MediaTypeModel[] = [];
|
let res: MediaTypeModel[] = [];
|
||||||
for (const api of this.apis) {
|
for (const api of this.apis) {
|
||||||
if (apisToQuery.contains(api.apiName) && (this.plugin.settings[[api.apiName, "game"].filter(s => s).join('') as keyof typeof this.plugin.settings] || this.plugin.settings[[api.apiName, "default"].filter(s => s).join('') as keyof typeof this.plugin.settings])) {
|
if (apisToQuery.contains(api.apiName) && (this.plugin.settings[[api.apiName, mediaType].filter(s => s).join('') as keyof typeof this.plugin.settings] || this.plugin.settings[[api.apiName, "default"].filter(s => s).join('') as keyof typeof this.plugin.settings])) {
|
||||||
const apiRes = await api.searchByTitle(query);
|
const apiRes = await api.searchByTitle(query);
|
||||||
res = res.concat(apiRes);
|
res = res.concat(apiRes);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
*/
|
*/
|
||||||
async createLinkWithSearchModal(): Promise<void> {
|
async createLinkWithSearchModal(): Promise<void> {
|
||||||
const apiSearchResults: MediaTypeModel[] = await this.modalHelper.openAdvancedSearchModal({}, async advancedSearchModalData => {
|
const apiSearchResults: MediaTypeModel[] = await this.modalHelper.openAdvancedSearchModal({}, async advancedSearchModalData => {
|
||||||
return await this.apiManager.query(advancedSearchModalData.query, advancedSearchModalData.apis);
|
return await this.apiManager.query(advancedSearchModalData.query, advancedSearchModalData.apis, "default");
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!apiSearchResults) {
|
if (!apiSearchResults) {
|
||||||
|
|
@ -186,7 +186,7 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
let apiSearchResults: MediaTypeModel[] = await this.modalHelper.openSearchModal(searchModalOptions ?? {}, async searchModalData => {
|
let apiSearchResults: MediaTypeModel[] = await this.modalHelper.openSearchModal(searchModalOptions ?? {}, async searchModalData => {
|
||||||
types = searchModalData.types;
|
types = searchModalData.types;
|
||||||
const apis = this.apiManager.apis.filter(x => x.hasTypeOverlap(searchModalData.types)).map(x => x.apiName);
|
const apis = this.apiManager.apis.filter(x => x.hasTypeOverlap(searchModalData.types)).map(x => x.apiName);
|
||||||
return await this.apiManager.query(searchModalData.query, apis);
|
return await this.apiManager.query(searchModalData.query, apis, searchModalData.types.toString());
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!apiSearchResults) {
|
if (!apiSearchResults) {
|
||||||
|
|
@ -218,7 +218,7 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
|
|
||||||
async createEntryWithAdvancedSearchModal(): Promise<void> {
|
async createEntryWithAdvancedSearchModal(): Promise<void> {
|
||||||
const apiSearchResults: MediaTypeModel[] = await this.modalHelper.openAdvancedSearchModal({}, async advancedSearchModalData => {
|
const apiSearchResults: MediaTypeModel[] = await this.modalHelper.openAdvancedSearchModal({}, async advancedSearchModalData => {
|
||||||
return await this.apiManager.query(advancedSearchModalData.query, advancedSearchModalData.apis);
|
return await this.apiManager.query(advancedSearchModalData.query, advancedSearchModalData.apis, "default");
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!apiSearchResults) {
|
if (!apiSearchResults) {
|
||||||
|
|
@ -570,7 +570,7 @@ export default class MediaDbPlugin extends Plugin {
|
||||||
|
|
||||||
let results: MediaTypeModel[] = [];
|
let results: MediaTypeModel[] = [];
|
||||||
try {
|
try {
|
||||||
results = await this.apiManager.query(title, [selectedAPI]);
|
results = await this.apiManager.query(title, [selectedAPI], "default");
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
erroredFiles.push({ filePath: file.path, error: e.toString() });
|
erroredFiles.push({ filePath: file.path, error: e.toString() });
|
||||||
continue;
|
continue;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue