mgbuild 1.7.7 → 1.7.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.
package/lib/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as br from "./mgs/br";
2
2
  import * as rm from "./mgs/rm";
3
+ import * as mo from "./mgs/mo";
3
4
  export * from "./mgs/md";
4
5
  export * from "./hqs";
5
6
  export { GeekGen } from "./utils/tools";
@@ -7,4 +8,5 @@ export * from "./@types";
7
8
  export declare const AlternativeSources: {
8
9
  br: typeof br;
9
10
  rm: typeof rm;
11
+ mo: typeof mo;
10
12
  };
package/lib/index.js CHANGED
@@ -35771,6 +35771,13 @@ __nccwpck_require__.d(rm_namespaceObject, {
35771
35771
  "Scraper": () => (rm_Scraper)
35772
35772
  });
35773
35773
 
35774
+ // NAMESPACE OBJECT: ./src/mgs/mo/index.ts
35775
+ var mo_namespaceObject = {};
35776
+ __nccwpck_require__.r(mo_namespaceObject);
35777
+ __nccwpck_require__.d(mo_namespaceObject, {
35778
+ "Scraper": () => (mo_Scraper)
35779
+ });
35780
+
35774
35781
  ;// CONCATENATED MODULE: ./node_modules/cheerio/dist/esm/options.js
35775
35782
  const defaultOpts = {
35776
35783
  _useHtmlParser2: false,
@@ -54243,7 +54250,11 @@ function tools_getText(url, options) {
54243
54250
  });
54244
54251
  }
54245
54252
  function urlFromSrcSet(srcset) {
54246
- return ((srcset === null || srcset === void 0 ? void 0 : srcset.split(" ").filter((a) => a.includes("http")).at(-1)) || "");
54253
+ var _a;
54254
+ return (((_a = srcset === null || srcset === void 0 ? void 0 : srcset.split(",").map((a) => {
54255
+ const [url, val] = a.split(" ").filter(Boolean);
54256
+ return { url: url.trim(), size: Number(val.replace(/\D/g, "")) };
54257
+ }).sort((a, b) => b.size - a.size).find((a) => a.url.includes("http"))) === null || _a === void 0 ? void 0 : _a.url) || "");
54247
54258
  }
