§
   FéØXó{è\ã                   ó*  — d Z ddlZddlmZmZ ddlmZ ddlm	Z
mZ dZdZddd	œZd
ZdZdZd                     ej        ej        z   ¦  «        Zd„ ZdddddddœZd„ Zd„ Zd„ Z G d„ de¦  «        Z G d„ de¦  «        Z G d„ de¦  «        Zd„ Zd„ Z dS )u™  The questionnaire of the guide (docs/plan/onboarding/000-plan.md D9-D13, D34, D35): the genres of the genre section,
then the best known films and series of the chosen genres, each genre in turn, as the global Kvalita nÃ¡vrhÅ¯ sees them
(wcs/quality: western titles, services and ratings first, like Pro tebe and Å½Ã¡nry), each with the CZ services it runs on.

Data only, never a window: the wizard asks, a thread of `Prefetch` fetches ahead (TMDb answers go through the cache of
wcs/foryou/api, the services through wcs/services/store). What the household chose goes into the library as liked titles
in Moje filmy / Moje seriÃ¡ly, the seeds of Pro tebe (`save`).
é    N)ÚapiÚfeatures)Úcatalog)ÚlistsÚrulesé   i,  é–   ©ÚmovieÚtvé   zhttps://image.tmdb.org/t/p/w342z https://image.tmdb.org/t/p/w1280ú|c                  óP   ‡ — ddl mŠ  ˆ fd„t          j        d¦  «        D ¦   «         S )z7[(key, name)] of the genre section, in its order (D12).r   ©Ú
genre_namec                 ó*   •— g | ]}| ‰|¦  «        f‘ŒS © r   )Ú.0Úkeyr   s     €úb/Users/chudy/Library/Application Support/Kodi/addons/plugin.video.milionar/wcs/onboarding/picks.pyú
<listcomp>zgenres.<locals>.<listcomp>   s&   ø€ ÐAÐAÐA sˆS�*�*˜S‘/”/Ð"ÐAÐAÐAó    Ú )Úwcs.genres.widgetsr   r   Úlistedr   s   @r   Úgenresr      s9   ø€ à-Ð-Ð-Ð-Ð-Ð-ØAÐAÐAÐA­g¬n¸RÑ.@Ô.@ÐAÑAÔAÐAr   )i°%  éP   )é   )i*  )ÚhorrorÚthrillerÚromanceÚhistoryÚmusicÚtvmoviec                 óÄ   — t          t          j        | |¦  «        ¦  «        }|s!|dk    rt                               | d¦  «        }t          t          |¦  «        ¦  «        S )zEThe TMDb genre ids the questionnaire asks for `key` in `media` (D35).r   r   )Útupler   ÚidsÚ
TV_NEARESTÚgetÚsorted)r   Úmediar'   s      r   Ú	genre_idsr,   %   sR   € å
•”˜C Ñ'Ô'Ñ
(Ô
(€CØð &�5˜D’=�=Ý�nŠn˜S "Ñ%Ô%ˆÝ•˜‘”ÑÔÐr   c                 óÐ   ‡— ˆfd„t           j        D ¦   «         t          d„ ‰D ¦   «         ¦  «        z   }g }|D ]-}t          || ¦  «        }|r||vr|                     |¦  «         Œ.|S )zhThe genre id groups of the chosen genres, one per distinct group, the genre section's order first (D34).c                 ó   •— g | ]}|‰v ¯|‘Œ	S r   r   )r   ÚkÚkeyss     €r   r   zstreams_of.<locals>.<listcomp>/   s   ø€ Ð8Ð8Ð8�1¨a°4¨i¨iˆQ¨i¨i¨ir   c              3   ó6   K  — | ]}|t           j        v¯|V — Œd S ©N)r   Ú
POPULARITY)r   r/   s     r   ú	<genexpr>zstreams_of.<locals>.<genexpr>/   s1   è è € ÐAqÐAqÈÐUVÕ^eÔ^pÐUpÐUpÀ!ÐUpÐUpÐUpÐUpÐAqÐAqr   )r   r3   r*   r,   Úappend)r+   r0   ÚorderÚoutr   r'   s    `    r   Ú
streams_ofr8   -   sƒ   ø€ à8Ð8Ð8Ð8�Ô*Ð8Ñ8Ô8½6ÐAqÐAqÈTÐAqÑAqÔAqÑ;qÔ;qÑq€EØ
€CØð ð ˆÝ˜˜UÑ#Ô#ˆØð 	�3˜c�>�>Ø�JŠJ�s‰OŒOˆOøØ€Jr   c                 ón   — dd                      d„ |D ¦   «         ¦  «        |t          |          t          ddœS )zIThe discover query of one page of one genre: the most voted known titles.zvote_count.descr   c              3   ó4   K  — | ]}t          |¦  «        V — Œd S r2   )Ústr)r   Úis     r   r4   zparams.<locals>.<genexpr>:   s(   è è € ÐAVÐAVÈQÅ#ÀaÁ&Ä&ÐAVÐAVÐAVÐAVÐAVÐAVr   Úfalse)Úsort_byÚwith_genresÚpagezvote_count.gteÚwith_original_languageÚinclude_adult)ÚjoinÚ	MIN_VOTESÚLANGS)r+   r'   r@   s      r   ÚparamsrF   8   sE   € à(¸¿ºÐAVÐAVÐRUÐAVÑAVÔAVÑ9VÔ9VÐ`dÝ'¨Ô.Í%Ðbiðkð kð kr   c                   ó$   — e Zd ZdZd„ Zd„ Zd„ ZdS )ÚStreamzAThe good titles of one genre, page after page of TMDb's discover.c                 óP   — ||c| _         | _        ddg c| _        | _        | _        d S )Nr   F)r+   r'   r@   ÚdoneÚqueue)Úselfr+   r'   s      r   Ú__init__zStream.__init__A   s,   € Ø$ cÐˆŒ
�D”HØ+,¨e°RÐ(ˆŒ	�4”9˜dœj˜j˜jr   c                 ól  ‡ — ‰ xj         dz  c_         t          j        d                     ‰ j        ¦  «        t          ‰ j        ‰ j        ‰ j         ¦  «        ¦  «        }|r‰ j         t          k    rd‰ _        ‰ j	         
                    ˆ fd„t          j        |‰ j        ¦  «        D ¦   «         ¦  «         d S )Né   zdiscover/{}Tc              3   óv   •K  — | ]3}|                      d ¦  «        ¯t          j        |‰j        ¦  «        V — Œ4dS )Úposter_pathN)r)   ÚFÚcardr+   )r   ÚitemrL   s     €r   r4   zStream._page.<locals>.<genexpr>J   sU   øè è € ð 6ð 6°tØ!ŸXšX mÑ4Ô4ð6�!œ&  t¤zÑ2Ô2ð 6ð 6ð 6ð 6ð 6ð 6r   )r@   r   ÚresultsÚformatr+   rF   r'   Ú	MAX_PAGESrJ   rK   ÚextendÚquality_listsÚkeep)rL   Úitemss   ` r   Ú_pagezStream._pageE   s¿   ø€ Øˆ	Œ	�Q‰ˆ	Œ	Ý”˜M×0Ò0°´Ñ<Ô<½fÀTÄZÐQUÔQYÐ[_Ô[dÑ>eÔ>eÑfÔfˆØð 	˜œ	¥YÒ.Ð.ØˆDŒIØŒ
