55
66from plexapi import media , settings , utils
77from plexapi .exceptions import BadRequest , NotFound
8- from plexapi .utils import deprecated
8+ from plexapi .utils import deprecated , openOrRead
99
1010
1111class AdvancedSettingsMixin :
@@ -341,14 +341,14 @@ def uploadArt(self, url=None, filepath=None):
341341
342342 Parameters:
343343 url (str): The full URL to the image to upload.
344- filepath (str): The full file path the the image to upload.
344+ filepath (str): The full file path the the image to upload or file-like object .
345345 """
346346 if url :
347347 key = f'/library/metadata/{ self .ratingKey } /arts?url={ quote_plus (url )} '
348348 self ._server .query (key , method = self ._server ._session .post )
349349 elif filepath :
350350 key = f'/library/metadata/{ self .ratingKey } /arts'
351- data = open (filepath , 'rb' ). read ( )
351+ data = openOrRead (filepath )
352352 self ._server .query (key , method = self ._server ._session .post , data = data )
353353 return self
354354
@@ -392,14 +392,14 @@ def uploadBanner(self, url=None, filepath=None):
392392
393393 Parameters:
394394 url (str): The full URL to the image to upload.
395- filepath (str): The full file path the the image to upload.
395+ filepath (str): The full file path the the image to upload or file-like object .
396396 """
397397 if url :
398398 key = f'/library/metadata/{ self .ratingKey } /banners?url={ quote_plus (url )} '
399399 self ._server .query (key , method = self ._server ._session .post )
400400 elif filepath :
401401 key = f'/library/metadata/{ self .ratingKey } /banners'
402- data = open (filepath , 'rb' ). read ( )
402+ data = openOrRead (filepath )
403403 self ._server .query (key , method = self ._server ._session .post , data = data )
404404 return self
405405
@@ -448,14 +448,14 @@ def uploadPoster(self, url=None, filepath=None):
448448
449449 Parameters:
450450 url (str): The full URL to the image to upload.
451- filepath (str): The full file path the the image to upload.
451+ filepath (str): The full file path the the image to upload or file-like object .
452452 """
453453 if url :
454454 key = f'/library/metadata/{ self .ratingKey } /posters?url={ quote_plus (url )} '
455455 self ._server .query (key , method = self ._server ._session .post )
456456 elif filepath :
457457 key = f'/library/metadata/{ self .ratingKey } /posters'
458- data = open (filepath , 'rb' ). read ( )
458+ data = openOrRead (filepath )
459459 self ._server .query (key , method = self ._server ._session .post , data = data )
460460 return self
461461
@@ -501,7 +501,7 @@ def uploadTheme(self, url=None, filepath=None, timeout=None):
501501
502502 Parameters:
503503 url (str): The full URL to the theme to upload.
504- filepath (str): The full file path to the theme to upload.
504+ filepath (str): The full file path to the theme to upload or file-like object .
505505 timeout (int, optional): Timeout, in seconds, to use when uploading themes to the server.
506506 (default config.TIMEOUT).
507507 """
@@ -510,7 +510,7 @@ def uploadTheme(self, url=None, filepath=None, timeout=None):
510510 self ._server .query (key , method = self ._server ._session .post , timeout = timeout )
511511 elif filepath :
512512 key = f'/library/metadata/{ self .ratingKey } /themes'
513- data = open (filepath , 'rb' ). read ( )
513+ data = openOrRead (filepath )
514514 self ._server .query (key , method = self ._server ._session .post , data = data , timeout = timeout )
515515 return self
516516
0 commit comments