Skip to content

Commit

Permalink
fix get_anime_details
Browse files Browse the repository at this point in the history
  • Loading branch information
yoshikuniii committed Nov 15, 2023
1 parent 5fe2caf commit 5855e1e
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 14 deletions.
1 change: 0 additions & 1 deletion example.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
print(anime_details.season)
print(anime_details.synopsis)
print(anime_details.genres) # output on list data type. Example : ['Comedy', 'Ecchi', 'Slice of Life']
print(anime_details.released)
print(anime_details.status)
print(anime_details.image_url)

Expand Down
4 changes: 1 addition & 3 deletions pynimeapi/classes/datatype.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,12 @@ def __str__(self):
class AnimeDetailsObj:
def __init__(
self, season: str, title: str,
synopsis: str, genres: list,
released: int, status: str,
synopsis: str, genres: list, status: str,
image_url: str):
self.title = title
self.season = season
self.synopsis = synopsis
self.genres = genres
self.released = released
self.status = status
self.image_url = image_url

Expand Down
19 changes: 11 additions & 8 deletions pynimeapi/pynime.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def __init__(self, base_url: str = "https://gogoanimeapp.com"):
self.baseURL = base_url # domain of GoGoAnime. please update regularly

def version(self):
return "0.1.56"
return "0.1.57"

def search_anime(self, anime_title: str) -> SearchResultObj:
"""
Expand Down Expand Up @@ -62,7 +62,6 @@ def get_anime_details(self, anime_category_url: str) -> AnimeDetailsObj:
.season : season of anime aired
.synopsis : plot of anime
.genres : genres
.released : year of released
.status : status, ongoing or finished
.image_url : anime cover image
'''
Expand All @@ -76,11 +75,16 @@ def get_anime_details(self, anime_category_url: str) -> AnimeDetailsObj:
title = info_body.find("h1").text.strip()
season = other_info[0].text.replace("\n", "").replace("Type: ", "")
synopsis = other_info[1].text.replace("\n", "")
genres = [
x["title"]
for x in BeautifulSoup(str(other_info[2]), "lxml").find_all("a")
]
released = other_info[3].text.replace("Released: ", "")

# look for genres
genres = [] # empty list
pattern_genres = re.compile(r'Genre:\s*(.*)$')
match_genres = pattern_genres.search(other_info[3].text.replace("\n", ""))

if match_genres:
genres = match_genres.group(1).split(', ')


status = other_info[4].text.replace("\n", "").replace("Status: ", "")
image_url = image_url

Expand All @@ -89,7 +93,6 @@ def get_anime_details(self, anime_category_url: str) -> AnimeDetailsObj:
season=season,
synopsis=synopsis,
genres=genres,
released=released,
status=status,
image_url=image_url
)
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pynimeapi"
version = "0.1.56"
version = "0.1.57"
description = "Yet simple API wrapper for GoGoAnime"
authors = ["Yoshkuni Kuniumi <101183804+yoshikuniii@users.noreply.github.com>"]
license = "GNU General Public License v3.0"
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from setuptools import setup, find_packages

VERSION = '0.1.56'
VERSION = '0.1.57'
DESCRIPTION = 'Yet simple API wrapper for GoGoAnime'
LONG_DESCRIPTION = 'PyNime is a (simple) straightforward Python3 script to scrape GoGoAnime using Python. The project ' \
'is a work in progress, not finished yet. But, the code works well, feel free to take part of the ' \
Expand Down

0 comments on commit 5855e1e

Please sign in to comment.