×Òð 6ð 6ð 6ð 6½}Ô?QÐRWÐY]ÔYcÑ?dÔ?dð 6ñ 6ô 6ñ 	6ô 	6ð 	6ð 	6ð 	6r   c                 ó  — 	 | j         r\| j                              d¦  «        }t          j        | j        |d         ¦  «        }||vr|                     |¦  «         |S | j         °\| j        rdS |                      ¦   «          Œ�)zGThe next card nobody has shown yet, or None when the genre has no more.Tr   ÚidN)rK   ÚpoprR   r   r+   ÚaddrJ   r\   )rL   ÚseenrS   r   s       r   ÚtakezStream.takeM   s‡   € ð		Ø”*ð  Ø”z—~’~ aÑ(Ô(�Ý”e˜DœJ¨¨T¬
Ñ3Ô3�Ø˜d�?�?Ø—H’H˜S‘M”M�MØ�Kð ”*ð  ð Œyð Ø�tØ�JŠJ‰LŒLˆLð		r   N)Ú__name__Ú
__module__Ú__qualname__Ú__doc__rM   r\   rb   r   r   r   rH   rH   >   sG   € € € € € ØKÐKð8ð 8ð 8ð6ð 6ð 6ðð ð ð ð r   rH   c                   ó:   — e Zd ZdZd„ Zed„ ¦   «         Zd„ Zd„ ZdS )ÚPoolzeThe good titles of one media for the chosen genres: the best known title of each genre in turn (D34).c                 ó   ‡— ‰t          |¦  «        c| _        | _        g dc| _        | _        t          ¦   «         | _        t          j        ¦   «         | _	        ˆfd„t          ‰| j        ¦  «        D ¦   «         | _        d S )Nr   c                 ó0   •— g | ]}t          ‰|¦  «        ‘ŒS r   )rH   )r   r'   r+   s     €r   r   z!Pool.__init__.<locals>.<listcomp>c   s#   ø€ ÐSÐSÐS¨s�˜u cÑ*Ô*ÐSÐSÐSr   )r&   r+   r0   ÚcardsÚturnÚsetra   Ú	threadingÚLockÚlockr8   Ústreams)rL   r+   r0   s    ` r   rM   zPool.__init__^   sn   ø€ Ø %¥u¨T¡{¤{ÐˆŒ
�D”IØ " AÐˆŒ
�D”IÝ‘E”EˆŒ	Ý”NÑ$Ô$ˆŒ	ØSÐSÐSÐSµjÀÈÌ	Ñ6RÔ6RÐSÑSÔSˆŒˆˆr   c                 ó>   — t          d„ | j        D ¦   «         ¦  «        S )Nc              3   ó4   K  — | ]}|j         o|j         V — Œd S r2   )rJ   rK   )r   Ústreams     r   r4   zPool.done.<locals>.<genexpr>g   s.   è è € ÐOÐO¸�6”;Ð3 v¤|Ð#3ÐOÐOÐOÐOÐOÐOr   )Úallrq   ©rL   s    r   rJ   z	Pool.donee   s!   € åÐOÐOÀ$Ä,ÐOÑOÔOÑOÔOÐOr   c                 óÂ  — | j         5  t          | j        ¦  «        |k     r“| j        sŒ| j        | j        t          | j        ¦  «        z           }| xj        dz  c_        |                     | j        ¦  «        }|�| j                             |¦  «         t          | j        ¦  «        |k     r| j        ¯Œt          | j        ¦  «        cddd¦  «         S # 1 swxY w Y   dS )zOAt least `count` cards (fewer when TMDb has no more); returns all cards so far.rO   N)
rp   Úlenrk   rJ   rq   rl   rb   ra   r5   Úlist)rL   Úcountrt   rS   s       r   Úfillz	Pool.filli   s  € àŒYð 	$ð 	$Ý�d”j‘/”/ EÒ)Ð)°$´)Ð)Øœ d¤iµ#°d´lÑ2CÔ2CÑ&CÔD�Ø�	”	˜Q‘�	”	Ø—{’{ 4¤9Ñ-Ô-�ØÐ#Ø”J×%Ò% dÑ+Ô+Ð+õ �d”j‘/”/ EÒ)Ð)°$´)Ð)õ ˜œ
Ñ#Ô#ð	$ð 	$ð 	$ð 	$ñ 	$ô 	$ð 	$ð 	$ð 	$ð 	$ð 	$ð 	$øøøð 	$ð 	$ð 	$ð 	$ð 	$ð 	$s   ˆB?CÃCÃCc                 óL   — ddl m} |                     d„ |D ¦   «         ¦  «        S )zV{'movie:603': services} of these cards, fetched now when the cache does not know them.r   ©Ústorec                 ó.   — g | ]}|d          |d         f‘ŒS )r+   r^   r   )r   Úcs     r   r   z!Pool.services.<locals>.<listcomp>w   s%   € ÐBÐBÐB°q˜a œj¨!¨D¬'Ð2ÐBÐBÐBr   )Úwcs.servicesr~   Úensure)rL   rk   r~   s      r   ÚserviceszPool.servicest   s5   € à&Ð&Ð&Ð&Ð&Ð&Ø�|Š|ÐBÐB¸EÐBÑBÔBÑCÔCÐCr   N)	rc   rd   re   rf   rM   ÚpropertyrJ   r{   rƒ   r   r   r   rh   rh   [   sm   € € € € € ØoÐoðTð Tð Tð ðPð Pñ „XðPð	$ð 	$ð 	$ðDð Dð Dð Dð Dr   rh   c                   ó*   — e Zd ZdZd„ Zd„ Zd„ Zd„ ZdS )ÚPrefetchzœFetches the next step's cards while the household is still choosing (D13): the films and series of the genres
    chosen so far, a thread that only fetches.c                 ó0   — i | _         d | _        d | _        d S r2   )ÚpoolsÚthreadÚwantedrv   s    r   rM   zPrefetch.__init__~   s   € ØˆŒ
