From b7bc51f358d352b6153e3cd280046bb9839eaf9b Mon Sep 17 00:00:00 2001 From: marco Date: Sat, 22 Feb 2020 11:14:10 +0100 Subject: [PATCH] ops --- channels.json | 45 ++++ lib/cloudscraper/exceptions/__init__.py | 0 .../exceptions/cloudflare_exceptions.py | 31 +++ .../exceptions/reCaptcha_exceptions.py | 49 +++++ lib/cloudscraper/reCaptcha/9kw.py | 202 ++++++++++++++++++ 5 files changed, 327 insertions(+) create mode 100644 channels.json create mode 100644 lib/cloudscraper/exceptions/__init__.py create mode 100644 lib/cloudscraper/exceptions/cloudflare_exceptions.py create mode 100644 lib/cloudscraper/exceptions/reCaptcha_exceptions.py create mode 100644 lib/cloudscraper/reCaptcha/9kw.py diff --git a/channels.json b/channels.json new file mode 100644 index 00000000..7a41019f --- /dev/null +++ b/channels.json @@ -0,0 +1,45 @@ +{ + "altadefinizione01": "https://altadefinizione01.media", + "altadefinizione01_link": "https://altadefinizione01.kim", + "altadefinizioneclick": "https://altadefinizione.style", + "animeforce": "https://ww1.animeforce.org", + "animeleggendari": "https://animepertutti.com", + "animesaturn": "https://www.animesaturn.com", + "animestream": "https://www.animeworld.it", + "animesubita": "http://www.animesubita.org", + "animetubeita": "http://www.animetubeita.com", + "animeunity": "https://www.animeunity.it", + "animeworld": "https://www.animeworld.tv", + "casacinema": "https://www.casacinema.bid", + "casacinemaInfo": "https://casacinema.blue", + "cb01anime": "https://www.cineblog01.ink", + "cinetecadibologna": "http://cinestore.cinetecadibologna.it", + "dreamsub": "https://dreamsub.stream", + "dsda": "https://www.dsda.press/", + "fastsubita": "https://fastsubita.com", + "filmgratis": "https://www.filmaltadefinizione.org", + "filmigratis": "https://filmigratis.org", + "filmpertutti": "https://www.filmpertutti.date", + "filmsenzalimiticc": "https://www.filmsenzalimiti.london", + "filmstreaming01": "https://filmstreaming01.com", + "guardarefilm": "https://www.guardarefilm.red", + "guardaserie_stream": "https://guardaserie.store", + "guardaserieclick": "https://www.guardaserie.media", + "ilgeniodellostreaming": "https://ilgeniodellostreaming.si", + "italiaserie": "https://italiaserie.org", + "mondoserietv": "https://mondoserietv.com", + "netfreex": "https://www.netfreex.pro", + "piratestreaming": "https://www.piratestreaming.gratis", + "polpotv": "https://polpo.tv", + "pufimovies": "https://pufimovies.com", + "raiplay": "https://www.raiplay.it", + "seriehd": "https://seriehd.click", + "serietvonline": "https://serietvonline.icu", + "serietvsubita": "http://serietvsubita.xyz", + "serietvu": "https://www.serietvu.link", + "streamtime": "https://t.me/s/StreamTime", + "tantifilm": "https://www.tantifilm.eu", + "toonitalia": "https://toonitalia.org", + "vedohd": "https://vedohd.uno", + "vvvvid": "https://www.vvvvid.it" +} \ No newline at end of file diff --git a/lib/cloudscraper/exceptions/__init__.py b/lib/cloudscraper/exceptions/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/lib/cloudscraper/exceptions/cloudflare_exceptions.py b/lib/cloudscraper/exceptions/cloudflare_exceptions.py new file mode 100644 index 00000000..e7a25e16 --- /dev/null +++ b/lib/cloudscraper/exceptions/cloudflare_exceptions.py @@ -0,0 +1,31 @@ +# ------------------------------------------------------------------------------- # + + +class Cloudflare_Loop_Protection(Exception): + """ + Raise error for recursive depth protection + """ + + +class Cloudflare_Block(Exception): + """ + Raise error for Cloudflare 1020 block + """ + + +class Cloudflare_Error_IUAM(Exception): + """ + Raise error for problem extracting IUAM paramters from Cloudflare payload + """ + + +class Cloudflare_Error_reCaptcha(Exception): + """ + Raise error for problem extracting reCaptcha paramters from Cloudflare payload + """ + + +class Cloudflare_reCaptcha_Provider(Exception): + """ + Raise error for reCaptcha from Cloudflare, no provider loaded. + """ diff --git a/lib/cloudscraper/exceptions/reCaptcha_exceptions.py b/lib/cloudscraper/exceptions/reCaptcha_exceptions.py new file mode 100644 index 00000000..4a263d1d --- /dev/null +++ b/lib/cloudscraper/exceptions/reCaptcha_exceptions.py @@ -0,0 +1,49 @@ +# ------------------------------------------------------------------------------- # + + +class reCaptcha_Service_Unavailable(Exception): + """ + Raise error for external services that cannot be reached + """ + + +class reCaptcha_Error_From_API(Exception): + """ + Raise error for error from API response. + """ + + +class reCaptcha_Account_Error(Exception): + """ + Raise error for reCaptcha provider account problem. + """ + + +class reCaptcha_Timeout(Exception): + """ + Raise error for reCaptcha provider taking too long. + """ + + +class reCaptcha_Bad_Parameter(NotImplementedError): + """ + Raise error for bad or missing Parameter. + """ + + +class reCaptcha_Bad_Job_ID(Exception): + """ + Raise error for invalid job id. + """ + + +class reCaptcha_Report_Error(Exception): + """ + Raise error for reCaptcha provider unable to report bad solve. + """ + + +class reCaptcha_Import_Error(Exception): + """ + Raise error for reCaptcha, cannot import a module. + """ diff --git a/lib/cloudscraper/reCaptcha/9kw.py b/lib/cloudscraper/reCaptcha/9kw.py new file mode 100644 index 00000000..d887cf80 --- /dev/null +++ b/lib/cloudscraper/reCaptcha/9kw.py @@ -0,0 +1,202 @@ +from __future__ import absolute_import + +import re +import requests +import reCaptcha_exceptions + +try: + import polling +except ImportError: + import sys + sys.tracebacklimit = 0 + raise reCaptcha_exceptions.reCaptcha_Import_Error( + "Please install the python module 'polling' via pip or download it from " + "https://github.com/justiniso/polling/" + ) + +from . import reCaptcha + + +class captchaSolver(reCaptcha): + + def __init__(self): + super(captchaSolver, self).__init__('9kw') + self.host = 'https://www.9kw.eu/index.cgi' + self.maxtimeout = 180 + self.session = requests.Session() + + # ------------------------------------------------------------------------------- # + + @staticmethod + def checkErrorStatus(response): + if response.status_code in [500, 502]: + raise reCaptcha_exceptions.reCaptcha_Service_Unavailable( + '9kw: Server Side Error {}'.format(response.status_code) + ) + + error_codes = { + 1: 'No API Key available.', + 2: 'No API key found.', + 3: 'No active API key found.', + 4: 'API Key has been disabled by the operator. ', + 5: 'No user found.', + 6: 'No data found.', + 7: 'Found No ID.', + 8: 'found No captcha.', + 9: 'No image found.', + 10: 'Image size not allowed.', + 11: 'credit is not sufficient.', + 12: 'what was done.', + 13: 'No answer contain.', + 14: 'Captcha already been answered.', + 15: 'Captcha to quickly filed.', + 16: 'JD check active.', + 17: 'Unknown problem.', + 18: 'Found No ID.', + 19: 'Incorrect answer.', + 20: 'Do not timely filed (Incorrect UserID).', + 21: 'Link not allowed.', + 22: 'Prohibited submit.', + 23: 'Entering prohibited.', + 24: 'Too little credit.', + 25: 'No entry found.', + 26: 'No Conditions accepted.', + 27: 'No coupon code found in the database.', + 28: 'Already unused voucher code.', + 29: 'maxTimeout under 60 seconds.', + 30: 'User not found.', + 31: 'An account is not yet 24 hours in system.', + 32: 'An account does not have the full rights.', + 33: 'Plugin needed a update.', + 34: 'No HTTPS allowed.', + 35: 'No HTTP allowed.', + 36: 'Source not allowed.', + 37: 'Transfer denied.', + 38: 'Incorrect answer without space', + 39: 'Incorrect answer with space', + 40: 'Incorrect answer with not only numbers', + 41: 'Incorrect answer with not only A-Z, a-z', + 42: 'Incorrect answer with not only 0-9, A-Z, a-z', + 43: 'Incorrect answer with not only [0-9,- ]', + 44: 'Incorrect answer with not only [0-9A-Za-z,- ]', + 45: 'Incorrect answer with not only coordinates', + 46: 'Incorrect answer with not only multiple coordinates', + 47: 'Incorrect answer with not only data', + 48: 'Incorrect answer with not only rotate number', + 49: 'Incorrect answer with not only text', + 50: 'Incorrect answer with not only text and too short', + 51: 'Incorrect answer with not enough chars', + 52: 'Incorrect answer with too many chars', + 53: 'Incorrect answer without no or yes', + 54: 'Assignment was not found.' + } + + if response.text.startswith('{'): + if response.json().get('error'): + raise reCaptcha_exceptions.reCaptcha_Error_From_API(error_codes.get(int(response.json().get('error')))) + else: + error_code = int(re.search(r'^00(?P\d+)', response.text).groupdict().get('error_code', 0)) + if error_code: + raise reCaptcha_exceptions.reCaptcha_Error_From_API(error_codes.get(error_code)) + + # ------------------------------------------------------------------------------- # + + def requestJob(self, jobID): + if not jobID: + raise reCaptcha_exceptions.reCaptcha_Bad_Job_ID( + "9kw: Error bad job id to request reCaptcha against." + ) + + def _checkRequest(response): + if response.ok and response.json().get('answer') != 'NO DATA': + return response + + self.checkErrorStatus(response) + + return None + + response = polling.poll( + lambda: self.session.get( + self.host, + params={ + 'apikey': self.api_key, + 'action': 'usercaptchacorrectdata', + 'id': jobID, + 'info': 1, + 'json': 1 + } + ), + check_success=_checkRequest, + step=10, + timeout=(self.maxtimeout + 10) + ) + + if response: + return response.json().get('answer') + else: + raise reCaptcha_exceptions.reCaptcha_Timeout("9kw: Error failed to solve reCaptcha.") + + # ------------------------------------------------------------------------------- # + + def requestSolve(self, site_url, site_key): + def _checkRequest(response): + if response.ok and response.text.startswith('{') and response.json().get('captchaid'): + return response + + self.checkErrorStatus(response) + + return None + + response = polling.poll( + lambda: self.session.post( + self.host, + data={ + 'apikey': self.api_key, + 'action': 'usercaptchaupload', + 'interactive': 1, + 'file-upload-01': site_key, + 'oldsource': 'recaptchav2', + 'pageurl': site_url, + 'maxtimeout': self.maxtimeout, + 'json': 1 + }, + allow_redirects=False + ), + check_success=_checkRequest, + step=5, + timeout=(self.maxtimeout + 10) + ) + + if response: + return response.json().get('captchaid') + else: + raise reCaptcha_exceptions.reCaptcha_Bad_Job_ID('9kw: Error no valid job id was returned.') + + # ------------------------------------------------------------------------------- # + + def getCaptchaAnswer(self, site_url, site_key, reCaptchaParams): + jobID = None + + if not reCaptchaParams.get('api_key'): + raise reCaptcha_exceptions.reCaptcha_Bad_Parameter("9kw: Missing api_key parameter.") + + self.api_key = reCaptchaParams.get('api_key') + + if reCaptchaParams.get('maxtimeout'): + self.maxtimeout = reCaptchaParams.get('maxtimeout') + + if reCaptchaParams.get('proxy'): + self.session.proxies = reCaptchaParams.get('proxies') + + try: + jobID = self.requestSolve(site_url, site_key) + return self.requestJob(jobID) + except polling.TimeoutException: + raise reCaptcha_exceptions.reCaptcha_Timeout( + "9kw: reCaptcha solve took to long to execute 'captchaid' {}, aborting.".format(jobID) + ) + +# ------------------------------------------------------------------------------- # + + +captchaSolver()