
    KJi5                     ^    d Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
mZ  G d de          ZdS )zV
This module provides the Movie class, used to store information about
a given movie.
    )deepcopy)linguistics)
_Containeranalyze_titlebuild_titlecanonicalTitle	cmpMoviesflattenc                      e Zd ZdZdZi ddddddd	dd
ddddddddddddddddddddddddddd d!d"dd#d#d#d$d%d&d%d'Zd(Zd ZeZ	d) Z
d* Zd+ Zd, Zd- Zd:d/Zd0 Zd1 Zd2 Zd3 Zd4 ZeZd5 Zd6 Zd7 Zd8 Zd9 Zd.S );MovieaD  A Movie.

    Every information about a movie can be accessed as::

        movieObject['information']

    to get a list of the kind of information stored in a
    Movie object, use the keys() method; some useful aliases
    are defined (as "casting" for the "casting director" key); see
    the keys_alias dictionary.
    )mainplotztv scheduleairingzuser ratingratingplot summaryr   zplot summarieszdirected bydirector	directorswriterswriteractorscast	actressesakaakaszalso known ascountry	countrieszproduction countryzproduction countriesgenregenresruntimeruntimeslang	languagesz
color info	cover urlfull-size cover urlznumber of seasonscertificatesznumber of episodesfaqstech)colorcoverzfull-size coverseasonslanguagecertificatecertificationscertificationzepisodes numberfaq	technicalzfrequently asked questions)r   triviazalternate versionsgoofsquotesdvd	laserdiscnews
soundtrackzcrazy creditsbusinesssupplementszvideo reviewr&   c                     |                     d          }|rd| j        vr|                     |           |                     dd          | _        |                     dd          | _        dS )a  Initialize a Movie object.

        *movieID* -- the unique identifier for the movie.
        *title* -- the title of the Movie, if not in the data dictionary.
        *myTitle* -- your personal title for the movie.
        *myID* -- your personal identifier for the movie.
        *data* -- a dictionary used to initialize the object.
        *currentRole* -- a Character instance representing the current role
                         or duty of a person in this movie, or a Person
                         object representing the actor/actress who played
                         a given character in a Movie.  If a string is
                         passed, an object is automatically build.
        *roleID* -- if available, the characterID/personID of the currentRole
                    object.
        *roleIsPerson* -- when False (default) the currentRole is assumed
                          to be a Character object, otherwise a Person.
        *notes* -- notes for the person referred in the currentRole
                    attribute; e.g.: '(voice)'.
        *accessSystem* -- a string representing the data access system used.
        *titlesRefs* -- a dictionary with references to movies.
        *namesRefs* -- a dictionary with references to persons.
        *charactersRefs* -- a dictionary with references to characters.
        *modFunct* -- function called returning text fields.
        titlemovieIDNmyTitle )getdata	set_titler<   r=   )selfkwdsr;   s      J/var/www/html/auto_sub_bot/venv/lib/python3.11/site-packages/imdb/Movie.py_initzMovie._init^   si    2 !! 	"WDI--NN5!!!xx	400xx	2..    c                 "    d| _         d| _        dS )zReset the Movie object.Nr>   )r<   r=   rB   s    rD   _resetzMovie._reset}   s    rF   c                 X    t          |          }| j                            |           dS )zSet the title of the movie.N)r   r@   update)rB   r;   d_titles      rD   rA   zMovie.set_title   s+    &&	!!!!!rF   c                 h    g }d| j         v r|g dz  }d| j         v r|g dz  }d| j         v r|dgz  }|S )z-Valid keys to append to the data.keys() list.r;   )canonical titlelong imdb titlelong imdb canonical titlesmart canonical titlesmart long imdb canonical title
