
    ljS                        d dl m Z  d dlmZ  G d d      Z G d de      Z G d de      Z G d	 d
e      Z G d de      Z G d de      Z G d de      Z	 G d de      Z
 G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d d e      Z G d! d"e      Z G d# d$e      Z G d% d&e      Z G d' d(      Z G d) d*e      Z G d+ d,e      Z G d- d.e      Z G d/ d0e      Z G d1 d2e      Z G d3 d4e      Z G d5 d6e      Z G d7 d8e      Z G d9 d:e      Z G d; d<e      Z G d= d>e      Z y?)@    )datetime)quotec                       e Zd ZdZddZy)EditFieldMixinz' Mixin for editing Plex object fields. c                 p    | d|xs d| d|rdndi}|j                  |        | j                  di |S )a   Edit the field of a Plex object. All field editing methods can be chained together.
            Also see :func:`~plexapi.base.PlexPartialObject.batchEdits` for batch editing fields.

            Parameters:
                field (str): The name of the field to edit.
                value (str): The value to edit the field to.
                locked (bool): True (default) to lock the field, False to unlock the field.

            Example:

                .. code-block:: python

                    # Chaining multiple field edits with reloading
                    Movie.editTitle('A New Title').editSummary('A new summary').editTagline('A new tagline').reload()

        z.value .locked   r    )update_edit)selffieldvaluelockedkwargseditss         @/DATA/.local/lib/python3.12/site-packages/plexapi/mixins/edit.py	editFieldzEditFieldMixin.editField   sM    $ gVekrgWFq
 	Vtzz"E""    NT)__name__
__module____qualname____doc__r   r   r   r   r   r      s
    1#r   r   c                       e Zd ZdZddZy)AddedAtMixinz8 Mixin for Plex objects that can have an added at date. c                    t        |t              r7t        t        t	        j
                  |d      j                                     }n2t        |t              r"t        t        |j                                     }| j                  d||      S )a-   Edit the added at date.

            Parameters:
                addedAt (int or str or datetime): The new value as a unix timestamp (int),
                    "YYYY-MM-DD" (str), or datetime object.
                locked (bool): True (default) to lock the field, False to unlock the field.
        %Y-%m-%daddedAtr   )
