react-native-consumet 0.4.3 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/android/src/main/java/com/consumet/ConsumetModule.kt +3 -3
  2. package/lib/commonjs/index.js +1 -0
  3. package/lib/commonjs/index.js.map +1 -1
  4. package/lib/commonjs/models/index.js.map +1 -1
  5. package/lib/commonjs/models/proxy.js +80 -25
  6. package/lib/commonjs/models/proxy.js.map +1 -1
  7. package/lib/commonjs/models/types.js.map +1 -1
  8. package/lib/commonjs/providers/anime/animekai.js +19 -14
  9. package/lib/commonjs/providers/anime/animekai.js.map +1 -1
  10. package/lib/commonjs/providers/anime/zoro.js +26 -19
  11. package/lib/commonjs/providers/anime/zoro.js.map +1 -1
  12. package/lib/commonjs/providers/meta/anilist.js +38 -208
  13. package/lib/commonjs/providers/meta/anilist.js.map +1 -1
  14. package/lib/commonjs/providers/meta/mal.js +4 -4
  15. package/lib/commonjs/providers/meta/mal.js.map +1 -1
  16. package/lib/commonjs/providers/meta/tmdb.js +4 -14
  17. package/lib/commonjs/providers/meta/tmdb.js.map +1 -1
  18. package/lib/commonjs/providers/movies/multimovies.js +16 -8
  19. package/lib/commonjs/providers/movies/multimovies.js.map +1 -1
  20. package/lib/commonjs/utils/index.js +4 -4
  21. package/lib/commonjs/utils/utils.js +140 -4
  22. package/lib/commonjs/utils/utils.js.map +1 -1
  23. package/lib/module/index.js +1 -0
  24. package/lib/module/index.js.map +1 -1
  25. package/lib/module/models/index.js.map +1 -1
  26. package/lib/module/models/proxy.js +80 -25
  27. package/lib/module/models/proxy.js.map +1 -1
  28. package/lib/module/models/types.js.map +1 -1
  29. package/lib/module/providers/anime/animekai.js +18 -14
  30. package/lib/module/providers/anime/animekai.js.map +1 -1
  31. package/lib/module/providers/anime/zoro.js +25 -19
  32. package/lib/module/providers/anime/zoro.js.map +1 -1
  33. package/lib/module/providers/meta/anilist.js +39 -209
  34. package/lib/module/providers/meta/anilist.js.map +1 -1
  35. package/lib/module/providers/meta/mal.js +5 -5
  36. package/lib/module/providers/meta/mal.js.map +1 -1
  37. package/lib/module/providers/meta/tmdb.js +5 -15
  38. package/lib/module/providers/meta/tmdb.js.map +1 -1
  39. package/lib/module/providers/movies/multimovies.js +16 -8
  40. package/lib/module/providers/movies/multimovies.js.map +1 -1
  41. package/lib/module/utils/index.js +2 -2
  42. package/lib/module/utils/index.js.map +1 -1
  43. package/lib/module/utils/utils.js +126 -1
  44. package/lib/module/utils/utils.js.map +1 -1
  45. package/lib/typescript/commonjs/src/index.d.ts +3 -2
  46. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  47. package/lib/typescript/commonjs/src/models/index.d.ts +2 -2
  48. package/lib/typescript/commonjs/src/models/index.d.ts.map +1 -1
  49. package/lib/typescript/commonjs/src/models/proxy.d.ts +6 -7
  50. package/lib/typescript/commonjs/src/models/proxy.d.ts.map +1 -1
  51. package/lib/typescript/commonjs/src/models/types.d.ts +4 -1
  52. package/lib/typescript/commonjs/src/models/types.d.ts.map +1 -1
  53. package/lib/typescript/commonjs/src/providers/anime/animekai.d.ts.map +1 -1
  54. package/lib/typescript/commonjs/src/providers/anime/zoro.d.ts.map +1 -1
  55. package/lib/typescript/commonjs/src/providers/meta/anilist.d.ts +0 -3
  56. package/lib/typescript/commonjs/src/providers/meta/anilist.d.ts.map +1 -1
  57. package/lib/typescript/commonjs/src/providers/meta/tmdb.d.ts.map +1 -1
  58. package/lib/typescript/commonjs/src/providers/movies/multimovies.d.ts.map +1 -1
  59. package/lib/typescript/commonjs/src/utils/index.d.ts +2 -2
  60. package/lib/typescript/commonjs/src/utils/index.d.ts.map +1 -1
  61. package/lib/typescript/commonjs/src/utils/utils.d.ts +15 -1
  62. package/lib/typescript/commonjs/src/utils/utils.d.ts.map +1 -1
  63. package/lib/typescript/module/src/index.d.ts +3 -2
  64. package/lib/typescript/module/src/index.d.ts.map +1 -1
  65. package/lib/typescript/module/src/models/index.d.ts +2 -2
  66. package/lib/typescript/module/src/models/index.d.ts.map +1 -1
  67. package/lib/typescript/module/src/models/proxy.d.ts +6 -7
  68. package/lib/typescript/module/src/models/proxy.d.ts.map +1 -1
  69. package/lib/typescript/module/src/models/types.d.ts +4 -1
  70. package/lib/typescript/module/src/models/types.d.ts.map +1 -1
  71. package/lib/typescript/module/src/providers/anime/animekai.d.ts.map +1 -1
  72. package/lib/typescript/module/src/providers/anime/zoro.d.ts.map +1 -1
  73. package/lib/typescript/module/src/providers/meta/anilist.d.ts +0 -3
  74. package/lib/typescript/module/src/providers/meta/anilist.d.ts.map +1 -1
  75. package/lib/typescript/module/src/providers/meta/tmdb.d.ts.map +1 -1
  76. package/lib/typescript/module/src/providers/movies/multimovies.d.ts.map +1 -1
  77. package/lib/typescript/module/src/utils/index.d.ts +2 -2
  78. package/lib/typescript/module/src/utils/index.d.ts.map +1 -1
  79. package/lib/typescript/module/src/utils/utils.d.ts +15 -1
  80. package/lib/typescript/module/src/utils/utils.d.ts.map +1 -1
  81. package/package.json +5 -2
  82. package/src/index.tsx +3 -0
  83. package/src/models/index.ts +2 -0
  84. package/src/models/proxy.ts +80 -30
  85. package/src/models/types.ts +6 -1
  86. package/src/providers/anime/animekai.ts +17 -14
  87. package/src/providers/anime/zoro.ts +25 -20
  88. package/src/providers/meta/anilist.ts +71 -324
  89. package/src/providers/meta/mal.ts +5 -5
  90. package/src/providers/meta/tmdb.ts +5 -15
  91. package/src/providers/movies/multimovies.ts +15 -11
  92. package/src/utils/index.ts +2 -2
  93. package/src/utils/utils.ts +162 -1
