init (pre-existing): added template oop implementation
This commit is contained in:
commit
0625362cda
13 changed files with 178 additions and 0 deletions
45
src/providers/hianime.py
Normal file
45
src/providers/hianime.py
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
# Dependencies
|
||||
import re
|
||||
import requests
|
||||
from urllib.parse import quote_plus as urlencode
|
||||
# Assets
|
||||
from core.provider import Provider
|
||||
|
||||
|
||||
|
||||
|
||||
search_expr = '<a href="([^"]+)" title="[^"]+" class="dynamic-name" data-jname="[^"]+"'
|
||||
|
||||
search_expr2 = ('<div class="flw-item">\s*'
|
||||
'<div class="film-poster">\s*')
|
||||
#'<div class="film-detail">.+</div>\s*'
|
||||
#'<div class="clearfix">.+\s*'
|
||||
#'</div>\s*'
|
||||
#'</div>')
|
||||
|
||||
class hianime(Provider):
|
||||
_NAME = 'HiAnime'
|
||||
_BOOTSTRAP = 'https://hianime.tv'
|
||||
def __init__(self) -> None:
|
||||
pass
|
||||
def GetMirrors(self) -> list[str]:
|
||||
content = requests.get('https://hianime.tv').text
|
||||
expr = '<a href="([a-z\./:]+)" title="">'
|
||||
|
||||
# for some reason hianime doesn't advertise `hianime.to` as a mirror
|
||||
matches = re.findall(expr, content)
|
||||
if 'https://hianime.to' not in matches:
|
||||
matches.append('https://hianime.to')
|
||||
return matches
|
||||
|
||||
def SearchAnime(self, mirror: str, query: str) -> list[str]: #-> list[Anime]:
|
||||
urlsafe_query = urlencode(query)
|
||||
url = f'{mirror}/search?keyword={urlsafe_query}&sort=default'
|
||||
content = requests.get(url).text
|
||||
#print(content)
|
||||
|
||||
matches = re.findall(search_expr, content)
|
||||
return matches
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue