Skip to content

Commit

Permalink
Refactor APIs and Proxy (#152)
Browse files Browse the repository at this point in the history
* refactor: restructure api calls

* lint: format with prettier

* fix: tv text

* lint: correct linting on command-search

* fix: carousel types
  • Loading branch information
ctrlsam authored Nov 3, 2024
1 parent d3bb15d commit c7bacb8
Show file tree
Hide file tree
Showing 145 changed files with 6,660 additions and 6,381 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "next/core-web-vitals"
"extends": ["next/core-web-vitals", "plugin:prettier/recommended"]
}
6 changes: 3 additions & 3 deletions .github/ISSUE_TEMPLATE/bug_report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ body:
description: Got more details or a screenshot? Throw them in here.
placeholder: 'FYI: This only happens in Chrome for me...'
validations:
required: false
required: false

- type: dropdown
id: browsers-affected
Expand All @@ -60,12 +60,12 @@ body:
description: If you've got some techy details or logs, we'd love to see them.
render: shell
validations:
required: false
required: false

- type: checkboxes
id: code-of-conduct
attributes:
label: Code of Conduct Agreement
options:
- label: I agree to follow this project's Code of Conduct.
required: true
required: true
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
<!-- Explain the **motivation** for making this change. What existing problem does the pull request solve? -->
<!-- Try to link to an open issue for more information. -->

**Other information**
**Other information**
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ updates:
- package-ecosystem: 'npm' # See documentation for possible values
directory: '/' # Location of package manifests
schedule:
interval: 'weekly'
interval: 'weekly'
10 changes: 10 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"$schema": "https://json.schemastore.org/prettierrc",
"singleQuote": true,
"trailingComma": "all",
"semi": true,
"bracketSpacing": true,
"tabWidth": 2,
"printWidth": 100,
"plugins": ["prettier-plugin-tailwindcss"]
}
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,19 +63,17 @@ npm install
```

### Go to the 'config` folder and edit the values as per your requirement or leave them as it is

Add a ENV FILE with:

```env
DOWNLOAD_API_URL=https://v1.api.ani.rohi.dev/api/dramacool
CONSUMET_API_URL=https://consumet_api_url (deploy your own with the instructions below, dont end with slash)
CONSUMET_API_ANILIST_URL=https://consumet_api_url/meta/anilist (MENTION meta/anilist)
TMDB_PROXY_URL=https://sup-proxy.zephex0-f6c.workers.dev (optional - deploy your own with the instructions below, dont end with slash)
TMDB_API_KEY=(get your own api key with the instructions below)
```

<a href="https://github.com/avalynndev/animetize-api">Deploy your own Consumet API</a>

<a href="https://github.com/real-zephex/Good-Proxy">Deploy your own TMDB Proxy</a>

<a href="https://www.themoviedb.org/settings/api/request">Get your own TMDB api key here after registering</a>

### 3. Run on development &/or production
Expand All @@ -96,7 +94,6 @@ npm start
[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Favalynndev%2Fenjoytown&env=DOWNLOAD_API_URL,CONSUMET_API_URL,CONSUMET_API_ANILIST_URL,TMDB_PROXY_URL)


## Found a Bug? 🐞

Uh-oh, looks like you stumbled upon a bug? No worries, we're here to squash it! Just head over to our [**issues**](https://github.com/avalynndev/enjoytown/issues) section on GitHub and let us know what's up.
Expand All @@ -109,5 +106,4 @@ Uh-oh, looks like you stumbled upon a bug? No worries, we're here to squash it!

Feel free to contribute to this project! Whether you're an experienced developer or have been in the field for a while, your help is valuable.