@@ -18,6 +18,7 @@ import {
18
18
  type ProxyConfig,
19
19
  type ITitle,
20
20
  type IStaff,
21
+ type AniZipEpisode,
21
22
  } from '../../models';
22
23
  import {
23
24
  anilistSearchQuery,
@@ -40,8 +41,7 @@ import AnimeKai from '../anime/animekai';
40
41
  import AnimePahe from '../anime/animepahe';
41
42
  import Mangasee123 from '../manga/mangasee123';
42
43
  import Bilibili from '../anime/bilibili';
43
- import { ANIFY_URL, compareTwoStrings, getHashFromImage } from '../../utils/utils';
44
- import type { AniZipEpisode } from '../../models/types';
44
+ import { ANIFY_URL, findSimilarTitles, getHashFromImage } from '../../utils/utils';
45
45
 
46
46
  class Anilist extends AnimeParser {
47
47
  override readonly name = 'Anilist';
@@ -578,18 +578,15 @@ class Anilist extends AnimeParser {
578
578
  airDate: item.airDate ?? null,
579
579
  }));
580
580
  if (!animeInfo.episodes?.length) {
581
- animeInfo.episodes = await this.fetchDefaultEpisodeList(
582
- {
583
- idMal: animeInfo.malId! as number,
584
- season: data.data.Media.season,
585
- startDate: { year: parseInt(animeInfo.releaseDate!) },
586
- title: {
587
- english: animeInfo.title?.english!,
588
- romaji: animeInfo.title?.romaji!,
589
- },
581
+ animeInfo.episodes = await this.fetchDefaultEpisodeList({
582
+ idMal: animeInfo.malId! as number,
583
+ season: data.data.Media.season,
584
+ startDate: { year: parseInt(animeInfo.releaseDate!) },
585
+ title: {
586
+ english: animeInfo.title?.english!,
587
+ romaji: animeInfo.title?.romaji!,
590
588
  },
591
- id
592
- );
589
+ });
593
590
  animeInfo.episodes = animeInfo.episodes?.map((episode: IAnimeEpisode) => {
594
591
  if (!episode.image) {
595
592
  episode.image = animeInfo.image;
@@ -600,18 +597,15 @@ class Anilist extends AnimeParser {
600
597
  });
601
598
  }
602
599
  } catch (err) {
603
- animeInfo.episodes = await this.fetchDefaultEpisodeList(
604
- {
605
- idMal: animeInfo.malId! as number,
606
- season: data.data.Media.season,
607
- startDate: { year: parseInt(animeInfo.releaseDate!) },
608
- title: {
609
- english: animeInfo.title?.english!,
610
- romaji: animeInfo.title?.romaji!,
611
- },
600
+ animeInfo.episodes = await this.fetchDefaultEpisodeList({
601
+ idMal: animeInfo.malId! as number,
602
+ season: data.data.Media.season,
603
+ startDate: { year: parseInt(animeInfo.releaseDate!) },
604
+ title: {
605
+ english: animeInfo.title?.english!,
606
+ romaji: animeInfo.title?.romaji!,
612
607
  },
613
- id
614
- );
608
+ });
615
609
 
616
610
  animeInfo.episodes = animeInfo.episodes?.map((episode: IAnimeEpisode) => {
617
611
  if (!episode.image) {
@@ -625,19 +619,16 @@ class Anilist extends AnimeParser {
625
619
  return animeInfo;
626
620
  }
627
621
  } else
628
- animeInfo.episodes = await this.fetchDefaultEpisodeList(
629
- {
630
- idMal: animeInfo.malId! as number,
631
- season: data.data.Media.season,
632
- startDate: { year: parseInt(animeInfo.releaseDate!) },
633
- title: {
634
- english: animeInfo.title?.english!,
635
- romaji: animeInfo.title?.romaji!,
636
- },
637
- externalLinks: data.data.Media.externalLinks.filter((link: any) => link.type === 'STREAMING'),
622
+ animeInfo.episodes = await this.fetchDefaultEpisodeList({
623
+ idMal: animeInfo.malId! as number,
624
+ season: data.data.Media.season,
625
+ startDate: { year: parseInt(animeInfo.releaseDate!) },
626
+ title: {
627
+ english: animeInfo.title?.english!,
628
+ romaji: animeInfo.title?.romaji!,
638
629
  },
639
- id
640
- );
630
+ externalLinks: data.data.Media.externalLinks.filter((link: any) => link.type === 'STREAMING'),
631
+ });
641
632
 
642
633
  if (fetchFiller) {
643
634
  const { data: fillerData } = await this.client.get(
@@ -701,239 +692,6 @@ class Anilist extends AnimeParser {
701
692
  }
702
693
  };
703
694
 
704
- private findAnime = async (
705
- title: { romaji: string; english: string },
706
- season: string,
707
- startDate: number,
708
- malId: number,
709
- anilistId: string,
710
- externalLinks?: any
711
- ): Promise<IAnimeEpisode[]> => {
712
- title.english = title.english ?? title.romaji;
713
- title.romaji = title.romaji ?? title.english;
714
-
715
- title.english = title.english.toLowerCase();
716
- title.romaji = title.romaji.toLowerCase();
717
-
718
- if (title.english === title.romaji) {
719
- // console.log(
720
- // 'findAnime',
721
- // await this.findAnimeSlug(title.english, season, startDate, malId, anilistId, externalLinks)
722
- // );
723
- return (await this.findAnimeSlug(title.english, season, startDate, malId, anilistId, externalLinks)) ?? [];
724
- }
725
-
726
- const romajiPossibleEpisodes = await this.findAnimeSlug(
727
- title.romaji,
728
- season,
729
- startDate,
730
- malId,
731
- anilistId,
732
- externalLinks
733
- );
734
-
735
- if (romajiPossibleEpisodes) {
736
- return romajiPossibleEpisodes;
737
- }
738
-
739
- const englishPossibleEpisodes = await this.findAnimeSlug(
740
- title.english,
741
- season,
742
- startDate,
743
- malId,
744
- anilistId,
745
- externalLinks
746
- );
747
- // console.log('romajiPossibleEpisodes', romajiPossibleEpisodes);
748
- // console.log('englishPossibleEpisodes', englishPossibleEpisodes);
749
- return englishPossibleEpisodes ?? [];
750
- };
751
-
752
- private findAnimeSlug = async (
753
- title: string,
754
- season: string,
755
- startDate: number,
756
- malId: number,
757
- anilistId: string,
758
- externalLinks?: any
759
- ): Promise<IAnimeEpisode[] | undefined> => {
760
- if (this.provider instanceof Anify) return (await this.provider.fetchAnimeInfo(anilistId)).episodes!;
761
-
762
- const slug = title.replace(/[^0-9a-zA-Z]+/g, ' ');
763
-
764
- let possibleAnime: any | undefined;
765
-
766
- if (malId && !(this.provider instanceof Bilibili)) {
767
- const malAsyncReq = await this.client.get(`${this.malSyncUrl}/mal/anime/${malId}`, {
768
- validateStatus: () => true,
769
- });
770
-
771
- if (malAsyncReq.status === 200) {
772
- const sitesT = malAsyncReq.data.Sites as {
773
- [k: string]: {
774
- [k: string]: { url: string; page: string; title: string };
775
- };
776
- };
777
- let sites = Object.values(sitesT).map((v, i) => {
778
- const obj: any = [...Object.values(Object.values(sitesT)[i]!)];
779
- const pages = obj.map((v: { page: string; url: string; title: string }) => ({
780
- page: v.page,
781
- url: v.url,
782
- title: v.title,
783
- }));
784
- return pages;
785
- }) as any[];
786
-
787
- sites = sites.flat();
788
-
789
- sites.sort((a, b) => {
790
- const targetTitle = malAsyncReq.data.title.toLowerCase();
791
-
792
- const firstRating = compareTwoStrings(targetTitle, a.title.toLowerCase());
793
- const secondRating = compareTwoStrings(targetTitle, b.title.toLowerCase());
794
-
795
- // Sort in descending order
796
- return secondRating - firstRating;
797
- });
798
-
799
- const possibleSource = sites.find((s) => {
800
- if (s.page.toLowerCase() === this.provider.name.toLowerCase()) return false;
801
- });
802
-
803
- if (possibleSource) {
804
- try {
805
- possibleAnime = await this.provider.fetchAnimeInfo(new URL(possibleSource.url).pathname.slice(1));
806
- } catch (err) {
807
- console.error(err);
808
- possibleAnime = await this.findAnimeRaw(slug);
809
- }
810
- } else possibleAnime = await this.findAnimeRaw(slug);
811
- } else possibleAnime = await this.findAnimeRaw(slug);
812
- } else possibleAnime = await this.findAnimeRaw(slug, externalLinks);
813
-
814
- if (!possibleAnime) return undefined;
815
-
816
- // // To avoid a new request, lets match and see if the anime show found is in sub/dub
817
-
818
- // const expectedType = dub ? SubOrSub.DUB : SubOrSub.SUB;
819
-
820
- // // Have this as a fallback in the meantime for compatibility
821
- // if (possibleAnime.subOrDub) {
822
- // if (possibleAnime.subOrDub !== SubOrSub.BOTH && possibleAnime.subOrDub !== expectedType) {
823
- // return undefined;
824
- // }
825
- // } else if ((!possibleAnime.hasDub && dub) || (!possibleAnime.hasSub && !dub)) {
826
- // return undefined;
827
- // }
828
-
829
- // if (this.provider instanceof Zoro) {
830
- // // Set the correct episode sub/dub request type
831
- // possibleAnime.episodes.forEach((_: any, index: number) => {
832
- // if (possibleAnime.subOrDub === SubOrSub.BOTH) {
833
- // possibleAnime.episodes[index].id = possibleAnime.episodes[index].id.replace(`$both`, dub ? '$dub' : '$sub');
834
- // }
835
- // });
836
- // }
837
-
838
- const possibleProviderEpisodes = possibleAnime.episodes as IAnimeEpisode[];
839
- // console.log('possibleProviderEpisodes', possibleProviderEpisodes);
840
- return possibleProviderEpisodes;
841
- // if (
842
- // typeof possibleProviderEpisodes[0]?.image !== 'undefined' &&
843
- // typeof possibleProviderEpisodes[0]?.title !== 'undefined' &&
844
- // typeof possibleProviderEpisodes[0]?.description !== 'undefined'
845
- // )
846
- // return possibleProviderEpisodes;
847
-
848
- // const options = {
849
- // headers: { 'Content-Type': 'application/json' },
850
- // query: kitsuSearchQuery(slug),
851
- // };
852
-
853
- // const newEpisodeList = await this.findKitsuAnime(possibleProviderEpisodes, options, season, startDate);
854
- // return newEpisodeList;
855
- };
856
-
857
- private findKitsuAnime = async (
858
- possibleProviderEpisodes: IAnimeEpisode[],
859
- options: {},
860
- season?: string,
861
- startDate?: number
862
- ) => {
863
- try {
864
- const kitsuEpisodes = await this.client.post(this.kitsuGraphqlUrl, options);
865
- const episodesList = new Map();
866
- if (kitsuEpisodes?.data.data) {
867
- const { nodes } = kitsuEpisodes.data.data.searchAnimeByTitle;
868
-
869
- if (nodes) {
870
- nodes.forEach((node: any) => {
871
- if (node.season === season && node.startDate.trim().split('-')[0] === startDate?.toString()) {
872
- const episodes = node.episodes.nodes;
873
-
874
- for (const episode of episodes) {
875
- const i = episode?.number.toString().replace(/"/g, '');
876
-
877
- let name;
878
- let description;
879
- let thumbnail;
880
-
881
- let thumbnailHash;
882
-
883
- if (episode?.description?.en)
884
- description = episode?.description.en.toString().replace(/"/g, '').replace('\\n', '\n');
885
- if (episode?.thumbnail) {
886
- thumbnail = episode?.thumbnail.original.url.toString().replace(/"/g, '');
887
- thumbnailHash = getHashFromImage(episode?.thumbnail.original.url.toString().replace(/"/g, ''));
888
- }
889
-
890
- if (episode) {
891
- if (episode.titles?.canonical) name = episode.titles.canonical.toString().replace(/"/g, '');
892
- episodesList.set(i, {
893
- episodeNum: episode?.number.toString().replace(/"/g, ''),
894
- title: name,
895
- description,
896
- createdAt: episode?.createdAt,
897
- thumbnail,
898
- });
899
- continue;
900
- }
901
- episodesList.set(i, {
902
- episodeNum: undefined,
903
- title: undefined,
904
- description: undefined,
905
- createdAt: undefined,
906
- thumbnail,
907
- thumbnailHash,
908
- });
909
- }
910
- }
911
- });
912
- }
913
- }
914
-
915
- const newEpisodeList: IAnimeEpisode[] = [];
916
- if (possibleProviderEpisodes?.length !== 0) {
917
- possibleProviderEpisodes?.forEach((ep: any, i: any) => {
918
- const j = (i + 1).toString();
919
- newEpisodeList.push({
920
- id: ep.id as string,
921
- title: ep.title ?? episodesList.get(j)?.title ?? null,
922
- image: ep.image ?? episodesList.get(j)?.thumbnail ?? null,
923
- imageHash: getHashFromImage(ep.image ?? episodesList.get(j)?.thumbnail ?? null),
924
- number: ep.number as number,
925
- createdAt: ep.createdAt ?? episodesList.get(j)?.createdAt ?? null,
926
- description: ep.description ?? episodesList.get(j)?.description ?? null,
927
- url: (ep.url as string) ?? null,
928
- });
929
- });
930
- }
931
- return newEpisodeList;
932
- } catch (error) {
933
- return possibleProviderEpisodes;
934
- }
935
- };
936
-
937
695
  /**
938
696
  * @param page page number to search for (optional)
939
697
  * @param perPage number of results per page (optional)
@@ -1221,48 +979,45 @@ class Anilist extends AnimeParser {
1221
979
  }
1222
980
  };
1223
981
 
1224
- private findAnimeRaw = async (slug: string, externalLinks?: any) => {
1225
- const findAnime = (await this.provider.search(slug)) as ISearch<IAnimeResult>;
1226
-
1227
- if (findAnime.results.length === 0) return undefined;
1228
-
1229
- // Sort the retrieved info for more accurate results.
982
+ private findAnimeRaw = async (title: ITitle) => {
983
+ const searchTerm = title?.romaji || title?.english || title?.userPreferred || '';
984
+ const findAnime = (await this.provider.search(searchTerm)) as ISearch<IAnimeResult>;
1230
985
 
1231
- let topRating = 0;
1232
-
1233
- findAnime.results.sort((a, b) => {
1234
- const targetTitle = slug.toLowerCase();
1235
-
1236
- let firstTitle: string;
1237
- let secondTitle: string;
986
+ if (!findAnime?.results) {
987
+ return {} as IAnimeEpisode[];
988
+ }
1238
989
 
1239
- if (typeof a.title === 'string') firstTitle = a.title as string;
1240
- else firstTitle = a.title.english ?? a.title.romaji ?? '';
990
+ // Run similar title searches in parallel
991
+ const [mappedEng, mappedRom] = await Promise.all([
992
+ Promise.resolve(findSimilarTitles(title?.english || '', findAnime.results)),
993
+ Promise.resolve(findSimilarTitles(title?.romaji || '', findAnime.results)),
994
+ ]);
1241
995
 
1242
- if (typeof b.title === 'string') secondTitle = b.title as string;
1243
- else secondTitle = b.title.english ?? b.title.romaji ?? '';
996
+ // Use Set for efficient deduplication
997
+ const uniqueResults = Array.from(new Set([...mappedEng, ...mappedRom].map((item) => JSON.stringify(item)))).map(
998
+ (str) => JSON.parse(str)
999
+ );
1244
1000
 
1245
- const firstRating = compareTwoStrings(targetTitle, firstTitle.toLowerCase());
1246
- const secondRating = compareTwoStrings(targetTitle, secondTitle.toLowerCase());
1001
+ // Sort by similarity score
1002
+ uniqueResults.sort((a, b) => (b.similarity || 0) - (a.similarity || 0));
1003
+ const mappings: any = {};
1004
+ for (const obj of uniqueResults) {
1005
+ const match = obj.title.replace(/\(TV\)/g, '').match(/\(([^)0-9]+)\)/);
1006
+ const key = match ? match[1].replace(/\s+/g, '-').toLowerCase() : 'sub';
1247
1007
 
1248
- if (firstRating > topRating) {
1249
- topRating = firstRating;
1250
- }
1251
- if (secondRating > topRating) {
1252
- topRating = secondRating;
1008
+ if (!mappings[key]) {
1009
+ mappings[key] = obj.id;
1253
1010
  }
1254
1011
 
1255
- // Sort in descending order
1256
- return secondRating - firstRating;
1257
- });
1258
-
1259
- if (topRating >= 0.7) {
1260
- return await this.provider.fetchAnimeInfo(findAnime.results[0]?.id!);
1012
+ // Early return if we have both sub and dub
1013
+ if (mappings.sub && mappings.dub) break;
1261
1014
  }
1262
-
1263
- return undefined;
1015
+ // console.log('mappings', mappings);
1016
+ // console.time('animeinfo');
1017
+ const animeInfo = await this.provider.fetchAnimeInfo(mappings.sub || mappings.dub);
1018
+ // console.timeEnd('animeinfo');
1019
+ return animeInfo.episodes as IAnimeEpisode[];
1264
1020
  };
1265
-
1266
1021
  /**
1267
1022
  * @returns a random anime
1268
1023
  */
@@ -1350,26 +1105,16 @@ class Anilist extends AnimeParser {
1350
1105
  }
1351
1106
  };
1352
1107
 
1353
- private fetchDefaultEpisodeList = async (
1354
- Media: {
1355
- idMal: number;
1356
- title: { english: string; romaji: string };
1357
- season: string;
1358
- startDate: { year: number };
1359
- externalLinks?: any;
1360
- },
1361
- id: string
1362
- ) => {
1108
+ private fetchDefaultEpisodeList = async (Media: {
1109
+ idMal: number;
1110
+ title: { english: string; romaji: string };
1111
+ season: string;
1112
+ startDate: { year: number };
1113
+ externalLinks?: any;
1114
+ }) => {
1363
1115
  let episodes: IAnimeEpisode[] = [];
1364
1116
 
1365
- episodes = await this.findAnime(
1366
- { english: Media.title?.english!, romaji: Media.title?.romaji! },
1367
- Media.season!,
1368
- Media.startDate.year,
1369
- Media.idMal as number,
1370
- id,
1371
- Media.externalLinks
1372
- );
1117
+ episodes = await this.findAnimeRaw({ english: Media.title?.english!, romaji: Media.title?.romaji! });
1373
1118
  // console.log('fetchDefaultEpisodeList', episodes);
1374
1119
  return episodes;
1375
1120
  };
@@ -1403,10 +1148,12 @@ class Anilist extends AnimeParser {
1403
1148
  this.provider instanceof AnimePahe
1404
1149
  ) {
1405
1150
  try {
1151
+ console.time('fetchEpisodesListById');
1406
1152
  const [animeMetaData, providerEpisodes] = await Promise.all([
1407
1153
  this.client.get(`https://api.ani.zip/mappings?anilist_id=${id}`).then((res) => res.data),
1408
- this.fetchDefaultEpisodeList(Media, id),
1154
+ this.fetchDefaultEpisodeList(Media),
1409
1155
  ]);
1156
+ console.timeEnd('fetchEpisodesListById');
1410
1157
  //to get the actual episode ids we make use of fetchDefaultEpisodeList
1411
1158
  const normalizedEpisodes = (
1412
1159
  Object.entries(animeMetaData.episodes || {}) as [string, AniZipEpisode & IAnimeEpisode][]
@@ -1448,7 +1195,7 @@ class Anilist extends AnimeParser {
1448
1195
  // });
1449
1196
  possibleAnimeEpisodes = mergeEpisodes(normalizedEpisodes, providerEpisodes);
1450
1197
  if (!possibleAnimeEpisodes.length) {
1451
- possibleAnimeEpisodes = await this.fetchDefaultEpisodeList(Media, id);
1198
+ possibleAnimeEpisodes = await this.fetchDefaultEpisodeList(Media);
1452
1199
  possibleAnimeEpisodes = possibleAnimeEpisodes?.map((episode: IAnimeEpisode) => {
1453
1200
  if (!episode.image) {
1454
1201
  episode.image = Media.coverImage.extraLarge ?? Media.coverImage.large ?? Media.coverImage.medium;
@@ -1461,7 +1208,7 @@ class Anilist extends AnimeParser {
1461
1208
  });
1462
1209
  }
1463
1210
  } catch (err) {
1464
- possibleAnimeEpisodes = await this.fetchDefaultEpisodeList(Media, id);
1211
+ possibleAnimeEpisodes = await this.fetchDefaultEpisodeList(Media);
1465
1212
 
1466
1213
  possibleAnimeEpisodes = possibleAnimeEpisodes?.map((episode: IAnimeEpisode) => {
1467
1214
  if (!episode.image) {
@@ -1475,7 +1222,7 @@ class Anilist extends AnimeParser {
1475
1222
  });
1476
1223
  return possibleAnimeEpisodes;
1477
1224
  }
1478
- } else possibleAnimeEpisodes = await this.fetchDefaultEpisodeList(Media, id);
1225
+ } else possibleAnimeEpisodes = await this.fetchDefaultEpisodeList(Media);
1479
1226
 
1480
1227
  if (fetchFiller) {
1481
1228
  const { data: fillerData } = await this.client.get(
@@ -12,7 +12,7 @@ import {
12
12
  type IEpisodeServer,
13
13
  MediaFormat,
14
14
  } from '../../models';
15
- import { substringAfter, substringBefore, compareTwoStrings, kitsuSearchQuery, range } from '../../utils';
15
+ import { substringAfter, substringBefore, calculateStringSimilarity, kitsuSearchQuery, range } from '../../utils';
16
16
  import Gogoanime from '../anime/gogoanime';
17
17
  import Zoro from '../anime/zoro';
18
18
  import Anify from '../anime/anify';
@@ -296,8 +296,8 @@ class Myanimelist extends AnimeParser {
296
296
  if (typeof b.title === 'string') secondTitle = b.title as string;
297
297
  else secondTitle = b.title.english ?? b.title.romaji ?? '';
298
298
 
299
- const firstRating = compareTwoStrings(targetTitle, firstTitle.toLowerCase());
300
- const secondRating = compareTwoStrings(targetTitle, secondTitle.toLowerCase());
299
+ const firstRating = calculateStringSimilarity(targetTitle, firstTitle.toLowerCase());
300
+ const secondRating = calculateStringSimilarity(targetTitle, secondTitle.toLowerCase());
301
301
 
302
302
  // Sort in descending order
303
303
  return secondRating - firstRating;
@@ -350,8 +350,8 @@ class Myanimelist extends AnimeParser {
350
350
  sites.sort((a, b) => {
351
351
  const targetTitle = malAsyncReq.data.title.toLowerCase();
352
352
 
353
- const firstRating = compareTwoStrings(targetTitle, a.title.toLowerCase());
354
- const secondRating = compareTwoStrings(targetTitle, b.title.toLowerCase());
353
+ const firstRating = calculateStringSimilarity(targetTitle, a.title.toLowerCase());
354
+ const secondRating = calculateStringSimilarity(targetTitle, b.title.toLowerCase());
355
355
 
356
356
  // Sort in descending order
357
357
  return secondRating - firstRating;
@@ -12,7 +12,7 @@ import {
12
12
  type IMovieEpisode,
13
13
  } from '../../models';
14
14
  import type { IPeopleResult } from '../../models/types';
15
- import { compareTwoStrings } from '../../utils';
15
+ import { calculateStringSimilarity } from '../../utils';
16
16
  import FlixHQ from '../movies/flixhq';
17
17
  import type { AxiosAdapter } from 'axios';
18
18
 
@@ -198,20 +198,10 @@ class TMDB extends MovieParser {
198
198
  if (type === 'movie') info.episodeId = InfoFromProvider?.episodes![0]?.id;
199
199
 
200
200
  info.title = data?.title || data?.name;
201
- info.translations = data?.translations?.translations.map((translation: any) => ({
202
- title: translation.data?.title || data?.name || undefined,
203
- description: translation.data?.overview || undefined,
204
- language: translation?.english_name || undefined,
205
- }));
206
201
 
207
202
  //images
208
203
  info.image = `https://image.tmdb.org/t/p/original${data?.poster_path}`;
209
204
  info.cover = `https://image.tmdb.org/t/p/original${data?.backdrop_path}`;
210
- info.logos = data?.images?.logos.map((logo: { file_path: string; aspect_ratio: number; width: number }) => ({
211
- url: `https://image.tmdb.org/t/p/original${logo.file_path}`,
212
- aspectRatio: logo?.aspect_ratio,
213
- width: logo?.width,
214
- }));
215
205
 
216
206
  info.type = type === 'movie' ? TvType.MOVIE : TvType.TVSERIES;
217
207
  info.rating = data?.vote_average || 0;
@@ -317,7 +307,7 @@ class TMDB extends MovieParser {
317
307
  releaseDate: episode.air_date,
318
308
  description: episode.overview,
319
309
  url: episodeFromProvider?.url || undefined,
320
- img: !episode?.still_path
310
+ image: !episode?.still_path
321
311
  ? undefined
322
312
  : {
323
313
  mobile: `https://image.tmdb.org/t/p/w300${episode.still_path}`,
@@ -357,7 +347,7 @@ class TMDB extends MovieParser {
357
347
  season: 1,
358
348
  releaseDate: data.release_date,
359
349
  description: data.overview,
360
- img: !data?.backdrop_path
350
+ image: !data?.backdrop_path
361
351
  ? undefined
362
352
  : {
363
353
  mobile: `https://image.tmdb.org/t/p/w300${data.backdrop_path}`,
@@ -413,8 +403,8 @@ class TMDB extends MovieParser {
413
403
  if (typeof b.title === 'string') secondTitle = b.title as string;
414
404
  else secondTitle = (b?.title as string) ?? '';
415
405
 
416
- const firstRating = compareTwoStrings(targetTitle, firstTitle.toLowerCase());
417
- const secondRating = compareTwoStrings(targetTitle, secondTitle.toLowerCase());
406
+ const firstRating = calculateStringSimilarity(targetTitle, firstTitle.toLowerCase());
407
+ const secondRating = calculateStringSimilarity(targetTitle, secondTitle.toLowerCase());
418
408
 
419
409
  // Sort in descending order
420
410
  return secondRating - firstRating;
@@ -13,9 +13,9 @@ import { MixDrop, StreamTape, StreamWish, VidHide } from '../../extractors';
13
13
 
14
14
  class MultiMovies extends MovieParser {
15
15
  override readonly name = 'MultiMovies';
16
- protected override baseUrl = 'https://multimovies.guru';
16
+ protected override baseUrl = 'https://multimovies.digital';
17
17
  protected override logo =
18
- 'https://multimovies.guru/wp-content/uploads/2024/01/cropped-CompressJPEG.online_512x512_image.png';
18
+ 'https://multimovies.digital/wp-content/uploads/2024/01/cropped-CompressJPEG.online_512x512_image.png';
19
19
  protected override classPath = 'MOVIES.MultiMovies';
20
20
  override supportedTypes = new Set([TvType.MOVIE, TvType.TVSERIES]);
21
21
  constructor(customBaseURL?: string) {
@@ -383,13 +383,15 @@ class MultiMovies extends MovieParser {
383
383
  const headers = {
384
384
  'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36',
385
385
  };
386
-
387
- const playerRes = await this.client.post(`${this.baseUrl}/wp-admin/admin-ajax.php`, formData, {
388
- headers,
386
+ console.log(`${this.baseUrl}/wp-admin/admin-ajax.php`, formData);
387
+ const response = await fetch(`${this.baseUrl}/wp-admin/admin-ajax.php`, {
388
+ method: 'POST',
389
+ headers: headers,
390
+ body: formData,
389
391
  });
390
-
391
- const iframeUrl =
392
- playerRes.data?.embed_url?.match(/<iframe[^>]+src="([^"]+)"[^>]*>/i)?.[1] || playerRes.data?.embed_url;
392
+ const playerRes = await response.json();
393
+ // console.log('playerRes', playerRes);
394
+ const iframeUrl = playerRes?.embed_url?.match(/<iframe[^>]+src="([^"]+)"[^>]*>/i)?.[1] || playerRes?.embed_url;
393
395
 
394
396
  // Handle non-multimovies case
395
397
  if (!iframeUrl.includes('multimovies')) {
@@ -417,12 +419,14 @@ class MultiMovies extends MovieParser {
417
419
  headers,
418
420
  });
419
421
 
422
+ // console.log('streamResponse', streamResponse.data);
423
+
420
424
  if (!streamResponse.data) {
421
425
  throw new Error('No stream data found');
422
426
  }
423
427
 
424
428
  const streamDetails = streamResponse.data;
425
- const mresultKeys = new Set(Object.keys(streamDetails.mresult));
429
+ const mresultKeys = new Set(Object.keys(JSON.parse(atob(streamDetails.mresult))));
426
430
  const siteUrlsKeys = new Set(Object.keys(streamDetails.siteUrls));
427
431
 
428
432
  // Find common keys
@@ -436,19 +440,19 @@ class MultiMovies extends MovieParser {
436
440
  streamDetails.siteFriendlyNames[site] === 'StreamHG'
437
441
  ? 'StreamWish'
438
442
  : streamDetails.siteFriendlyNames[site],
439
- url: streamDetails.siteUrls[site] + streamDetails.mresult[site],
443
+ url: streamDetails.siteUrls[site] + JSON.parse(atob(streamDetails.mresult))[site],
440
444
  };
441
445
  });
442
446
 
443
447
  return { servers, fileId };
444
448
  } else {
445
- //@Durgesh
446
449
  return {
447
450
  servers: [{ name: 'StreamWish', url: iframeUrl }],
448
451
  fileId: iframeUrl.split('/').pop() ?? '',
449
452
  };
450
453
  }
451
454
  } catch (err) {
455
+ console.log(err);
452
456
  throw new Error((err as Error).message);
453
457
  }
454
458
  }
@@ -30,7 +30,7 @@ import {
30
30
  convertDuration,
31
31
  substringAfter,
32
32
  substringBefore,
33
- compareTwoStrings,
33
+ calculateStringSimilarity,
34
34
  } from './utils';
35
35
  import {
36
36
  anilistSearchQuery,
@@ -88,7 +88,7 @@ export {
88
88
  AsianLoad,
89
89
  substringAfter,
90
90
  substringBefore,
91
- compareTwoStrings,
91
+ calculateStringSimilarity,
92
92
  VidMoly,
93
93
  getKKey,
94
94
  MegaUp,