-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from chytanka/develop
feat: pixiv
- Loading branch information
Showing
15 changed files
with
170 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import { LinkParser } from "./link-parser"; | ||
|
||
export class PixivLinkParser extends LinkParser { | ||
override regex = /pixiv\.net\/(?:en\/)?artworks\/(\d+)/; | ||
override site = 'pixiv'; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
import { HttpClient } from '@angular/common/http'; | ||
import { inject, Injectable } from '@angular/core'; | ||
import { Observable, map } from 'rxjs'; | ||
import { environment } from '../../../environments/environment'; | ||
import { CompositionEpisode, CompositionPublisher } from '../../common/common-read'; | ||
import { Base64 } from '../../shared/utils'; | ||
|
||
@Injectable({ | ||
providedIn: 'root' | ||
}) | ||
export class PixivService { | ||
http: HttpClient = inject(HttpClient) | ||
|
||
getComposition(id: string): Observable<CompositionEpisode> { | ||
return this.http.get<any>(environment.proxy + Base64.toBase64(environment.pixivHost + id)) | ||
.pipe(map((data) => { return this.map(data.body) })) | ||
} | ||
|
||
map(data: any): CompositionEpisode { | ||
|
||
const mappedResponse = { | ||
title: data.illust_details.title, | ||
nsfw: data.illust_details.tags.includes('R-18'), | ||
publisher: { | ||
id: data.author_details.user_id as string, | ||
site: `https://pixiv.net/en/users/` + data.author_details.user_id as string, | ||
name: data.author_details.user_name as string, | ||
avatar: environment.proxy + Base64.toBase64(data.author_details.profile_img.main) + '&ref=https://www.pixiv.net' as string, | ||
description: '', | ||
links: [] | ||
} as unknown as CompositionPublisher, | ||
|
||
images: (data.illust_details.manga_a ? data.illust_details.manga_a.map((item: any, index: number) => { | ||
return { | ||
src: item.url, | ||
width: data.illust_details.illust_images[index].illust_image_width, | ||
height: data.illust_details.illust_images[index].illust_image_height | ||
}; | ||
}) : [ | ||
{ | ||
src: data.illust_details.url, | ||
width: data.illust_details.illust_images[0].illust_image_width, | ||
height: data.illust_details.illust_images[0].illust_image_height | ||
} | ||
]) | ||
|
||
.filter((i: any) => i.src).map((img: any) => { | ||
return { | ||
src: environment.proxy + Base64.toBase64(img.src) + '&ref=https://www.pixiv.net', | ||
width: img.width, | ||
height: img.height | ||
} | ||
}) | ||
|
||
}; | ||
// ugoira_meta.frames for animation | ||
return mappedResponse; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { PixivShellComponent } from './pixiv-shell/pixiv-shell.component'; | ||
|
||
const routes: Routes = [ | ||
{ path: '', redirectTo: '/', pathMatch: 'full' }, | ||
{ | ||
path: ':id', | ||
component: PixivShellComponent | ||
} | ||
]; | ||
|
||
@NgModule({ | ||
imports: [RouterModule.forChild(routes)], | ||
exports: [RouterModule] | ||
}) | ||
export class PixivRoutingModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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://pixiv.net" target="_blank" rel="noopener noreferrer">Pixiv</a> | ||
API. | ||
{{lang.ph().thanks}}<br>{{lang.ph().detalisCopy}}</p> | ||
|
||
</app-common-read> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Component, inject, OnDestroy } from '@angular/core'; | ||
import { PixivService } from '../data-access/pixiv.service'; | ||
import { PIXIV_PATH } from '../../app-routing.module'; | ||
import { switchMap, of } from 'rxjs'; | ||
import { ReadBaseComponent } from '../../common/common-read'; | ||
import { Base64 } from '../../shared/utils'; | ||
|
||
@Component({ | ||
selector: 'app-pixiv-shell', | ||
templateUrl: './pixiv-shell.component.html', | ||
styleUrl: './pixiv-shell.component.scss' | ||
}) | ||
export class PixivShellComponent extends ReadBaseComponent implements OnDestroy { | ||
pixiv = inject(PixivService) | ||
|
||
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.pixiv.getComposition(path)).pipe(this.catchError(), this.tapSetTitle(), | ||
this.tapSaveToHistory(PIXIV_PATH, path), | ||
this.tapSaveToCurrentPlaylistItem(PIXIV_PATH, path), | ||
this.finalizeLoading()); | ||
}) | ||
); | ||
|
||
constructor() { | ||
super() | ||
} | ||
|
||
ngOnDestroy(): void { | ||
this.plObserv?.unsubscribe(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { PixivRoutingModule } from './pixiv-routing.module'; | ||
import { CommonReadModule } from '../common/common-read'; | ||
import { PixivShellComponent } from './pixiv-shell/pixiv-shell.component'; | ||
|
||
|
||
@NgModule({ | ||
declarations: [ | ||
PixivShellComponent | ||
], | ||
imports: [ | ||
CommonModule, | ||
PixivRoutingModule, | ||
CommonReadModule | ||
] | ||
}) | ||
export class PixivModule { } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters