Skip to content

Commit

Permalink
Fix sito
Browse files Browse the repository at this point in the history
Aggiunta la funzione setCookie
  • Loading branch information
MainKronos committed May 1, 2021
1 parent 547a1e2 commit db2d6a9
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 11 deletions.
27 changes: 17 additions & 10 deletions animeworld/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import inspect

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': ''}

def find(animeName):
ret = {}
Expand Down Expand Up @@ -46,20 +47,26 @@ class Anime:

def __init__(self, link):
self.link = link
self.html = self.__getHTML()
self.__setCookie()
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):
raw = self.__getHTML().text
cookies['AWCookietest'] = re.search(r'document\.cookie="AWCookietest=(.+) ;', raw).group(1)

# Private
@HealthCheck
def __getHTML(self):
r = requests.get(self.link, headers = HDR, cookies={})
r = requests.get(self.link, headers = HDR, cookies=cookies)
r.raise_for_status()
return r.content
return r

# Private
@HealthCheck
Expand Down Expand Up @@ -219,7 +226,7 @@ def _getFileLink(self):
anime_id = self.link.split("/")[-1]
video_link = "https://www.animeworld.tv/api/episode/serverPlayerAnimeWorld?id={}".format(anime_id)

sb_get = requests.get(video_link, headers = self._HDR, cookies={})
sb_get = requests.get(video_link, headers = self._HDR, cookies=cookies)
sb_get.raise_for_status()

soupeddata = BeautifulSoup(sb_get.content, "html.parser")
Expand All @@ -241,10 +248,10 @@ def _getFileLink(self):
external_link = "https://www.animeworld.tv/api/episode/serverPlayerAnimeWorld?id={}".format(anime_id)
"https://www.animeworld.tv/api/episode/serverPlayerAnimeWorld?id=vKmnNB"

sb_get = requests.get(self.link, headers = self._HDR, cookies={})
sb_get = requests.get(self.link, headers = self._HDR, cookies=cookies)
sb_get.raise_for_status()

sb_get = requests.get(external_link, headers = self._HDR, cookies={})
sb_get = requests.get(external_link, headers = self._HDR, cookies=cookies)
soupeddata = BeautifulSoup(sb_get.content, "html.parser")
sb_get.raise_for_status()

Expand All @@ -264,10 +271,10 @@ def _getFileLink(self):
anime_id = self.link.split("/")[-1]
external_link = "https://www.animeworld.tv/api/episode/serverPlayerAnimeWorld?id={}".format(anime_id)

sb_get = requests.get(self.link, headers = self._HDR, cookies={})
sb_get = requests.get(self.link, headers = self._HDR, cookies=cookies)
sb_get.raise_for_status()

sb_get = requests.get(external_link, headers = self._HDR, cookies={})
sb_get = requests.get(external_link, headers = self._HDR, cookies=cookies)
soupeddata = BeautifulSoup(sb_get.content, "html.parser")
sb_get.raise_for_status()

Expand All @@ -283,11 +290,11 @@ class Streamtape(Server):
# Protected
@HealthCheck
def _getFileLink(self):
sb_get = requests.get(self.link, headers = self._HDR, cookies={})
sb_get = requests.get(self.link, headers = self._HDR, cookies=cookies)
if sb_get.status_code == 200:
soupeddata = BeautifulSoup(sb_get.content, "html.parser")
site_link = soupeddata.find("div", { "id" : "external-downloads" }).find("a", { "class" : "btn-streamtape" }).get("href")
sb_get = requests.get(site_link, headers = self._HDR, cookies={})
sb_get = requests.get(site_link, headers = self._HDR, cookies=cookies)
if sb_get.status_code == 200:

soupeddata = BeautifulSoup(sb_get.content, "html.parser")
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="animeworld", # Replace with your own username
version="1.3.2",
version="1.3.3",
author="MainKronos",
author_email="[email protected]",
description="AnimeWorld UNOFFICIAL API",
Expand Down

0 comments on commit db2d6a9

Please sign in to comment.