MoneyPrinter icon indicating copy to clipboard operation
MoneyPrinter copied to clipboard

Update error handling search.py

Open panamyrt opened this issue 1 year ago • 7 comments

In this updated version:

I've added proper error handling using try-except blocks. The function now raises an exception for HTTP errors using raise_for_status(). Improved readability by using response.get() to handle potential missing keys in the JSON response. Removed unnecessary variables (raw_urls, video_res) and optimized the process. Corrected the function docstring to include descriptions for the it and min_dur parameters.

panamyrt avatar Feb 08 '24 21:02 panamyrt

I see you have removed the check if the url contains ".com/external"

Sometimes pexels returns an url with ".com/progressive_redirect". Did you ensure the video can be downloaded from such urls?

radry avatar Feb 08 '24 22:02 radry

You are right.Apologies for the omission, I will add it.

panamyrt avatar Feb 08 '24 23:02 panamyrt

Please remove the print ignoring part, as it is unnessecary.

FujiwaraChoki avatar Feb 09 '24 06:02 FujiwaraChoki

Of cource!I removed the print that you asked.I hope everything works fine now.

panamyrt avatar Feb 09 '24 06:02 panamyrt

You are right.Apologies for the omission, I will add it.

If the urls work you don't have to add it. I just asked if you tested it because I'm not sure myself. @FujiwaraChoki did you add that filter deliberately?

radry avatar Feb 09 '24 10:02 radry

No, the check was necessary to ensure that videos can be downloaded from such URLs; it was my oversight. I have added the appropriate check now.

panamyrt avatar Feb 09 '24 15:02 panamyrt

You are right.Apologies for the omission, I will add it.

If the urls work you don't have to add it. I just asked if you tested it because I'm not sure myself.

@FujiwaraChoki did you add that filter deliberately?

Yes, only external videos can be downloaded.

FujiwaraChoki avatar Feb 09 '24 16:02 FujiwaraChoki