ØˆŒØˆŒˆˆr   c                 ó¦   — |t          t          |¦  «        ¦  «        f}|| j        vrt          ||d         ¦  «        | j        |<   | j        |         S )NrO   )r&   r*   rˆ   rh   )rL   r+   r0   r   s       r   ÚpoolzPrefetch.poolƒ   sL   € Ø•e�F 4™LœLÑ)Ô)Ð*ˆØ�d”jÐ Ð Ý" 5¨#¨a¬&Ñ1Ô1ˆDŒJ�s‰OØŒz˜#ŒÐr   c                 óâ   ‡ ‡— t          t          |¦  «        ¦  «        ‰ _        ‰ j        sdS ‰ j        Šˆ ˆfd„}t          j        |dd¬¦  «        ‰ _        ‰ j                             ¦   «          dS )zJThe genres changed: fetch the first cards of both media in the background.Nc                  óÎ   •— dD ]`} ‰j         ‰k    r d S ‰                     | ‰¦  «        }|                     |                     t          ¦  «        d t          …         ¦  «         Œad S )Nr
   )rŠ   rŒ   rƒ   r{   ÚFIRST)r+   rŒ   rL   rŠ   s     €€r   ÚworkzPrefetch.start.<locals>.work�   sm   ø€ Ø(ð 8ð 8�Ø”; &Ò(Ð(Ø�F�FØ—y’y ¨Ñ/Ô/�Ø—’˜dŸiši­Ñ.Ô.¨vµ¨vÔ6Ñ7Ô7Ð7Ð7ð	8ð 8r   zmilionar-onboarding-prefetchT)ÚtargetÚnameÚdaemon)r&   r*   rŠ   rn   ÚThreadr‰   Ústart)rL   r0   r�   rŠ   s   `  @r   r•   zPrefetch.start‰   s„   øø€ å�F 4™LœLÑ)Ô)ˆŒØŒ{ð 	ØˆFØ”ˆð	8ð 	8ð 	8ð 	8ð 	8ð 	8õ  Ô&¨dÐ9WÐ`dÐeÑeÔeˆŒØŒ×ÒÑÔÐÐÐr   c                 ó¾   — | j                              |t          t          |¦  «        ¦  «        f¦  «        }|d uo#|j        pt          |j        ¦  «        t          k    S r2   )rˆ   r)   r&   r*   rJ   rx   rk   r�   )rL   r+   r0   rŒ   s       r   ÚreadyzPrefetch.readyš   sL   € ØŒz�~Š~˜u¥e­F°4©L¬LÑ&9Ô&9Ð:Ñ;Ô;ˆØ˜4ÐÐK T¤YÐ%Jµ#°d´j±/´/ÅUÒ2JÐKr   N)rc   rd   re   rf   rM   rŒ   r•   r—   r   r   r   r†   r†   z   s_   € € € € € ð2ð 2ðð ð ð
