
    lj .                     h   d dl mZ d dlmZ d dlmZ  G d d      Z G d d      Z G d d	ee      Z G d
 d      Z	 G d d      Z
 G d de	e
      Z G d d      Z G d d      Z G d dee      Z G d d      Z G d d      Z G d dee      Z G d d      Z G d d      Z G d  d!ee      Zy")#    )
quote_plus)media)
openOrReadc                        e Zd ZdZed        Zy)ArtUrlMixinz@ Mixin for Plex objects that can have a background artwork url. c                 h    | j                  dd      }|r| j                  j                  |d      S dS )z) Return the art url for the Plex object. artgrandparentArtTincludeTokenN	firstAttr_serverurlselfr	   s     E/DATA/.local/lib/python3.12/site-packages/plexapi/mixins/resources.pyartUrlzArtUrlMixin.artUrl
   s6     nnU$45;>t||$7HDH    N)__name__
__module____qualname____doc__propertyr    r   r   r   r      s    JI Ir   r   c                       e Zd ZdZd Zd Zy)ArtLockMixinzC Mixin for Plex objects that can have a locked background artwork. c                 *     | j                   di ddiS )z0 Lock the background artwork for a Plex object. 
art.locked   r   _editr   s    r   lockArtzArtLockMixin.lockArt       tzz.\1-..r   c                 *     | j                   di ddiS )z2 Unlock the background artwork for a Plex object. r   r   r   r!   r#   s    r   	unlockArtzArtLockMixin.unlockArt   r%   r   N)r   r   r   r   r$   r'   r   r   r   r   r      s    M//r   r   c                   *    e Zd ZdZd ZddZd Zd Zy)ArtMixinz: Mixin for Plex objects that can have background artwork. c                 `    | j                  d| j                   dt        j                        S )z@ Returns list of available :class:`~plexapi.media.Art` objects. /library/metadata//artscls)
fetchItems	ratingKeyr   Artr#   s    r   artszArtMixin.arts    s(    !3DNN3C5IuyyYYr   Nc                 l   |rXd| j                    dt        |       }| j                  j                  || j                  j                  j
                         | S |rWd| j                    d}t        |      }| j                  j                  || j                  j                  j
                  |       | S )z Upload a background artwork from a url or filepath.

            Parameters:
                url (str): The full URL to the image to upload.
                filepath (str): The full file path to the image to upload or file-like object.
        r+   z
/arts?url=methodr,   r5   datar0   r   r   query_sessionpostr   r   r   filepathkeyr7   s        r   	uploadArtzArtMixin.uploadArt$   s     &t~~&6jC@QRCLLs4<<+@+@+E+EF
 	 &t~~&6e<Ch'DLLs4<<+@+@+E+EDQr   c                 &    |j                          | S )z Set the background artwork for a Plex object.

            Parameters:
                art (:class:`~plexapi.media.Art`): The art object to select.
        selectr   s     r   setArtzArtMixin.setArt4   s     	

