|
| 1 | +import subprocess |
1 | 2 | import requests
|
2 | 3 | from bs4 import BeautifulSoup, NavigableString, Tag
|
3 | 4 | from fake_useragent import UserAgent
|
4 | 5 |
|
| 6 | + |
5 | 7 | BASE_URL = "https://ww1.gogoanime2.org"
|
6 | 8 |
|
7 | 9 |
|
@@ -153,6 +155,10 @@ def get_anime_episode(episode_endpoint: str) -> list:
|
153 | 155 |
|
154 | 156 | return [f"{BASE_URL}{episode_url}", f"{BASE_URL}{download_url}"]
|
155 | 157 |
|
| 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) |
156 | 162 |
|
157 | 163 | if __name__ == "__main__":
|
158 | 164 | anime_name = input("Enter anime name: ").strip()
|
@@ -186,3 +192,16 @@ def get_anime_episode(episode_endpoint: str) -> list:
|
186 | 192 | episode_url, download_url = get_anime_episode(chosen_episode["url"])
|
187 | 193 | print(f"\nTo watch, ctrl+click on {episode_url}.")
|
188 | 194 | 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