-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: split parser functions in different files
- Loading branch information
1 parent
a4b8a5c
commit 5f4fc9a
Showing
11 changed files
with
147 additions
and
136 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,8 @@ | ||
from .terminal import removeFilesAndDirectories, zip | ||
from .unionLeitor import parser | ||
from .unionLeitor import getMangaListPage | ||
from .unionLeitor import getMangaListPage | ||
from .unionLeitor import isUrl | ||
from .unionLeitor import isValidUrl | ||
from .unionLeitor import isValidImage | ||
from .unionLeitor import isValidMangaImage | ||
from .unionLeitor import isNotBanner | ||
from .unionLeitor import isMangaLink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
from . import parser | ||
from .mangaListPage import getMangaListPage | ||
from .mangaListPage import getMangaListPage | ||
from .isUrl import isUrl | ||
from .isValidUrl import isValidUrl | ||
from .isValidImage import isValidImage | ||
from .isValidMangaImage import isValidMangaImage | ||
from .isNotBanner import isNotBanner | ||
from .isMangaLink import isMangaLink |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
def isMangaLink(url: str) -> bool: | ||
""" Verifica se a URL informada é de um mangá ou não. | ||
Parameters | ||
---------- | ||
url: :class:`str` | ||
URL que deseja verificar. | ||
Returns | ||
------- | ||
:class:`bool` | ||
""" | ||
|
||
if(url.find("manga") != -1): | ||
return True | ||
|
||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
def isNotBanner(url: str) -> bool: | ||
""" Verifica se a imagem é um banner. | ||
Parameters | ||
---------- | ||
url: :class:`str` | ||
URL que deseja verificar. | ||
Returns | ||
------- | ||
:class:`bool` | ||
""" | ||
|
||
if(url.find("banner") != -1): | ||
return False | ||
|
||
return True |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import List | ||
|
||
def isUrl(url: str) -> bool: | ||
""" Verifica se o que foi passado é uma URL ou não. | ||
Parameters | ||
---------- | ||
url: :class:`str` | ||
URL que deseja verificar. | ||
Returns | ||
------- | ||
:class:`bool` | ||
""" | ||
|
||
valid_urls: List[str] = ["https://", "http://"] | ||
|
||
for valid_url in valid_urls: | ||
if(url.find(valid_url) != -1): | ||
return True | ||
|
||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from typing import List | ||
|
||
def isValidImage(url: str) -> bool: | ||
""" Verifica se a URL passada é de uma imagem ou não. | ||
Obs: Tipos aceitos: .avif, .gif, .jpg, .jpeg, .png, .svg | ||
Parameters | ||
---------- | ||
url: :class:`str` | ||
URL que deseja verificar. | ||
Returns | ||
------- | ||
:class:`bool` | ||
""" | ||
|
||
image_extensions: List[str] = [".avif", ".gif", ".jpg", ".jpeg", ".png", ".svg"] | ||
|
||
for image_extension in image_extensions: | ||
if(url.find(image_extension) != -1): | ||
return True | ||
|
||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from typing import List | ||
|
||
def isValidMangaImage(url: str) -> bool: | ||
""" Verifica se a URL passada é de uma página contendo a imagem de uma | ||
página de mangá do site `unionleitor.top/`. | ||
Parameters | ||
---------- | ||
url: :class:`str` | ||
URL que deseja verificar. | ||
Returns | ||
------- | ||
:class:`bool` | ||
""" | ||
|
||
validations: List[str] = ["umangas.club", "unionleitor.top", "leitor", "mangas"] | ||
counter: int = 0 | ||
|
||
for validation in validations: | ||
if(url.find(validation) != -1): | ||
counter += 1 | ||
|
||
return counter >= 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
from typing import List | ||
|
||
def isValidUrl(url: str) -> bool: | ||
""" Verifica se a URL passada é de uma página do site `unionleitor.top/`. | ||
Parameters | ||
---------- | ||
url: :class:`str` | ||
URL que deseja verificar. | ||
Returns | ||
------- | ||
:class:`bool` | ||
""" | ||
|
||
valid_urls: List[str] = ["unionleitor.top"] | ||
|
||
for valid_url in valid_urls: | ||
if(url.find(valid_url) != -1): | ||
return True | ||
|
||
return False |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters