Skip to content
This repository was archived by the owner on Jul 14, 2024. It is now read-only.

Commit bdd560a

Browse files
DevanAbinayaartrixdotdevAijazmakerb
authored
Update v4.4.0 - Finale - Merged Branch beta to main (#121)
* migrate to typescript * feat: Implement a way to review/rate anime (#108) * Make details cover lead back to anime page * Make 'markProgress' use object instead of param list * Import Link * Implement Rate modal * Pass session into useAniList Co-authored-by: Factiven <[email protected]> * Reimplement using markComplete & add toast for failure * redefined ratemodal * fix: home page client error * update version --------- Co-authored-by: Factiven <[email protected]> * Update changelogs version to v4.4.0 * feat: Add PreviousEpisode and NextEpisode to media controls (#111) * Make details cover lead back to anime page * Make 'markProgress' use object instead of param list * Import Link * Implement Rate modal * Pass session into useAniList Co-authored-by: Factiven <[email protected]> * Reimplement using markComplete & add toast for failure * redefined ratemodal * fix: home page client error * update version * Update version to v4.4.0 in changelogs.tsx * Implement next and previous buttons to video controls * fix subtitle button bugs --------- Co-authored-by: Factiven <[email protected]> * Add getRemovedMedia function and handle redirect for removed media * redesign: Redesign schedules page (#112) * Remove trailing commas * Polish schedules page & Remove unneeded styles * Add scroll animations * Add scrolling animation to time view * Refactor schedule page layout and styling --------- Co-authored-by: Factiven <[email protected]> * Added seeking buttons and fixed vercel error (#113) * readded seek buttons and vercel support * Redesign player layout on mobile and fix seek button * Update changelogs and player buttons --------- Co-authored-by: Factiven <[email protected]> * Refactor episode fetching and data formatting * v4.4.0 - Finale * update .env.example --------- Co-authored-by: Artrix <[email protected]> Co-authored-by: A i j a Z <[email protected]>
1 parent cd08c2e commit bdd560a

File tree

135 files changed

+7724
-3243
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

135 files changed

+7724
-3243
lines changed

.env.example

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,15 @@
1-
## AniList
21
CLIENT_ID="get the id from here https://anilist.co/settings/developer"
32
CLIENT_SECRET="get the secret from here https://anilist.co/settings/developer"
43
GRAPHQL_ENDPOINT="https://graphql.anilist.co"
54

6-
## NextAuth
75
NEXTAUTH_SECRET='run this cmd in your bash terminal (openssl rand -base64 32) with no bracket, and paste it here'
86
NEXTAUTH_URL="for development use http://localhost:3000/ and for production use your domain url"
9-
10-
## NextJS
11-
PROXY_URI="This is what I use for proxying video https://github.com/chaycee/M3U8Proxy. Don't put / at the end of the url."
12-
API_URI="host your own API from this repo https://github.com/consumet/api.consumet.org. Don't put / at the end of the url."
137
DISQUS_SHORTNAME='put your disqus shortname here (optional)'
14-
# ADMIN_USERNAME=""
8+
# ADMIN_USERNAME="Your AniList account username"
159

16-
## Prisma
17-
DATABASE_URL="Your postgresql connection url"
10+
## Use any postgresql db, or supabase for free options
11+
DATABASE_URL="postgresql://user:password@host:6543/postgres?pgbouncer=true"
12+
DIRECT_URL="postgresql://user:password@host:5432/postgres"
1813

19-
## Redis
2014
# If you don't want to use redis, just comment the REDIS_URL (press ctrl + / on windows or cmd + / on mac)
21-
REDIS_URL="redis://username:password@host:port"
15+
REDIS_URL="redis://user:password@host:port"

.gitignore

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,11 @@
88

99
# testing
1010
/coverage
11-
/pages/en/test.js
11+
/pages/en/test.tsx
12+
/pages/en/test-player.tsx
1213
/components/devComp
14+
/components/test
15+
/pages/en/w2g.tsx
1316

1417
# next.js
1518
/.next/
@@ -27,6 +30,8 @@ docker-compose.yml
2730
/assets/dummyData.json
2831
/backup
2932
release-template.md
33+
.vscode
34+
pnpm-lock.yaml
3035

3136
# debug
3237
npm-debug.log*

.prettierrc.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"bracketSpacing": true,
3-
"printWidth": 80
3+
"printWidth": 80,
4+
"trailingComma": "none"
45
}

README.md

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,17 @@
2626

2727
</p>
2828

29+
> [!WARNING]
30+
>
31+
> As of Jul 14 2024, this repository is no longer maintained and will not receive any further updates or support from the author. If you choose to use the code in this repository, please do so at your own risk.
32+
>
33+
> ### Important Points:
34+
> - **No Updates**: There will be no further updates or improvements made to this repository.
35+
> - **No Support**: The author will not provide any support, fixes, or acknowledge any issues found in the code.
36+
> - **Use at Your Own Risk**: Any errors, bugs, or other issues that arise from using this code are your responsibility.
37+
>
38+
> Thank you for your understanding.
39+
2940
<p align="center">
3041
<img src="https://github.com/Ani-Moopa/Moopa/assets/97084324/c17d5d6a-36a2-4d08-957d-ad4683dcdf0d" alt="main">
3142
</p>
@@ -56,7 +67,7 @@
5667

5768
</details>
5869

59-
> **Warning:** If you are not familiar with JavaScript or any other programming language related to this project, please learn it first before attempting to work on this project. **I won't be able to help anyone who doesn't know how to do basic stuff.**
70+
> **Warning:** If you are not familiar with JavaScript or any other programming language related to this project, please learn it first before attempting to work on this project. **I won't help anyone who doesn't know how to do basic stuff.**
6071
6172
## Introduction
6273

@@ -117,26 +128,20 @@ npm install
117128
3. Create `.env` file in the root folder and put this inside the file :
118129

119130
```bash
120-
## AniList
121131
CLIENT_ID="get the id from here https://anilist.co/settings/developer"
122132
CLIENT_SECRET="get the secret from here https://anilist.co/settings/developer"
123133
GRAPHQL_ENDPOINT="https://graphql.anilist.co"
124134

125-
## NextAuth
126135
NEXTAUTH_SECRET='run this cmd in your bash terminal (openssl rand -base64 32) with no bracket, and paste it here'
127136
NEXTAUTH_URL="for development use http://localhost:3000/ and for production use your domain url"
128-
129-
## NextJS
130-
PROXY_URI="This is what I use for proxying video https://github.com/chaycee/M3U8Proxy. Don't put / at the end of the url."
131-
API_URI="host your own API from this repo https://github.com/consumet/api.consumet.org. Don't put / at the end of the url."
132137
DISQUS_SHORTNAME='put your disqus shortname here (optional)'
133138

134-
## Prisma
135-
DATABASE_URL="Your postgresql connection url"
139+
## Use any postgresql db, or supabase for free options
140+
DATABASE_URL="postgresql://user:password@host:6543/postgres?pgbouncer=true"
141+
DIRECT_URL="postgresql://user:password@host:5432/postgres"
136142

137-
## Redis
138143
# If you don't want to use redis, just comment the REDIS_URL (press ctrl + / on windows or cmd + / on mac)
139-
REDIS_URL="rediss://username:password@host:port"
144+
REDIS_URL="redis://user:password@host:port"
140145
```
141146

142147
4. Add this endpoint as Redirect Url on AniList Developer :

components/anime/episode.js

Lines changed: 54 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,45 @@ import ThumbnailDetail from "./viewMode/thumbnailDetail";
66
import ListMode from "./viewMode/listMode";
77
import { toast } from "sonner";
88

9-
function allProvider(response, setMapProviders, setProviderId) {
10-
const getMap = response.find((i) => i?.map === true);
11-
let allProvider = response;
9+
const ITEMS_PER_PAGE = 13;
10+
const DEFAULT_VIEW = 3;
1211

13-
if (getMap) {
14-
allProvider = response.filter((i) => {
12+
const fetchEpisodes = async (info, isDub, refresh = false) => {
13+
const response = await fetch(
14+
`/api/v2/episode/${info.id}?releasing=${
15+
info.status === "RELEASING" ? "true" : "false"
16+
}${isDub ? "&dub=true" : ""}${refresh ? "&refresh=true" : ""}`
17+
).then((res) => res.json());
18+
19+
const providers = filterProviders(response);
20+
21+
return providers;
22+
};
23+
24+
const filterProviders = (response) => {
25+
const providersWithMap = response.find((i) => i?.map === true);
26+
let providers = response;
27+
28+
if (providersWithMap) {
29+
providers = response.filter((i) => {
1530
if (i?.providerId === "gogoanime" && i?.map !== true) {
1631
return null;
1732
}
1833
return i;
1934
});
20-
setMapProviders(getMap?.episodes);
2135
}
2236

23-
if (allProvider.length > 0) {
24-
const defaultProvider = allProvider.find(
37+
return providers;
38+
};
39+
40+
const setDefaultProvider = (providers, setProviderId) => {
41+
if (providers.length > 0) {
42+
const defaultProvider = providers.find(
2543
(x) => x.providerId === "gogoanime" || x.providerId === "9anime"
2644
);
27-
setProviderId(defaultProvider?.providerId || allProvider[0].providerId); // set to first provider id
45+
setProviderId(defaultProvider?.providerId || providers[0].providerId);
2846
}
29-
30-
return allProvider;
31-
}
47+
};
3248

3349
export default function AnimeEpisode({
3450
info,
@@ -48,20 +64,13 @@ export default function AnimeEpisode({
4864
const [isDub, setIsDub] = useState(false);
4965

5066
const [providers, setProviders] = useState(null);
51-
const [mapProviders, setMapProviders] = useState(null);
5267

5368
useEffect(() => {
5469
setLoading(true);
5570
const fetchData = async () => {
56-
const response = await fetch(
57-
`/api/v2/episode/${info.id}?releasing=${
58-
info.status === "RELEASING" ? "true" : "false"
59-
}${isDub ? "&dub=true" : ""}`
60-
).then((res) => res.json());
61-
62-
const providers = allProvider(response, setMapProviders, setProviderId);
63-
64-
setView(Number(localStorage.getItem("view")) || 3);
71+
const providers = await fetchEpisodes(info, isDub);
72+
setDefaultProvider(providers, setProviderId);
73+
setView(Number(localStorage.getItem("view")) || DEFAULT_VIEW);
6574
setArtStorage(JSON.parse(localStorage.getItem("artplayer_settings")));
6675
setProviders(providers);
6776
setLoading(false);
@@ -71,20 +80,16 @@ export default function AnimeEpisode({
7180
return () => {
7281
setCurrentPage(1);
7382
setProviders(null);
74-
setMapProviders(null);
7583
};
76-
77-
// eslint-disable-next-line react-hooks/exhaustive-deps
78-
}, [info.id, isDub]);
84+
}, [info.id, isDub]); // eslint-disable-next-line react-hooks/exhaustive-deps
7985

8086
const episodes =
81-
providers
82-
?.find((provider) => provider.providerId === providerId)
83-
?.episodes?.slice(0, mapProviders?.length) || [];
87+
providers?.find((provider) => provider.providerId === providerId)
88+
?.episodes || [];
8489

8590
const lastEpisodeIndex = currentPage * itemsPerPage;
8691
const firstEpisodeIndex = lastEpisodeIndex - itemsPerPage;
87-
let currentEpisodes = episodes.slice(firstEpisodeIndex, lastEpisodeIndex);
92+
let currentEpisodes = episodes?.slice(firstEpisodeIndex, lastEpisodeIndex);
8893

8994
const totalPages = Math.ceil(episodes.length / itemsPerPage);
9095

@@ -98,9 +103,10 @@ export default function AnimeEpisode({
98103

99104
useEffect(() => {
100105
if (
101-
!mapProviders ||
102-
mapProviders?.every(
106+
!currentEpisodes ||
107+
currentEpisodes?.every(
103108
(item) =>
109+
// item?.img?.includes("null") ||
104110
item?.img?.includes("https://s4.anilist.co/") ||
105111
item?.image?.includes("https://s4.anilist.co/") ||
106112
item?.img === null
@@ -173,67 +179,13 @@ export default function AnimeEpisode({
173179
setLoading(true);
174180
clearTimeout(debounceTimeout);
175181
debounceTimeout = setTimeout(async () => {
176-
const res = await fetch(
177-
`/api/v2/episode/${info.id}?releasing=${
178-
info.status === "RELEASING" ? "true" : "false"
179-
}${isDub ? "&dub=true" : ""}&refresh=true`
180-
);
181-
if (!res.ok) {
182-
const json = await res.json();
183-
if (res.status === 429) {
184-
toast.error(json.error);
185-
const resp = await fetch(
186-
`/api/v2/episode/${info.id}?releasing=${
187-
info.status === "RELEASING" ? "true" : "false"
188-
}${isDub ? "&dub=true" : ""}`
189-
).then((res) => res.json());
190-
191-
if (resp) {
192-
const providers = allProvider(
193-
resp,
194-
setMapProviders,
195-
setProviderId
196-
);
197-
setProviders(providers);
198-
}
199-
} else {
200-
toast.error("Something went wrong");
201-
setProviders([]);
202-
}
203-
setLoading(false);
204-
} else {
205-
const remainingRequests = res.headers.get("X-RateLimit-Remaining");
206-
toast.success("Remaining requests " + remainingRequests);
207-
208-
const data = await res.json();
209-
const getMap = data.find((i) => i?.map === true) || data[0];
210-
let allProvider = data;
211-
212-
if (getMap) {
213-
allProvider = data.filter((i) => {
214-
if (i?.providerId === "gogoanime" && i?.map !== true) {
215-
return null;
216-
}
217-
return i;
218-
});
219-
setMapProviders(getMap?.episodes);
220-
}
221-
222-
if (allProvider.length > 0) {
223-
const defaultProvider = allProvider.find(
224-
(x) => x.providerId === "gogoanime" || x.providerId === "9anime"
225-
);
226-
setProviderId(
227-
defaultProvider?.providerId || allProvider[0].providerId
228-
); // set to first provider id
229-
}
230-
231-
setView(Number(localStorage.getItem("view")) || 3);
232-
setArtStorage(JSON.parse(localStorage.getItem("artplayer_settings")));
233-
setProviders(allProvider);
234-
setLoading(false);
235-
}
236-
}, 1000);
182+
const providers = await fetchEpisodes(info, isDub, true);
183+
setDefaultProvider(providers, setProviderId);
184+
setView(Number(localStorage.getItem("view")) || DEFAULT_VIEW);
185+
setArtStorage(JSON.parse(localStorage.getItem("artplayer_settings")));
186+
setProviders(providers);
187+
setLoading(false);
188+
}, 5000);
237189
} catch (err) {
238190
console.log(err);
239191
toast.error("Something went wrong");
@@ -257,7 +209,7 @@ export default function AnimeEpisode({
257209
onClick={() => {
258210
handleRefresh();
259211
setProviders(null);
260-
setMapProviders(null);
212+
// setMapProviders(null);
261213
}}
262214
className="relative flex flex-col items-center w-5 h-5 group"
263215
>
@@ -376,7 +328,7 @@ export default function AnimeEpisode({
376328
view={view}
377329
setView={setView}
378330
episode={currentEpisodes}
379-
map={mapProviders}
331+
// map={mapProviders}
380332
/>
381333
</div>
382334
</div>
@@ -395,9 +347,9 @@ export default function AnimeEpisode({
395347
{Array.isArray(providers) ? (
396348
providers.length > 0 ? (
397349
currentEpisodes.map((episode, index) => {
398-
const mapData = mapProviders?.find(
399-
(i) => i.number === episode.number
400-
);
350+
// const mapData = mapProviders?.find(
351+
// (i) => i.number === episode.number
352+
// );
401353

402354
return (
403355
<Fragment key={index}>
@@ -406,7 +358,7 @@ export default function AnimeEpisode({
406358
key={index}
407359
index={index}
408360
info={info}
409-
image={mapData?.img || mapData?.image}
361+
// image={mapData?.img || mapData?.image}
410362
providerId={providerId}
411363
episode={episode}
412364
artStorage={artStorage}
@@ -417,9 +369,9 @@ export default function AnimeEpisode({
417369
{view === 2 && (
418370
<ThumbnailDetail
419371
key={index}
420-
image={mapData?.img || mapData?.image}
421-
title={mapData?.title}
422-
description={mapData?.description}
372+
// image={mapData?.img || mapData?.image}
373+
// title={mapData?.title}
374+
// description={mapData?.description}
423375
index={index}
424376
epi={episode}
425377
provider={providerId}

components/anime/mobile/reused/infoChip.js renamed to components/anime/mobile/reused/infoChip.tsx

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,20 @@
1-
import React from "react";
2-
import { getFormat } from "../../../../utils/getFormat";
1+
import React, { CSSProperties, FC } from "react";
2+
import { getFormat } from "@/utils/getFormat";
33

4-
export default function InfoChip({ info, color, className }) {
4+
interface Info {
5+
episodes?: number;
6+
averageScore?: number;
7+
format?: string;
8+
status?: string;
9+
}
10+
11+
interface InfoChipProps {
12+
info: Info;
13+
color: any;
14+
className: string;
15+
}
16+
17+
const InfoChip: FC<InfoChipProps> = ({ info, color, className }) => {
518
return (
619
<div
720
className={`flex-wrap w-full justify-start md:pt-1 gap-4 ${className}`}
@@ -40,4 +53,6 @@ export default function InfoChip({ info, color, className }) {
4053
)}
4154
</div>
4255
);
43-
}
56+
};
57+
58+
export default InfoChip;

0 commit comments

Comments
 (0)