@untidy/animeflv
Advanced tools
Comparing version 0.1.1 to 0.2.0
@@ -1,2 +0,2 @@ | ||
export { getInformation, getInformationMobile, getPages, getTitles, getTitlesMobile } from './cheerio.js'; | ||
export { getInformation, getInformationMobile, getPages, getTitles, getTitlesMobile, getVideos } from './cheerio.js'; | ||
export { browseAnime, browseFilter } from './url.js'; |
@@ -22,2 +22,6 @@ export interface TitleMobile { | ||
} | ||
export interface Video { | ||
server?: string; | ||
url?: string; | ||
} | ||
/** | ||
@@ -38,3 +42,3 @@ * @description Retrieves the information of the title/anime for the path "anime" on the desktop site. | ||
* @param html - Plain html text. | ||
* @returns Returns an Array of objects with the following properties: `title`, `slug`, `type`, `description` and `cover`. | ||
* @returns An array of objects with the following properties: `title`, `slug`, `type`, `description` and `cover`. | ||
*/ | ||
@@ -45,11 +49,18 @@ export declare function getTitles(html: string): Title[]; | ||
* @param html - Plain html text. | ||
* @returns Returns an Array of objects with the following properties: `title`, `slug`, `type` and `cover`. | ||
* @returns An array of objects with the following properties: `title`, `slug`, `type` and `cover`. | ||
*/ | ||
export declare function getTitlesMobile(html: string): TitleMobile[]; | ||
/** | ||
* @description Allows retrieving the pagination for the path "browse". Works on desktop and mobile site. | ||
* @description Get pagination suffix pages for the path "browse" by parsing the given HTML. | ||
* Works on both desktop and mobile sites. | ||
* @param html - Plain html text. | ||
* @returns Returns an array from the pagination containing suffix pages. | ||
* - example: ['/browse?page=1', '/browse?page=2'] | ||
* @returns An array of strings containing the suffix pages for the pagination. | ||
* - Example: ['/browse?page=1', '/browse?page=2'] | ||
*/ | ||
export declare function getPages(html: string): string[]; | ||
/** | ||
* @description Allows retrieving the videos for the path "ver". Works on desktop and mobile site. | ||
* @param html - Plain html text. | ||
* @returns An array of objects containing the server name and the URL. | ||
*/ | ||
export declare function getVideos(html: string): Video[]; |
@@ -77,3 +77,3 @@ import { load } from 'cheerio'; | ||
* @param html - Plain html text. | ||
* @returns Returns an Array of objects with the following properties: `title`, `slug`, `type`, `description` and `cover`. | ||
* @returns An array of objects with the following properties: `title`, `slug`, `type`, `description` and `cover`. | ||
*/ | ||
@@ -96,3 +96,3 @@ export function getTitles(html) { | ||
* @param html - Plain html text. | ||
* @returns Returns an Array of objects with the following properties: `title`, `slug`, `type` and `cover`. | ||
* @returns An array of objects with the following properties: `title`, `slug`, `type` and `cover`. | ||
*/ | ||
@@ -112,6 +112,7 @@ export function getTitlesMobile(html) { | ||
/** | ||
* @description Allows retrieving the pagination for the path "browse". Works on desktop and mobile site. | ||
* @description Get pagination suffix pages for the path "browse" by parsing the given HTML. | ||
* Works on both desktop and mobile sites. | ||
* @param html - Plain html text. | ||
* @returns Returns an array from the pagination containing suffix pages. | ||
* - example: ['/browse?page=1', '/browse?page=2'] | ||
* @returns An array of strings containing the suffix pages for the pagination. | ||
* - Example: ['/browse?page=1', '/browse?page=2'] | ||
*/ | ||
@@ -130,1 +131,31 @@ export function getPages(html) { | ||
} | ||
/** | ||
* @description Allows retrieving the videos for the path "ver". Works on desktop and mobile site. | ||
* @param html - Plain html text. | ||
* @returns An array of objects containing the server name and the URL. | ||
*/ | ||
export function getVideos(html) { | ||
const videos = []; | ||
const cheerioInstance = load(html); | ||
cheerioInstance('script:not([src])').each((_index, element) => { | ||
const scriptContent = cheerioInstance(element).html(); | ||
// early return if is null or doesn't include episodes | ||
if (scriptContent === null || !scriptContent.includes('SUB')) | ||
return; | ||
const titleObjects = scriptContent.match(/"title"\s*:\s*"([^"]+)"/g); | ||
const codeObjects = scriptContent.match(/"code"\s*:\s*"([^"]+)"/g); | ||
if (!titleObjects || !codeObjects) | ||
return; | ||
if (titleObjects.length !== codeObjects.length) | ||
return; | ||
const titles = titleObjects.map((title) => title.replace(/"/g, '').replace('title:', '')); | ||
const links = codeObjects.map((code) => code.replace(/"/g, '').replace('code:', '')); | ||
for (let i = 0; i < titles.length; i++) { | ||
videos.push({ | ||
server: titles[i], | ||
url: links[i], | ||
}); | ||
} | ||
}); | ||
return videos; | ||
} |
@@ -1,2 +0,2 @@ | ||
export { getInformation, getInformationMobile, getPages, getTitles, getTitlesMobile } from './cheerio.js'; | ||
export { getInformation, getInformationMobile, getPages, getTitles, getTitlesMobile, getVideos } from './cheerio.js'; | ||
export { browseAnime, browseFilter } from './url.js'; |
@@ -1,2 +0,2 @@ | ||
export { getInformation, getInformationMobile, getPages, getTitles, getTitlesMobile } from './cheerio.js'; | ||
export { getInformation, getInformationMobile, getPages, getTitles, getTitlesMobile, getVideos } from './cheerio.js'; | ||
export { browseAnime, browseFilter } from './url.js'; |
{ | ||
"name": "@untidy/animeflv", | ||
"description": "web scraping tools for animeflv site", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"type": "module", | ||
@@ -34,3 +34,3 @@ "main": "./dist/index.js", | ||
"devDependencies": { | ||
"@types/node": "^20.4.1", | ||
"@types/node": "^20.4.2", | ||
"cheerio": "1.0.0-rc.12", | ||
@@ -37,0 +37,0 @@ "tsx": "^3.12.7", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
28289
315
0