@@ -59,7 +59,7 @@ def _build_item(self, path, is_playable):
5959 return {
6060 'label' : label ,
6161 'path' : path ,
62- 'thumbnail' : self ._get_image_url (),
62+ 'thumbnail' : self ._get_image_url ('480x270' , True ),
6363 'is_playable' : is_playable ,
6464 'info_type' : 'video' ,
6565 'info' : {
@@ -70,7 +70,7 @@ def _build_item(self, path, is_playable):
7070 'aired' : self ._get_air_date ()
7171 },
7272 'properties' : {
73- 'fanart_image' : self ._get_image_url (),
73+ 'fanart_image' : self ._get_image_url ('1920x1080' , False ),
7474 'TotalTime' : str (self ._get_duration ()),
7575 },
7676 'context_menu' : [
@@ -109,7 +109,7 @@ def _get_air_date(self):
109109 """
110110 return None
111111
112- def _get_image_url (self ):
112+ def _get_image_url (self , wished_res , wished_text ):
113113 """
114114 Abstract method to be implemented in child classes.
115115 Return url to image to display for the current item.
@@ -208,7 +208,7 @@ def build_item(self, path, is_playable):
208208 'playcount' : '1' if progress >= 0.95 else '0' ,
209209 },
210210 'properties' : {
211- 'fanart_image' : self ._get_image_url (),
211+ 'fanart_image' : self ._get_image_url ('1920x1080' , False ),
212212 # ResumeTime and TotalTime deprecated.
213213 # Use InfoTagVideo.setResumePoint() instead.
214214 'ResumeTime' : str (self ._get_time_offset ()),
@@ -238,20 +238,27 @@ def _parse_date_artetv(self, datestr):
238238 date = None
239239 return date
240240
241- def _get_image_url (self ):
241+ def _get_image_url (self , wished_res , wished_text ):
242242 item = self .json_dict
243243 image_url = None
244+ # extracting image from arte tv player endpoint
244245 if item .get ('images' ) and item .get ('images' )[0 ] and item .get ('images' )[0 ].get ('url' ):
245- # Remove query param type=TEXT to avoid title embeded in image
246- image_url = item .get ('images' )[0 ].get ('url' ).replace ('?type=TEXT' , '' )
247- # Set same image for fanart and thumbnail to spare network bandwidth
248- # and business logic easier to maintain
249- # if item.get('images')[0].get('alternateResolutions'):
250- # smallerImage = item.get('images')[0].get('alternateResolutions')[3]
251- # if smallerImage and smallerImage.get('url'):
252- # thumbnailUrl = smallerImage.get('url').replace('?type=TEXT', '')
253- if not image_url :
254- image_url = item .get ('mainImage' ).get ('url' ).replace ('__SIZE__' , '1920x1080' )
246+ image_url = item .get ('images' )[0 ].get ('url' )
247+ # extracting image from content data from arte tv home page or zone endpoint
248+ if item .get ('mainImage' ) and item .get ('mainImage' ).get ('url' ):
249+ image_url = item .get ('mainImage' ).get ('url' )
250+
251+ # post processing
252+ if isinstance (image_url , str ):
253+ if wished_text is False :
254+ # Remove query param type=TEXT to avoid title embeded in image
255+ image_url = image_url .replace ('?type=TEXT' , '' )
256+ if isinstance (wished_res , str ):
257+ # 940x530 is the most common size from player endpoint
258+ # __SIZE__ is the size from home page or zone endpoint
259+ for from_str in ['/940x530' , '/__SIZE__' ]:
260+ image_url = image_url .replace (from_str , f"/{ wished_res } " )
261+
255262 return image_url
256263
257264 def _get_kind (self ):
@@ -300,7 +307,7 @@ def build_item(self, path, is_playable):
300307 # year is not correctly used by kodi :(
301308 # the aired year will be used by kodi for production year :(
302309 # 'year': int(config.get('productionYear')),
303- 'country' : [country .get ('label' ) for country in \
310+ 'country' : [country .get ('label' ) for country in
304311 item .get ('productionCountries' , [])],
305312 'director' : item .get ('director' ),
306313 },
@@ -326,7 +333,8 @@ def _parse_date_hbbtv(self, datestr):
326333 level = xbmc .LOGWARNING )
327334 return date
328335
329- def _get_image_url (self ):
336+ def _get_image_url (self , wished_res , wished_text ):
337+ # parameter are ignored in HBB TV, but needed for abstraction | inheritance
330338 return self .json_dict .get ('imageUrl' )
331339
332340 def _get_kind (self ):
0 commit comments