
    Mj
                    `    d dl mZ d dlmZ d dlmZ ddlmZ ddlm	Z	m
Z
  G d d          Zd	S )
    )annotations)escape)Path   )NormalizedMovie)library_namemovie_folder_namec                  8    e Zd ZdddZdd	ZddZddZddZdS )	NfoWriter/strmroot_dirstrdb_mountc                b    t          |          | _        |                    d          | _        d S N/)r   r   stripr   )selfr   r   s      moviebot\nfo_writer.py__init__zNfoWriter.__init__   s&    X s++    movier   returnc                L   | j         t          |j                  z  t          |j        |j        |j                  z  }|                    dd           |j        dk    rdnd}|| dz  }|                    | 	                    ||          d           t          |          S )NTparentsexist_okr   tvshow.nfoutf-8encoding)r   r   
media_typer	   titleyeartmdb_idmkdir
write_text_contentr   )r   r   foldertagpaths        r   writezNfoWriter.write   s    e.>!?!??BSTYT_afakmrmzB{B{{TD111)W44gg(3$eS11GDDD4yyr   	strm_pathc                6   |j         dk    r|                     |          S t          |          }|j                            dd           |                    d          }|                    |                     |d          d           t          |          S )Nr   Tr   r   r    r!   )	r#   r-   r   parentr'   with_suffixr(   r)   r   )r   r   r.   r,   nfo_paths        r   write_for_strmzNfoWriter.write_for_strm   s    w&&::e$$$I$666##F++DMM%99GLLL8}}r   db_strm_pathc                    d| j          d}|                    |          s|                     |          S |t          |          d          }|                     || j        |z            S r   )r   
startswithr-   lenr3   r   )r   r   r4   prefixrelatives        r   write_for_db_strmzNfoWriter.write_for_db_strm    sm    %T]%%%&&v.. 	%::e$$$F-""5$-(*BCCCr   r+   c                   dd| ddt          |j                   ddt          |j                   ddt          |j                   d	d
t          |j                   ddt          |j                   ddt          |j                   ddt          |j                   ddt          |j                   ddt          |j	                   dg}|j
        D ](}|                    dt          |           d           )|j        D ](}|                    dt          |           d           )|j        D ](}|                    dt          |           d           )|j        D ](}|                    dt          |           d           )|                    d| d           d                    |          dz   S ) Nz7<?xml version="1.0" encoding="UTF-8" standalone="yes"?><>z	  <title>z</title>z  <originaltitle>z</originaltitle>z  <plot>z</plot>z  <year>z</year>z  <runtime>z
</runtime>z	  <thumb>z</thumb>z
  <fanart>z	</fanart>z
  <imdbid>z	</imdbid>z
  <tmdbid>z	</tmdbid>z	  <genre>z</genre>z  <country>z
</country>z  <actor><name>z</name></actor>z  <director>z</director>z</
)r   r$   original_titlecontentr%   runtime
poster_urlbackdrop_urlimdb_idr&   genresappend	countriesactors	directorsjoin)r   r   r+   linesgenrecountryactordirectors           r   r)   zNfoWriter._content'   s   EJJJ5u{++555Nu'; < <NNN5vem,,5552vej))222;&//;;;:u/00:::> 233>>>9..9999..999
 \ 	> 	>ELL<VE]]<<<==== 	D 	DGLLBvgBBBCCCC\ 	K 	KELLI6%==IIIJJJJ 	G 	GHLLEx(8(8EEEFFFF[#[[[!!!yy$&&r   N)r   )r   r   r   r   )r   r   r   r   )r   r   r.   r   r   r   )r   r   r4   r   r   r   )r   r   r+   r   r   r   )__name__
__module____qualname__r   r-   r3   r:   r)    r   r   r   r   
   s        , , , , ,      D D D D' ' ' ' ' 'r   r   N)
__future__r   htmlr   pathlibr   modelsr   utilsr   r	   r   rS   r   r   <module>rY      s    " " " " " "             # # # # # # 2 2 2 2 2 2 2 24' 4' 4' 4' 4' 4' 4' 4' 4' 4'r   