@@ -48,10 +48,11 @@ def get_error_reason(self) -> str:
4848 Returns:
4949 str: The error message from the response body, or a default message if not available.
5050 """
51- result = self ._response .json ()
5251 default_reason = f"status_code={ self .status_code } "
53- if isinstance (result , dict ):
54- return result .get ("error_message" , default_reason )
52+ if self ._response .headers .get ("Content-Type" ) == "application/json" :
53+ result = self ._response .json ()
54+ if isinstance (result , dict ):
55+ return result .get ("error_message" , default_reason )
5556 return default_reason
5657
5758
@@ -133,14 +134,10 @@ def __init__(
133134 ValueError: If neither `api_key` nor both `username` and `password` are provided.
134135 """
135136 if not base_url .startswith (("http://" , "https://" )):
136- raise ValueError (
137- "base_url must be a valid URL starting with http:// or https://"
138- )
137+ raise ValueError ("base_url must be a valid URL starting with http:// or https://" )
139138
140139 if not api_key and not (username and password ):
141- raise ValueError (
142- "Either api_key or both username and password must be provided"
143- )
140+ raise ValueError ("Either api_key or both username and password must be provided" )
144141
145142 self ._base_url = base_url .rstrip ("/" )
146143 self ._timeout = timeout
@@ -391,9 +388,7 @@ def get_icon_by_feed_id(self, feed_id: int) -> dict:
391388 """
392389 return self .get_feed_icon (feed_id )
393390
394- def create_feed (
395- self , feed_url : str , category_id : Optional [int ] = None , ** kwargs
396- ) -> int :
391+ def create_feed (self , feed_url : str , category_id : Optional [int ] = None , ** kwargs ) -> int :
397392 """
398393 Create a new feed.
399394
@@ -659,9 +654,7 @@ def get_entries(self, **kwargs) -> dict:
659654 return response .json ()
660655 self ._handle_error_response (response )
661656
662- def update_entry (
663- self , entry_id : int , title : Optional [str ] = None , content : Optional [str ] = None
664- ) -> dict :
657+ def update_entry (self , entry_id : int , title : Optional [str ] = None , content : Optional [str ] = None ) -> dict :
665658 """
666659 Update an entry.
667660
@@ -781,9 +774,7 @@ def get_enclosure(self, enclosure_id: int) -> dict:
781774 return response .json ()
782775 self ._handle_error_response (response )
783776
784- def update_enclosure (
785- self , enclosure_id : int , media_progression : Optional [int ] = None
786- ) -> bool :
777+ def update_enclosure (self , enclosure_id : int , media_progression : Optional [int ] = None ) -> bool :
787778 """
788779 Update an enclosure.
789780
0 commit comments