54248
54259
  function getJSON(url, options) {
54249
54260
  return __awaiter(this, void 0, void 0, function* () {
@@ -55514,6 +55525,311 @@ class rm_Scraper {
55514
55525
  }
55515
55526
  }
55516
55527
 
55528
+ ;// CONCATENATED MODULE: ./src/mgs/mo/manga.ts
55529
+
55530
+
55531
+ function mo_manga_getChapters($, slug) {
55532
+ const chapters = [];
55533
+ $(".wp-manga-chapter a").each((_, el) => {
55534
+ var _a;
55535
+ const chapter = {};
55536
+ const number = (_a = $(el)) === null || _a === void 0 ? void 0 : _a.text();
55537
+ const link = $(el).attr("href");
55538
+ if (!link)
55539
+ return;
55540
+ chapter.id = mo_manga_getChapterCode(link);
55541
+ chapter.number = getChapterNumber(number);
55542
+ if (chapter.number === undefined)
55543
+ return;
55544
+ chapter.title = getChapterTitle(chapter.number);
55545
+ chapter.geek = `capitulo-${chapter.number}-${slug}`;
55546
+ chapters.push(chapter);
55547
+ });
55548
+ return chapters.reverse();
55549
+ }
55550
+ function mo_manga_getChapterCode(link) {
55551
+ var _a;
55552
+ return (_a = link === null || link === void 0 ? void 0 : link.split("/")) === null || _a === void 0 ? void 0 : _a.filter((a) => a).slice(-2).join("/");
55553
+ }
55554
+ function mo_manga_scrapeTags($) {
55555
+ const tags = [];
55556
+ $(".genres-content a").each((_, el) => {
55557
+ const tag = $(el).text();
55558
+ if (!tag)
55559
+ return;
55560
+ tags.push(tag);
55561
+ });
55562
+ return getTags(tags.join(""));
55563
+ }
55564
+ function mo_manga_getDescription($) {
55565
+ var _a, _b, _c;
55566
+ return (_c = (_b = (_a = $(".post-content_item > div > p")) === null || _a === void 0 ? void 0 : _a.text()) === null || _b === void 0 ? void 0 : _b.replace(/\r|\n/gi, "")) === null || _c === void 0 ? void 0 : _c.trim();
55567
+ }
55568
+ function mo_manga_getManga($, slug) {
55569
+ var _a, _b;
55570
+ const manga = {};
55571
+ manga.title = (_b = (_a = $(".post-title h1")) === null || _a === void 0 ? void 0 : _a.text()) === null || _b === void 0 ? void 0 : _b.trim();
55572
+ manga.geek = GeekGen(manga.title);
55573
+ manga.slug = toSlug(manga.title);
55574
+ if (!slug)
55575
+ return manga;
55576
+ manga.description = mo_manga_getDescription($);
55577
+ manga.cover = urlFromSrcSet($(".summary_image .img-responsive").attr("srcset"));
55578
+ manga.tags = mo_manga_scrapeTags($);
55579
+ manga.available = !manga.tags.includes("+18");
55580
+ const isValidCover = !manga.cover.includes("data:image");
55581
+ if (!isValidCover)
55582
+ manga.cover = "";
55583
+ return manga;
55584
+ }
55585
+
55586
+ ;// CONCATENATED MODULE: ./src/mgs/mo/chapter.ts
55587
+ var mo_chapter_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
55588
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
55589
+ return new (P || (P = Promise))(function (resolve, reject) {
55590
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
55591
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
55592
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
55593
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
55594
+ });
55595
+ };
55596
+ function mo_chapter_getChapter($) {
55597
+ return mo_chapter_awaiter(this, void 0, void 0, function* () {
55598
+ try {
55599
+ const pages = [];
55600
+ $(".reading-content img").each((_, el) => {
55601
+ const page = $(el).attr("src");
55602
+ if (!page)
55603
+ return;
55604
+ pages.push(page.trim());
55605
+ });
55606
+ return { pages };
55607
+ }
55608
+ catch (e) {
55609
+ return { pages: [] };
55610
+ }
55611
+ });
55612
+ }
55613
+
55614
+ ;// CONCATENATED MODULE: ./src/mgs/mo/recent.ts
55615
+
55616
+ function mo_recent_getRecentList($) {
55617
+ const recents = [];
55618
+ $(".page-listing-item .page-item-detail").each((_, el) => {
55619
+ var _a, _b;
55620
+ const aTag = $(el).find(".post-title a");
55621
+ const link = aTag === null || aTag === void 0 ? void 0 : aTag.attr("href");
55622
+ const title = (_a = aTag === null || aTag === void 0 ? void 0 : aTag.text()) === null || _a === void 0 ? void 0 : _a.trim();
55623
+ const cover = urlFromSrcSet((_b = $(el).find(".item-thumb img")) === null || _b === void 0 ? void 0 : _b.attr("srcset"));
55624
+ const isValidCover = !cover.includes("data:image");
55625
+ if (!link)
55626
+ return;
55627
+ const manga = {
55628
+ title,
55629
+ cover: isValidCover ? cover : undefined,
55630
+ code: getSlug(link),
55631
+ chapters: [],
55632
+ };
55633
+ $(el)
55634
+ .find(".list-chapter .chapter a")
55635
+ .each((_, el) => {
55636
+ const title = $(el).text();
55637
+ if (!title)
55638
+ return;
55639
+ const number = getChapterNumber(title);
55640
+ if (!number)
55641
+ return;
55642
+ manga.chapters.push(number);
55643
+ });
55644
+ recents.push(manga);
55645
+ });
55646
+ return recents;
55647
+ }
55648
+
55649
+ ;// CONCATENATED MODULE: ./src/mgs/mo/headers.ts
55650
+ /* harmony default export */ const mo_headers = ({
55651
+ manga: {
55652
+ referer: "https://mangaonline.blog/",
55653
+ accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
55654
+ "accept-language": "pt-BR,pt;q=0.9",
55655
+ "cache-control": "no-cache",
55656
+ priority: "u=0, i",
55657
+ pragma: "no-cache",
55658
+ "sec-ch-ua": '"Not.A/Brand";v="8", "Chromium";v="117", "Google Chrome";v="114"',
55659
+ "sec-ch-ua-mobile": "?0",
55660
+ "sec-ch-ua-platform": '"Windows"',
55661
+ "sec-fetch-dest": "document",
55662
+ "sec-fetch-mode": "navigate",
55663
+ "sec-fetch-site": "none",
55664
+ "sec-fetch-user": "?1",
55665
+ "sec-gpc": "1",
55666
+ "upgrade-insecure-requests": "1",
55667
+ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36",
55668
+ },
55669
+ chapter: {
55670
+ referer: "https://mangaonline.blog/",
55671
+ accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
55672
+ "accept-language": "pt-BR,pt;q=0.9",
55673
+ "cache-control": "no-cache",
55674
+ priority: "u=0, i",
55675
+ pragma: "no-cache",
55676
+ "sec-ch-ua": '"Not.A/Brand";v="8", "Chromium";v="117", "Google Chrome";v="114"',
55677
+ "sec-ch-ua-mobile": "?0",
55678
+ "sec-ch-ua-platform": '"Windows"',
55679
+ "sec-fetch-dest": "document",
55680
+ "sec-fetch-mode": "navigate",
55681
+ "sec-fetch-site": "none",
55682
+ "sec-fetch-user": "?1",
55683
+ "sec-gpc": "1",
55684
+ "upgrade-insecure-requests": "1",
55685
+ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36",
55686
+ },
55687
+ chapterList: {
55688
+ accept: "*/*",
55689
+ "accept-language": "pt-BR,pt;q=0.7",
55690
+ "cache-control": "no-cache",
55691
+ pragma: "no-cache",
55692
+ priority: "u=1, i",
55693
+ "sec-ch-ua": '"Not.A/Brand";v="8", "Chromium";v="117", "Google Chrome";v="114"',
55694
+ "sec-ch-ua-mobile": "?0",
55695
+ "sec-ch-ua-platform": '"Windows"',
55696
+ "sec-fetch-dest": "empty",
55697
+ "sec-fetch-mode": "cors",
55698
+ "sec-fetch-site": "same-origin",
55699
+ "sec-gpc": "1",
55700
+ "x-requested-with": "XMLHttpRequest",
55701
+ "Referrer-Policy": "strict-origin-when-cross-origin",
55702
+ },
55703
+ recent: {
55704
+ referer: "https://mangaonline.blog/",
55705
+ accept: "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8",
55706
+ "accept-language": "pt-BR,pt;q=0.9",
55707
+ "cache-control": "no-cache",
55708
+ priority: "u=0, i",
55709
+ pragma: "no-cache",
55710
+ "sec-ch-ua": '"Not.A/Brand";v="8", "Chromium";v="117", "Google Chrome";v="114"',
55711
+ "sec-ch-ua-mobile": "?0",
55712
+ "sec-ch-ua-platform": '"Windows"',
55713
+ "sec-fetch-dest": "document",
55714
+ "sec-fetch-mode": "navigate",
55715
+ "sec-fetch-site": "none",
55716
+ "sec-fetch-user": "?1",
55717
+ "sec-gpc": "1",
55718
+ "upgrade-insecure-requests": "1",
55719
+ "user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36",
55720
+ },
55721
+ });
55722
+
55723
+ ;// CONCATENATED MODULE: ./src/mgs/mo/config.ts
55724
+ /* harmony default export */ const mo_config = ({
55725
+ manga: {
55726
+ SCRAPE_BASE_URL: "https://mangaonline.blog",
55727
+ EMPTY_THUMB: "https://i.imgur.com/2rtqQH3.jpg",
55728
+ EMPTY_BACKGROUND: "https://i.imgur.com/c46jEEF.jpg",
55729
+ },
55730
+ });
55731
+
55732
+ ;// CONCATENATED MODULE: ./src/mgs/mo/index.ts
55733
+ var mo_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
55734
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
55735
+ return new (P || (P = Promise))(function (resolve, reject) {
55736
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
55737
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
55738
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
55739
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
55740
+ });
55741
+ };
55742
+
55743
+
55744
+
55745
+
55746
+
55747
+
55748
+ const { manga: mo_manga } = mo_config;
55749
+ class mo_Scraper {
55750
+ constructor(logger) {
55751
+ this.logger = logger;
55752
+ }
55753
+ chapterList(referer, slug) {
55754
+ var _a;
55755
+ return mo_awaiter(this, void 0, void 0, function* () {
55756
+ const url = `${referer}/ajax/chapters/`;
55757
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.call(this, {
55758
+ type: "ping",
55759
+ method: "manga",
55760
+ time: Date.now().toString(),
55761
+ url,
55762
+ });
55763
+ const html = yield HTML(url, {
55764
+ headers: Object.assign(Object.assign({}, mo_headers.chapterList), { referer: url }),
55765
+ method: "POST",
55766
+ });
55767
+ return mo_manga_getChapters(html, slug);
55768
+ });
55769
+ }
55770
+ manga(manga_code) {
55771
+ var _a;
55772
+ return mo_awaiter(this, void 0, void 0, function* () {
55773
+ const url = `${mo_manga.SCRAPE_BASE_URL}/manga/${manga_code}`;
55774
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.call(this, {
55775
+ type: "ping",
55776
+ method: "manga",
55777
+ time: Date.now().toString(),
55778
+ url,
55779
+ });
55780
+ const html = yield HTML(url, {
55781
+ headers: mo_headers.manga,
55782
+ });
55783
+ const data = mo_manga_getManga(html, manga_code);
55784
+ data.chapters = yield this.chapterList(url, data.slug);
55785
+ return data;
55786
+ });
55787
+ }
55788
+ chapterById(chapter_id) {
55789
+ var _a;
55790
+ return mo_awaiter(this, void 0, void 0, function* () {
55791
+ const url = `${mo_manga.SCRAPE_BASE_URL}/manga/${chapter_id}`;
55792
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.call(this, {
55793
+ type: "ping",
55794
+ method: "chapter",
55795
+ time: Date.now().toString(),
55796
+ url,
55797
+ });
55798
+ const html = yield HTML(url, {
55799
+ headers: mo_headers.chapter,
55800
+ });
55801
+ return mo_chapter_getChapter(html);
55802
+ });
55803
+ }
55804
+ chapter(manga_code, chapter_number) {
55805
+ return mo_awaiter(this, void 0, void 0, function* () {
55806
+ const data = yield this.manga(manga_code);
55807
+ const chapter = data.chapters.find((chapter) => chapter.number === chapter_number);
55808
+ if (!chapter.id)
55809
+ return { pages: [] };
55810
+ return this.chapterById(chapter.id);
55811
+ });
55812
+ }
55813
+ recents(page = 1) {
55814
+ var _a;
55815
+ return mo_awaiter(this, void 0, void 0, function* () {
55816
+ let url = mo_manga.SCRAPE_BASE_URL;
55817
+ if (page > 1)
55818
+ url += `/page/${page}`;
55819
+ (_a = this.logger) === null || _a === void 0 ? void 0 : _a.call(this, {
55820
+ type: "ping",
55821
+ method: "recents",
55822
+ time: Date.now().toString(),
55823
+ url,
55824
+ });
55825
+ const mangas = yield HTML(url, {
55826
+ headers: mo_headers.recent,
55827
+ });
55828
+ return mo_recent_getRecentList(mangas);
55829
+ });
55830
+ }
55831
+ }
55832
+
55517
55833
  ;// CONCATENATED MODULE: ./src/mgs/md/core/utils.ts