ð ð ðð ð ð"Lð Lð Lð Lð Lr   r†   c                 ó4  — |                       d¦  «        rt          | d         ¦  «        gng }|                       d¦  «        rB|                     d                     | d         ¦  «                             dd¦  «        ¦  «         d                     |¦  «        S )z6The line under the hero's title: year, rating, genres.ÚyearÚratingu
   â˜… {:.1f}ú.ú,u     Â·  )r)   r;   r5   rV   ÚreplacerC   )rS   Úpartss     r   ÚfactsrŸ   Ÿ   s‡   € à#'§8¢8¨FÑ#3Ô#3Ð;�S��f”ÑÔÐÐ¸€EØ‡x‚x�ÑÔð LØ�Š�\×(Ò(¨¨h¬Ñ8Ô8×@Ò@ÀÀcÑJÔJÑKÔKÐKØ�=Š=˜ÑÔÐr   c                 óº   — ddl m} d}d| fd|ffD ]I\  }}|D ]A}|                     ||d         d¦  «         |                     ||d         d¦  «         |dz  }ŒBŒJ|S )	ui   The chosen titles into Moje filmy / Moje seriÃ¡ly as liked (D9): the seeds of Pro tebe. Returns how many.r   r}   r   r   r^   TÚlikerO   )Úwcs.library2r~   Úset_in_listÚset_feedback)ÚmoviesÚseriesr~   rz   r+   rk   rS   s          r   Úsaver§   §   s˜   € à"Ð"Ð"Ð"Ð"Ð"Ø€EØ! 6Ð*¨T°6¨NÐ;ð ð ‰ˆˆuØð 	ð 	ˆDØ×Ò˜e T¨$¤Z°Ñ6Ô6Ð6Ø×Ò˜u d¨4¤j°&Ñ9Ô9Ð9Ø�Q‰JˆEˆEð	ð €Lr   )!rf   rn   Ú
wcs.foryour   r   rR   Ú
wcs.genresr   Úwcs.qualityr   rY   r   r�   ÚPAGErD   rW   ÚPOSTERÚBACKDROPrC   ÚWESTERNÚHOMErE   r   r(   r,   r8   rF   ÚobjectrH   rh   r†   rŸ   r§   r   r   r   ú<module>r±      s¶  ððð ð Ð Ð Ð à )Ð )Ð )Ð )Ð )Ð )Ð )Ð )Ø Ð Ð Ð Ð Ð Ø 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5Ð 5à
€Ø	€Ø Ð%Ð%€	à€	Ø	*€Ø-€Ø�Š�” ¤Ñ+Ñ,Ô,€ðBð Bð Bð #°
ÀuÐYaÐlqØð ð  €
ðð ð ðð ð ðkð kð kðð ð ð ð ˆVñ ô ð ð:Dð Dð Dð Dð Dˆ6ñ Dô Dð Dð>"Lð "Lð "Lð "Lð "Lˆvñ "Lô "Lð "LðJ ð  ð  ð	ð 	ð 	ð 	ð 	r   