[![Star History Chart](https://api.star-history.com/svg?repos=avalynndev/enjoytown&type=Date)](https://star-history.com/embed?secret=#avalynndev/enjoytown&Date)
6 changes: 3 additions & 3 deletions app/anime/[id]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import DetailsContainer from "@/components/containers/anime/details";
import Gogoanime from "@consumet/extensions/dist/providers/anime/gogoanime";
import Anilist from "@consumet/extensions/dist/providers/meta/anilist";
import DetailsContainer from '@/components/containers/anime/details';
import Gogoanime from '@consumet/extensions/dist/providers/anime/gogoanime';
import Anilist from '@consumet/extensions/dist/providers/meta/anilist';

export default async function Info({ params }: any) {
const id = params.id;
Expand Down
34 changes: 15 additions & 19 deletions app/anime/page.tsx
Original file line number Diff line number Diff line change
@@ -1,57 +1,53 @@
import FeaturedAnime from "@/components/featured/anime";
import Carousal from "@/components/carousal/anime";
import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs";
import FeaturedAnime from '@/components/featured/anime';
import Carousal from '@/components/carousal/anime';
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';

export default function Home() {
return (
<>
<section className="container grid items-center gap-6 pb-8 pt-6 md:py-10">
<Carousal />
<Tabs defaultValue="trending" className="w-full">
<TabsList className="w-full grid grid-cols-3 pb-4">
<TabsList className="grid w-full grid-cols-3 pb-4">
<TabsTrigger value="trending">Trending</TabsTrigger>
<TabsTrigger value="popular">Popular</TabsTrigger>
<TabsTrigger value="recent">Recent</TabsTrigger>
</TabsList>
<TabsContent value="trending">
<div className="flex items-center justify-between gap-2 pb-4 py-4">
<div className="flex items-center justify-between gap-2 py-4 pb-4">
<div>
<h1 className="text-2xl font-mono leading-tight tracking-tighter md:text-4x font-bold">
<h1 className="md:text-4x font-mono text-2xl font-bold leading-tight tracking-tighter">
Trending Anime
</h1>

<p className="text-muted-foreground">
Anime ordered by trending.
</p>
<p className="text-muted-foreground">Anime ordered by trending.</p>
</div>
</div>
<FeaturedAnime featureType="trending"/>
<FeaturedAnime featureType="trending" />
</TabsContent>
<TabsContent value="popular">
<div className="flex items-center justify-between gap-2 pb-4 py-4">
<div className="flex items-center justify-between gap-2 py-4 pb-4">
<div>
<h1 className="text-2xl font-mono leading-tight tracking-tighter md:text-4x font-bold">
<h1 className="md:text-4x font-mono text-2xl font-bold leading-tight tracking-tighter">
Popular Anime
</h1>

<p className="text-muted-foreground">
Anime that are all-time popular.
</p>
<p className="text-muted-foreground">Anime that are all-time popular.</p>
</div>
</div>
<FeaturedAnime featureType="popular"/>
<FeaturedAnime featureType="popular" />
</TabsContent>
<TabsContent value="recent">
<div className="flex items-center justify-between gap-2 pb-4 py-4">
<div className="flex items-center justify-between gap-2 py-4 pb-4">
<div>
<h1 className="text-2xl font-mono leading-tight tracking-tighter md:text-4x font-bold">
<h1 className="md:text-4x font-mono text-2xl font-bold leading-tight tracking-tighter">
Recent Episodes
</h1>

<p className="text-muted-foreground">Episodes released recently</p>
</div>
</div>
<FeaturedAnime featureType="recent"/>
<FeaturedAnime featureType="recent" />
</TabsContent>
</Tabs>
</section>
Expand Down
47 changes: 19 additions & 28 deletions app/anime/watch/[id]/[episode]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,23 @@
import Link from "next/link";
import DetailsContainer from "@/components/containers/anime/details";
import Gogoanime from "@consumet/extensions/dist/providers/anime/gogoanime";
import Anilist from "@consumet/extensions/dist/providers/meta/anilist";
import { Badge } from "@/components/ui/badge";
import { Download } from "lucide-react";
import Link from 'next/link';
import DetailsContainer from '@/components/containers/anime/details';
import Gogoanime from '@consumet/extensions/dist/providers/anime/gogoanime';
import Anilist from '@consumet/extensions/dist/providers/meta/anilist';
import { Badge } from '@/components/ui/badge';
import { Download } from 'lucide-react';
import {
Breadcrumb,
BreadcrumbItem,
BreadcrumbLink,
BreadcrumbList,
BreadcrumbPage,
BreadcrumbSeparator,
} from "@/components/ui/breadcrumb";
import WatchContainer from "@/components/containers/anime/watch";
} from '@/components/ui/breadcrumb';
import WatchContainer from '@/components/containers/anime/watch';

import { MediaPlayer, MediaProvider } from "@vidstack/react";
import {
defaultLayoutIcons,
DefaultVideoLayout,
} from "@vidstack/react/player/layouts/default";
import "@vidstack/react/player/styles/default/theme.css";
import "@vidstack/react/player/styles/default/layouts/video.css";
import { MediaPlayer, MediaProvider } from '@vidstack/react';
import { defaultLayoutIcons, DefaultVideoLayout } from '@vidstack/react/player/layouts/default';
import '@vidstack/react/player/styles/default/theme.css';
import '@vidstack/react/player/styles/default/layouts/video.css';

interface WatchDataSources {
url: string;
Expand All @@ -38,24 +35,21 @@ export default async function Watch({ params }: any) {
return urlObj.toString();
}

const cleanedUrl = removeQueryParams(data.download || "", [
"token",
"expires",
]);
const cleanedUrl = removeQueryParams(data.download || '', ['token', 'expires']);
const defaultSourceUrl =
data.sources
.map((value: any) => {
const source = value as WatchDataSources;
if (source.quality === "default") {
if (source.quality === 'default') {
return source.url;
}
return null;
})
.filter((url: string | null) => url !== null)[0] || undefined;
return (
<div className="max-w-6xl pb-1 mx-auto px-4 pt-10">
<div className="mx-auto max-w-6xl px-4 pb-1 pt-10">
<div className="pb-4">
<div className="flex flex-col text-center items-center justify-center">
<div className="flex flex-col items-center justify-center text-center">
<div className="flex flex-col flex-wrap pb-2">
<Breadcrumb>
<BreadcrumbList>
Expand All @@ -73,22 +67,19 @@ export default async function Watch({ params }: any) {
</div>
</div>
</div>
<div className="flex flex-row items-center justify-center w-full">
<div className="flex w-full flex-row items-center justify-center">
<div className="flex flex-col text-center">
<div className="pb-2">
<Link href={cleanedUrl}>
<Badge
variant="outline"
className="cursor-pointer whitespace-nowrap"
>
<Badge variant="outline" className="cursor-pointer whitespace-nowrap">
<Download className="mr-1.5" size={12} />
Download Episode
</Badge>
</Link>
</div>
</div>
</div>
<div className="max-w-4xl mx-auto flex">
<div className="mx-auto flex max-w-4xl">
<MediaPlayer src={defaultSourceUrl}>
<MediaProvider />
<DefaultVideoLayout icons={defaultLayoutIcons} />
Expand Down
Loading

0 comments on commit c7bacb8

Please sign in to comment.