Skip to content
This repository was archived by the owner on Oct 19, 2019. It is now read-only.

Commit 8c6363e

Browse files
committed
converted to typescript
1 parent 036556f commit 8c6363e

40 files changed

+1270
-1114
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
node_modules
22
.idea
3-
.git
3+
.git
4+
dist
5+
types

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
node_modules
22
.idea
3-
.git
3+
.git
4+
lib

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ Simple library which helps you to retrieve...
1414

1515
## Supported Sites
1616

17-
#### Stream
17+
#### Source
1818
- <sub><img src="http://www.google.com/s2/favicons?domain=openload.co" height="20"></sub> openload.co
1919
- <sub><img src="http://www.google.com/s2/favicons?domain=oload.tv" height="20"></sub> oload.tv
2020
- <sub><img src="http://www.google.com/s2/favicons?domain=streamcloud.eu" height="20"></sub> streamcloud.eu
@@ -23,7 +23,7 @@ Simple library which helps you to retrieve...
2323
- <sub><img src="http://www.google.com/s2/favicons?domain=streamango.com" height="20"></sub> streamango.com
2424
- <sub><img src="http://www.google.com/s2/favicons?domain=rapidvideo.com" height="20"></sub> rapidvideo.com
2525

26-
#### Link
26+
#### Hoster
2727
- <sub><img src="http://www.google.com/s2/favicons?domain=gogoanime.io" height="20"></sub> gogoanime.io
2828
- <sub><img src="http://www.google.com/s2/favicons?domain=kissanime.ru" height="20"></sub> kissanime.ru
2929
<hr>
@@ -36,7 +36,7 @@ npm install sourcescrapper
3636

3737
### Usage
3838
```js
39-
const {scrappers} = require('sourcescrapper');
39+
const { scrappers } = require('sourcescrapper');
4040

4141
(async () => {
4242
const url = 'some url';

index.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

lib/Error.js

Lines changed: 0 additions & 19 deletions
This file was deleted.

lib/Hoster.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

lib/Hoster.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import objectMerge = require("object-merge");
2+
import normalizeUrl = require("normalize-url");
3+
4+
5+
const _private = new WeakMap();
6+
7+
export class Hoster {
8+
public name: string;
9+
10+
constructor({ url, name }: { url:string, name:string }) {
11+
this.url = url;
12+
this.name = name;
13+
}
14+
15+
get url(): string {
16+
return _private.get(this).url;
17+
}
18+
set url(value: string) {
19+
(_private.get(this) || _private.set(this, {}).get(this)).url = normalizeUrl(value);
20+
}
21+
22+
toJSON(): object {
23+
return objectMerge(this, _private.get(this));
24+
}
25+
}

lib/HosterInfo.js

Lines changed: 0 additions & 27 deletions
This file was deleted.

lib/HosterInfo.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import objectMerge = require("object-merge");
2+
3+
import { Info } from './Info';
4+
import { Hoster } from './Hoster';
5+
6+
7+
const _private = new WeakMap();
8+
9+
export class HosterInfo extends Info {
10+
public title: string;
11+
constructor({ hoster, title }: { hoster?:Hoster[]|Hoster, title?:string } = {}) {
12+
super();
13+
14+
this.hoster = typeof hoster === 'undefined' ? [] : Array.isArray(hoster) ? hoster : [hoster];
15+
this.title = title;
16+
}
17+
18+
get hoster(): Hoster[] {
19+
return _private.get(this).hoster;
20+
}
21+
set hoster(value: Hoster[]) {
22+
(_private.get(this) || _private.set(this, {}).get(this)).hoster = value;
23+
}
24+
25+
toJSON(): object {
26+
return objectMerge(this, _private.get(this));
27+
}
28+
}

lib/HosterScrapper.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Scrapper } from './Scrapper';
2+
import { Runner } from "./Runner";
3+
import { HosterInfo } from "./HosterInfo";
4+
5+
6+
export type HosterScrapperExec = (args: any) => HosterInfo|Promise<HosterInfo|null>|null;
7+
8+
export class HosterScrapper extends Scrapper {
9+
constructor({ name, domain, runner, runnerOptions={}, exec }: { name:string, domain?:string[]|string, runner:Runner|string, runnerOptions?:any, exec:HosterScrapperExec }) {
10+
super({
11+
name,
12+
type: 'link',
13+
domain,
14+
runner,
15+
runnerOptions,
16+
exec
17+
});
18+
}
19+
}

0 commit comments

Comments
 (0)