isinstancestrintroundr   strptime	timestampr   )r   r    r   s      r   editAddedAtzAddedAtMixin.editAddedAt$   sj     gs#% 1 1': F P P RSTG*% 1 1 345G~~i~@@r   Nr   )r   r   r   r   r(   r   r   r   r   r   !   s    BAr   r   c                       e Zd ZdZddZy)AudienceRatingMixinz: Mixin for Plex objects that can have an audience rating. c                 *    | j                  d||      S )z Edit the audience rating.

            Parameters:
                audienceRating (float): The new value.
                locked (bool): True (default) to lock the field, False to unlock the field.
        audienceRatingr!   r   )r   r,   r   s      r   editAudienceRatingz&AudienceRatingMixin.editAudienceRating6   s     ~~.v~NNr   Nr   )r   r   r   r   r.   r   r   r   r*   r*   3   s    DOr   r*   c                       e Zd ZdZddZy)ContentRatingMixinz8 Mixin for Plex objects that can have a content rating. c                 *    | j                  d||      S )z Edit the content rating.

            Parameters:
                contentRating (str): The new value.
                locked (bool): True (default) to lock the field, False to unlock the field.
        contentRatingr!   r-   )r   r2   r   s      r   editContentRatingz$ContentRatingMixin.editContentRatingC        ~~o}V~LLr   Nr   )r   r   r   r   r3   r   r   r   r0   r0   @   s    BMr   r0   c                       e Zd ZdZddZy)CriticRatingMixinz7 Mixin for Plex objects that can have a critic rating. c                 *    | j                  d||      S )z Edit the critic rating.

            Parameters:
                criticRating (float): The new value.
                locked (bool): True (default) to lock the field, False to unlock the field.
        ratingr!   r-   )r   criticRatingr   s      r   editCriticRatingz"CriticRatingMixin.editCriticRatingP   s     ~~hV~DDr   Nr   )r   r   r   r   r:   r   r   r   r6   r6   M   s    AEr   r6   c                       e Zd ZdZddZy)EditionTitleMixinz8 Mixin for Plex objects that can have an edition title. c                 *    | j                  d||      S )z Edit the edition title. Plex Pass is required to edit this field.

            Parameters:
                editionTitle (str): The new value.
                locked (bool): True (default) to lock the field, False to unlock the field.
        editionTitler!   r-   )r   r>   r   s      r   editEditionTitlez"EditionTitleMixin.editEditionTitle]   s     ~~nl6~JJr   Nr   )r   r   r   r   r?   r   r   r   r<   r<   Z   s    BKr   r<   c                       e Zd ZdZddZy)OriginallyAvailableMixinzD Mixin for Plex objects that can have an originally available date. c                 l    t        |t              r|j                  d      }| j                  d||      S )a   Edit the originally available date.

            Parameters:
                originallyAvailable (str or datetime): The new value "YYYY-MM-DD (str) or datetime object.
                locked (bool): True (default) to lock the field, False to unlock the field.
        r   originallyAvailableAtr!   r"   r   strftimer   )r   originallyAvailabler   s      r   editOriginallyAvailablez0OriginallyAvailableMixin.editOriginallyAvailablej   s8     )84"5">">z"J~~57JSY~ZZr   Nr   )r   r   r   r   rG   r   r   r   rA   rA   g   s    N	[r   rA   c                       e Zd ZdZddZy)OriginalTitleMixinz9 Mixin for Plex objects that can have an original title. c                 *    | j                  d||      S )z Edit the original title.

            Parameters:
                originalTitle (str): The new value.
                locked (bool): True (default) to lock the field, False to unlock the field.
        originalTitler!   r-   )r   rK   r   s      r   editOriginalTitlez$OriginalTitleMixin.editOriginalTitley   r4   r   Nr   )r   r   r   r   rL   r   r   r   rI   rI   v   s    CMr   rI   c                       e Zd ZdZddZy)SortTitleMixinz4 Mixin for Plex objects that can have a sort title. c                 *    | j                  d||      S )z Edit the sort title.

            Parameters:
                sortTitle (str): The new value.
                locked (bool): True (default) to lock the field, False to unlock the field.
        	titleSortr!   r-   )r   	sortTitler   s      r   editSortTitlezSortTitleMixin.editSortTitle   s     ~~k9V~DDr   Nr   )r   r   r   r   rR   r   r   r   rN   rN      s    >Er   rN   c                       e Zd ZdZddZy)StudioMixinz0 Mixin for Plex objects that can have a studio. c                 *    | j                  d||      S )z Edit the studio.

            Parameters:
                studio (str): The new value.
                locked (bool): True (default) to lock the field, False to unlock the field.
        studior!   r-   )r   rV   r   s      r   
