U o.aV(@sddlZddlZddlZddlZddlZddlZddlZddlZddlZddl Z ddl Z ddl Z ddl Z ddl mZddl mZdZdddZd d Zd d Zd dZddZddZddZGdddZddZddZddZdS)N)client)controlzEnigma2Tv-XtraTcCsv|r:z"td|d||d}Wqrd}YqrXn8z&td|d|d|d}Wnd}YnX|S)Nz(?i)z ([\S\s]+?)r(?i)([\S\s]+?))researchgroup)textZ from_stringZ to_stringZ excludingrrs/storage/emulated/0/Android/data/org.mmc.matrix/files/.kodi/addons/plugin.video.iptv.mmc/resources/modules/tools.py regex_from_tos0  rcCs td|d|d|}|S)Nrrr)r findall)r Z start_withZend_withr rrr regex_get_all*src CsTtjddtj|dt|dtj|dtj|dtj|}d}tt|t |}| ||d|j d ||d d | d ||d kr| ddt jttjd||dd}n||dks|dks|dkr |j d ||d d t jttjd||dd}n0|j d ||d d t jttjd||dd}|S)Nr?url=&mode=&name= &iconimage= &description=TiconthumbVideo)TitlePlottype infoLabels fanart_image IsPlayabletruerFhandleurllistitemisFolder )sysargvurllibparse quote_plusstrxbmclogxbmcguiListItemsetArtsetInfo setProperty xbmcpluginaddDirectoryItemintendOfDirectory) namer'mode iconimagefanart descriptionuoklizrrraddDir0sb         rFc  Cstjddtj|dt|dtj|dtj|dtj|} d} t|} | ||d| j d ||||| || d d | d || d dg}| ddt|df| d| j |ddt jttjd| | dd} | S)NrrrrrrTrr)rrZRatingYearDurationZCastGenrerr!r#r$z Play Trailerz@XBMC.RunPlugin(plugin://plugin.video.Enigma2Tv-Xtra/?mode=9&url=r)zMovie InformationzXBMC.Action(Info)) replaceItemsrFr%)r-r.r/r0r1r2r5r6r7r8r9appendaddContextMenuItemsr:r;r<)r>r'r?r@rArByearcastratingruntimegenrerCrDrEcmrrr addDirMetaUsX        rScCs8i}d|d<tj||ddj}|dd}|dS)NZTheWizardIsHerez User-AgentF)headersverifyasciiignorezutf-8)requestssessiongetr encodedecode)r'rTlinkrrrOPEN_URLs  r^c Cstdtjtdd}tdddddd}|rtj |d krt |D]\}}}d }|t |7}|d krT|D]*}zt tj||WqzYqzXqz|D]*}zt tj||WqYqXqqTt}|td td dS) NzCLEAR CACHE ACTIVATEDzspecial://homecachezPlease Confirmz    rucCsg}tjd}t|dkrtjd}|dd}|t|ddkrX|dt|d}|d}i}tt|D]2}i}||d}t|dkrr|d||d<qr|S) N?rr/r&=)r-r.rhreplacesplitrange)param paramstringparams cleanedparams pairsofparamsi splitparamsrrr get_paramss      rc@s6eZdZddZd ddZddZdd Zd d ZdS) TrailercCs4d|_d|_dt|j|_d|_d|_d|_dS)Nzhttp://www.youtube.comZ4QUl6YVN5QnZES3JnSU1NVmRPajZSb1pnUWhaSzRHM3MybDZXeVhnz&key=%szVhttps://www.googleapis.com/youtube/v3/search?part=snippet&type=video&maxResults=5&q=%sz/https://www.googleapis.com/youtube/v3/search?q=!http://www.youtube.com/watch?v=%s) base_linkkey_linkbase64urlsafe_b64decode search_linkyoutube_search youtube_watch)selfrrr__init__s zTrailer.__init__NcCsz|||}|dkrWdStd}|dkr8td}td}tj|||d}z|d|iWn YnX|jdd|id tj||Wn YnXdS) Nzlistitem.titlerzlistitem.labelz listitem.icon)ra iconImageZthumbnailImagerrtitler)workerr infoLabelitemr7r8playerplay)rr>r'rrrrrrrs&    z Trailer.playcCszf||jr,||}|dkr&t|WS|ds^|j|}||}|dkrXt|WStWn:|d}|j|}||}|dkrYdS|YSXdS)Nzhttp://z trailer) startswithrresolve Exceptionrrr )rr>r'queryrrrrs(        zTrailer.workercCsztjtjj|jdd}|jtj||j}t|}t |d}dd|D}|D] }| |}|dk rd|WSqdWnYdSXdS)NqritemscSsg|]}|ddqS)idvideoIdr).0rrrr sz"Trailer.search..) r/r0parse_qsrrr1rrrequestjsonloadsr)rr'rresultrrrrr s"  zTrailer.searchcCsz|dddddddd}td|}tj|dd d id }d |}tj|dd d id }t|dkrttd|rtd|}|WSYdSXdS)Nz?v=rxrwrryrdivrzunavailable-submessage)attrsrzwatch7-notification-areaz[a-zA-Z]z/plugin://plugin.video.youtube/play/?video_id=%s) r|rrparseDOMrbrhrr r )rr'rrmessageZalertrrrr s4   zTrailer.resolve)N)__name__ __module__ __qualname__rrrr rrrrrrs  rcCs*ttjtj}|d|d}|S)N)z8.8.8.8rr)socketAF_INET SOCK_DGRAMconnect getsockname)srrr getlocalip's  rcCs td}td|}t|S)Nzhttp://canyouseeme.org/z(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?))r^r r r2r )openiprrr getexternalip.s rcCsd|krd}nd|krd}nd|kr*d}n|d|kr8d}nnd |krFd }n`d |krTd }nRd |krbd}nDd|krpd}n6d|kr~d}n(d|krd}nd|krd}n d|krd}|S)N01JanuaryZ02ZFebuary03MarchZ04April05MayZ06JuneZ07JulyZ08ZAugastZ09 September10October11November12Decemberr)nummonthrrrMonthNumToName6s2r)T)r`r r-r3rrstringr/rXrjr:r5rrrrrlrrrFrSr^rurrrrrrrrrs6   %* #j