Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit be2fb13

Browse files
authoredOct 2, 2024··
Update fetch_anime_and_play.py
1 parent 00e9d86 commit be2fb13

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed
 

‎web_programming/fetch_anime_and_play.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
import subprocess
12
import requests
23
from bs4 import BeautifulSoup, NavigableString, Tag
34
from fake_useragent import UserAgent
45

6+
57
BASE_URL = "https://ww1.gogoanime2.org"
68

79

@@ -153,6 +155,10 @@ def get_anime_episode(episode_endpoint: str) -> list:
153155

154156
return [f"{BASE_URL}{episode_url}", f"{BASE_URL}{download_url}"]
155157

158+
def download_video(download_url: str, output_filename: str):
159+
"""Download video using ffmpeg."""
160+
command = ['ffmpeg', '-i', download_url, output_filename]
161+
subprocess.run(command, check=True)
156162

157163
if __name__ == "__main__":
158164
anime_name = input("Enter anime name: ").strip()
@@ -186,3 +192,16 @@ def get_anime_episode(episode_endpoint: str) -> list:
186192
episode_url, download_url = get_anime_episode(chosen_episode["url"])
187193
print(f"\nTo watch, ctrl+click on {episode_url}.")
188194
print(f"To download, ctrl+click on {download_url}.")
195+
196+
197+
# Add an option to download or not
198+
download_choice = input("\nDo you want to download this episode? (yes/no): ").strip().lower()
199+
if download_choice in ["yes", "y"]:
200+
output_filename = f"{chosen_anime['title']} - {chosen_episode['title']}.mp4" # Change extension as needed
201+
download_video(download_url, output_filename)
202+
print(f"{chosen_episode['title']} has been downloaded as {output_filename}.")
203+
else:
204+
print("Download skipped.")
205+
206+
#if error download please install ffmeg
207+
#brew install ffmpeg for mac

0 commit comments

Comments
 (0)
Please sign in to comment.