episode of)long imdb episode titleseries titlecanonical series titleepisode titlecanonical episode titlesmart canonical series titlesmart canonical episode titler#   r$   r@   )rB   addkeyss     rD   _additional_keyszMovie._additional_keys   sw    di ; ; ; ;G 49$$ 9 9 9 9G
 $)##-..GrF   c                     |                      d          }|r	|d         }n<|                      d          }|r%t          j                             |d                   }|S )zZGuess the language of the title of this movie; returns None
        if there are no hints.r"   r   r   )r?   r   COUNTRY_LANG)rB   r!   r   s      rD   guessLanguagezMovie.guessLanguage   sb     xx$$ 	@7DDhh{++G @"/33GAJ??rF   Nc                     || j                             dd          }||                                 }t          ||          S )zReturn the canonical title, guessing its language.
        The title can be forces with the 'title' argument (internally
        used) and the language can be forced with the 'lang' argument,
        otherwise it's auto-detected.Nr;   r>   )r!   )r@   r?   r`   r   )rB   r;   r!   s      rD   smartCanonicalTitlezMovie.smartCanonicalTitle   sG    
 =IMM'2..E<%%''De$////rF   c                 \    t          |t                    r|                    dd          S |S )z>Get the title from a Movie object or return the string itself.r;   r>   )
isinstancer   r?   )rB   objs     rD   _getSeriesTitlezMovie._getSeriesTitle   s-    c5!! 	(777B'''
rF   c                 B   d| j         v r3|dk    rt          | j                   S |dk    r |                     | j         d                   S |dk    r/|                     | j         d                   }t          |          S |dk    r5|                     | j         d                   }|                     |          S |dk    r| j                             dd          S |d	k    r(t          | j                             dd                    S |d
k    r.|                     | j                             dd                    S d| j         v r|dk    r| j         d         S |dk    rt          | j                   S |dk    rt          | j         d                   S |dk    r |                     | j         d                   S |dk    rt          | j         d          S |dk    r)t          | j         d|                                           S |dk    r|                                 S dS )zHandle special keys.rS   rT   rU   rV   rY   rW   r;   r>   rX   rZ   rO   rN   rQ   rP   T	canonicalrR   )ri   r!   r$   N)r@   r   rf   r   rb   r?   r`   get_fullsizeURL)rB   key	ser_titles      rD   _getitemzMovie._getitem   s4   49$$///"49---&&++DIl,CDDD000 00<1HII	%i000666 00<1HII	//	:::''y}}Wb111111%dimmGR&@&@AAA777//	gr0J0JKKKdig~~y)))))"49---)))%di&8999/////	'0BCCC333"49====999"494CUCUCWCWXXXX''''')))trF   c                     | j         S )zReturn the movieID.)r<   rH   s    rD   getIDzMovie.getID   s
    |rF   c                     d| j         v S )z?The Movie is "false" if the self.data does not contain a title.r;   r[   rH   s    rD   __bool__zMovie.__bool__   s     $)##rF   c                 
   t          || j                  sdS d| j        v r9d|j        v r0t          | j        d          t          |j        d          k    rdS | j        |j        k    r| j        | j        |j        k    rdS dS )zjReturn true if this and the compared object have the same
        long imdb title and/or movieID.
        Fr;   rh   T)rd   	__class__r@   r   accessSystemr<   )rB   others     rD   isSameTitlezMovie.isSameTitle   s    
 %00 	5diGuz$9$9DI777;uz]b;c;c;ccc4 222(T\U]-J-J4urF   c           	         ddl m } ddlm} ddlm} t          ||          rLt	          | j        d|t          t          t          t          f          D ]}|
                    |          r dS nt          ||          rQt	          | j        d|t          t          t          t          f          D ]}|
                    |j                  r dS  nzt          ||          rLt	          | j        d|t          t          t          t          f          D ]}|
                    |          r dS nt          |t                    r	|| j        v S dS )zReturn true if the given Person object is listed in this Movie,
        or if the the given Character is represented in this Movie.   )	Character)Company)PersonT)yieldDictKeysscalar	toDescendF)ry   rz   r{   rd   r
   r@   listdicttupler   isSamecurrentRolestr)rB   itemry   rz   r{   pcs          rD   __contains__zMovie.__contains__   s    	)((((($$$$$$""""""dF## 	%TYd6(,dE5'AC C C    ;;q>>  44   i(( 	%TYd6(,dE5'AC C C    ;;q}--  44   g&& 	%TYd7(,dE5'AC C C    ;;q>>  44   c"" 	%49$$urF   c                    t          d| j        | j        | j        t	          | j        |          t	          | j        |          | j        | j        | j	        t	          | j
        |          t	          | j        |          t	          | j        |                    }t          | j                  |_        |                    | j                   |S )z'Return a deep copy of a Movie instance.r>   )r;   r<   r=   myIDr@   r   roleIsPersonnotesrt   
titlesRefs	namesRefscharactersRefs)r   r<   r=   r   r   r@   r   _roleIsPersonr   rt   r   r   r   r   current_infoset_mod_functmodFunct)rB   memoms      rD   __deepcopy__zMovie.__deepcopy__  s    DL$,yx	4'@'@&t'7>>#1
1B%dot<<$T^T::!)$*=t!D!DF F F d/00	&&&rF   c                     d| v r|                      d          }n|                      d          }d| j        d| j        d|dS )z(String representation of a Movie object.rT   rO   z
<Movie id:[z	] title:_z_>)r?   r<   rt   )rB   r;   s     rD   __repr__zMovie.__repr__  sY     %,,HH677EEHH.//E15t?P?P?PRWRWRWXXrF   c                 .    |                      dd          S )zSimply print the short title.r;   r>   )r?   rH   s    rD   __str__zMovie.__str__#  s    xx$$$rF   c                 2   | sdS d!d}d|                      dd          z  }|                      d          }|r|dd                    |          z  z  }|                      d          }|r|d	 ||          z  z  }|                      d
          }|r|d ||          z  z  }|                      d          }|r|dd         }|d ||          z  z  }|                      d          }|r|dd                    |          z  z  }|                      d          }|r|dd                    |          z  z  }|                      d          }	|	r|dd                    |	          z  z  }|                      d          }
