@serifpersia/dango 3.3.7 → 3.3.8

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 (67) hide show
  1. package/README.md +1 -1
  2. package/client/dist/assets/{AnimeCard-WlhU88fn.js → AnimeCard-D4qo4289.js} +1 -1
  3. package/client/dist/assets/{AnimeInfo-BCLagpbu.js → AnimeInfo-BdRRm4So.js} +1 -1
  4. package/client/dist/assets/{AnimeInfoPage-o0U_OXKP.js → AnimeInfoPage-DeJNAKMR.js} +2 -2
  5. package/client/dist/assets/{Asmr-ieGJ_BcQ.js → Asmr-D0EGRYsv.js} +1 -1
  6. package/client/dist/assets/{AsmrResetProgressModal-BwaoVski.js → AsmrResetProgressModal-Gs0GmVaT.js} +1 -1
  7. package/client/dist/assets/{AvSyncCalibrator-CXvBuY4l.js → AvSyncCalibrator-D8hqarVB.js} +1 -1
  8. package/client/dist/assets/{Home-DjLpvsp8.js → Home-BnBzjFkW.js} +1 -1
  9. package/client/dist/assets/Insights-i9QgY3nE.js +1 -0
  10. package/client/dist/assets/{LibraryListPage-B2nhFFrc.js → LibraryListPage-D3hTqTRU.js} +1 -1
  11. package/client/dist/assets/{ListeningList-okIpsKCr.js → ListeningList-BgWsfu40.js} +1 -1
  12. package/client/dist/assets/{Manga-3u9nVNZC.js → Manga-Dn-CYins.js} +1 -1
  13. package/client/dist/assets/MangaInfoPage-EmQoK7Bv.js +1 -0
  14. package/client/dist/assets/MangaReadPage-xJB8K2YU.js +1 -0
  15. package/client/dist/assets/{MangaResetProgressModal-Ch8RjwbO.js → MangaResetProgressModal-Dian37PQ.js} +1 -1
  16. package/client/dist/assets/{Mature-pINwl5wj.js → Mature-DQtXKOXc.js} +1 -1
  17. package/client/dist/assets/{MediaCard-DDiYEAm8.js → MediaCard-DpKoY-1j.js} +1 -1
  18. package/client/dist/assets/{Music-B1swlVLI.js → Music-BP43Zqmq.js} +1 -1
  19. package/client/dist/assets/{OptionListMenu-CzH2VSPh.js → OptionListMenu-Bj9ebsW3.js} +1 -1
  20. package/client/dist/assets/{Player-SKPWb-o8.js → Player-O2Cy2GF1.js} +2 -2
  21. package/client/dist/assets/{PlayerSettings-jrmY95-i.js → PlayerSettings-DYZ272Yp.js} +1 -1
  22. package/client/dist/assets/{QueueOptionsButton-CcVP7Vi6.js → QueueOptionsButton-lv26-6jp.js} +1 -1
  23. package/client/dist/assets/{QueueRail-Cj-PU9EV.js → QueueRail-B7DeSFoA.js} +1 -1
  24. package/client/dist/assets/{Radio-CRlbaxQt.js → Radio-qQBYnVfY.js} +1 -1
  25. package/client/dist/assets/{ReadingList-wRtHGNo8.js → ReadingList-BT8kUjCB.js} +1 -1
  26. package/client/dist/assets/{ResetProgressModal-BokfoYFB.js → ResetProgressModal-DWeiO-hs.js} +1 -1
  27. package/client/dist/assets/{Search-BOOBeTVA.js → Search-BkvPYN33.js} +1 -1
  28. package/client/dist/assets/{Settings-BgrcswJD.js → Settings-CyZEBF6S.js} +1 -1
  29. package/client/dist/assets/{SkeletonGrid-C6S7OYHn.js → SkeletonGrid-B5loz7ii.js} +1 -1
  30. package/client/dist/assets/Trackers-JK-aXBYC.js +2 -0
  31. package/client/dist/assets/{Tv-ByVckozq.js → Tv-BwXWJxMy.js} +1 -1
  32. package/client/dist/assets/{TvInfo-fJ9SFMK8.js → TvInfo-Dzyq6ucH.js} +1 -1
  33. package/client/dist/assets/{TvPopup-yfH7p0y0.js → TvPopup-PlCU30FO.js} +1 -1
  34. package/client/dist/assets/{TvSearch-CBNWDByW.js → TvSearch-BYwCf5kO.js} +1 -1
  35. package/client/dist/assets/{TvWatchlist-BqjZ2-4A.js → TvWatchlist-BiJU6pKT.js} +1 -1
  36. package/client/dist/assets/{Watchlist-B_Q2hEiJ.js → Watchlist-BOEeGXH9.js} +1 -1
  37. package/client/dist/assets/{hls-kIF7bMpF.js → hls-C11FOWHj.js} +1 -1
  38. package/client/dist/assets/index-CtoKRNLc.js +178 -0
  39. package/client/dist/assets/{useAnimeInfoData-BKSrS8eN.js → useAnimeInfoData-kr3WOIWH.js} +1 -1
  40. package/client/dist/assets/{useAsmr-Byj8Qiwp.js → useAsmr-CB9THf0m.js} +1 -1
  41. package/client/dist/assets/{useAsmrPopup-CLcWCCXf.js → useAsmrPopup-cT_Uu41e.js} +1 -1
  42. package/client/dist/assets/useMangaLibrary-rM6z3_0E.js +1 -0
  43. package/client/dist/assets/{useMangaPopup-ZonOP5_c.js → useMangaPopup-PnmSctHu.js} +1 -1
  44. package/client/dist/assets/{useProviders-CymA42ZB.js → useProviders-B3VB7A9M.js} +1 -1
  45. package/client/dist/assets/{useTv-CPj6Cf42.js → useTv-BTUKMH7Q.js} +1 -1
  46. package/client/dist/assets/{useTvLibrary-COsyN8yu.js → useTvLibrary-C0sX-ilZ.js} +1 -1
  47. package/client/dist/index.html +1 -1
  48. package/package.json +2 -2
  49. package/server/dist/controllers/data.controller.js +1 -0
  50. package/server/dist/controllers/insights.controller.js +3 -2
  51. package/server/dist/controllers/manga-library.controller.js +54 -0
  52. package/server/dist/controllers/watchlist.controller.js +13 -1
  53. package/server/dist/lib/anilist.js +36 -3
  54. package/server/dist/lib/mal.js +69 -0
  55. package/server/dist/lib/tracker/anilist-tracker.js +66 -0
  56. package/server/dist/lib/tracker/manga-sync.service.js +792 -0
  57. package/server/dist/repositories/manga.repository.js +17 -2
  58. package/server/dist/routes/manga-library.routes.js +2 -0
  59. package/server/dist/routes/tracker.routes.js +123 -0
  60. package/server/dist/sync.js +8 -1
  61. package/server/package.json +1 -1
  62. package/client/dist/assets/Insights-lQcQoeES.js +0 -1
  63. package/client/dist/assets/MangaInfoPage-Cat-B487.js +0 -1
  64. package/client/dist/assets/MangaReadPage-CyLRxzvl.js +0 -1
  65. package/client/dist/assets/Trackers-DLcTEJJW.js +0 -2
  66. package/client/dist/assets/index-C65i4HWv.js +0 -178
  67. package/client/dist/assets/useMangaLibrary-U7tUo8nx.js +0 -1
