diff --git a/src/libs/linkstaker.pw.ts b/src/libs/linkstaker.pw.ts deleted file mode 100644 index 62dd239..0000000 --- a/src/libs/linkstaker.pw.ts +++ /dev/null @@ -1,35 +0,0 @@ -import { BaseUrlResolver, ResolvedMediaItem } from "../BaseResolver"; - -export class LinkstakerResolver extends BaseUrlResolver { - constructor() { - super({ - domains: [/https?:\/\/linkstaker/] - }); - } - - async resolveInner(_urlToResolve: string): Promise { - var links = [] as ResolvedMediaItem[]; - const response = await this.gotInstance(_urlToResolve); - var regex = /\("download"\)\.src="([^"]*)/g - -//COMBINE BOTH LINKSTAKER IMPLEMENTATION... - - var el = regex.exec(response.body)![1]; - if (el) { - var response2 = await this.gotInstance(el, { - headers: { - 'Range': 'bytes=0-1' - } - }); - const regexp = /filename=\"(.*)\"/gi; - const title = regexp.exec(response2.headers['content-disposition'] as string)![1]; - var result = { - link: el, - title: title, - isPlayable: true - }; - links.push(result); - } - return links; - } -} diff --git a/src/libs/linkstaker.ts b/src/libs/linkstaker.ts index aaa877b..a0d1ab3 100644 --- a/src/libs/linkstaker.ts +++ b/src/libs/linkstaker.ts @@ -13,24 +13,28 @@ export class LinkstakerResolver extends BaseUrlResolver { title: 'title', body: 'body@html' }); - var regex_link = /"file": "(https:[^"]*)"/g; - var link = regex_link.exec(obj.body)![1]; + const regex_link = /("file": "(https:[^"]*)")|(\("download"\)\.src="([^"]*))/g; + const regex_link_result = regex_link.exec(obj.body); + const link = regex_link_result && (regex_link_result[2] || regex_link_result[4]); if (link) { - var title = decodeURIComponent(obj.title).replace(/\+/g, ' '); - title = title.replace(' - Google Drive', '').trim(); - var result = { - link: link, - title: title, - isPlayable: true - }; - links.push(result); - var gdriveUrl = new URL(link); if (gdriveUrl.hostname.toLowerCase().endsWith('googleusercontent.com')) { + console.log(`${_urlToResolve} : googleusercontent.com link found in the page, reconstructing the drive.google.com link.`); const googleDocId = gdriveUrl.pathname.split('/').slice(-1)[0]; const constructedGoogleLInk = `https://drive.google.com/file/d/${googleDocId}/view`; links.push({ link: constructedGoogleLInk, isPlayable: false } as ResolvedMediaItem); + } else { + var title = decodeURIComponent(obj.title).replace(/\+/g, ' '); + title = title.replace(' - Google Drive', '').trim(); + var result = { + link: link, + title: title, + isPlayable: true + }; + links.push(result); } + } else { + console.log(`${_urlToResolve} : No valid link found in the page.`); } return links; } diff --git a/src/libs/racaty.ts b/src/libs/racaty.ts deleted file mode 100644 index 35bb8f3..0000000 --- a/src/libs/racaty.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { BaseUrlResolver, ResolvedMediaItem } from "../BaseResolver"; - -export class RacatyResolver extends BaseUrlResolver { - constructor() { - super({ - domains: [/https?:\/\/racaty/] - }); - } - - async resolveInner(_urlToResolve: string): Promise { - var links = []; - const response = await this.gotInstance(_urlToResolve); - const form = await this.getHiddenForm(response.body); - - const response2 = await this.gotInstance.post(_urlToResolve, { - body: form - }); - - const link = await this.xInstance(response2.body, '#DIV_1>a@href'); - if (link) { - const title = this.extractFileNameFromUrl(link); - var result = {title, link, isPlayable:true} as ResolvedMediaItem; - links.push(result); - } - return links; - } -} \ No newline at end of file