|
r,|d|
z  z  }|                      d          }|r|d|z  z  }|dz  }|                      d          }|s|                      d          }|r|g}|r5|d         }|                    d          }|dk    r
|d|         }|d |z  z  }|S )"z<Return a string with a pretty-printed summary for the movie.r>   , c                     g }| D ]A}|                     dd          }|j        r|d|j        z  z  }|                    |           B|                    |          S )z)Build a pretty string with name and role.namer>   z (%s))r?   r   appendjoin)
personListjoinernlpersonns        rD   _nameAndRolez#Movie.summary.<locals>._nameAndRole,  sg    B$  JJvr**% 66#555A		!;;r??"rF   zMovie
=====
Title: %s
rP   r   zGenres: %s.
r   zDirector: %s.
r   zWriter: %s.
r   N   z
Cast: %s.
r    zRuntime: %s.
r   zCountry: %s.
r"   zLanguage: %s.
r   z
Rating: %svotesz (%s votes)z.
r   r   r   z::zPlot: %s)r   )r?   r   find)rB   r   sr   r   r   r   r   r   r!   r   nr_votesr   is                 rD   summaryzMovie.summary'  s    	2	# 	# 	# 	# ($((3NPR*S*SS(## 	5499V#4#444A88J'' 	<"\\(%;%;;;A(## 	8<<#7#777Axx 	48Dd!3!333A((:&& 	7!DIIg$6$666AHH[))	 	9!DIIi$8$888Axx$$ 	5"TYYt__44A(## 	&&Axx((H .]X--JAxx 	88N++D v 	#7D		$ABwwBQBxd""ArF   )NN)__name__
__module____qualname____doc__default_info
keys_aliaskeys_tomodify_list
_image_keyr	   cmpFunctrE   rI   rA   r]   r`   rb   rf   rm   ro   rq   rv   isSameMovier   r   r   r   r    rF   rD   r   r   #   s>       
 
 $Lxx 	 	&	
 	z 	Z 	8 	& 	V 	v 	 	; 	k 	 	  	:!" 	#$ 0&%('/&,;  J@ JH/ / />  
" " "
  $
 
 
	0 	0 	0 	0  " " "H  $ $ $
   K  2  Y Y Y% % %7 7 7 7 7rF   r   N)r   copyr   imdbr   
imdb.utilsr   r   r   r   r	   r
   r   r   rF   rD   <module>r      s   " 
                           { { { { {J { { { { {rF   