Skip to content

Commit 05f9bb7

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent 3be769d commit 05f9bb7

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

web_programming/fetch_anime_and_play.py

+16-7
Original file line numberDiff line numberDiff line change
@@ -154,11 +154,13 @@ def get_anime_episode(episode_endpoint: str) -> list:
154154

155155
return [f"{BASE_URL}{episode_url}", f"{BASE_URL}{download_url}"]
156156

157+
157158
def download_video(download_url: str, output_filename: str):
158159
"""Download video using ffmpeg."""
159-
command = ['ffmpeg', '-i', download_url, output_filename]
160+
command = ["ffmpeg", "-i", download_url, output_filename]
160161
subprocess.run(command, check=True)
161162

163+
162164
if __name__ == "__main__":
163165
anime_name = input("Enter anime name: ").strip()
164166
anime_list = search_scraper(anime_name)
@@ -184,22 +186,29 @@ def download_video(download_url: str, output_filename: str):
184186
for i, episode in enumerate(episode_list):
185187
print(f"{i + 1}. {episode['title']}")
186188

187-
episode_choice = int(input("\nChoose an episode by serial number: ").strip())
189+
episode_choice = int(
190+
input("\nChoose an episode by serial number: ").strip()
191+
)
188192
chosen_episode = episode_list[episode_choice - 1]
189193
print(f"You chose {chosen_episode['title']}. Searching...")
190194

191195
episode_url, download_url = get_anime_episode(chosen_episode["url"])
192196
print(f"\nTo watch, ctrl+click on {episode_url}.")
193-
194197

195198
# Add an option to download or not
196-
download_choice = input("\nDo you want to download this episode? (yes/no): ").strip().lower()
199+
download_choice = (
200+
input("\nDo you want to download this episode? (yes/no): ")
201+
.strip()
202+
.lower()
203+
)
197204
if download_choice in ["yes", "y"]:
198205
output_filename = f"{chosen_anime['title']} - {chosen_episode['title']}.mp4" # Change extension as needed
199206
download_video(download_url, output_filename)
200-
print(f"{chosen_episode['title']} has been downloaded as {output_filename}.")
207+
print(
208+
f"{chosen_episode['title']} has been downloaded as {output_filename}."
209+
)
201210
else:
202211
print("Download skipped.")
203212

204-
#if error download please install ffmeg
205-
#brew install ffmpeg for mac
213+
# if error download please install ffmeg
214+
# brew install ffmpeg for mac

0 commit comments

Comments
 (0)