Skip to content

Commit

Permalink
2.11.0
Browse files Browse the repository at this point in the history
  • Loading branch information
mbme committed Aug 7, 2024
1 parent f85d91e commit 35d05f5
Show file tree
Hide file tree
Showing 12 changed files with 264 additions and 207 deletions.
345 changes: 179 additions & 166 deletions docs/scraper.user.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions docs/scraper.user.js.map

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scraper",
"version": "2.10.0",
"version": "2.11.0",
"description": "Scrape the data from the page you're on.",
"main": "index.js",
"types": "types/index.d.ts",
Expand Down
15 changes: 9 additions & 6 deletions types/scrapers/any-image.d.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
import { Scraper } from './scraper';
export type Image = {
typeName: 'Image';
import { BaseScrapeResult, Scraper } from './scraper';
export interface Image extends BaseScrapeResult<'Image'> {
imageURL: string;
};
export declare class ImageScraper extends Scraper<'Image', Image> {
}
export declare class ImageScraper extends Scraper<Image> {
readonly pattern: URLPattern;
readonly scrape: () => Image;
scrape(): {
typeName: "Image";
version: number;
imageURL: string;
};
}
25 changes: 19 additions & 6 deletions types/scrapers/imdb-film.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Scraper } from './scraper';
export type IMDBFilm = {
typeName: 'IMDBFilm';
import { BaseScrapeResult, Scraper } from './scraper';
export interface IMDBFilm extends BaseScrapeResult<'IMDBFilm'> {
title: string;
coverURL: string;
releaseDate: string;
Expand All @@ -12,8 +11,22 @@ export type IMDBFilm = {
episodes?: number;
duration: string;
description: string;
};
export declare class IMDBFilmScraper extends Scraper<'IMDBFilm', IMDBFilm> {
}
export declare class IMDBFilmScraper extends Scraper<IMDBFilm> {
readonly pattern: URLPattern;
readonly scrape: () => Promise<IMDBFilm>;
scrape(): Promise<{
typeName: "IMDBFilm";
version: number;
title: string;
coverURL: string;
releaseDate: string;
originalLanguage: string;
countriesOfOrigin: string;
creators: string;
cast: string;
seasons: number | undefined;
episodes: number | undefined;
duration: string;
description: string;
}>;
}
2 changes: 1 addition & 1 deletion types/scrapers/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import { IMDBFilm } from './imdb-film';
import { Image } from './any-image';
export type { YakabooBook, SteamGame, MyAnimeListAnime, IMDBFilm, Image };
export type ScrapedData = YakabooBook | SteamGame | MyAnimeListAnime | IMDBFilm | Image;
export declare const SCRAPERS: Scraper<ScrapedData['typeName'], ScrapedData>[];
export declare const SCRAPERS: Scraper<ScrapedData>[];
20 changes: 14 additions & 6 deletions types/scrapers/myanimelist-anime.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import { Scraper } from './scraper';
export type MyAnimeListAnime = {
typeName: 'MyAnimeListAnime';
import { BaseScrapeResult, Scraper } from './scraper';
export interface MyAnimeListAnime extends BaseScrapeResult<'MyAnimeListAnime'> {
title: string;
coverURL: string;
releaseDate: string;
creators: string;
duration: string;
description: string;
};
export declare class MyAnimeListAnimeScraper extends Scraper<'MyAnimeListAnime', MyAnimeListAnime> {
}
export declare class MyAnimeListAnimeScraper extends Scraper<MyAnimeListAnime> {
readonly pattern: URLPattern;
readonly scrape: () => MyAnimeListAnime;
scrape(): {
typeName: "MyAnimeListAnime";
version: number;
title: string;
coverURL: string;
releaseDate: string;
creators: string;
duration: string;
description: string;
};
}
8 changes: 5 additions & 3 deletions types/scrapers/scraper.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import 'urlpattern-polyfill';
export declare abstract class Scraper<TypeName extends string, Data extends {
export interface BaseScrapeResult<TypeName extends string> {
typeName: TypeName;
}> {
version: number;
}
export declare abstract class Scraper<R extends BaseScrapeResult<string>> {
abstract readonly pattern: URLPattern;
abstract readonly scrape: (() => Data) | (() => Promise<Data>);
abstract scrape(): Promise<R> | R;
}
19 changes: 13 additions & 6 deletions types/scrapers/steam-game.d.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,20 @@
import { Scraper } from './scraper';
export type SteamGame = {
typeName: 'SteamGame';
import { BaseScrapeResult, Scraper } from './scraper';
export interface SteamGame extends BaseScrapeResult<'SteamGame'> {
coverURL: string;
name: string;
releaseDate: string;
developers: string;
description: string;
};
export declare class SteamGameScraper extends Scraper<'SteamGame', SteamGame> {
}
export declare class SteamGameScraper extends Scraper<SteamGame> {
readonly pattern: URLPattern;
readonly scrape: () => SteamGame;
scrape(): {
typeName: "SteamGame";
version: number;
coverURL: string;
name: string;
releaseDate: string;
developers: string;
description: string;
};
}
23 changes: 17 additions & 6 deletions types/scrapers/yakaboo-book.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Scraper } from './scraper';
export type YakabooBook = {
typeName: 'YakabooBook';
import { BaseScrapeResult, Scraper } from './scraper';
export interface YakabooBook extends BaseScrapeResult<'YakabooBook'> {
coverURL: string;
title: string;
authors: string;
Expand All @@ -10,8 +9,20 @@ export type YakabooBook = {
publisher: string;
pages: number;
language: string;
};
export declare class YakabooBookScraper extends Scraper<'YakabooBook', YakabooBook> {
}
export declare class YakabooBookScraper extends Scraper<YakabooBook> {
readonly pattern: URLPattern;
readonly scrape: () => Promise<YakabooBook>;
scrape(): Promise<{
typeName: "YakabooBook";
version: number;
coverURL: string;
title: string;
authors: string;
publicationDate: string;
description: string;
translators: string;
publisher: string;
pages: number;
language: string;
}>;
}
2 changes: 1 addition & 1 deletion types/tsconfig.tsbuildinfo

Large diffs are not rendered by default.

0 comments on commit 35d05f5

Please sign in to comment.