Skip to content

Commit

Permalink
fix: anisearch search is blocked
Browse files Browse the repository at this point in the history
  • Loading branch information
infanf committed Nov 4, 2023
1 parent 236e46a commit 486026e
Show file tree
Hide file tree
Showing 7 changed files with 64 additions and 37 deletions.
4 changes: 2 additions & 2 deletions frontend/src/app/anime/details/details.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -443,9 +443,9 @@ <h2>
[disabled]="busy"
enterkeyhint="done"
/>
<button class="btn btn-primary" (click)="findAnisearch()">
<!-- <button class="btn btn-primary" (click)="findAnisearch()">
<myanili-icon-anisearch></myanili-icon-anisearch>
</button>
</button> -->
</div>
</div>
</div>
Expand Down
50 changes: 29 additions & 21 deletions frontend/src/app/anime/details/details.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { Component, Input, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { Button } from '@components/dialogue/dialogue.component';
import { StreamPipe } from '@components/stream.pipe';
import { AnisearchComponent } from '@external/anisearch/anisearch.component';
import { AnnComponent } from '@external/ann/ann.component';
import { AnnictComponent } from '@external/annict/annict.component';
import { KitsuComponent } from '@external/kitsu/kitsu.component';
Expand Down Expand Up @@ -208,20 +207,21 @@ export class AnimeDetailsComponent implements OnInit {
}),
);
}
if (!this.anime.my_extension.anisearchId) {
promises.push(
this.anisearch
.getId(this.anime.title, 'anime', {
parts: this.anime.num_episodes,
year: this.anime.start_season?.year,
})
.then(anisearchId => {
if (anisearchId && this?.anime?.my_extension) {
this.anime.my_extension.anisearchId = anisearchId;
}
}),
);
}
/** @deprecated currently not working */
// if (!this.anime.my_extension.anisearchId) {
// promises.push(
// this.anisearch
// .getId(this.anime.title, 'anime', {
// parts: this.anime.num_episodes,
// year: this.anime.start_season?.year,
// })
// .then(anisearchId => {
// if (anisearchId && this?.anime?.my_extension) {
// this.anime.my_extension.anisearchId = anisearchId;
// }
// }),
// );
// }
if (!this.anime.my_extension.livechartId) {
const livechartPromise = new Promise(async resolve => {
const livechartId = await this.livechart.getId(this.id, anime.title);
Expand Down Expand Up @@ -267,6 +267,12 @@ export class AnimeDetailsComponent implements OnInit {
this.anime.my_extension.apSlug = apSlug;
}
}
if (!this.anime.my_extension.anisearchId) {
const anisearchId = await this.livechart.getAnisearchId(this.anime.my_extension.livechartId);
if (anisearchId && this?.anime?.my_extension) {
this.anime.my_extension.anisearchId = anisearchId;
}
}
if (promises.length && anime.my_extension && anime.my_list_status?.status) {
if ('series' in anime.my_extension) delete anime.my_extension.series;
const { Base64 } = await import('js-base64');
Expand Down Expand Up @@ -697,13 +703,15 @@ export class AnimeDetailsComponent implements OnInit {
});
}

/** @deprecated doesn't work anymore */
async findAnisearch() {
if (!this.anime || !this.editExtension) return;
const modal = this.modalService.open(AnisearchComponent);
modal.componentInstance.title = this.anime.title;
modal.closed.subscribe(value => {
if (this.editExtension) this.editExtension.anisearchId = Number(value);
});
return;
// if (!this.anime || !this.editExtension) return;
// const modal = this.modalService.open(AnisearchComponent);
// modal.componentInstance.title = this.anime.title;
// modal.closed.subscribe(value => {
// if (this.editExtension) this.editExtension.anisearchId = Number(value);
// });
}

async findAnnict() {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/app/manga/details/details.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -693,9 +693,9 @@ <h2>
[disabled]="busy"
enterkeyhint="done"
/>
<button class="btn btn-primary" (click)="findAnisearch()">
<!-- <button class="btn btn-primary" (click)="findAnisearch()">
<myanili-icon-anisearch></myanili-icon-anisearch>
</button>
</button> -->
</div>
</div>
</div>
Expand Down
17 changes: 9 additions & 8 deletions frontend/src/app/manga/details/details.component.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component, Input, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { PlatformPipe } from '@components/platform.pipe';
import { AnisearchComponent } from '@external/anisearch/anisearch.component';
import { AnnComponent } from '@external/ann/ann.component';
import { BakamangaComponent } from '@external/bakamanga/bakamanga.component';
import { KitsuComponent } from '@external/kitsu/kitsu.component';
Expand Down Expand Up @@ -673,14 +672,16 @@ export class MangaDetailsComponent implements OnInit {
});
}

