tamoor622498 / DailyHistoryBot

A python twitter bot that posts history facts.
0 stars 0 forks source link

Some images being unable to be tweeted. #1

Open tamoor622498 opened 3 years ago

tamoor622498 commented 3 years ago

The main issue is that some of the images "ImageDownload" gets are not tweetable using the API, but is able to be tweeted used the browser version. Another point of interest I've found is that this error is much more likely to occur on windows than on a linux distro. The latter leads me to conclude this is a problem with how windows saves images

tamoor622498 commented 3 years ago

I think I found a solution or a way to reduce the occurrence of the error. When "ImageDownload" gets the link for an image (ex. //upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Sukhoi_Su-47Berkut%28S-37%29_in_2001.jpg/220px-Sukhoi_Su-47Berkut%28S-37%29_in_2001.jpg). I change the pixel size to be be 1000 (ex. https://upload.wikimedia.org/wikipedia/commons/thumb/b/b4/Sukhoi_Su-47_Berkut_%28S-37%29_in_2001.jpg/1000px-Sukhoi_Su-47_Berkut_%28S-37%29_in_2001.jpg). This gives me a higher quality image. But, I'm using BeautifulSoup to get all of the "img" tags on a page, this includes the asset images that can't be resized and give a 404 error if you change the URL. I've added an array that contains some of the most used asset images, this should reduce the occurrence of the error. Not a full solution, but the event text is still tweeted.