-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
257 additions
and
112 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
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: | ||
|
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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,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> |
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 |
---|---|---|
|
@@ -187,4 +187,10 @@ export interface EpisodeResponse { | |
quality: string; | ||
} | ||
]; | ||
subtitles: [ | ||
{ | ||
lang: string; | ||
url: string; | ||
} | ||
]; | ||
} |
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,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; | ||
}; |
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