Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions web_programming/fetch_anime_and_play.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import subprocess
import requests
from bs4 import BeautifulSoup, NavigableString, Tag
from fake_useragent import UserAgent


BASE_URL = "https://ww1.gogoanime2.org"

Check failure on line 7 in web_programming/fetch_anime_and_play.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

web_programming/fetch_anime_and_play.py:1:1: I001 Import block is un-sorted or un-formatted


def search_scraper(anime_name: str) -> list:
Expand Down Expand Up @@ -153,6 +155,10 @@

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)

Check failure on line 161 in web_programming/fetch_anime_and_play.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (S603)

web_programming/fetch_anime_and_play.py:161:5: S603 `subprocess` call: check for execution of untrusted input

if __name__ == "__main__":
anime_name = input("Enter anime name: ").strip()
Expand Down Expand Up @@ -186,3 +192,16 @@
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}.")

Check failure on line 195 in web_programming/fetch_anime_and_play.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (W293)

web_programming/fetch_anime_and_play.py:195:1: W293 Blank line contains whitespace

# Add an option to download or not
download_choice = input("\nDo you want to download this episode? (yes/no): ").strip().lower()

Check failure on line 198 in web_programming/fetch_anime_and_play.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

web_programming/fetch_anime_and_play.py:198:89: E501 Line too long (105 > 88)
if download_choice in ["yes", "y"]:
output_filename = f"{chosen_anime['title']} - {chosen_episode['title']}.mp4" # Change extension as needed

Check failure on line 200 in web_programming/fetch_anime_and_play.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

web_programming/fetch_anime_and_play.py:200:89: E501 Line too long (122 > 88)
download_video(download_url, output_filename)
print(f"{chosen_episode['title']} has been downloaded as {output_filename}.")

Check failure on line 202 in web_programming/fetch_anime_and_play.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (E501)

web_programming/fetch_anime_and_play.py:202:89: E501 Line too long (93 > 88)
else:
print("Download skipped.")

#if error download please install ffmeg
#brew install ffmpeg for mac
Loading