Skip to content

Commit

Permalink
add new field complete_title in fetching drama
Browse files Browse the repository at this point in the history
Difference from `title`:
	Example: `Goblin (2016)`
      Title = `Goblin`
      Complete Title = `Goblin (2016)`
  • Loading branch information
tbdsux committed Apr 1, 2023
1 parent e8fdb1c commit 657d240
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
7 changes: 6 additions & 1 deletion api/fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@ def _get_main_container(self) -> None:
# these are the most important drama infos / details

# TITLE
self.info["title"] = container.find("h1", class_="film-title").find("a").text
# Example: Goblin (2016)
# Title = Goblin
# Complete Title = Goblin (2016)
film_title = container.find("h1", class_="film-title")
self.info["title"] = film_title.find("a").get_text().strip()
self.info["complete_title"] = film_title.get_text().strip()

# RATING (could be either N/A or with number)
self.info["rating"] = self._handle_rating(
Expand Down
12 changes: 8 additions & 4 deletions tests/test_main.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ def test_index() -> None:
def test_sample_drama() -> None:
dramas = [
{
"id": "65743-alien-girl-chai-xiao-qi-2",
"title": "My Girlfriend Is an Alien 2",
"id": "18452-goblin",
"expected": {"title": "Goblin", "complete_title": "Goblin (2016)"},
},
{
"id": "58953-mouse",
"expected": {"title": "Mouse", "complete_title": "Mouse (2021)"},
},
{"id": "58953-mouse", "title": "Mouse"},
]

for i in dramas:
Expand All @@ -27,7 +30,8 @@ def test_sample_drama() -> None:

print(r.json()["data"])

assert r.json()["data"]["title"] == i["title"]
assert r.json()["data"]["title"] == i["expected"]["title"]
assert r.json()["data"]["complete_title"] == i["expected"]["complete_title"]


def test_unknown_drama() -> None:
Expand Down

1 comment on commit 657d240

@vercel
Copy link

@vercel vercel bot commented on 657d240 Apr 1, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

kuryana – ./

kuryana.vercel.app
kuryana-git-master-theboringdude.vercel.app
kuryana-theboringdude.vercel.app

Please sign in to comment.