editStudiozStudioMixin.editStudio   s     ~~hv~>>r   Nr   )r   r   r   r   rW   r   r   r   rT   rT      s
    :?r   rT   c                       e Zd ZdZddZy)SummaryMixinz1 Mixin for Plex objects that can have a summary. c                 *    | j                  d||      S )z Edit the summary.

            Parameters:
                summary (str): The new value.
                locked (bool): True (default) to lock the field, False to unlock the field.
        summaryr!   r-   )r   r[   r   s      r   editSummaryzSummaryMixin.editSummary        ~~i~@@r   Nr   )r   r   r   r   r\   r   r   r   rY   rY          ;Ar   rY   c                       e Zd ZdZddZy)TaglineMixinz1 Mixin for Plex objects that can have a tagline. c                 *    | j                  d||      S )z Edit the tagline.

            Parameters:
                tagline (str): The new value.
                locked (bool): True (default) to lock the field, False to unlock the field.
        tagliner!   r-   )r   rb   r   s      r   editTaglinezTaglineMixin.editTagline   r]   r   Nr   )r   r   r   r   rc   r   r   r   r`   r`      r^   r   r`   c                       e Zd ZdZddZy)
TitleMixinz/ Mixin for Plex objects that can have a title. c                 n    i }| j                   dk(  r| j                  |d<    | j                  d|fd|i|S )z Edit the title.

            Parameters:
                title (str): The new value.
                locked (bool): True (default) to lock the field, False to unlock the field.
        albumzartist.id.valuetitler   )TYPEparentRatingKeyr   )r   rh   r   r   s       r   	editTitlezTitleMixin.editTitle   sC     99(,(<(<F$%t~~guFVFvFFr   Nr   )r   r   r   r   rk   r   r   r   re   re      s    9Gr   re   c                       e Zd ZdZddZy)TrackArtistMixinz6 Mixin for Plex objects that can have a track artist. c                 *    | j                  d||      S )z Edit the track artist.

            Parameters:
                trackArtist (str): The new value.
                locked (bool): True (default) to lock the field, False to unlock the field.
        rK   r!   r-   )r   trackArtistr   s      r   editTrackArtistz TrackArtistMixin.editTrackArtist   s     ~~o{6~JJr   Nr   )r   r   r   r   rp   r   r   r   rm   rm      s    @Kr   rm   c                       e Zd ZdZddZy)TrackNumberMixinz6 Mixin for Plex objects that can have a track number. c                 *    | j                  d||      S )z Edit the track number.

            Parameters:
                trackNumber (int): The new value.
                locked (bool): True (default) to lock the field, False to unlock the field.
        indexr!   r-   )r   trackNumberr   s      r   editTrackNumberz TrackNumberMixin.editTrackNumber   s     ~~g{6~BBr   Nr   )r   r   r   r   rv   r   r   r   rr   rr      s    @Cr   rr   c                       e Zd ZdZddZy)TrackDiscNumberMixinz; Mixin for Plex objects that can have a track disc number. c                 *    | j                  d||      S )z Edit the track disc number.

            Parameters:
                discNumber (int): The new value.
                locked (bool): True (default) to lock the field, False to unlock the field.
        parentIndexr!   r-   )r   
discNumberr   s      r   editDiscNumberz#TrackDiscNumberMixin.editDiscNumber   s     ~~mZ~GGr   Nr   )r   r   r   r   r|   r   r   r   rx   rx      s    EHr   rx   c                       e Zd ZdZddZy)PhotoCapturedTimeMixinz7 Mixin for Plex objects that can have a captured time. c                 l    t        |t              r|j                  d      }| j                  d||      S )a
   Edit the photo captured time.

            Parameters:
                capturedTime (str or datetime): The new value "YYYY-MM-DD hh:mm:ss" (str) or datetime object.
                locked (bool): True (default) to lock the field, False to unlock the field.
        z%Y-%m-%d %H:%M:%SrC   r!   rD   )r   capturedTimer   s      r   editCapturedTimez'PhotoCapturedTimeMixin.editCapturedTime   s5     lH-'001DEL~~5|F~SSr   Nr   )r   r   r   r   r   r   r   r   r~   r~      s    A	Tr   r~   c                       e Zd ZdZddZy)UserRatingMixinz5 Mixin for Plex objects that can have a user rating. c                 *    | j                  d||      S )z Edit the user rating.

            Parameters:
                userRating (float): The new value.
                locked (bool): True (default) to lock the field, False to unlock the field.
        
userRatingr!   r-   )r   r   r   s      r   editUserRatingzUserRatingMixin.editUserRating  s     ~~lJv~FFr   Nr   )r   r   r   r   r   r   r   r   r   r      s    ?Gr   r   c                   J    e Zd ZdZddZed        Zed        Zedd       Zy)EditTagsMixinz% Mixin for editing Plex object tags. c                    t        |t              s|g}|s1t        | | j                  |      g       }t        |t              r||z   }| j	                  | j                  |      |||      }|j                  |        | j                  di |S )a   Edit the tags of a Plex object. All tag editing methods can be chained together.
            Also see :func:`~plexapi.base.PlexPartialObject.batchEdits` for batch editing tags.

            Parameters:
                tag (str): Name of the tag to edit.
                items (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags to add or remove.
                locked (bool): True (default) to lock the tags, False to unlock the tags.
                remove (bool): True to remove the tags in items.

            Example:

                .. code-block:: python

                    # Chaining multiple tag edits with reloading
                    Show.addCollection('New Collection').removeGenre('Action').addLabel('Favorite').reload()

        r   )r"   listgetattr
_tagPlural
_tagHelper_tagSingularr   r   )r   tagitemsr   remover   tagsr   s           r   editTagszEditTagsMixin.editTags  s    $ %&GE4!5r:D$%u 1 1# 6vvNVtzz"E""r   c                 8    | dk(  ry| dk(  ry| d   dk(  r| dd S | S )z$ Return the singular name of a tag. 	countriescountrysimilarsNr   r   s    r   r   zEditTagsMixin._tagSingular,  s5     +IW^s8O
r   c                 8    | dk(  ry| dk(  ry| d   dk7  r| dz   S | S )z" Return the plural name of a tag. r   r   r   r   r   r   r   s    r   r   zEditTagsMixin._tagPlural7  s4     )IW^9
r   c                     t        |t              s|g}|  d|rdndi}|r"|  d}dj                  d |D              ||<   |S t        |      D ]  \  }}t	        |        d| d}|||<    |S )	z: Return a dict of the query parameters for editing a tag. r	   r
   r   z[].tag.tag-,c              3   D   K   | ]  }t        t        |              y w)N)r   r#   ).0ts     r   	<genexpr>z+EditTagsMixin._tagHelper.<locals>.<genexpr>N  s     $BEqU3q6]Es    [z	].tag.tag)r"   r   join	enumerater#   )r   r   r   r   datatagnameiitems           r   r   zEditTagsMixin._tagHelperB  s     %&GE e7O&Qa
 [)GHH$BE$BBDM 	 %U+4 XJas)4 $W , r   N)TF)	r   r   r   r   r   staticmethodr   r   r   r   r   r   r   r     sF    /#<      r   r   c                        e Zd ZdZddZddZy)CollectionMixinz3 Mixin for Plex objects that can have collections. c                 *    | j                  d||      S )z Add a collection tag(s).

            Parameters:
                collections (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        
collectionr!   r   r   collectionsr   s      r   addCollectionzCollectionMixin.addCollectionZ  s     }}\;v}FFr   c                 ,    | j                  d||d      S )z Remove a collection tag(s).

            Parameters:
                collections (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        r   Tr   r   r   r   s      r   removeCollectionz CollectionMixin.removeCollectionc  s     }}\;vd}SSr   Nr   )r   r   r   r   r   r   r   r   r   r   r   W  s    =GTr   r   c                        e Zd ZdZddZddZy)CountryMixinz1 Mixin for Plex objects that can have countries. c                 *    | j                  d||      S )z Add a country tag(s).

            Parameters:
                countries (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        r   r!   r   r   r   r   s      r   
addCountryzCountryMixin.addCountryp  s     }}Y	&}AAr   c                 ,    | j                  d||d      S )z Remove a country tag(s).

            Parameters:
                countries (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        r   Tr   r   r   s      r   removeCountryzCountryMixin.removeCountryy  s     }}Y	&}NNr   Nr   )r   r   r   r   r   r   r   r   r   r   r   m  s    ;BOr   r   c                        e Zd ZdZddZddZy)DirectorMixinz1 Mixin for Plex objects that can have directors. c                 *    | j                  d||      S )z Add a director tag(s).

            Parameters:
                directors (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        directorr!   r   r   	directorsr   s      r   addDirectorzDirectorMixin.addDirector       }}Z6}BBr   c                 ,    | j                  d||d      S )z Remove a director tag(s).

            Parameters:
                directors (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        r   Tr   r   r   s      r   removeDirectorzDirectorMixin.removeDirector       }}Z6$}OOr   Nr   )r   r   r   r   r   r   r   r   r   r   r         ;CPr   r   c                        e Zd ZdZddZddZy)
GenreMixinz. Mixin for Plex objects that can have genres. c                 *    | j                  d||      S )z Add a genre tag(s).

            Parameters:
                genres (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        genrer!   r   r   genresr   s      r   addGenrezGenreMixin.addGenre       }}WfV}<<r   c                 ,    | j                  d||d      S )z Remove a genre tag(s).

            Parameters:
                genres (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        r   Tr   r   r   s      r   removeGenrezGenreMixin.removeGenre       }}WfVD}IIr   Nr   )r   r   r   r   r   r   r   r   r   r   r         8=Jr   r   c                        e Zd ZdZddZddZy)
LabelMixinz. Mixin for Plex objects that can have labels. c                 *    | j                  d||      S )z Add a label tag(s).

            Parameters:
                labels (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        labelr!   r   r   labelsr   s      r   addLabelzLabelMixin.addLabel  r   r   c                 ,    | j                  d||d      S )z Remove a label tag(s).

            Parameters:
                labels (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        r   Tr   r   r   s      r   removeLabelzLabelMixin.removeLabel  r   r   Nr   )r   r   r   r   r   r   r   r   r   r   r     r   r   r   c                        e Zd ZdZddZddZy)	MoodMixinz- Mixin for Plex objects that can have moods. c                 *    | j                  d||      S )z Add a mood tag(s).

            Parameters:
                moods (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        moodr!   r   r   moodsr   s      r   addMoodzMoodMixin.addMood  s     }}VU6}::r   c                 ,    | j                  d||d      S )z Remove a mood tag(s).

            Parameters:
                moods (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        r   Tr   r   r   s      r   
removeMoodzMoodMixin.removeMood  s     }}VU6$}GGr   Nr   )r   r   r   r   r   r   r   r   r   r   r     s    7;Hr   r   c                        e Zd ZdZddZddZy)ProducerMixinz1 Mixin for Plex objects that can have producers. c                 *    | j                  d||      S )z Add a producer tag(s).

            Parameters:
                producers (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        producerr!   r   r   	producersr   s      r   addProducerzProducerMixin.addProducer  r   r   c                 ,    | j                  d||d      S )z Remove a producer tag(s).

            Parameters:
                producers (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        r   Tr   r   r   s      r   removeProducerzProducerMixin.removeProducer  r   r   Nr   )r   r   r   r   r   r   r   r   r   r   r     r   r   r   c                        e Zd ZdZddZddZy)SimilarArtistMixinz7 Mixin for Plex objects that can have similar artists. c                 *    | j                  d||      S )z Add a similar artist tag(s).

            Parameters:
                artists (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        r   r!   r   r   artistsr   s      r   addSimilarArtistz#SimilarArtistMixin.addSimilarArtist  s     }}Y}??r   c                 ,    | j                  d||d      S )z Remove a similar artist tag(s).

            Parameters:
                artists (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        r   Tr   r   r   s      r   removeSimilarArtistz&SimilarArtistMixin.removeSimilarArtist  s     }}Yt}LLr   Nr   )r   r   r   r   r   r   r   r   r   r   r     s    A@Mr   r   c                        e Zd ZdZddZddZy)
StyleMixinz. Mixin for Plex objects that can have styles. c                 *    | j                  d||      S )z Add a style tag(s).

            Parameters:
                styles (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        styler!   r   r   stylesr   s      r   addStylezStyleMixin.addStyle
  r   r   c                 ,    | j                  d||d      S )z Remove a style tag(s).

            Parameters:
                styles (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        r   Tr   r   r   s      r   removeStylezStyleMixin.removeStyle  r   r   Nr   )r   r   r   r   r   r   r   r   r   r   r     r   r   r   c                        e Zd ZdZddZddZy)TagMixinz, Mixin for Plex objects that can have tags. c                 *    | j                  d||      S )z Add a tag(s).

            Parameters:
                tags (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        r   r!   r   r   r   r   s      r   addTagzTagMixin.addTag   s     }}UD}88r   c                 ,    | j                  d||d      S )z Remove a tag(s).

            Parameters:
                tags (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        r   Tr   r   r  s      r   	removeTagzTagMixin.removeTag)  s     }}UD}EEr   Nr   )r   r   r   r   r  r  r   r   r   r  r    s    69Fr   r  c                        e Zd ZdZddZddZy)WriterMixinz/ Mixin for Plex objects that can have writers. c                 *    | j                  d||      S )z Add a writer tag(s).

            Parameters:
                writers (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        writerr!   r   r   writersr   s      r   	addWriterzWriterMixin.addWriter6  s     }}Xwv}>>r   c                 ,    | j                  d||d      S )z Remove a writer tag(s).

            Parameters:
                writers (List<str> or List<:class:`~plexapi.media.MediaTag`>): List of tags.
                locked (bool): True (default) to lock the field, False to unlock the field.
        r
  Tr   r   r  s      r   removeWriterzWriterMixin.removeWriter?  s     }}Xwvd}KKr   Nr   )r   r   r   r   r  r  r   r   r   r  r  3  s    9?Lr   r  N)!r   urllib.parser   r   r   r*   r0   r6   r<   rA   rI   rN   rT   rY   r`   re   rm   rr   rx   r~   r   r   r   r   r   r   r   r   r   r   r   r  r  r   r   r   <module>r     s    # #8A> A$
O. 
O
M 
M
E 
E
K 
K[~ [
M 
M
E^ 
E
?. 
?
A> 
A
A> 
AG G"
K~ 
K
C~ 
C
H> 
HT^ T
Gn 
GI IXTm T,O= O,PM P,J J,J J,H H,PM P,M M,J J,F} F,L- Lr   