diff --git a/.gitignore b/.gitignore index 75d80aa..81498d6 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.bat animeworld.egg-info/ build/ -tests/ \ No newline at end of file +tests/ +*.pyc diff --git a/README.md b/README.md index 78d3521..0e7031e 100644 --- a/README.md +++ b/README.md @@ -51,4 +51,7 @@ scaricato ## Utilizzo Avanzato Per testare velocemete le funzionalità della libreria è possibile usare consultare il file di esempio: [`example.py`](/documentation/example.py). -Per un utilizzo avanzato consultare la [documentazione](../../wiki). \ No newline at end of file +Per un utilizzo avanzato consultare la [documentazione](../../wiki). + + +Per l'accesso al codice sorgente, alla documentazione e agli esempi andare [**qui**](https://github.com/MainKronos/Sonarr-AnimeDownloader/issues/6). \ No newline at end of file diff --git a/animeworld/__init__.py b/animeworld/__init__.py index 905c0b3..51f7a30 100644 --- a/animeworld/__init__.py +++ b/animeworld/__init__.py @@ -7,7 +7,10 @@ HDR = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36'} cookies = {'AWCookietest': None} -def find(animeName): + +## Function ########################################## + +def find(animeName): # Deprecata ret = {} search = "https://www.animeworld.tv/search?keyword={}".format(animeName.replace(" ", "%20")) @@ -31,6 +34,10 @@ def wrapper(*args, **kwargs): raise DeprecatedLibrary(funName, errLine) return wrapper +######################################################## + +## Class ############################################### + class Anime: # mapped = { # 2:"DoodStream", @@ -47,23 +54,24 @@ class Anime: def __init__(self, link): self.link = link - self.__setCookie() + self.__fixCookie() self.html = self.__getHTML().content # self.server = self.__getServer() # self.nome = self.getName() # self.trama = self.getTrama() # self.info = self.getInfo() - ### INFO #### # Private - @HealthCheck - def __setCookie(self): - if cookies['AWCookietest'] == None: - raw = self.__getHTML().text - cookies['AWCookietest'] = re.search(r'document\.cookie="AWCookietest=(.+) ;', raw).group(1) + def __fixCookie(self): + try: + res = self.__getHTML() + cookies['AWCookietest'] = re.search(r'document\.cookie="AWCookietest=(.+) ;', res.text).group(1) + except AttributeError: + pass + + ### INFO #### # Private - @HealthCheck def __getHTML(self): r = requests.get(self.link, headers = HDR, cookies=cookies) r.raise_for_status() @@ -308,7 +316,9 @@ def download(self, title=None): else: title = self.sanitize(title) return self._downloadIn(title) -### ERRORS ###### +######################################################## + +## ERRORS ############################################# class ServerNotSupported(Exception): # Il server da dove si tenta di scaricare l'episodio non è supportato def __init__(self, server): @@ -327,4 +337,4 @@ def __init__(self, funName, line): self.funName = funName self.line = line self.message = f"Il sito è cambiato, di conseguenza la libreria è DEPRECATA. -> [{funName} - {line}]" - super().__init__(self.message) \ No newline at end of file + super().__init__(self.message) diff --git a/documentation/example.py b/documentation/example.py index 6f7ef89..7e746d5 100644 --- a/documentation/example.py +++ b/documentation/example.py @@ -6,7 +6,7 @@ def main(): try: anime = aw.Anime(link="https://www.animeworld.tv/play/jaku-chara-tomozaki-kun.RDPHq") - print("Titolo", anime.getName()) # Titolo dell'anime + print("Titolo:", anime.getName()) # Titolo dell'anime print("\n----------------------------------\n") diff --git a/setup.py b/setup.py index 4517828..0de5c0e 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="animeworld", # Replace with your own username - version="1.3.4", + version="1.3.5", author="MainKronos", author_email="lorenzo.chesi@live.it", description="AnimeWorld UNOFFICIAL API",