r   c                     d| j                    d}| j                  j                  || j                  j                  j                         | S )z$ Delete the art from a Plex object. r+   z/artr4   r0   r   r9   r:   deleter   r>   s     r   	deleteArtzArtMixin.deleteArt=   sA    "4>>"2$73t||'<'<'C'CDr   NN)r   r   r   r   r2   r?   rC   rH   r   r   r   r)   r)      s    DZ r   r)   c                   0    e Zd ZdZed        Zed        Zy)LogoUrlMixinz2 Mixin for Plex objects that can have a logo url. c                 <    t        d | j                  D        d      S )z( Return the API path to the logo image. c              3   T   K   | ]   }|j                   d k(  s|j                   " yw)	clearLogoNtyper   .0is     r   	<genexpr>z$LogoUrlMixin.logo.<locals>.<genexpr>J   s      IKq166[3HQUUK   ((Nnextimagesr#   s    r   logozLogoUrlMixin.logoG   s     IDKKI4PPr   c                 l    | j                   r'| j                  j                  | j                   d      S dS )z* Return the logo url for the Plex object. Tr   N)rY   r   r   r#   s    r   logoUrlzLogoUrlMixin.logoUrlL   s0     BFt||		=TPTTr   N)r   r   r   r   r   rY   r[   r   r   r   rK   rK   D   s/    <Q Q U Ur   rK   c                       e Zd ZdZd Zd Zy)LogoLockMixinz5 Mixin for Plex objects that can have a locked logo. c                 *     | j                   di ddiS )z" Lock the logo for a Plex object. clearLogo.lockedr    r   r!   r#   s    r   lockLogozLogoLockMixin.lockLogoU       tzz4/344r   c                 *     | j                   di ddiS )z$ Unlock the logo for a Plex object. r_   r   r   r!   r#   s    r   
unlockLogozLogoLockMixin.unlockLogoY   ra   r   N)r   r   r   r   r`   rc   r   r   r   r]   r]   R   s    ?55r   r]   c                   *    e Zd ZdZd ZddZd Zd Zy)	LogoMixinz- Mixin for Plex objects that can have logos. c                 `    | j                  d| j                   dt        j                        S )zA Returns list of available :class:`~plexapi.media.Logo` objects. r+   /clearLogosr-   )r/   r0   r   Logor#   s    r   logoszLogoMixin.logosa   s+    !3DNN3C;OUZU_U_``r   Nc                 l   |rXd| j                    dt        |       }| j                  j                  || j                  j                  j
                         | S |rWd| j                    d}t        |      }| j                  j                  || j                  j                  j
                  |       | S )z Upload a logo from a url or filepath.

            Parameters:
                url (str): The full URL to the image to upload.
                filepath (str): The full file path to the image to upload or file-like object.
        r+   z/clearLogos?url=r4   rg   r6   r8   r<   s        r   
uploadLogozLogoMixin.uploadLogoe        &t~~&66FzRUFWXCLLs4<<+@+@+E+EF
 	 &t~~&6kBCh'DLLs4<<+@+@+E+EDQr   c                 &    |j                          | S )z Set the logo for a Plex object.

            Parameters:
                logo (:class:`~plexapi.media.Logo`): The logo object to select.
        rA   )r   rY   s     r   setLogozLogoMixin.setLogou   s     	r   c                     d| j                    d}| j                  j                  || j                  j                  j                         | S )z% Delete the logo from a Plex object. r+   z
/clearLogor4   rE   rG   s     r   
deleteLogozLogoMixin.deleteLogo~   A    "4>>"2*=3t||'<'<'C'CDr   rI   )r   r   r   r   ri   rk   rn   rp   r   r   r   re   re   ^   s    7a r   re   c                   0    e Zd ZdZed        Zed        Zy)PosterUrlMixinz4 Mixin for Plex objects that can have a poster url. c                 j    | j                  ddd      }|r| j                  j                  |d      S dS )z+ Return the thumb url for the Plex object. thumbparentThumbgrandparentThumbTr   Nr   )r   ru   s     r   thumbUrlzPosterUrlMixin.thumbUrl   8     w7IJ=Bt||D9LLr   c                     | j                   S )z Alias to self.thumbUrl. )rx   r#   s    r   	posterUrlzPosterUrlMixin.posterUrl   s     }}r   N)r   r   r   r   r   rx   r{   r   r   r   rs   rs      s-    >M M
  r   rs   c                       e Zd ZdZd Zd Zy)PosterLockMixinz7 Mixin for Plex objects that can have a locked poster. c                 *     | j                   di ddiS )z$ Lock the poster for a Plex object. thumb.lockedr    r   r!   r#   s    r   
