
    g
                     L    d dl Z d dlmZ d dlmZ d dlmZ  G d de      Zd Zy)    N)defaultdict)ConfigParser)utilsc                   $    e Zd ZdZd ZddZd Zy)
PlexConfigat   PlexAPI configuration object. Settings are stored in an INI file within the
        user's home directory and can be overridden after importing plexapi by simply
        setting the value. See the documentation section 'Configuration' for more
        details on available options.

        Parameters:
            path (str): Path of the configuration file to load.
    c                 z    t        j                  |        | j                  |       | j                         | _        y )N)r   __init__read_asDictdata)selfpaths     #/opt/Tautulli/lib/plexapi/config.pyr	   zPlexConfig.__init__   s(    d#		$LLN	    Nc                 n   	 d|j                         j                  dd       }t        j                  j	                  |      }|N|j                         j                  d      \  }}| j                  j	                  |i       j	                  ||      }|rt        j                  ||      S |S #  |cY S xY w)a[   Returns the specified configuration value or <default> if not found.

            Parameters:
                key (str): Configuration variable to load in the format '<section>.<variable>'.
                default: Default value to use if key not found.
                cast (func): Cast the value to the specified type before returning.
        PLEXAPI_._)
upperreplaceosenvirongetlowersplitr   r   cast)r   keydefaultr   envkeyvaluesectionnames           r   r   zPlexConfig.get   s    
			 3 3C =>?FJJNN6*E} #		 1 1# 6		gr266tWE.25::dE*==	Ns   B)B. ,B. .B4c                     t        t              }| j                  D ]Q  }| j                  |   j                         D ]/  \  }}|dk7  s|||j	                            |j	                         <   1 S t        |      S )z3 Returns all configuration values as a dictionary. __name__)r   dict	_sectionsitemsr   )r   configr!   r"   r    s        r   r   zPlexConfig._asDict,   sw    T"~~ 	BG#~~g6<<> Be:%<AF7==?+DJJL9B	B F|r   )NN)r$   
__module____qualname____doc__r	   r   r    r   r   r   r   	   s    #
(r   r   c                      ddl } | j                  | j                  | j                  | j                  | j
                  | j                  | j                  | j                  | j                  dddS )zX Convenience function returns a dict of all base X-Plex-* headers for session requests. r   N2zexternal-media)zX-Plex-PlatformzX-Plex-Platform-VersionzX-Plex-ProvideszX-Plex-ProductzX-Plex-VersionzX-Plex-DevicezX-Plex-Device-NamezX-Plex-Client-IdentifierzX-Plex-LanguagezX-Plex-Sync-VersionzX-Plex-Features)
plexapiX_PLEX_PLATFORMX_PLEX_PLATFORM_VERSIONX_PLEX_PROVIDESX_PLEX_PRODUCTX_PLEX_VERSIONX_PLEX_DEVICEX_PLEX_DEVICE_NAMEX_PLEX_IDENTIFIERX_PLEX_LANGUAGE)r/   s    r   reset_base_headersr9   6   sf    "22#*#B#B"22!00!00 ..%88$+$=$="22"+ r   )	r   collectionsr   configparserr   r/   r   r   r9   r,   r   r   <module>r<      s#    	 # % * *Zr   