Enable ruff DTZ005 rule (#11327)

* Enable ruff DTZ005 rule

* Fix other/gauss_easter.py

* Fix

* Fix web_programming/instagram_pic.py

* Fix web_programming/instagram_video.py

* Apply suggestions from code review

* Update instagram_pic.py

* datetime.now(tz=UTC).astimezone()

* .astimezone()

* Fix

---------

Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
Maxim Smolskiy
2024-03-25 23:54:11 +03:00
committed by GitHub
parent ead54314f2
commit b5cb1fba0d
4 changed files with 6 additions and 7 deletions

View File

@ -1,4 +1,4 @@
from datetime import datetime
from datetime import UTC, datetime
import requests
from bs4 import BeautifulSoup
@ -36,7 +36,7 @@ def download_image(url: str) -> str:
if not image_data:
return f"Failed to download the image from {image_url}."
file_name = f"{datetime.now():%Y-%m-%d_%H:%M:%S}.jpg"
file_name = f"{datetime.now(tz=UTC).astimezone():%Y-%m-%d_%H:%M:%S}.jpg"
with open(file_name, "wb") as out_file:
out_file.write(image_data)
return f"Image downloaded and saved in the file {file_name}"

View File

@ -1,4 +1,4 @@
from datetime import datetime
from datetime import UTC, datetime
import requests
@ -11,7 +11,7 @@ def download_video(url: str) -> bytes:
if __name__ == "__main__":
url = input("Enter Video/IGTV url: ").strip()
file_name = f"{datetime.now():%Y-%m-%d_%H:%M:%S}.mp4"
file_name = f"{datetime.now(tz=UTC).astimezone():%Y-%m-%d_%H:%M:%S}.mp4"
with open(file_name, "wb") as fp:
fp.write(download_video(url))
print(f"Done. Video saved to disk as {file_name}.")