lockPosterzPosterLockMixin.lockPoster       tzz0^Q/00r   c                 *     | j                   di ddiS )z& Unlock the poster for a Plex object. r   r   r   r!   r#   s    r   unlockPosterzPosterLockMixin.unlockPoster   r   r   N)r   r   r   r   r   r   r   r   r   r}   r}      s    A11r   r}   c                   *    e Zd ZdZd ZddZd Zd Zy)PosterMixinz/ Mixin for Plex objects that can have posters. c                 `    | j                  d| j                   dt        j                        S )zC Returns list of available :class:`~plexapi.media.Poster` objects. r+   /postersr-   )r/   r0   r   Posterr#   s    r   posterszPosterMixin.posters   s+    !3DNN3C8LRWR^R^__r   Nc                 l   |rXd| j                    dt        |       }| j                  j                  || j                  j                  j
                         | S |rWd| j                    d}t        |      }| j                  j                  || j                  j                  j
                  |       | S )z Upload a poster from a url or filepath.

            Parameters:
                url (str): The full URL to the image to upload.
                filepath (str): The full file path to the image to upload or file-like object.
        r+   z/posters?url=r4   r   r6   r8   r<   s        r   uploadPosterzPosterMixin.uploadPoster   s     &t~~&6mJsOCTUCLLs4<<+@+@+E+EF
 	 &t~~&6h?Ch'DLLs4<<+@+@+E+EDQr   c                 &    |j                          | S )z Set the poster for a Plex object.

            Parameters:
                poster (:class:`~plexapi.media.Poster`): The poster object to select.
        rA   )r   posters     r   	setPosterzPosterMixin.setPoster   s     	r   c                     d| j                    d}| j                  j                  || j                  j                  j                         | S )z' Delete the poster from a Plex object. r+   z/thumbr4   rE   rG   s     r   deletePosterzPosterMixin.deletePoster   A    "4>>"2&93t||'<'<'C'CDr   rI   )r   r   r   r   r   r   r   r   r   r   r   r   r      s    9` r   r   c                   0    e Zd ZdZed        Zed        Zy)SquareArtUrlMixinz8 Mixin for Plex objects that can have a square art url. c                 <    t        d | j                  D        d      S )z. Return the API path to the square art image. c              3   T   K   | ]   }|j                   d k(  s|j                   " yw)backgroundSquareNrO   rQ   s     r   rT   z.SquareArtUrlMixin.squareArt.<locals>.<genexpr>   s!     PKq166=O3OQUUKrU   NrV   r#   s    r   	squareArtzSquareArtUrlMixin.squareArt   s     PDKKPRVWWr   c                 l    | j                   r'| j                  j                  | j                   d      S dS )z0 Return the square art url for the Plex object. Tr   N)r   r   r   r#   s    r   squareArtUrlzSquareArtUrlMixin.squareArtUrl   s0     GKnnt||TB^Z^^r   N)r   r   r   r   r   r   r   r   r   r   r   r      s/    BX X _ _r   r   c                       e Zd ZdZd Zd Zy)SquareArtLockMixinz; Mixin for Plex objects that can have a locked square art. c                 *     | j                   di ddiS )z( Lock the square art for a Plex object. squareArt.lockedr    r   r!   r#   s    r   lockSquareArtz SquareArtLockMixin.lockSquareArt   ra   r   c                 *     | j                   di ddiS )z* Unlock the square art for a Plex object. r   r   r   r!   r#   s    r   unlockSquareArtz"SquareArtLockMixin.unlockSquareArt   ra   r   N)r   r   r   r   r   r   r   r   r   r   r      s    E55r   r   c                   *    e Zd ZdZd ZddZd Zd Zy)SquareArtMixinz2 Mixin for Plex objects that can have square art. c                 `    | j                  d| j                   dt        j                        S )zF Returns list of available :class:`~plexapi.media.SquareArt` objects. r+   /squareArtsr-   )r/   r0   r   	SquareArtr#   s    r   
squareArtszSquareArtMixin.squareArts   s+    !3DNN3C;OUZUdUdeer   Nc                 l   |rXd| j                    dt        |       }| j                  j                  || j                  j                  j
                         | S |rWd| j                    d}t        |      }| j                  j                  || j                  j                  j
                  |       | S )z Upload a square art from a url or filepath.

            Parameters:
                url (str): The full URL to the image to upload.
                filepath (str): The full file path to the image to upload or file-like object.
        r+   z/squareArts?url=r4   r   r6   r8   r<   s        r   uploadSquareArtzSquareArtMixin.uploadSquareArt   rl   r   c                 &    |j                          | S )z Set the square art for a Plex object.

            Parameters:
                squareArt (:class:`~plexapi.media.SquareArt`): The square art object to select.
        rA   )r   r   s     r   setSquareArtzSquareArtMixin.setSquareArt   s     	r   c                     d| j                    d}| j                  j                  || j                  j                  j                         | S )z+ Delete the square art from a Plex object. r+   z
