From e3207e95a81ea44a0e637511420e553c6e42864f Mon Sep 17 00:00:00 2001 From: Toasty Date: Thu, 21 Mar 2024 08:51:19 -0500 Subject: [PATCH 1/3] added turkish123 --- src/providers/movies/index.ts | 2 + src/providers/movies/turkish123.ts | 105 +++++++++++++++++++++++++++++ test/movies/turkish123.test.ts | 21 ++++++ 3 files changed, 128 insertions(+) create mode 100644 src/providers/movies/turkish123.ts create mode 100644 test/movies/turkish123.test.ts diff --git a/src/providers/movies/index.ts b/src/providers/movies/index.ts index e358fb5a2..52f480f0e 100644 --- a/src/providers/movies/index.ts +++ b/src/providers/movies/index.ts @@ -5,6 +5,7 @@ import Goku from './goku'; import KissAsian from './kissasian'; import MovieHdWatch from './movidhdwatch'; import SmashyStream from './smashystream'; +import Turkish from './turkish123'; import ViewAsian from './viewAsian'; export default { @@ -16,4 +17,5 @@ export default { MovieHdWatch, SmashyStream, ViewAsian, + Turkish, }; diff --git a/src/providers/movies/turkish123.ts b/src/providers/movies/turkish123.ts new file mode 100644 index 000000000..b255db7fd --- /dev/null +++ b/src/providers/movies/turkish123.ts @@ -0,0 +1,105 @@ +import { load } from 'cheerio'; +import { IAnimeInfo, IEpisodeServer, IMovieInfo, ISource, MovieParser, TvType } from '../../models'; +import axios from 'axios'; + +export default class Turkish extends MovieParser { + name: string = 'Turkish123'; + protected baseUrl: string = 'https://turkish123.ac/'; + protected classPath: string = 'MOVIES.Turkish'; + supportedTypes: Set = new Set([TvType.TVSERIES]); + + async fetchMediaInfo(mediaId: string, type?: string | undefined): Promise { + var info: IMovieInfo = { id: mediaId, title: '' }; + + try { + var { data } = await this.client(this.baseUrl + mediaId, { + headers: { + 'User-Agent': + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36', + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', + Referer: this.baseUrl, + }, + }); + const $ = load(data); + info.image = $('#content-cover') + .attr('style')! + .match(/url\((.*?)\)/)![1]; + info.title = $('.mvic-desc > h1').text(); + info.description = $('.f-desc') + .text() + .replace(/[\n\t\b]/g, ''); + info.romaji = $('.yellowi').text(); + info.tags = $('.mvici-left > p:nth-child(3)') + .find('a') + .map((_, e) => $(e).text()) + .get(); + info.rating = parseFloat($('.imdb-r').text()); + info.releaseDate = $('.mvici-right > p:nth-child(3)').find('a').first().text(); + info.totalEpisodes = $('.les-content > a').length; + info.episodes = $('.les-content > a') + .map((i, e) => ({ + id: $(e).attr('href')!.split('/').slice(-2)[0], + title: `Episode ${i + 1}`, + })) + .get(); + } catch (error) {} + return info; + } + async fetchEpisodeSources(episodeId: string, ...args: any): Promise { + var source: ISource = { sources: [{ url: '' }], headers: { Referer: 'https://tukipasti.com' } }; + try { + var { data } = await this.client(this.baseUrl + episodeId, { + headers: { + 'User-Agent': + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36', + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', + Referer: this.baseUrl, + }, + }); + const resp = await (await axios(data.match(/"(https:\/\/tukipasti.com\/t\/.*?)"/)![1])).data; + source.sources[0].url = resp.match(/var urlPlay = '(.*?)'/)![1]; + } catch (error) {} + return source; + } + fetchEpisodeServers(episodeId: string, ...args: any): Promise { + throw new Error('Method not implemented.'); + } + async search(q: string, ...args: any[]): Promise { + var params = `wp-admin/admin-ajax.php?s=${q}&action=searchwp_live_search&swpengine=default&swpquery=${q}`; + try { + var { data } = await this.client(this.baseUrl + params, { + headers: { + 'User-Agent': + 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36', + 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', + Referer: this.baseUrl, + }, + }); + const $ = load(data); + var result: IMovieInfo[] = []; + $('li') + .not('.ss-bottom') + .each((_, ele) => { + result.push({ + id: $(ele).find('a').attr('href')!.replace(this.baseUrl, '').replace('/', ''), + image: + $(ele) + .find('a') + .attr('style')! + .match(/url\((.*?)\)/)![1] ?? '', + title: $(ele).find('.ss-title').text(), + tags: $(ele) + .find('.ss-info >a') + .not('.ss-title') + .map((_, e) => $(e).text()) + .get() + .filter(v => v != 'NULL'), + }); + }); + return result; + } catch (error) { + console.log(error); + } + return []; + } +} diff --git a/test/movies/turkish123.test.ts b/test/movies/turkish123.test.ts new file mode 100644 index 000000000..78788e31a --- /dev/null +++ b/test/movies/turkish123.test.ts @@ -0,0 +1,21 @@ +import { MOVIES } from '../../src/providers'; + +jest.setTimeout(120000); + +const turk = new MOVIES.Turkish(); + +test('returns a filled array of tv', async () => { + const data = await turk.search('sen'); + expect(data).not.toEqual([]); +}); + +test('returns info of movie', async () => { + const data = await turk.fetchMediaInfo('sen-cal-kapimi'); + expect(data.episodes).not.toEqual([]); + expect(data.title).not.toEqual(''); +}); + +test('returns a m3u8 links', async () => { + const data = await turk.fetchEpisodeSources('sen-cal-kapimi-episode-2'); + expect(data.sources[0].url).not.toEqual(''); +}); From f62b97263e0d74d51e8131225f86c6c07cb36f89 Mon Sep 17 00:00:00 2001 From: codefactor-io Date: Thu, 21 Mar 2024 13:58:32 +0000 Subject: [PATCH 2/3] [CodeFactor] Apply fixes to commit e3207e9 --- src/providers/movies/turkish123.ts | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/providers/movies/turkish123.ts b/src/providers/movies/turkish123.ts index b255db7fd..e0e1467f5 100644 --- a/src/providers/movies/turkish123.ts +++ b/src/providers/movies/turkish123.ts @@ -9,10 +9,10 @@ export default class Turkish extends MovieParser { supportedTypes: Set = new Set([TvType.TVSERIES]); async fetchMediaInfo(mediaId: string, type?: string | undefined): Promise { - var info: IMovieInfo = { id: mediaId, title: '' }; + const info: IMovieInfo = { id: mediaId, title: '' }; try { - var { data } = await this.client(this.baseUrl + mediaId, { + const { data } = await this.client(this.baseUrl + mediaId, { headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36', @@ -46,9 +46,9 @@ export default class Turkish extends MovieParser { return info; } async fetchEpisodeSources(episodeId: string, ...args: any): Promise { - var source: ISource = { sources: [{ url: '' }], headers: { Referer: 'https://tukipasti.com' } }; + const source: ISource = { sources: [{ url: '' }], headers: { Referer: 'https://tukipasti.com' } }; try { - var { data } = await this.client(this.baseUrl + episodeId, { + const { data } = await this.client(this.baseUrl + episodeId, { headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36', @@ -65,9 +65,9 @@ export default class Turkish extends MovieParser { throw new Error('Method not implemented.'); } async search(q: string, ...args: any[]): Promise { - var params = `wp-admin/admin-ajax.php?s=${q}&action=searchwp_live_search&swpengine=default&swpquery=${q}`; + const params = `wp-admin/admin-ajax.php?s=${q}&action=searchwp_live_search&swpengine=default&swpquery=${q}`; try { - var { data } = await this.client(this.baseUrl + params, { + const { data } = await this.client(this.baseUrl + params, { headers: { 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36', @@ -76,7 +76,7 @@ export default class Turkish extends MovieParser { }, }); const $ = load(data); - var result: IMovieInfo[] = []; + const result: IMovieInfo[] = []; $('li') .not('.ss-bottom') .each((_, ele) => { From 9a59a00bf5865652a7361882b5866ce3fe9dcff2 Mon Sep 17 00:00:00 2001 From: Toast <46423269+Toasty360@users.noreply.github.com> Date: Thu, 21 Mar 2024 22:33:03 -0500 Subject: [PATCH 3/3] Update turkish123.ts - removed unwanted args - replaced axios --- src/providers/movies/turkish123.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/providers/movies/turkish123.ts b/src/providers/movies/turkish123.ts index e0e1467f5..7f27538c7 100644 --- a/src/providers/movies/turkish123.ts +++ b/src/providers/movies/turkish123.ts @@ -8,7 +8,7 @@ export default class Turkish extends MovieParser { protected classPath: string = 'MOVIES.Turkish'; supportedTypes: Set = new Set([TvType.TVSERIES]); - async fetchMediaInfo(mediaId: string, type?: string | undefined): Promise { + async fetchMediaInfo(mediaId: string): Promise { const info: IMovieInfo = { id: mediaId, title: '' }; try { @@ -45,7 +45,7 @@ export default class Turkish extends MovieParser { } catch (error) {} return info; } - async fetchEpisodeSources(episodeId: string, ...args: any): Promise { + async fetchEpisodeSources(episodeId: string): Promise { const source: ISource = { sources: [{ url: '' }], headers: { Referer: 'https://tukipasti.com' } }; try { const { data } = await this.client(this.baseUrl + episodeId, { @@ -56,15 +56,15 @@ export default class Turkish extends MovieParser { Referer: this.baseUrl, }, }); - const resp = await (await axios(data.match(/"(https:\/\/tukipasti.com\/t\/.*?)"/)![1])).data; + const resp = (await this.client(data.match(/"(https:\/\/tukipasti.com\/t\/.*?)"/)![1])).data; source.sources[0].url = resp.match(/var urlPlay = '(.*?)'/)![1]; } catch (error) {} return source; } - fetchEpisodeServers(episodeId: string, ...args: any): Promise { + fetchEpisodeServers(): Promise { throw new Error('Method not implemented.'); } - async search(q: string, ...args: any[]): Promise { + async search(q: string): Promise { const params = `wp-admin/admin-ajax.php?s=${q}&action=searchwp_live_search&swpengine=default&swpquery=${q}`; try { const { data } = await this.client(this.baseUrl + params, {