Skip to content
This repository has been archived by the owner on Oct 4, 2024. It is now read-only.

Commit

Permalink
Update anime downloaders with episode URL changes
Browse files Browse the repository at this point in the history
  • Loading branch information
ReiLoko4 committed Feb 18, 2024
1 parent 1d8e1f8 commit 11fc5e7
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 13 deletions.
6 changes: 3 additions & 3 deletions MangaYouKnow/backend/anime_downloaders/anime_fire.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def get_episodes(self, anime_id: str) -> list[Chapter] | bool:
return episodes[::-1]
return False

def get_episode_url(self, episode_id: str) -> Episode | bool:
def get_episode_url(self, episode_id: str) -> Episode | str:
response = self.session.get(f'{self.base_url}/animes/{episode_id}')
if response.status_code == 200:
soup = BeautifulSoup(response.content, 'html.parser')
Expand All @@ -73,5 +73,5 @@ def get_episode_url(self, episode_id: str) -> Episode | bool:
)
for episode in video_json.json()['data']
][::-1]
return False
return False
return f'{self.base_url}/animes/{episode_id}'
return f'{self.base_url}/animes/{episode_id}'
2 changes: 1 addition & 1 deletion MangaYouKnow/backend/anime_downloaders/animes_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,4 @@ def get_episode_url(self, episode_id: str) -> Episode | list[Episode] | bool:
)
for iframe, a in zip(iframes, a)
]
return False
return f'{self.base_url}/episodio/{episode_id}'
6 changes: 4 additions & 2 deletions MangaYouKnow/backend/anime_downloaders/animes_vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,12 @@ def get_episodes(self, anime_id: str) -> list[Chapter] | bool:
return episodes[::-1]
return False

def get_episode_url(self, episode_id: str) -> Episode | bool:
def get_episode_url(self, episode_id: str) -> Episode | str:
response = self.session.get(f'{self.base_url}/animes/{episode_id}')
if response.status_code == 200:
soup = BeautifulSoup(response.content, 'html.parser')
return f'{self.base_url}/animes/{episode_id}'

div_script = soup.find_all('div', {'wire:initial-data': True})[1]
script = json.loads(div_script['wire:initial-data'])
urls = []
Expand All @@ -125,5 +127,5 @@ def get_episode_url(self, episode_id: str) -> Episode | bool:
)
for url, label in zip(urls, labels)
][::-1]
return False
return f'{self.base_url}/animes/{episode_id}'

4 changes: 2 additions & 2 deletions MangaYouKnow/backend/anime_downloaders/better_anime.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,10 +85,10 @@ def get_url_by_quality(self, quality_info: str) -> str | bool:
if quality_match:
return quality_match.group(1).replace('\\', '')

def get_episode_url(self, episode_id: str) -> list[Episode] | Episode | bool:
def get_episode_url(self, episode_id: str) -> list[Episode] | Episode | str:
response = self.session.get(f'{self.base_url}/anime/{episode_id}')
if not response:
return False
return f'{self.base_url}/anime/{episode_id}'
url_and_label = []
matches = re.findall(r'qualityString\["([^"]*)"\]\s*=\s*"([^"]*)"', response.text)
for match in matches:
Expand Down
2 changes: 1 addition & 1 deletion MangaYouKnow/backend/anime_downloaders/goyabu.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,4 +73,4 @@ def get_episode_url(self, episode_id: str) -> Episode | bool:
return Episode(
url=url
)
return False
return f'{self.base_url}/{episode_id}'
26 changes: 23 additions & 3 deletions MangaYouKnow/screen/components/manga_open.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import webbrowser

import flet as ft
import pyperclip
from backend.database import DataBase
from backend.managers import DownloadManager
from backend.models import Chapter, Episode
Expand Down Expand Up @@ -85,12 +88,27 @@ def read(source, manga: Favorite, chapter: Chapter, chapters: list[Chapter], lan
dl.download_mpv()
status.value = 'Procurando o episódio...'
page.update()
print(chapter)
episode_urls = dl.get_episode_url(source, chapter.id)
print(episode_urls)
if type(episode_urls) == bool:
if type(episode_urls) == str:
status.value = 'Erro ao encontrar o episódio!'
status.color = ft.colors.RED_500
row_content.controls = []
row_content.controls = [
ft.Column([
ft.Text('Você pode assistir diretamente no link: '),
ft.TextField(value=episode_urls, read_only=True, width=240, border_radius=20, height=70, border_color=ft.colors.GREY_700, focused_border_color=ft.colors.BLUE_300),
ft.Row([
ft.FilledButton('Copiar', on_click=lambda e: pyperclip.copy(episode_urls), ),
ft.FilledButton('Abrir no navegador', on_click=lambda e: webbrowser.open(episode_urls),),
], alignment=ft.MainAxisAlignment.CENTER, width=250),
ft.Text('Assistiu?'),
ft.Row([
ft.IconButton(icon=ft.icons.CHECK, on_click=lambda e: (togle_readed(source, manga, chapter, language if language else None, True), MangaOpen(manga_info, source_languages, togle_notify, page, is_index, cards_row, mangas_card_notify))),
ft.IconButton(icon=ft.icons.HIGHLIGHT_REMOVE, on_click=lambda e: MangaOpen(manga_info, source_languages, togle_notify, page, is_index, cards_row, mangas_card_notify)),
], alignment=ft.MainAxisAlignment.CENTER, width=250),
])
]
page.update()
return
def select_option(ep: Episode):
Expand Down Expand Up @@ -133,8 +151,10 @@ def select_option(ep: Episode):
MangaOpen(manga_info, source_languages, togle_notify, page, is_index, cards_row, mangas_card_notify)

btns_list: list[ft.IconButton] = []
def togle_readed(source, manga: Favorite, chapter: Chapter, language: str=None):
def togle_readed(source, manga: Favorite, chapter: Chapter, language: str=None, just_read: bool=False) -> None:
if db.is_readed(source, manga.id, manga.source_id, chapter.id, language if language else None):
if just_read:
return
db.delete_all_readed_above(manga, source, chapter, chapters_by_source[f'{source}_{language_options.value}'], language if language else None)
else:
db.add_all_readed_below(manga, source, chapter, chapters_by_source[f'{source}_{language_options.value}'], language if language else None)
Expand Down
2 changes: 1 addition & 1 deletion MangaYouKnow/screen/pages/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ def __init__(self, page: ft.Page):
]
anime_options = [
ft.dropdown.Option('ba', text='BetterAnime'),
# ft.dropdown.Option('av', text='AnimesVision'),
ft.dropdown.Option('av', text='AnimesVision'),
ft.dropdown.Option('af', text='AnimeFire'),
# ft.dropdown.Option('ah', text='AnimesHouse'),
ft.dropdown.Option('go', text='Goyabu'),
Expand Down

0 comments on commit 11fc5e7

Please sign in to comment.