Skip to content

Commit b783544

Browse files
authored
Merge pull request #6 from Jemeni11/imgur-support
Released Version 4.1.0
2 parents 75268e9 + a855d56 commit b783544

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
[//]: # (- **Fixed** for any bug fixes.)
1414
[//]: # (- **Security** in case of vulnerabilities.)
1515

16+
## [4.1.0] - 2024-04-17
17+
18+
### Added
19+
- Added a user agent string to help download imgur images.
20+
1621
## [4.0.0] - 2024-02-28
1722

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

8994

95+
[4.1.0]: https://github.com/Jemeni11/FicImage/compare/v4.0.0...v4.1.0
9096
[4.0.0]: https://github.com/Jemeni11/FicImage/compare/v3.0.0...v4.0.0
9197
[3.0.0]: https://github.com/Jemeni11/FicImage/compare/v2.1.0...v3.0.0
9298
[2.1.0]: https://github.com/Jemeni11/FicImage/compare/v2.0.0...v2.1.0

FicImage/image.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,15 @@ def get_image_from_url(
4949
imgdata = PIL_Image_to_bytes(compressed_base64_image, file_ext)
5050

5151
return imgdata, file_ext, f"image/{file_ext}"
52-
52+
elif url.startswith("https://imgur.com/"):
53+
url = "https://i.imgur.com/" + url.split("https://imgur.com/")[-1]
54+
5355
with requests.Session() as session:
54-
img = session.get(url, stream=True)
56+
headers = {
57+
'user-agent': "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
58+
"Chrome/122.0.0.0 Safari/537.36"
59+
}
60+
img = session.get(url, stream=True, headers=headers)
5561

5662
if img.headers.get("content-type", "") == "image/svg+xml":
5763
return img.content, "svg", "image/svg+xml"

FicImage/main.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from .image import get_image_from_url
88
from .utils import config_check, load_config_json, default_ficimage_settings
99

10-
__version__ = "4.0.0"
10+
__version__ = "4.1.0"
1111

1212

1313
def update_epub(path_to_epub, config_file_path, debug):

pyproject.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "FicImageScript"
3-
version = "4.0.0"
3+
version = "4.1.0"
44
authors = [
55
{ name="Emmanuel C. Jemeni", email="[email protected]" }
66
]

setup.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="FicImageScript",
8-
version="4.0.0",
8+
version="4.1.0",
99
author="Emmanuel C. Jemeni",
1010
author_email="[email protected]",
1111
description="FicImage is an application designed to enhance the reading experience of FicHub epubs.",

0 commit comments

Comments
 (0)