Skip to content

Commit

Permalink
Merge pull request #6 from Jemeni11/imgur-support
Browse files Browse the repository at this point in the history
Released Version 4.1.0
  • Loading branch information
Jemeni11 authored Apr 17, 2024
2 parents 75268e9 + a855d56 commit b783544
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
[//]: # (- **Fixed** for any bug fixes.)
[//]: # (- **Security** in case of vulnerabilities.)

## [4.1.0] - 2024-04-17

### Added
- Added a user agent string to help download imgur images.

## [4.0.0] - 2024-02-28

### Fixed
Expand Down Expand Up @@ -87,6 +92,7 @@ match the new README format. The content type was updated from `text/markdown` t
- Released FicImageScript


[4.1.0]: https://github.com/Jemeni11/FicImage/compare/v4.0.0...v4.1.0
[4.0.0]: https://github.com/Jemeni11/FicImage/compare/v3.0.0...v4.0.0
[3.0.0]: https://github.com/Jemeni11/FicImage/compare/v2.1.0...v3.0.0
[2.1.0]: https://github.com/Jemeni11/FicImage/compare/v2.0.0...v2.1.0
Expand Down
10 changes: 8 additions & 2 deletions FicImage/image.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,15 @@ def get_image_from_url(
imgdata = PIL_Image_to_bytes(compressed_base64_image, file_ext)

return imgdata, file_ext, f"image/{file_ext}"

elif url.startswith("https://imgur.com/"):
url = "https://i.imgur.com/" + url.split("https://imgur.com/")[-1]

with requests.Session() as session:
img = session.get(url, stream=True)
headers = {
'user-agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/122.0.0.0 Safari/537.36"
}
img = session.get(url, stream=True, headers=headers)

if img.headers.get("content-type", "") == "image/svg+xml":
return img.content, "svg", "image/svg+xml"
Expand Down
2 changes: 1 addition & 1 deletion FicImage/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from .image import get_image_from_url
from .utils import config_check, load_config_json, default_ficimage_settings

__version__ = "4.0.0"
__version__ = "4.1.0"


def update_epub(path_to_epub, config_file_path, debug):
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "FicImageScript"
version = "4.0.0"
version = "4.1.0"
authors = [
{ name="Emmanuel C. Jemeni", email="[email protected]" }
]
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="FicImageScript",
version="4.0.0",
version="4.1.0",
author="Emmanuel C. Jemeni",
author_email="[email protected]",
description="FicImage is an application designed to enhance the reading experience of FicHub epubs.",
Expand Down

0 comments on commit b783544

Please sign in to comment.