55518
55834
  var utils_awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {
55519
55835
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
@@ -56302,9 +56618,11 @@ function getHqDetails(id) {
56302
56618
 
56303
56619
 
56304
56620
 
56621
+
56305
56622
  const AlternativeSources = {
56306
56623
  br: br_namespaceObject,
56307
56624
  rm: rm_namespaceObject,
56625
+ mo: mo_namespaceObject,
56308
56626
  };
56309
56627
 
56310
56628
  })();
@@ -0,0 +1,4 @@
1
+ /// <reference types="cheerio" />
2
+ export declare function getChapter($: cheerio.Root): Promise<{
3
+ pages: string[];
4
+ }>;
@@ -0,0 +1,8 @@
1
+ declare const _default: {
2
+ manga: {
3
+ SCRAPE_BASE_URL: string;
4
+ EMPTY_THUMB: string;
5
+ EMPTY_BACKGROUND: string;
6
+ };
7
+ };
8
+ export default _default;
@@ -0,0 +1,73 @@
1
+ declare const _default: {
2
+ manga: {
3
+ referer: string;
4
+ accept: string;
5
+ "accept-language": string;
6
+ "cache-control": string;
7
+ priority: string;
8
+ pragma: string;
9
+ "sec-ch-ua": string;
10
+ "sec-ch-ua-mobile": string;
11
+ "sec-ch-ua-platform": string;
12
+ "sec-fetch-dest": string;
13
+ "sec-fetch-mode": string;
14
+ "sec-fetch-site": string;
15
+ "sec-fetch-user": string;
16
+ "sec-gpc": string;
17
+ "upgrade-insecure-requests": string;
18
+ "user-agent": string;
19
+ };
20
+ chapter: {
21
+ referer: string;
22
+ accept: string;
23
+ "accept-language": string;
24
+ "cache-control": string;
25
+ priority: string;
26
+ pragma: string;
27
+ "sec-ch-ua": string;
28
+ "sec-ch-ua-mobile": string;
29
+ "sec-ch-ua-platform": string;
30
+ "sec-fetch-dest": string;
31
+ "sec-fetch-mode": string;
32
+ "sec-fetch-site": string;
33
+ "sec-fetch-user": string;
34
+ "sec-gpc": string;
35
+ "upgrade-insecure-requests": string;
36
+ "user-agent": string;
37
+ };
38
+ chapterList: {
39
+ accept: string;
40
+ "accept-language": string;
41
+ "cache-control": string;
42
+ pragma: string;
43
+ priority: string;
44
+ "sec-ch-ua": string;
45
+ "sec-ch-ua-mobile": string;
46
+ "sec-ch-ua-platform": string;
47
+ "sec-fetch-dest": string;
48
+ "sec-fetch-mode": string;
49
+ "sec-fetch-site": string;
50
+ "sec-gpc": string;
51
+ "x-requested-with": string;
52
+ "Referrer-Policy": string;
53
+ };
54
+ recent: {
55
+ referer: string;
56
+ accept: string;
57
+ "accept-language": string;
58
+ "cache-control": string;
59
+ priority: string;
60
+ pragma: string;
61
+ "sec-ch-ua": string;
62
+ "sec-ch-ua-mobile": string;
63
+ "sec-ch-ua-platform": string;
64
+ "sec-fetch-dest": string;
65
+ "sec-fetch-mode": string;
66
+ "sec-fetch-site": string;
67
+ "sec-fetch-user": string;
68
+ "sec-gpc": string;
69
+ "upgrade-insecure-requests": string;
70
+ "user-agent": string;
71
+ };
72
+ };
73
+ export default _default;
@@ -0,0 +1,21 @@
1
+ type Log = {
2
+ type: "ping" | "error";
3
+ method: string;
4
+ url: string;
5
+ time: string;
6
+ };
7
+ type Logger = (log: Log) => any;
8
+ export declare class Scraper {
9
+ private logger?;
10
+ constructor(logger?: Logger);
11
+ private chapterList;
12
+ manga(manga_code: string): Promise<import("../..").ScrapedManga>;
13
+ chapterById(chapter_id: string | number): Promise<{
14
+ pages: string[];
15
+ }>;
16
+ chapter(manga_code: string, chapter_number: number): Promise<{
17
+ pages: string[];
18
+ }>;
19
+ recents(page?: number): Promise<import("../..").RecentScrapeList[]>;
20
+ }
21
+ export {};
@@ -0,0 +1,4 @@
1
+ /// <reference types="cheerio" />
2
+ import { ScrapedHostChapter, ScrapedManga } from "../../@types";
3
+ export declare function getChapters($: cheerio.Root, slug: string): ScrapedHostChapter[];
4
+ export declare function getManga($: cheerio.Root, slug: string): ScrapedManga;
@@ -0,0 +1,3 @@
1
+ /// <reference types="cheerio" />
2
+ import { RecentScrapeList } from "../../@types";
3
+ export declare function getRecentList($: cheerio.Root): RecentScrapeList[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mgbuild",
3
- "version": "1.7.7",
3
+ "version": "1.7.8",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "keywords": [],