From 4bc6a886f2ce4d4e385400aaf2caaf94168b9a97 Mon Sep 17 00:00:00 2001 From: Alfian Ali Murtadlo <115053112+AlfianAliM@users.noreply.github.com> Date: Wed, 2 Oct 2024 13:41:31 +0700 Subject: [PATCH 01/15] Update fetch_anime_and_play.py --- web_programming/fetch_anime_and_play.py | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/web_programming/fetch_anime_and_play.py b/web_programming/fetch_anime_and_play.py index fd7c3a3a7381..296f51259fac 100644 --- a/web_programming/fetch_anime_and_play.py +++ b/web_programming/fetch_anime_and_play.py @@ -1,3 +1,4 @@ +import subprocess import requests from bs4 import BeautifulSoup, NavigableString, Tag from fake_useragent import UserAgent @@ -153,6 +154,10 @@ def get_anime_episode(episode_endpoint: str) -> list: return [f"{BASE_URL}{episode_url}", f"{BASE_URL}{download_url}"] +def download_video(download_url: str, output_filename: str): + """Download video using ffmpeg.""" + command = ['ffmpeg', '-i', download_url, output_filename] + subprocess.run(command, check=True) if __name__ == "__main__": anime_name = input("Enter anime name: ").strip() @@ -173,16 +178,28 @@ def get_anime_episode(episode_endpoint: str) -> list: episode_list = search_anime_episode_list(chosen_anime["url"]) if len(episode_list) == 0: - print("No episode found for this anime") + print("No episodes found for this anime") else: print(f"Found {len(episode_list)} results: ") for i, episode in enumerate(episode_list): - print(f"{i+1}. {episode['title']}") + print(f"{i + 1}. {episode['title']}") - episode_choice = int(input("\nChoose an episode by serial no: ").strip()) + episode_choice = int(input("\nChoose an episode by serial number: ").strip()) chosen_episode = episode_list[episode_choice - 1] print(f"You chose {chosen_episode['title']}. Searching...") episode_url, download_url = get_anime_episode(chosen_episode["url"]) print(f"\nTo watch, ctrl+click on {episode_url}.") - print(f"To download, ctrl+click on {download_url}.") + + + # Add an option to download or not + download_choice = input("\nDo you want to download this episode? (yes/no): ").strip().lower() + if download_choice in ["yes", "y"]: + output_filename = f"{chosen_anime['title']} - {chosen_episode['title']}.mp4" # Change extension as needed + download_video(download_url, output_filename) + print(f"{chosen_episode['title']} has been downloaded as {output_filename}.") + else: + print("Download skipped.") + + #if error download please install ffmeg + #brew install ffmpeg for mac From 3623fbc7cc195d4f5630d8f0b1d6b950bbc16e5e Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 2 Oct 2024 06:43:46 +0000 Subject: [PATCH 02/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- web_programming/fetch_anime_and_play.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/web_programming/fetch_anime_and_play.py b/web_programming/fetch_anime_and_play.py index 296f51259fac..6c51cc977997 100644 --- a/web_programming/fetch_anime_and_play.py +++ b/web_programming/fetch_anime_and_play.py @@ -154,11 +154,13 @@ def get_anime_episode(episode_endpoint: str) -> list: return [f"{BASE_URL}{episode_url}", f"{BASE_URL}{download_url}"] + def download_video(download_url: str, output_filename: str): """Download video using ffmpeg.""" - command = ['ffmpeg', '-i', download_url, output_filename] + command = ["ffmpeg", "-i", download_url, output_filename] subprocess.run(command, check=True) + if __name__ == "__main__": anime_name = input("Enter anime name: ").strip() anime_list = search_scraper(anime_name) @@ -184,22 +186,29 @@ def download_video(download_url: str, output_filename: str): for i, episode in enumerate(episode_list): print(f"{i + 1}. {episode['title']}") - episode_choice = int(input("\nChoose an episode by serial number: ").strip()) + episode_choice = int( + input("\nChoose an episode by serial number: ").strip() + ) chosen_episode = episode_list[episode_choice - 1] print(f"You chose {chosen_episode['title']}. Searching...") episode_url, download_url = get_anime_episode(chosen_episode["url"]) print(f"\nTo watch, ctrl+click on {episode_url}.") - # Add an option to download or not - download_choice = input("\nDo you want to download this episode? (yes/no): ").strip().lower() + download_choice = ( + input("\nDo you want to download this episode? (yes/no): ") + .strip() + .lower() + ) if download_choice in ["yes", "y"]: output_filename = f"{chosen_anime['title']} - {chosen_episode['title']}.mp4" # Change extension as needed download_video(download_url, output_filename) - print(f"{chosen_episode['title']} has been downloaded as {output_filename}.") + print( + f"{chosen_episode['title']} has been downloaded as {output_filename}." + ) else: print("Download skipped.") - #if error download please install ffmeg - #brew install ffmpeg for mac + # if error download please install ffmeg + # brew install ffmpeg for mac From 3080c05e331dafcb3650a8d06c427b77784927a4 Mon Sep 17 00:00:00 2001 From: Alfian Ali Murtadlo <115053112+AlfianAliM@users.noreply.github.com> Date: Wed, 2 Oct 2024 13:53:48 +0700 Subject: [PATCH 03/15] Update fetch_anime_and_play.py --- web_programming/fetch_anime_and_play.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/fetch_anime_and_play.py b/web_programming/fetch_anime_and_play.py index 6c51cc977997..d777d1cd066a 100644 --- a/web_programming/fetch_anime_and_play.py +++ b/web_programming/fetch_anime_and_play.py @@ -202,7 +202,7 @@ def download_video(download_url: str, output_filename: str): .lower() ) if download_choice in ["yes", "y"]: - output_filename = f"{chosen_anime['title']} - {chosen_episode['title']}.mp4" # Change extension as needed + output_filename = f"{chosen_episode['title']}.mp4" # Change extension as needed download_video(download_url, output_filename) print( f"{chosen_episode['title']} has been downloaded as {output_filename}." From 5149d1f3d56d3ed032f02ebcfe0065a51eb50884 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 2 Oct 2024 06:54:08 +0000 Subject: [PATCH 04/15] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- web_programming/fetch_anime_and_play.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web_programming/fetch_anime_and_play.py b/web_programming/fetch_anime_and_play.py index d777d1cd066a..b4f9323920bf 100644 --- a/web_programming/fetch_anime_and_play.py +++ b/web_programming/fetch_anime_and_play.py @@ -202,7 +202,9 @@ def download_video(download_url: str, output_filename: str): .lower() ) if download_choice in ["yes", "y"]: - output_filename = f"{chosen_episode['title']}.mp4" # Change extension as needed + output_filename = ( + f"{chosen_episode['title']}.mp4" # Change extension as needed + ) download_video(download_url, output_filename) print( f"{chosen_episode['title']} has been downloaded as {output_filename}." From 9ea8bcbf5604e735dccbeda4a772491b2e488551 Mon Sep 17 00:00:00 2001 From: Alfian Ali Murtadlo <115053112+AlfianAliM@users.noreply.github.com> Date: Wed, 2 Oct 2024 13:54:51 +0700 Subject: [PATCH 05/15] Update fetch_anime_and_play.py --- web_programming/fetch_anime_and_play.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/fetch_anime_and_play.py b/web_programming/fetch_anime_and_play.py index b4f9323920bf..637fade901f3 100644 --- a/web_programming/fetch_anime_and_play.py +++ b/web_programming/fetch_anime_and_play.py @@ -1,5 +1,5 @@ -import subprocess import requests +import subprocess from bs4 import BeautifulSoup, NavigableString, Tag from fake_useragent import UserAgent From ad865bbd217f94f6f14653068e75389c6219a2ef Mon Sep 17 00:00:00 2001 From: Alfian Ali Murtadlo <115053112+AlfianAliM@users.noreply.github.com> Date: Wed, 2 Oct 2024 13:58:57 +0700 Subject: [PATCH 06/15] Update fetch_anime_and_play.py --- web_programming/fetch_anime_and_play.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web_programming/fetch_anime_and_play.py b/web_programming/fetch_anime_and_play.py index 637fade901f3..1284f9cdda8f 100644 --- a/web_programming/fetch_anime_and_play.py +++ b/web_programming/fetch_anime_and_play.py @@ -1,7 +1,7 @@ -import requests import subprocess -from bs4 import BeautifulSoup, NavigableString, Tag +import requests from fake_useragent import UserAgent +from bs4 import BeautifulSoup, NavigableString, Tag BASE_URL = "https://ww1.gogoanime2.org" From 73029819b0992023b3682ff3c428e055b76c0e6e Mon Sep 17 00:00:00 2001 From: Alfian Ali Murtadlo <115053112+AlfianAliM@users.noreply.github.com> Date: Wed, 2 Oct 2024 13:59:57 +0700 Subject: [PATCH 07/15] Update fetch_anime_and_play.py --- web_programming/fetch_anime_and_play.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/fetch_anime_and_play.py b/web_programming/fetch_anime_and_play.py index 1284f9cdda8f..b4f9323920bf 100644 --- a/web_programming/fetch_anime_and_play.py +++ b/web_programming/fetch_anime_and_play.py @@ -1,7 +1,7 @@ import subprocess import requests -from fake_useragent import UserAgent from bs4 import BeautifulSoup, NavigableString, Tag +from fake_useragent import UserAgent BASE_URL = "https://ww1.gogoanime2.org" From a40e52bc432d2f7c3b558863ec51d242553f0aa9 Mon Sep 17 00:00:00 2001 From: Alfian Ali Murtadlo <115053112+AlfianAliM@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:01:44 +0700 Subject: [PATCH 08/15] Update fetch_anime_and_play.py --- web_programming/fetch_anime_and_play.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/fetch_anime_and_play.py b/web_programming/fetch_anime_and_play.py index b4f9323920bf..1284f9cdda8f 100644 --- a/web_programming/fetch_anime_and_play.py +++ b/web_programming/fetch_anime_and_play.py @@ -1,7 +1,7 @@ import subprocess import requests -from bs4 import BeautifulSoup, NavigableString, Tag from fake_useragent import UserAgent +from bs4 import BeautifulSoup, NavigableString, Tag BASE_URL = "https://ww1.gogoanime2.org" From b6a65d870858a9af2ddf57db37a4609442470380 Mon Sep 17 00:00:00 2001 From: Alfian Ali Murtadlo <115053112+AlfianAliM@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:07:20 +0700 Subject: [PATCH 09/15] Update fetch_anime_and_play.py --- web_programming/fetch_anime_and_play.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/fetch_anime_and_play.py b/web_programming/fetch_anime_and_play.py index 1284f9cdda8f..b4f9323920bf 100644 --- a/web_programming/fetch_anime_and_play.py +++ b/web_programming/fetch_anime_and_play.py @@ -1,7 +1,7 @@ import subprocess import requests -from fake_useragent import UserAgent from bs4 import BeautifulSoup, NavigableString, Tag +from fake_useragent import UserAgent BASE_URL = "https://ww1.gogoanime2.org" From 675eab8e99dac55c66a79ee257c978360b4d0366 Mon Sep 17 00:00:00 2001 From: Alfian Ali Murtadlo <115053112+AlfianAliM@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:09:56 +0700 Subject: [PATCH 10/15] Update fetch_anime_and_play.py --- web_programming/fetch_anime_and_play.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/web_programming/fetch_anime_and_play.py b/web_programming/fetch_anime_and_play.py index b4f9323920bf..5ec687816f4a 100644 --- a/web_programming/fetch_anime_and_play.py +++ b/web_programming/fetch_anime_and_play.py @@ -1,6 +1,6 @@ -import subprocess -import requests from bs4 import BeautifulSoup, NavigableString, Tag +import requests +import subprocess from fake_useragent import UserAgent BASE_URL = "https://ww1.gogoanime2.org" From bd1a50d63cf16b7228bacc0952733a83f98391ea Mon Sep 17 00:00:00 2001 From: Alfian Ali Murtadlo <115053112+AlfianAliM@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:10:54 +0700 Subject: [PATCH 11/15] Update fetch_anime_and_play.py --- web_programming/fetch_anime_and_play.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/web_programming/fetch_anime_and_play.py b/web_programming/fetch_anime_and_play.py index 5ec687816f4a..5be523b7a9db 100644 --- a/web_programming/fetch_anime_and_play.py +++ b/web_programming/fetch_anime_and_play.py @@ -1,5 +1,6 @@ -from bs4 import BeautifulSoup, NavigableString, Tag import requests +from bs4 import BeautifulSoup, NavigableString, Tag + import subprocess from fake_useragent import UserAgent From eadf8a88a2d4392515525ec5fe52835c19835565 Mon Sep 17 00:00:00 2001 From: Alfian Ali Murtadlo <115053112+AlfianAliM@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:11:56 +0700 Subject: [PATCH 12/15] Update fetch_anime_and_play.py --- web_programming/fetch_anime_and_play.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_programming/fetch_anime_and_play.py b/web_programming/fetch_anime_and_play.py index 5be523b7a9db..044ba5e02692 100644 --- a/web_programming/fetch_anime_and_play.py +++ b/web_programming/fetch_anime_and_play.py @@ -1,7 +1,7 @@ import requests from bs4 import BeautifulSoup, NavigableString, Tag -import subprocess + from fake_useragent import UserAgent BASE_URL = "https://ww1.gogoanime2.org" From 2de5afc3d0f906afee49bc590d2d54ba1fa93467 Mon Sep 17 00:00:00 2001 From: Alfian Ali Murtadlo <115053112+AlfianAliM@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:12:48 +0700 Subject: [PATCH 13/15] Update fetch_anime_and_play.py --- web_programming/fetch_anime_and_play.py | 1 + 1 file changed, 1 insertion(+) diff --git a/web_programming/fetch_anime_and_play.py b/web_programming/fetch_anime_and_play.py index 044ba5e02692..b7feec668d6a 100644 --- a/web_programming/fetch_anime_and_play.py +++ b/web_programming/fetch_anime_and_play.py @@ -3,6 +3,7 @@ from fake_useragent import UserAgent +import subprocess BASE_URL = "https://ww1.gogoanime2.org" From e1be3d1287d91cb9e9736ed577d2bfb73f3e0e1f Mon Sep 17 00:00:00 2001 From: Alfian Ali Murtadlo <115053112+AlfianAliM@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:13:31 +0700 Subject: [PATCH 14/15] Update fetch_anime_and_play.py --- web_programming/fetch_anime_and_play.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/web_programming/fetch_anime_and_play.py b/web_programming/fetch_anime_and_play.py index b7feec668d6a..fa37e8ab44f0 100644 --- a/web_programming/fetch_anime_and_play.py +++ b/web_programming/fetch_anime_and_play.py @@ -1,9 +1,9 @@ +import subprocess + import requests from bs4 import BeautifulSoup, NavigableString, Tag - - from fake_useragent import UserAgent -import subprocess + BASE_URL = "https://ww1.gogoanime2.org" From 84263ca7464c93ff88df297a997521757fde889c Mon Sep 17 00:00:00 2001 From: Alfian Ali Murtadlo <115053112+AlfianAliM@users.noreply.github.com> Date: Wed, 2 Oct 2024 14:15:28 +0700 Subject: [PATCH 15/15] Update fetch_anime_and_play.py --- web_programming/fetch_anime_and_play.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/web_programming/fetch_anime_and_play.py b/web_programming/fetch_anime_and_play.py index fa37e8ab44f0..a06c2ed507b6 100644 --- a/web_programming/fetch_anime_and_play.py +++ b/web_programming/fetch_anime_and_play.py @@ -1,7 +1,9 @@ import subprocess import requests -from bs4 import BeautifulSoup, NavigableString, Tag +from bs4 import BeautifulSoup +from bs4 import NavigableString +from bs4 import Tag from fake_useragent import UserAgent