attempt to fix images

This commit is contained in:
Daniel Bulant 2022-09-20 19:59:39 +02:00 committed by GitHub
parent 44b3e042bb
commit 17d3b61fa4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 9 additions and 6 deletions

View file

@ -1,6 +1,7 @@
<script>
import SvelteMarkdown from "svelte-markdown";
import autoAnimate from "@formkit/auto-animate";
import { imageproxy } from "../utils/request";
export var entries;
export var itemsList;
@ -17,7 +18,7 @@
<a href="/{entry.id}" class="item" class:r18={!["safe", "suggestive"].includes(entry.attributes.contentRating)} on:click={() => open(entry)}>
<div class="flex">
{#if entry.relationships.find(t => t.type === "cover_art")}
<img class="cover" draggable="false" src="https://cors-anywhere.danbulant.cloud/https://uploads.mangadex.org/covers/{entry.id}/{entry.relationships.find(t => t.type === "cover_art").attributes.fileName}.512.jpg" alt="{title}" {title}>
<img class="cover" draggable="false" src="{imageproxy}/https://uploads.mangadex.org/covers/{entry.id}/{entry.relationships.find(t => t.type === "cover_art").attributes.fileName}.512.jpg" alt="{title}" {title}>
{:else}
Broken art
{/if}

View file

@ -1,5 +1,6 @@
<script>
import { goto, url } from "@roxi/routify/runtime/helpers";
import { imageproxy } from "../../../util/request";
export var page;
export var scoped;
@ -189,7 +190,7 @@
<a class="back" href={$url("../..")}>Back to chapter list</a>
</div>
<img draggable={false} bind:this={image} style="height: {actualHeight}px" on:load={loaded} on:touchstart={handleTouchStart} on:touchmove={handleTouchMove} on:mousedown={mouseclick} on:mouseup={preventDefault} src={`https://cors-anywhere.danbulant.cloud/${atHome.baseUrl}/${quality}/${atHome.chapter.hash}/${atHome.chapter[quality][page - 1]}`} alt="Page {page} in chapter {chapter.attributes.chapter} of {manga.title.en}">
<img draggable={false} bind:this={image} style="height: {actualHeight}px" on:load={loaded} on:touchstart={handleTouchStart} on:touchmove={handleTouchMove} on:mousedown={mouseclick} on:mouseup={preventDefault} src={`${imageproxy}/${atHome.baseUrl}/${quality}/${atHome.chapter.hash}/${atHome.chapter[quality][page - 1]}`} alt="Page {page} in chapter {chapter.attributes.chapter} of {manga.title.en}">
<div class="bottom">
{#if page > 1}

View file

@ -3,7 +3,7 @@
import Chapter from "../../components/chapter.svelte";
import { EpubGenerator } from "../../util/generateEpub";
import { CBZGenerator } from "../../util/generateCbz";
import request from "../../util/request";
import request, { imageproxy } from "../../util/request";
import { BaseGenerator } from "../../util/baseGenerator";
import { arraysEqual } from "../../util/arrays";
import { makeRequest } from "../../util/anilist";
@ -306,7 +306,7 @@
<div class="flex">
{#if relationships.find(t => t.type === "cover_art")}
<img class="cover" class:r18={!["safe", "suggestive"].includes(manga.contentRating)} draggable="false" src="https://uploads.mangadex.org/covers/{mangaId}/{relationships.find(t => t.type === "cover_art").attributes.fileName}.512.jpg" alt="" on:click={() => selectedImage = `https://uploads.mangadex.org/covers/${mangaId}/${relationships.find(t => t.type === "cover_art").attributes.fileName}.512.jpg`}>
<img class="cover" class:r18={!["safe", "suggestive"].includes(manga.contentRating)} draggable="false" src="{imageproxy}https://uploads.mangadex.org/covers/{mangaId}/{relationships.find(t => t.type === "cover_art").attributes.fileName}.512.jpg" alt="" on:click={() => selectedImage = `https://uploads.mangadex.org/covers/${mangaId}/${relationships.find(t => t.type === "cover_art").attributes.fileName}.512.jpg`}>
{/if}
<div class="info">
{#if relationships.find(t => t.type === "author")}

View file

@ -10,7 +10,7 @@
* @property {string} title
*/
import request, { proxy } from "./request";
import request, { proxy, imageproxy } from "./request";
const RETRY_LIMIT = 10;
@ -62,7 +62,7 @@ export class BaseGenerator {
async fetchImage(url, chapter) {
var res;
try {
res = await fetch("https://cors-anywhere.danbulant.cloud/" + url);
res = await fetch(imageproxy + url);
} catch(e) {
console.error(e);
res = await fetch(proxy + url);

View file

@ -1,4 +1,5 @@
export const proxy = "https://cors-anywhere.danbulant.cloud/";
export const imageproxy = "https://cors-anywhere.danbulant.workers.dev/";
export const base = proxy + "https://api.mangadex.org/";
function request(endpoint, query, type = "GET", body) {