Skip to content

Commit

Permalink
Merge pull request #19 from chytanka/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
rodzyk authored Aug 13, 2024
2 parents 5771099 + 9e6afcf commit fd0f995
Show file tree
Hide file tree
Showing 23 changed files with 293 additions and 9 deletions.
10 changes: 10 additions & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@ export const REDDIT_PATH = `reddit`;
export const READ_PATH = `read`;
export const LIST_PATH = `list`;
export const ZENKO_PATH = `zenko`;
export const NHENTAI_PATH = `nhentai`;
export const COMICK_PATH = `comick`;

const routes: Routes = [
{
Expand Down Expand Up @@ -58,6 +60,14 @@ const routes: Routes = [
path: ZENKO_PATH,
loadChildren: () => import('./zenko/zenko.module').then(m => m.ZenkoModule)
},
{
path: NHENTAI_PATH,
loadChildren: () => import('./nhentai/nhentai.module').then(m => m.NhentaiModule)
},
{
path: COMICK_PATH,
loadChildren: () => import('./comick/comick.module').then(m => m.ComickModule)
},
{
matcher: urlMatcher,
loadChildren: () => import('./link-parser/link-parser.module').then(m => m.LinkParserModule)
Expand Down
17 changes: 17 additions & 0 deletions src/app/comick/comick-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { ComickShellComponent } from './comick-shell/comick-shell.component';

const routes: Routes = [
{ path: '', redirectTo: '/', pathMatch: 'full' },
{
path: ':id',
component: ComickShellComponent
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class ComickRoutingModule { }
8 changes: 8 additions & 0 deletions src/app/comick/comick-shell/comick-shell.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<app-common-read [episode$]="episode$" [error$]="error$" [loading$]="loading$" (refreshData)="refreshData()"
[playlist]="playlistService.playlist()" [playlistLink]="playlistLink()" [currentPlaylistItem]="currentPlItem()">

<p>{{lang.ph().imagesVia}}<a href="https://nhentai.net" target="_blank" rel="noopener noreferrer">Nhentai</a>
API.
{{lang.ph().thanks}}<br>{{lang.ph().detalisCopy}}</p>

</app-common-read>
Empty file.
39 changes: 39 additions & 0 deletions src/app/comick/comick-shell/comick-shell.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Component, inject, OnDestroy } from '@angular/core';
import { ComickService } from '../data-access/comick.service';
import { switchMap, of } from 'rxjs';
import { ReadBaseComponent } from '../../common/common-read';
import { Base64 } from '../../shared/utils';
import { COMICK_PATH } from '../../app-routing.module';

@Component({
selector: 'app-comick-shell',
templateUrl: './comick-shell.component.html',
styleUrl: './comick-shell.component.scss'
})
export class ComickShellComponent extends ReadBaseComponent implements OnDestroy {
comick = inject(ComickService)

override episode$ = this.combineParamMapAndRefresh()
.pipe(this.tapStartLoading(),
switchMap(([params]) => {
const pathParam = params?.get('id');

if (!pathParam) return of(null);

const path = (Base64.isBase64(pathParam)) ? Base64.fromBase64(pathParam) : pathParam;

return (this.comick.getComposition(path)).pipe(this.catchError(), this.tapSetTitle(),
this.tapSaveToHistory(COMICK_PATH, path),
this.tapSaveToCurrentPlaylistItem(COMICK_PATH, path),
this.finalizeLoading());
})
);

constructor() {
super()
}

ngOnDestroy(): void {
this.plObserv?.unsubscribe();
}
}
19 changes: 19 additions & 0 deletions src/app/comick/comick.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { ComickRoutingModule } from './comick-routing.module';
import { ComickShellComponent } from './comick-shell/comick-shell.component';
import { CommonReadModule } from '../common/common-read';


@NgModule({
declarations: [
ComickShellComponent
],
imports: [
CommonModule,
ComickRoutingModule,
CommonReadModule
]
})
export class ComickModule { }
42 changes: 42 additions & 0 deletions src/app/comick/data-access/comick.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { HttpClient } from '@angular/common/http';
import { inject, Injectable } from '@angular/core';
import { Observable, map } from 'rxjs';
import { environment } from '../../../environments/environment';
import { CompositionEpisode } from '../../common/common-read';
import { Base64 } from '../../shared/utils';

@Injectable({
providedIn: 'root'
})
export class ComickService {
http: HttpClient = inject(HttpClient)

getComposition(id: string): Observable<CompositionEpisode> {
// environment.proxy + Base64.toBase64
return this.http.get<any>((environment.comickHost + id))
.pipe(map((data) => { return this.map(data) }))
}

map(data: any): CompositionEpisode {
const nsfw = data.matureContent;
const mappedResponse = {
title: data.chapTitle,
nsfw: nsfw, //['erotica', 'suggestive'].includes(data.chapter.md_comics.content_rating),
images: (data.chapter.md_images.map((item: any, index: number) => {
return {
src: `https://meo3.comick.pictures/${item.b2key}`,
height: item.h,
width: item.w
};
})).filter((i: any) => i.src)
// .map((img: any) => {
// return {
// src: environment.proxy + Base64.toBase64(`${img.src}`)
// }
// })

};

return mappedResponse;
}
}
7 changes: 6 additions & 1 deletion src/app/link-parser/link-parser/link-parser.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
import { Component, Signal, ViewChild, WritableSignal, computed, effect, inject, signal } from '@angular/core';
import { LinkParserService } from '../data-access/link-parser.service';
import {ZenkoLinkParser, ImgurLinkParser, JsonLinkParser, MangadexLinkParser, RedditLinkParser, TelegraphLinkParser } from '../utils';
import {ZenkoLinkParser, ImgurLinkParser, JsonLinkParser, MangadexLinkParser, RedditLinkParser, TelegraphLinkParser, NhentaiLinkParser } from '../utils';
import { ActivatedRoute, Router } from '@angular/router';
import { LangService } from '../../shared/data-access/lang.service';
import { Base64 } from '../../shared/utils';
import { Title } from '@angular/platform-browser';
import { LinkParserSettingsService } from '../data-access/link-parser-settings.service';
import { ComickLinkParser } from '../utils/comick-link-parser';

@Component({
selector: 'app-link-parser',
Expand Down Expand Up @@ -46,6 +47,8 @@ export class LinkParserComponent {
this.parser.parsers.push(new TelegraphLinkParser)
this.parser.parsers.push(new RedditLinkParser)
this.parser.parsers.push(new ZenkoLinkParser)
this.parser.parsers.push(new NhentaiLinkParser)
this.parser.parsers.push(new ComickLinkParser)
this.parser.parsers.push(new JsonLinkParser)
}

Expand Down Expand Up @@ -114,6 +117,8 @@ export class LinkParserComponent {
imgur: '//imgur.com/favicon.ico',
mangadex: '//mangadex.org/favicon.ico',
telegraph: '//telegra.ph/favicon.ico',
nhentai: '//nhentai.net/favicon.ico',
comick: '//comick.io/favicon.ico',
read: 'data:image/svg+xml,<svg xmlns=%22http://www.w3.org/2000/svg%22 viewBox=%220 0 100 100%22><text y=%22.9em%22 font-size=%2290%22>🗯️</text></svg>'
}

Expand Down
2 changes: 1 addition & 1 deletion src/app/link-parser/ui/footer/footer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const SOCIAL_LINKS: any[] = [
styleUrl: './footer.component.scss'
})
export class FooterComponent {
public readonly version: string = 'v2024.7.14'
public readonly version: string = 'v2024.8.13'
public lang: LangService = inject(LangService);

public social: any[] = SOCIAL_LINKS;
Expand Down
6 changes: 6 additions & 0 deletions src/app/link-parser/utils/comick-link-parser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { LinkParser } from "./link-parser";

export class ComickLinkParser extends LinkParser {
override regex = /comick\.io\/comic\/(?:[\w-]+)\/(\w+)/;
override site = 'comick';
};
3 changes: 2 additions & 1 deletion src/app/link-parser/utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export * from './mangadex-link-parser';
export * from './json-link-parser';
export * from './telegraph-link-parser';
export * from './reddit-link-parser';
export * from './zenko-link-parser';
export * from './zenko-link-parser';
export * from './nhentai-link-parser'
6 changes: 6 additions & 0 deletions src/app/link-parser/utils/nhentai-link-parser.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { LinkParser } from "./link-parser";

export class NhentaiLinkParser extends LinkParser {
override regex = /nhentai\.(?:net|to)\/g\/(\d+)/;
override site = 'nhentai';
};
5 changes: 4 additions & 1 deletion src/app/list/list-shell/list-shell.component.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Component, EffectCleanupRegisterFn, WritableSignal, computed, effect, inject, signal } from '@angular/core';
import { LinkParserService } from '../../link-parser/data-access/link-parser.service';
import { ImgurLinkParser, JsonLinkParser, LinkParser, MangadexLinkParser, RedditLinkParser, TelegraphLinkParser, ZenkoLinkParser } from '../../link-parser/utils';
import { ImgurLinkParser, JsonLinkParser, LinkParser, MangadexLinkParser, NhentaiLinkParser, RedditLinkParser, TelegraphLinkParser, ZenkoLinkParser } from '../../link-parser/utils';
import { DomManipulationService } from '../../shared/data-access';
import { LangService } from '../../shared/data-access/lang.service';
import { ComickLinkParser } from '../../link-parser/utils/comick-link-parser';


@Component({
Expand Down Expand Up @@ -86,6 +87,8 @@ export class ListShellComponent {
this.parser.parsers.push(new TelegraphLinkParser)
this.parser.parsers.push(new RedditLinkParser)
this.parser.parsers.push(new ZenkoLinkParser)
this.parser.parsers.push(new NhentaiLinkParser)
this.parser.parsers.push(new ComickLinkParser)
this.parser.parsers.push(new JsonLinkParser)
}

Expand Down
41 changes: 41 additions & 0 deletions src/app/nhentai/data-access/nhentai.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { HttpClient } from '@angular/common/http';
import { inject, Injectable } from '@angular/core';
import { Observable, map } from 'rxjs';
import { environment } from '../../../environments/environment';
import { CompositionEpisode } from '../../common/common-read';
import { Base64 } from '../../shared/utils';

@Injectable({
providedIn: 'root'
})
export class NhentaiService {
http: HttpClient = inject(HttpClient)

getComposition(id: string): Observable<CompositionEpisode> {
return this.http.get<any>(environment.proxy + Base64.toBase64(environment.nhentaiHost + id))
.pipe(map((data) => { return this.map(data) }))
}

imageType = new Map<string, string>().set('p', 'png').set('j', 'jpg').set('g', 'gif')

map(data: any): CompositionEpisode {
const mediaId = data.media_id;
const mappedResponse = {
title: data.title.pretty,
nsfw: true,
images: (data.images.pages.map((item: any, index: number) => {
return {
src: `https://i7.nhentai.net/galleries/${mediaId}/${index + 1}.${this.imageType.get(item.t)}`,
height: item.h,
width: item.w
};
})).filter((i: any) => i.src)
.map((img: any) => {
return { src: environment.proxy + Base64.toBase64(`${img.src}`) }
})

};

return mappedResponse;
}
}
17 changes: 17 additions & 0 deletions src/app/nhentai/nhentai-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { NgModule } from '@angular/core';
import { RouterModule, Routes } from '@angular/router';
import { NhentaiShellComponent } from './nhentai-shell/nhentai-shell.component';

const routes: Routes = [
{ path: '', redirectTo: '/', pathMatch: 'full' },
{
path: ':id',
component: NhentaiShellComponent
}
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class NhentaiRoutingModule { }
8 changes: 8 additions & 0 deletions src/app/nhentai/nhentai-shell/nhentai-shell.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<app-common-read [episode$]="episode$" [error$]="error$" [loading$]="loading$" (refreshData)="refreshData()"
[playlist]="playlistService.playlist()" [playlistLink]="playlistLink()" [currentPlaylistItem]="currentPlItem()">

<p>{{lang.ph().imagesVia}}<a href="https://nhentai.net" target="_blank" rel="noopener noreferrer">Nhentai</a>
API.
{{lang.ph().thanks}}<br>{{lang.ph().detalisCopy}}</p>

</app-common-read>
Empty file.
39 changes: 39 additions & 0 deletions src/app/nhentai/nhentai-shell/nhentai-shell.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import { Component, inject, OnDestroy } from '@angular/core';
import { NhentaiService } from '../data-access/nhentai.service';
import { switchMap, of } from 'rxjs';
import { NHENTAI_PATH } from '../../app-routing.module';
import { Base64 } from '../../shared/utils';
import { ReadBaseComponent } from '../../common/common-read';

@Component({
selector: 'app-nhentai-shell',
templateUrl: './nhentai-shell.component.html',
styleUrl: './nhentai-shell.component.scss'
})
export class NhentaiShellComponent extends ReadBaseComponent implements OnDestroy {
nhentai = inject(NhentaiService)

override episode$ = this.combineParamMapAndRefresh()
.pipe(this.tapStartLoading(),
switchMap(([params]) => {
const pathParam = params?.get('id');

if (!pathParam) return of(null);

const path = (Base64.isBase64(pathParam)) ? Base64.fromBase64(pathParam) : pathParam;

return (this.nhentai.getComposition(path)).pipe(this.catchError(), this.tapSetTitle(),
this.tapSaveToHistory(NHENTAI_PATH, path),
this.tapSaveToCurrentPlaylistItem(NHENTAI_PATH, path),
this.finalizeLoading());
})
);

constructor() {
super()
}

ngOnDestroy(): void {
this.plObserv?.unsubscribe();
}
}
19 changes: 19 additions & 0 deletions src/app/nhentai/nhentai.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';

import { NhentaiRoutingModule } from './nhentai-routing.module';
import { NhentaiShellComponent } from './nhentai-shell/nhentai-shell.component';
import { CommonReadModule } from '../common/common-read';


@NgModule({
declarations: [
NhentaiShellComponent
],
imports: [
CommonModule,
NhentaiRoutingModule,
CommonReadModule
]
})
export class NhentaiModule { }
2 changes: 1 addition & 1 deletion src/app/shared/ui/viewer/viewer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
[labelDisagree]="lang.ph().nsfwLabelDisagree" />
}
<figure [class]="{nsfw:episode?.nsfw, show: episode?.nsfw && showNsfw()}">
<img [id]="'page_'+(i+1)" [src]="img.src" [alt]="img.alt" [width]="img.width ?? 1000"
<img crossorigin="anonymous" [id]="'page_'+(i+1)" [src]="img.src" [alt]="img.alt" [width]="img.width ?? 1000"
[height]="img.height ?? 1000" [loading]="(i==0 || preLoad(i)) ? 'eager' : 'lazy'">
</figure>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/app/zenko/data-access/zenko.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ export class ZenkoService {

publisher: {
id: data.publisher.id as string,
site: data.publisher.id as string,
site: `https://zenko.online/teams/`+data.publisher.id as string,
name: data.publisher.name as string,
avatar: environment.proxy + Base64.toBase64(`https://zenko.b-cdn.net/${data.publisher.avatar}?optimizer=image&width=900&quality=90&height=auto`) as string,
description: data.publisher.description as string,
links: data.publisher.links.map((l: any) => { return { link: l.link, title: l.title }; })
links: data.publisher.links?.map((l: any) => { return { link: l.link, title: l.title }; })
} as unknown as CompositionPublisher,

images: (data.pages.map((item: any) => {
Expand Down
Loading

0 comments on commit fd0f995

Please sign in to comment.