Skip to content

Commit

Permalink
8.2.0
Browse files Browse the repository at this point in the history
Search type
  • Loading branch information
SuperZombi committed Feb 9, 2025
1 parent d4d6022 commit 949141f
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 16 deletions.
2 changes: 1 addition & 1 deletion HdRezkaApi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@


class HdRezkaApi():
__version__ = "8.1.0"
__version__ = "8.2.0"
def __init__(self, url, proxy={}, headers={}, cookies={}):
self.url = url.split(".html")[0] + ".html"
uri = urlparse(self.url)
Expand Down
23 changes: 18 additions & 5 deletions HdRezkaApi/utils/search.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from bs4 import BeautifulSoup
from functools import lru_cache, cached_property
from urllib.parse import urlparse
from .types import (HdRezkaType, HdRezkaTVSeries, HdRezkaMovie, HdRezkaCartoon, HdRezkaAnime)
from .errors import HTTP, LoginRequiredError, CaptchaError


Expand Down Expand Up @@ -83,13 +84,25 @@ def get_page(self, page):
items = soup.find_all(class_='b-content__inline_item')
if len(items) > 0: return list(map(self.process_item, items))

@staticmethod
def process_item(item):
# id = item.attrs['data-id']
# url = item.attrs['data-url']
@classmethod
def process_item(cls, item):
link = item.find(class_='b-content__inline_item-link').find('a')
cover = item.find(class_='b-content__inline_item-cover').find('img')
url = link.attrs['href']
title = link.text.strip()
image = cover.attrs['src']
return {"title": title, "url": url, "image": image}
cat = item.find(class_='cat')
type_ = cls.detect_type(list(filter(lambda x:x!='cat',cat['class']))) if cat else None
return {"title": title, "url": url, "image": image, "type": type_}

@staticmethod
def detect_type(classes):
if 'series' in classes:
return HdRezkaTVSeries()
elif 'films' in classes:
return HdRezkaMovie()
elif 'animation' in classes:
return HdRezkaAnime()
elif 'cartoons' in classes:
return HdRezkaCartoon()
return HdRezkaType(classes[0])
11 changes: 7 additions & 4 deletions HdRezkaApi/utils/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,18 @@ def __init__(self, name):
self.name = name
def __str__(self):
return self.name
def __repr__(self): return str(self)
def __eq__(self, other):
return self.__class__ == other.__class__ or self.__class__ == other or self.name == other

class HdRezkaTVSeries(HdRezkaType):
def __init__(self):
super().__init__("tv_series")
def __init__(self): super().__init__("tv_series")
class HdRezkaMovie(HdRezkaType):
def __init__(self):
super().__init__("movie")
def __init__(self): super().__init__("movie")
class HdRezkaCartoon(HdRezkaType):
def __init__(self): super().__init__("cartoon")
class HdRezkaAnime(HdRezkaType):
def __init__(self): super().__init__("anime")


class HdRezkaRating():
Expand Down
18 changes: 13 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# HdRezkaApi

<img src="https://shields.io/badge/version-v8.1.0-blue"> <a href="#donate"><img src="https://shields.io/badge/💲-Support_Project-2ea043"></a>
<img src="https://shields.io/badge/version-v8.2.0-blue"> <a href="#donate"><img src="https://shields.io/badge/💲-Support_Project-2ea043"></a>

## Install:
```
Expand Down Expand Up @@ -249,17 +249,23 @@ for page in results:
{
'title': 'Film name',
'url': 'https://hdrezka.ag/__FILM_URL.html',
'image': 'https://hdrezka.ag/image.jpg'
'image': 'https://hdrezka.ag/image.jpg',
'type': HdRezkaType()
}
```

#### HdRezkaType

`HdRezkaTVSeries`, `HdRezkaMovie`, `HdRezkaCartoon`, `HdRezkaAnime`.

#### All pages
```python
print(results.all_pages)
```
```
[
[{'title', 'url', 'image'}, ...],
[{'title', 'url', 'image'}, ...],
[ {'title', 'url', 'image', 'type'}, ...],
[ {'title', 'url', 'image', 'type'}, ...],
...
]
```
Expand All @@ -269,7 +275,9 @@ print(results.all)
```
```
[
{'title', 'url', 'image'}, {'title', 'url', 'image'}, ...
{'title', 'url', 'image', 'type'},
{'title', 'url', 'image', 'type'},
...
]
```
#### Specific page
Expand Down
2 changes: 1 addition & 1 deletion github/pypi.build
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"folder": "C:/Users/rost/Downloads/HdRezkaApi",
"package_name": "HdRezkaApi",
"version": "8.1.0",
"version": "8.2.0",
"description": "HDRezka Python API",
"readme": "C:/Users/rost/Downloads/README.md",
"username": "Super_Zombi",
Expand Down

0 comments on commit 949141f

Please sign in to comment.