/** @deprecated doesn't work anymore */
async findAnisearch() {
if (!this.manga || !this.editExtension) return;
const modal = this.modalService.open(AnisearchComponent);
modal.componentInstance.title = this.manga.title;
modal.componentInstance.type = 'manga';
modal.closed.subscribe((value: number) => {
if (this.editExtension) this.editExtension.anisearchId = Number(value);
});
return;
// if (!this.manga || !this.editExtension) return;
// const modal = this.modalService.open(AnisearchComponent);
// modal.componentInstance.title = this.manga.title;
// modal.componentInstance.type = 'manga';
// modal.closed.subscribe((value: number) => {
// if (this.editExtension) this.editExtension.anisearchId = Number(value);
// });
}

async findBaka() {
Expand Down
16 changes: 15 additions & 1 deletion frontend/src/app/services/anime/livechart.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ export class LivechartService {
singleAnime(id: $id) {
anidbUrl
animePlanetUrl
anisearchUrl
}
}
`;
Expand All @@ -105,6 +106,7 @@ export class LivechartService {
singleAnime: {
anidbUrl?: string;
animePlanetUrl?: string;
anisearchUrl?: string;
};
}>(QUERY, { id })
.toPromise();
Expand All @@ -114,9 +116,11 @@ export class LivechartService {
}
const anidbUrl = data.singleAnime.anidbUrl;
const animePlanetUrl = data.singleAnime.animePlanetUrl;
const anisearchUrl = data.singleAnime.anisearchUrl;
return {
anidbUrl,
animePlanetUrl,
anisearchUrl,
};
}

Expand All @@ -131,7 +135,7 @@ export class LivechartService {
}

async getAnimePlanetId(id?: number): Promise<string | undefined> {
if (!id) return undefined;
if (!id) return;
const { animePlanetUrl } = await this.getExternalUrls(id);
if (!animePlanetUrl) return;
const regex = /anime\/(.+)$/;
Expand All @@ -140,6 +144,16 @@ export class LivechartService {
return match[1];
}

async getAnisearchId(id?: number): Promise<number | undefined> {
if (!id) return;
const { anisearchUrl } = await this.getExternalUrls(id);
if (!anisearchUrl) return;
const regex = /anime\/(\d+)$/;
const match = regex.exec(anisearchUrl);
if (!match?.[1]) return;
return Number(match[1]);
}

async getAnimes(term: string) {
const { gql } = await import('@urql/core');
const QUERY = gql`
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/changelog.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
export const changelog: Changelog = {
changes: [
{
version: '2.28.2',
fixes: ['Anisearch: remove search while it is not working'],
},
{
version: '2.28.1',
features: ['Watchlist: add option to hide shows', 'Watchlist: add date'],
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"description": "MyAniLi",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"build": "docker-compose build --pull --no-cache",
"build": "docker compose build --pull --no-cache",
"dev:build": "npm run build && npm run dev",
"start": "docker-compose up -d",
"stop": "docker-compose down",
"start": "docker compose up -d",
"stop": "docker compose down",
"dev": "npm run start && docker exec -ti -w /frontend -u application myanili_app npm i && docker exec -ti -w /frontend -u application myanili_app npm run dev",
"shell": "npm run start && docker exec -ti -w /frontend -u application myanili_app bash",
"shell:root": "npm run start && docker exec -ti -w /frontend -u root myanili_app bash",
Expand Down

0 comments on commit 486026e

Please sign in to comment.