@@ -42,6 +42,60 @@ export class MangaLibraryController {
42
42
  res.json({ inLibrary: false, status: null });
43
43
  }
44
44
  };
45
+ getEntry = async (req, res) => {
46
+ try {
47
+ const item = MangaLibraryRepository.getById(mangaDb(req), req.params.id);
48
+ if (!item)
49
+ return res.status(404).json({ error: 'Not in library' });
50
+ res.json({ item });
51
+ }
52
+ catch {
53
+ res.status(500).json({ error: 'Failed to load entry' });
54
+ }
55
+ };
56
+ linkAnilist = async (req, res) => {
57
+ const { id, anilistId } = req.body ?? {};
58
+ const targetId = typeof id === 'string' ? id : '';
59
+ const mediaId = Number(anilistId);
60
+ if (!targetId || !Number.isInteger(mediaId) || mediaId <= 0) {
61
+ return res.status(400).json({ error: 'id and a numeric anilistId are required' });
62
+ }
63
+ try {
64
+ const db = mangaDb(req);
65
+ const row = MangaLibraryRepository.getById(db, targetId);
66
+ if (!row)
67
+ return res.status(404).json({ error: 'Library entry not found' });
68
+ if (String(row.provider).toLowerCase() === 'anilist') {
69
+ return res
70
+ .status(400)
71
+ .json({ error: 'Link a provider bookmark to the AniList entry, not the reverse' });
72
+ }
73
+ let progressMigrated = false;
74
+ await performMangaWriteTransaction(db, (tx) => {
75
+ MangaLibraryRepository.setAnilistId(tx, targetId, mediaId, 'manual');
76
+ const orphanId = `anilist:${mediaId}`;
77
+ if (orphanId !== targetId) {
78
+ const orphan = MangaLibraryRepository.getById(tx, orphanId);
79
+ const target = MangaLibraryRepository.getById(tx, targetId);
80
+ const targetProgress = MangaProgressRepository.getByManga(tx, targetId);
81
+ if (orphan?.lastChapterNumber &&
82
+ !target?.lastChapterNumber &&
83
+ targetProgress.length === 0) {
84
+ MangaLibraryRepository.setProgressPointer(tx, targetId, orphan.lastChapterNumber);
85
+ MangaProgressRepository.moveSyntheticChapters(tx, orphanId, targetId);
86
+ progressMigrated = true;
87
+ }
88
+ MangaLibraryRepository.delete(tx, orphanId);
89
+ MangaProgressRepository.deleteByManga(tx, orphanId);
90
+ }
91
+ });
92
+ res.json({ success: true, id: targetId, progressMigrated });
93
+ }
94
+ catch (err) {
95
+ logger.error({ err }, 'Failed to link manga to AniList');
96
+ res.status(500).json({ error: 'Failed to link entry' });
97
+ }
98
+ };
45
99
  getLibraryIds = async (req, res) => {
46
100
  try {
47
101
  res.json({ ids: MangaLibraryRepository.getIds(mangaDb(req)) });
@@ -450,7 +450,11 @@ export class WatchlistController {
450
450
  if (dual._id !== undefined)
451
451
  dual._id = row.id;
452
452
  try {
453
- ShowsMetaRepository.upsert(db, { id: row.id, thumbnail: poster });
453
+ ShowsMetaRepository.upsert(db, {
454
+ id: row.id,
455
+ thumbnail: poster,
456
+ popularityScore: meta?.score ?? (meta?.averageScore != null ? meta.averageScore / 10 : undefined),
457
+ });
454
458
  }
455
459
  catch {
456
460
  // ignore
@@ -470,6 +474,14 @@ export class WatchlistController {
470
474
  await this.sweepOfflinePosters(db);
471
475
  }
472
476
  async sweepOfflinePosters(db) {
477
+ try {
478
+ db.run(`UPDATE shows_meta SET name = (SELECT w.name FROM watchlist w WHERE w.id = shows_meta.id)
479
+ WHERE (name IS NULL OR TRIM(name) = '')
480
+ AND EXISTS (SELECT 1 FROM watchlist w WHERE w.id = shows_meta.id AND w.name IS NOT NULL AND TRIM(w.name) != '')`);
481
+ }
482
+ catch {
483
+ // ignore
484
+ }
473
485
  const [wlMissing, metaMissing] = await Promise.all([
474
486
  WatchlistRepository.getMissingThumbnails(db),
475
487
  ShowsMetaRepository.getShowIdsMissingMeta(db),
@@ -1128,11 +1128,11 @@ function extractEpisodes(result) {
1128
1128
  }
1129
1129
  return [];
1130
1130
  }
1131
- export async function searchAnilistByTitle(title) {
1131
+ export async function searchAnilistByTitle(title, type = 'ANIME') {
1132
1132
  const query = `
1133
1133
  query ($search: String) {
1134
1134
  Page(page: 1, perPage: 5) {
1135
- media(search: $search, type: ANIME) {
1135
+ media(search: $search, type: ${type}) {
1136
1136
  id
1137
1137
  title { romaji english native }
1138
1138
  }
@@ -1164,7 +1164,7 @@ export async function searchAnilistByTitle(title) {
1164
1164
  break;
1165
1165
  }
1166
1166
  if (!media || media.length === 0) {
1167
- if (anyFailed && anilistUnavailable()) {
1167
+ if (anyFailed && type === 'ANIME' && anilistUnavailable()) {
1168
1168
  const fb = await kitsuSearchAnime({ query: title, page: 1, perPage: 5 });
1169
1169
  if (fb.length > 0) {
1170
1170
  const best = fb[0];
@@ -1196,6 +1196,39 @@ export async function searchAnilistByTitle(title) {
1196
1196
  }
1197
1197
  return { id: best.id, title: best.title };
1198
1198
  }
1199
+ export async function searchAnilistMangaByTitle(title) {
1200
+ return searchAnilistByTitle(title, 'MANGA');
1201
+ }
1202
+ const MANGA_META_FRAGMENT = `id title { romaji english native } coverImage { large }`;
1203
+ export async function getMangaMetaById(id) {
1204
+ if (!id)
1205
+ return null;
1206
+ try {
1207
+ const result = await anilistRequest(`query ($id: Int) { Media(id: $id, type: MANGA) { ${MANGA_META_FRAGMENT} } }`, { id });
1208
+ const m = result?.data?.Media;
1209
+ if (!m)
1210
+ return null;
1211
+ return { id: m.id, title: m.title ?? {}, cover: m.coverImage?.large };
1212
+ }
1213
+ catch {
1214
+ return null;
1215
+ }
1216
+ }
1217
+ export async function getMangaMetaByMalId(malId) {
1218
+ const absMal = Math.abs(malId);
1219
+ if (!absMal)
1220
+ return null;
1221
+ try {
1222
+ const result = await anilistRequest(`query ($id: Int) { Media(idMal: $id, type: MANGA) { ${MANGA_META_FRAGMENT} } }`, { id: absMal });
1223
+ const m = result?.data?.Media;
1224
+ if (!m)
1225
+ return null;
1226
+ return { id: m.id, title: m.title ?? {}, cover: m.coverImage?.large };
1227
+ }
1228
+ catch {
1229
+ return null;
1230
+ }
1231
+ }
1199
1232
  export async function getAiredEpisodesForShows(ids, startDate, endDate) {
1200
1233
  const dayStart = Math.floor(startDate.getTime() / 1000);
1201
1234
  const dayEnd = Math.floor(endDate.getTime() / 1000);
@@ -913,6 +913,75 @@ export async function fetchMalUserList(username) {
913
913
  }
914
914
  return entries;
915
915
  }
916
+ export function mapMalMangaStatusCode(status) {
917
+ switch (status) {
918
+ case 1:
919
+ return 'Reading';
920
+ case 2:
921
+ return 'Completed';
922
+ case 3:
923
+ return 'On-Hold';
924
+ case 4:
925
+ return 'Dropped';
926
+ case 6:
927
+ return 'Planned';
928
+ default:
929
+ return null;
930
+ }
931
+ }
932
+ export async function fetchMalMangaList(username) {
933
+ const user = username.trim();
934
+ if (!user || /[^A-Za-z0-9_-]/.test(user))
935
+ throw new Error('Invalid MAL username');
936
+ const entries = [];
937
+ let offset = 0;
938
+ for (let page = 0; page < MAL_USER_LIST_MAX_PAGES; page++) {
939
+ const url = `https://myanimelist.net/mangalist/${encodeURIComponent(user)}/load.json?status=7&offset=${offset}`;
940
+ await politeWait();
941
+ const res = await fetch(url, {
942
+ headers: { 'User-Agent': UA, Accept: 'application/json' },
943
+ signal: AbortSignal.timeout(TIMEOUT_MS),
944
+ redirect: 'manual',
945
+ });
946
+ if (res.status === 400 || res.status === 404)
947
+ throw new Error(`MAL user "${user}" not found`);
948
+ if (res.status === 403 || res.status === 429) {
949
+ throw new Error(`MAL blocked the request (HTTP ${res.status}) — try again later`);
950
+ }
951
+ if (res.status >= 300 && res.status < 400) {
952
+ throw new Error(`MAL list for "${user}" is private or unavailable`);
953
+ }
954
+ if (!res.ok)
955
+ throw new Error(`MAL list fetch failed (HTTP ${res.status})`);
956
+ const data = await parseJsonBody(res);
957
+ if (!Array.isArray(data) || data.length === 0)
958
+ break;
959
+ for (const item of data) {
960
+ const rec = item;
961
+ const malId = Number(rec.manga_id);
962
+ if (!malId)
963
+ continue;
964
+ const titleRaw = typeof rec.manga_title === 'string' && rec.manga_title.trim() !== ''
965
+ ? rec.manga_title
966
+ : typeof rec.manga_title_eng === 'string'
967
+ ? rec.manga_title_eng
968
+ : '';
969
+ entries.push({
970
+ malId,
971
+ title: decodeHtml(titleRaw),
972
+ titleEnglish: typeof rec.manga_title_eng === 'string' && rec.manga_title_eng.trim() !== ''
973
+ ? decodeHtml(rec.manga_title_eng)
974
+ : null,
975
+ status: Number(rec.status) || 0,
976
+ chaptersRead: Number(rec.num_read_chapters ?? rec.num_chapters_read) || 0,
977
+ });
978
+ }
979
+ if (data.length < MAL_USER_LIST_PAGE_SIZE)
980
+ break;
981
+ offset += MAL_USER_LIST_PAGE_SIZE;
982
+ }
983
+ return entries;
984
+ }
916
985
  export async function malLatestReleases(store, format = 'TV', page = 1, size = 12) {
917
986
  const week = await malScheduleWeek(store);
918
987
  const seen = new Map();
@@ -11,11 +11,19 @@ export const ANILIST_TO_DANGO_STATUS = {
11
11
  };
12
12
  export const DANGO_TO_ANILIST_STATUS = {
13
13
  Watching: 'CURRENT',
14
+ Reading: 'CURRENT',
14
15
  Completed: 'COMPLETED',
15
16
  'On-Hold': 'PAUSED',
16
17
  Dropped: 'DROPPED',
17
18
  Planned: 'PLANNING',
18
19
  };
20
+ export const ANILIST_TO_MANGA_STATUS = {
21
+ CURRENT: 'Reading',
22
+ COMPLETED: 'Completed',
23
+ PAUSED: 'On-Hold',
24
+ DROPPED: 'Dropped',
25
+ PLANNING: 'Planned',
26
+ };
19
27
  export async function exchangeAuthorizationCode() {
20
28
  throw new Error('Authorization Code flow removed — use Implicit Grant (response_type=token) instead.');
21
29
  }
@@ -143,6 +151,64 @@ export class AniListTracker {
143
151
  }
144
152
  return entries;
145
153
  }
154
+ async fetchUserMangaList(userIdOrName) {
155
+ const query = `
156
+ query ($userId: Int, $userName: String) {
157
+ MediaListCollection(userId: $userId, userName: $userName, type: MANGA) {
158
+ lists {
159
+ entries {
160
+ id
161
+ mediaId
162
+ status
163
+ progress
164
+ progressVolumes
165
+ score(format: POINT_10)
166
+ updatedAt
167
+ media {
168
+ id
169
+ idMal
170
+ chapters
171
+ volumes
172
+ title { romaji english native }
173
+ coverImage { large }
174
+ }
175
+ }
176
+ }
177
+ }
178
+ }
179
+ `;
180
+ const variables = typeof userIdOrName === 'number'
181
+ ? { userId: userIdOrName }
182
+ : typeof userIdOrName === 'string'
183
+ ? { userName: userIdOrName }
184
+ : {};
185
+ const data = await this.request(query, variables);
186
+ const lists = data.MediaListCollection?.lists ?? [];
187
+ const entries = [];
188
+ for (const list of lists) {
189
+ for (const entry of list.entries ?? []) {
190
+ if (!entry.media)
191
+ continue;
192
+ if (entry.status === 'REPEATING')
193
+ continue;
194
+ entries.push({
195
+ mediaId: entry.mediaId,
196
+ entryId: entry.id,
197
+ idMal: entry.media.idMal ?? undefined,
198
+ status: ANILIST_TO_MANGA_STATUS[entry.status] ?? 'Planned',
199
+ progress: entry.progress ?? 0,
200
+ progressVolumes: entry.progressVolumes ?? undefined,
201
+ score: entry.score ?? undefined,
202
+ updatedAt: entry.updatedAt ?? 0,
203
+ title: entry.media.title ?? {},
204
+ coverImage: entry.media.coverImage?.large,
205
+ totalChapters: entry.media.chapters ?? undefined,
206
+ totalVolumes: entry.media.volumes ?? undefined,
207
+ });
208
+ }
209
+ }
210
+ return entries;
211
+ }
146
212
  async updateMediaEntry(params) {
147
213
  const mutation = `
148
214
  mutation ($mediaId: Int, $status: MediaListStatus, $progress: Int, $score: Float) {