/squareArtr4   rE   rG   s     r   deleteSquareArtzSquareArtMixin.deleteSquareArt  rq   r   rI   )r   r   r   r   r   r   r   r   r   r   r   r   r      s    <f r   r   c                        e Zd ZdZed        Zy)ThemeUrlMixinz3 Mixin for Plex objects that can have a theme url. c                 j    | j                  ddd      }|r| j                  j                  |d      S dS )z+ Return the theme url for the Plex object. themeparentThemegrandparentThemeTr   Nr   r   r   s     r   themeUrlzThemeUrlMixin.themeUrl  ry   r   N)r   r   r   r   r   r   r   r   r   r   r     s    =M Mr   r   c                       e Zd ZdZd Zd Zy)ThemeLockMixinz6 Mixin for Plex objects that can have a locked theme. c                 *     | j                   di ddiS )z# Lock the theme for a Plex object. theme.lockedr    r   r!   r#   s    r   	lockThemezThemeLockMixin.lockTheme  r   r   c                 *     | j                   di ddiS )z% Unlock the theme for a Plex object. r   r   r   r!   r#   s    r   unlockThemezThemeLockMixin.unlockTheme  r   r   N)r   r   r   r   r   r   r   r   r   r   r     s    @11r   r   c                   *    e Zd ZdZd ZddZd Zd Zy)
ThemeMixinz. Mixin for Plex objects that can have themes. c                 `    | j                  d| j                   dt        j                        S )zB Returns list of available :class:`~plexapi.media.Theme` objects. r+   /themesr-   )r/   r0   r   Themer#   s    r   themeszThemeMixin.themes!  s+    !3DNN3C7KQVQ\Q\]]r   Nc                 p   |rYd| j                    dt        |       }| j                  j                  || j                  j                  j
                  |       | S |rXd| j                    d}t        |      }| j                  j                  || j                  j                  j
                  ||       | S )a   Upload a theme from url or filepath.

            Warning: Themes cannot be deleted using PlexAPI!

            Parameters:
                url (str): The full URL to the theme to upload.
                filepath (str): The full file path to the theme to upload or file-like object.
                timeout (int, optional): Timeout, in seconds, to use when uploading themes to the server.
                    (default config.TIMEOUT).
        r+   z/themes?url=)r5   timeoutr   )r5   r7   r   r8   )r   r   r=   r   r>   r7   s         r   uploadThemezThemeMixin.uploadTheme%  s     &t~~&6l:c?BSTCLLs4<<+@+@+E+EwW
 	 &t~~&6g>Ch'DLLs4<<+@+@+E+EDZabr   c                     t        d      )z Set the theme for a Plex object.

            Raises:
                :exc:`~plexapi.exceptions.NotImplementedError`: Themes cannot be set through the API.
        zXThemes cannot be set through the API. Re-upload the theme using "uploadTheme" to set it.)NotImplementedErrorr   s     r   setThemezThemeMixin.setTheme9  s     "A
 	
r   c                     d| j                    d}| j                  j                  || j                  j                  j                         | S )z& Delete the theme from a Plex object. r+   z/themer4   rE   rG   s     r   deleteThemezThemeMixin.deleteThemeD  r   r   )NNN)r   r   r   r   r   r   r   r   r   r   r   r   r     s    8^(	
r   r   N)urllib.parser   plexapir   plexapi.utilsr   r   r   r)   rK   r]   re   rs   r}   r   r   r   r   r   r   r   r   r   r   <module>r      s    #  $I I	/ 	/${L $NU U	5 	5$m $N 	1 	1$./ $N_ _	5 	5$&(: $NM M	1 	1* *r   