Skip to content

Commit

Permalink
added subtitle & some bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
wovnep committed Jan 20, 2023
1 parent 1d17e66 commit fb94e05
Show file tree
Hide file tree
Showing 15 changed files with 257 additions and 112 deletions.
1 change: 1 addition & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
name: Release
run-name: ${{ github.ref_name }} release
on:
push:
tags:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
Aniluv is still under development. These are the features currently available on the app.

- Watch anime (Tv shows, Movies, etc.)
- Connect Anilist and manage your anime list
- Connect Anilist and manage your anime list(Login to see manage option.)
- Supports Windows, Linux and macOS
- Search and view anime info
- Get trending/popular releases
Expand Down
162 changes: 81 additions & 81 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "aniluv",
"private": true,
"version": "0.2.0",
"version": "0.3.1",
"author": "wovnep",
"type": "module",
"scripts": {
Expand All @@ -24,7 +24,7 @@
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^2.0.0",
"@tauri-apps/cli": "^1.2.2",
"@tauri-apps/cli": "^1.2.3",
"@tsconfig/svelte": "^3.0.0",
"@types/node": "^18.7.10",
"autoprefixer": "^10.4.13",
Expand Down
2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions src-tauri/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "aniluv"
version = "0.2.0"
version = "0.3.1"
description = "aniluv"
authors = ["wovnep"]
license = "MIT"
Expand All @@ -16,7 +16,7 @@ tauri-build = { version = "1.2", features = [] }
[dependencies]
serde_json = "1.0"
serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.2", features = ["http-all", "shell-open", "window-set-fullscreen"] }
tauri = { version = "1.2", features = ["fs-create-dir", "fs-exists", "fs-read-dir", "fs-read-file", "fs-write-file", "http-all", "path-all", "shell-open", "window-set-fullscreen"] }

[dependencies.tauri-plugin-store]
git = "https://github.com/tauri-apps/tauri-plugin-store"
Expand Down
23 changes: 17 additions & 6 deletions src-tauri/tauri.conf.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,27 +8,38 @@
},
"package": {
"productName": "Aniluv",
"version": "0.2.0"
"version": "0.3.1"
},
"tauri": {
"allowlist": {
"all": false,
"http": {
"all": true,
"request": true,
"scope": ["https://api.consumet.org/*", "https://graphql.anilist.co"]
"scope": ["https://api.consumet.org/*", "https://graphql.anilist.co/*"]
},
"window": {
"setFullscreen": true
},
"shell": {
"open": true
},
"fs": {
"exists": true,
"readFile": true,
"writeFile": true,
"createDir": true,
"readDir": true,
"scope": ["$APPCACHE/**"]
},
"path": {
"all": true
}
},
"bundle": {
"active": true,
"category": "Video",
"copyright": "wovnep",
"copyright": "© 2023 Aniluv",
"deb": {
"depends": []
},
Expand All @@ -40,8 +51,8 @@
"icons/icon.icns",
"icons/icon.ico"
],
"identifier": "aniluv",
"longDescription": "",
"identifier": "dev.wovnep.aniluv",
"longDescription": "A weeb app.",
"macOS": {
"entitlements": null,
"exceptionDomain": "",
Expand All @@ -59,7 +70,7 @@
}
},
"security": {
"csp": null
"csp": null, "devCsp": null
},
"updater": {
"active": false
Expand Down
2 changes: 1 addition & 1 deletion src/components/anilist/AnilistUpdate.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@
</script>

{#if user}
<div class="absolute right-0 mt-1">
<div class="mt-1">
<button on:click="{modaltoggle}" class="rounded-md bg-cyan-500 py-2 px-3 text-sm"> UPDATE LIST </button>
</div>
{:else}
Expand Down
33 changes: 33 additions & 0 deletions src/components/languages/ToggleLang.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<script lang="ts">
import { onMount } from "svelte";
import { store } from "../../lib/anilist/anilist-login";
export let isToggle = false;
const changeHandler = (e: any) => {
window.location.reload();
if (e.currentTarget.checked) {
store.set("lang", "all");
} else {
store.set("lang", "en");
}
};
onMount(async () => {
const lang = await store.get("lang");
if (lang === "all") {
isToggle = true;
} else {
isToggle = false;
}
});
</script>

<div class="flex h-full items-center text-center">
<div class="mr-1 text-sm font-thin">en</div>
<label class="relative inline-block h-5 w-10 rounded-full">
<input on:change="{changeHandler}" checked="{isToggle}" type="checkbox" class="peer h-0 w-0 opacity-0" />
<span
class="absolute top-0 left-0 right-0 bottom-0 cursor-pointer rounded-full bg-darker duration-300
before:absolute before:bottom-1 before:left-1 before:h-3 before:w-3 before:rounded-full before:bg-white
before:duration-300 before:content-[''] peer-checked:before:translate-x-5">
</span>
</label>
</div>
8 changes: 4 additions & 4 deletions src/components/suggestions/TvIndexCard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@
{#if params.index && params.index == i}
<div class="h-full w-full rounded-2xl px-5 text-start text-white backdrop-blur-[1px] backdrop-brightness-[.1]">
<div class="title pt-5 font-extrabold">
[{episodes.number}] {episodes.title}
[{episodes.number}] {episodes.title ? episodes.title : ""}
</div>
<div class="description mt-5 text-sm font-thin">
{episodes.description}
{episodes.description ? episodes.description : ""}
</div>
</div>
{:else}
<a href="/watch/{anime.id}/{i}" use:link>
<div class="h-full w-full rounded-2xl px-5 text-start text-white backdrop-blur-[1px] backdrop-brightness-50 hover:backdrop-brightness-[.7]">
<div class="title pt-5 font-extrabold">
[{episodes.number}] {episodes.title}
[{episodes.number}] {episodes.title ? episodes.title : ""}
</div>
<div class="description mt-5 text-sm font-thin">
{episodes.description}
{episodes.description ? episodes.description : ""}
</div>
</div>
</a>
Expand Down
8 changes: 7 additions & 1 deletion src/lib/gogo/gogo-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ export const getPopular = async () => {
});
return response.data;
};
export const getInfo = async (id: string) => {
export const getInfo = async (id: string, isZoro: boolean) => {
const client = await getClient();
const response = await client.request<InfoResponse>({
method: "GET",
url: `${baseURL}/info/${id}`,
query: {
provider: isZoro ? "zoro" : "gogoanime",
},
responseType: ResponseType.JSON,
});
return response.data;
Expand All @@ -43,6 +46,9 @@ export const getEpisode = async (epid: string) => {
const response = await client.request<EpisodeResponse>({
method: "GET",
url: `${baseURL}/watch/${epid}`,
query: {
provider: "gogoanime",
},
responseType: ResponseType.JSON,
});
const source = response.data.sources.filter((source) => source.quality == "default");
Expand Down
6 changes: 6 additions & 0 deletions src/lib/gogo/gogo-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,10 @@ export interface EpisodeResponse {
quality: string;
}
];
subtitles: [
{
lang: string;
url: string;
}
];
}
63 changes: 63 additions & 0 deletions src/lib/player/subtitles.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
import { extname, join } from "@tauri-apps/api/path";
import { BaseDirectory, exists, createDir, readDir, writeBinaryFile, readBinaryFile } from "@tauri-apps/api/fs";
import { getClient, ResponseType } from "@tauri-apps/api/http";
const baseURL = "https://api.consumet.org/meta/anilist/watch/";

interface ZoroQuery {
sources: [
{
url: string;
quality: string;
}
];
subtitles: [
{
url: string;
lang: string;
}
];
}
export const getSubtitle = async (epid: string) => {
const basePath = await join("subtitles", epid);
let finalList = [];
if (await exists(basePath, { dir: BaseDirectory.AppCache })) {
const dirList = await readDir(basePath, { dir: BaseDirectory.AppCache });
for (let i = 0; i < dirList.length; i++) {
if ((await extname(dirList[i].path)) === "vtt") {
const binaryData = await readBinaryFile(dirList[i].path);
const language = dirList[i].name.split(".vtt")[0];
finalList.push({
lang: language,
url: URL.createObjectURL(new Blob([binaryData], { type: "text/vtt" })),
});
}
}
} else {
await createDir(basePath, { dir: BaseDirectory.AppCache, recursive: true });
const client = await getClient();
const response = await client.request<ZoroQuery>({
method: "GET",
url: baseURL + epid,
query: {
provider: "zoro",
},
responseType: ResponseType.JSON,
});
const subtitleList = response.data.subtitles.filter((subtitle) => subtitle.lang !== "Thumbnails");
for (let i = 0; i < subtitleList.length; i++) {
const removeLangSpace = subtitleList[i].lang.split(" ")[0];
const res = await fetch(subtitleList[i].url);
const text = await res.text();
const blob = new Blob([text], {
type: "text/vtt",
});
const path = await join(basePath, removeLangSpace + ".vtt");
await writeBinaryFile(path, await blob.arrayBuffer(), { dir: BaseDirectory.AppCache });
finalList.push({
lang: removeLangSpace,
url: URL.createObjectURL(blob),
});
}
}
return finalList;
};
47 changes: 36 additions & 11 deletions src/routes/Player.svelte
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
<script lang="ts">
import { Player, Hls, DefaultUi } from "@vime/svelte";
import { Player, Hls, DefaultUi, Captions } from "@vime/svelte";
import { getInfo, getEpisode } from "../lib/gogo/gogo-client";
import { getSubtitle } from "../lib/player/subtitles";
import { link } from "svelte-spa-router";
import { appWindow } from "@tauri-apps/api/window";
import { createQuery } from "@tanstack/svelte-query";
import TvIndexCard from "../components/suggestions/TvIndexCard.svelte";
import OtherIndexCard from "../components/suggestions/OtherIndexCard.svelte";
import AnilistUpdate from "../components/anilist/AnilistUpdate.svelte";
import Loading from "../components/handling/Loading.svelte";
import ToggleLang from "../components/languages/ToggleLang.svelte";
import Error from "../components/handling/Error.svelte";
interface Parameters {
id: string;
index: number;
}
export let params: Parameters;
const info = createQuery({
let isToggle = false;
$: info = createQuery({
queryKey: [params.id],
queryFn: () => getInfo(params.id),
queryFn: () => getInfo(params.id, false),
});
$: zoroInfo = createQuery({
queryKey: [params.id + "_zoro"],
queryFn: () => getInfo(params.id, true),
});
const setFullscreen = async (e: any) => {
if (e.detail) {
Expand All @@ -29,9 +37,7 @@
{#if $info.isLoading}
<Loading index="2" />
{:else if $info.isError}
<div class="absolute right-0 left-0 top-0 bottom-0 ">
{$info.error}
</div>
<Error />
{:else if $info.isSuccess}
<div>
<a href="/" use:link>
Expand All @@ -46,14 +52,33 @@
<div class="bg-black w-full pt-[56.25%]"></div>
{:then episodes}
<Player theme="dark" style="--vm-player-theme: #555555; --vm-player-bg: #000000;" on:vmFullscreenChange="{setFullscreen}">
<Hls>
<source data-src="{episodes.url}" type="application/x-mpegURL" />
</Hls>
<DefaultUi noSpinner noCaptions />
{#if isToggle}
{#await getSubtitle($zoroInfo.data.episodes[params.index].id)}
<div class="bg-black w-full pt-[56.25%]"></div>
{:then subtitles}
<Hls>
<source data-src="{episodes.url}" type="application/x-mpegURL" />
{#each subtitles as subtitle}
<track kind="subtitles" src="{subtitle.url}" srclang="" label="{subtitle.lang}" />
{/each}
</Hls>
<DefaultUi noSpinner noCaptions>
<Captions style="--vm-captions-z-index: 10; --vm-captions-cue-bg-color: #000000; --vm-captions-cue-border-radius: 1px; --vm-captions-cue-padding: 10px; --vm-captions-text-color: #FFFFFF;" />
</DefaultUi>
{/await}
{:else}
<Hls>
<source data-src="{episodes.url}" type="application/x-mpegURL" />
</Hls>
<DefaultUi noSpinner noCaptions />
{/if}
</Player>
{/await}
<div>
<AnilistUpdate anime="{$info.data}" id="{params.id}" />
<div class="absolute right-0 flex items-center justify-between gap-2">
<ToggleLang bind:isToggle="{isToggle}" />
<AnilistUpdate anime="{$info.data}" id="{params.id}" />
</div>
<div class="mt-2 text-start text-2xl font-bold tracking-wide">
{#if $info.data.title.english}
{$info.data.title.english}
Expand Down
4 changes: 2 additions & 2 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@
border-radius: 100px;
}
::-webkit-scrollbar-thumb:vertical {
background: #121212;
background: rgb(0 0 0 / 100%);
border-radius: 100px;
}
::-webkit-scrollbar-thumb:horizontal {
background: #121212;
background: rgb(0 0 0 / 100%);
border-radius: 100px;
}

0 comments on commit fb94e05

Please sign in to comment.