SHOW:
|
|
- or go back to the newest paste.
1 | #-*- coding: utf-8 -*- | |
2 | # https://github.com/Kodi-vStream/venom-xbmc-addons | |
3 | from resources.lib.gui.hoster import cHosterGui | |
4 | from resources.lib.gui.gui import cGui | |
5 | from resources.lib.handler.inputParameterHandler import cInputParameterHandler | |
6 | from resources.lib.handler.outputParameterHandler import cOutputParameterHandler | |
7 | from resources.lib.handler.requestHandler import cRequestHandler | |
8 | from resources.lib.config import cConfig | |
9 | from resources.lib.parser import cParser | |
10 | from resources.lib.util import cUtil,VSlog | |
11 | import re,unicodedata,urllib2,time | |
12 | ||
13 | UA = 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:55.0) Gecko/20100101 Firefox/55.0' | |
14 | headers = { 'User-Agent' : UA } | |
15 | ||
16 | SITE_IDENTIFIER = 'cinemay_com' | |
17 | SITE_NAME = 'Cinemay' | |
18 | SITE_DESC = 'Films & Séries en streaming' | |
19 | ||
20 | URL_MAIN = 'http://www.cinemay.com/' | |
21 | ||
22 | MOVIE_NEWS = (URL_MAIN , 'showMovies') | |
23 | MOVIE_MOVIE = (URL_MAIN + 'films/', 'showMovies') | |
24 | MOVIE_GENRES = (True, 'showMovieGenres') | |
25 | ||
26 | SERIE_SERIES = (URL_MAIN + 'serie/', 'showMovies') | |
27 | ||
28 | URL_SEARCH = (URL_MAIN + '?s=', 'showMovies') | |
29 | URL_SEARCH_MOVIES = (URL_MAIN + '?s=', 'showMovies') | |
30 | URL_SEARCH_SERIES = (URL_MAIN + '?s=', 'showMovies') | |
31 | FUNCTION_SEARCH = 'showMovies' | |
32 | ||
33 | def load(): | |
34 | oGui = cGui() | |
35 | ||
36 | oOutputParameterHandler = cOutputParameterHandler() | |
37 | oOutputParameterHandler.addParameter('siteUrl', 'http://venom/') | |
38 | oGui.addDir(SITE_IDENTIFIER, 'showSearch', 'Recherche', 'search.png', oOutputParameterHandler) | |
39 | ||
40 | oOutputParameterHandler = cOutputParameterHandler() | |
41 | oOutputParameterHandler.addParameter('siteUrl', MOVIE_NEWS[0]) | |
42 | oGui.addDir(SITE_IDENTIFIER, MOVIE_NEWS[1], 'Films (Derniers ajouts)', 'films_news.png', oOutputParameterHandler) | |
43 | ||
44 | oOutputParameterHandler = cOutputParameterHandler() | |
45 | oOutputParameterHandler.addParameter('siteUrl', MOVIE_MOVIE[0]) | |
46 | oGui.addDir(SITE_IDENTIFIER, MOVIE_MOVIE[1], 'Films', 'films.png', oOutputParameterHandler) | |
47 | ||
48 | oOutputParameterHandler = cOutputParameterHandler() | |
49 | oOutputParameterHandler.addParameter('siteUrl', MOVIE_GENRES[0]) | |
50 | oGui.addDir(SITE_IDENTIFIER, MOVIE_GENRES[1], 'Films (Genres)', 'films_genres.png', oOutputParameterHandler) | |
51 | ||
52 | oOutputParameterHandler = cOutputParameterHandler() | |
53 | oOutputParameterHandler.addParameter('siteUrl', SERIE_SERIES[0]) | |
54 | oGui.addDir(SITE_IDENTIFIER, SERIE_SERIES[1], 'Séries', 'series.png', oOutputParameterHandler) | |
55 | ||
56 | ||
57 | oGui.setEndOfDirectory() | |
58 | ||
59 | def showSearch(): | |
60 | oGui = cGui() | |
61 | sSearchText = oGui.showKeyBoard() | |
62 | if (sSearchText != False): | |
63 | sUrl = URL_SEARCH[0] + sSearchText | |
64 | showMovies(sUrl) | |
65 | oGui.setEndOfDirectory() | |
66 | return | |
67 | ||
68 | def showMovieGenres(): | |
69 | oGui = cGui() | |
70 | ||
71 | liste = [] | |
72 | liste.append( ['Action',URL_MAIN + 'genre/action/'] ) | |
73 | liste.append( ['Animation',URL_MAIN + 'genre/animation/'] ) | |
74 | liste.append( ['Aventure',URL_MAIN + 'genre/aventure/'] ) | |
75 | liste.append( ['Comédie',URL_MAIN + 'genre/comedie/'] ) | |
76 | liste.append( ['Crime',URL_MAIN + 'genre/crime/'] ) | |
77 | liste.append( ['Documentaire',URL_MAIN + 'genre/documentaire/'] ) | |
78 | liste.append( ['Drame',URL_MAIN + 'genre/drame/'] ) | |
79 | liste.append( ['Horreur',URL_MAIN + 'genre/horreur/'] ) | |
80 | liste.append( ['Familial',URL_MAIN + 'genre/familial/'] ) | |
81 | liste.append( ['Guerre',URL_MAIN + 'genre/guerre/'] ) | |
82 | liste.append( ['Musique',URL_MAIN + 'genre/musique/'] ) | |
83 | liste.append( ['Policier',URL_MAIN + 'genre/policier/'] ) | |
84 | liste.append( ['Romance',URL_MAIN + 'genre/romance/'] ) | |
85 | liste.append( ['Thriller',URL_MAIN + 'genre/thriller/'] ) | |
86 | liste.append( ['Science_Fiction',URL_MAIN + 'genre/science-fiction/'] ) | |
87 | ||
88 | for sTitle,sUrl in liste: | |
89 | ||
90 | oOutputParameterHandler = cOutputParameterHandler() | |
91 | oOutputParameterHandler.addParameter('siteUrl', sUrl) | |
92 | oGui.addDir(SITE_IDENTIFIER, 'showMovies', sTitle, 'films_genres.png', oOutputParameterHandler) | |
93 | ||
94 | oGui.setEndOfDirectory() | |
95 | ||
96 | def showMovies(sSearch=''): | |
97 | oGui = cGui() | |
98 | ||
99 | if sSearch: | |
100 | sUrl = sSearch | |
101 | else: | |
102 | oInputParameterHandler = cInputParameterHandler() | |
103 | sUrl = oInputParameterHandler.getValue('siteUrl') | |
104 | #VSlog(sUrl) | |
105 | oRequestHandler = cRequestHandler(sUrl) | |
106 | sHtmlContent = oRequestHandler.request() | |
107 | #VSlog(sHtmlContent) | |
108 | oParser = cParser() | |
109 | ||
110 | sPattern = '<a href="([^"]+)" data-url=".+?" class=".+?" title="(.+?)"><img.+?src="(.+?)"' | |
111 | aResult = oParser.parse(sHtmlContent, sPattern) | |
112 | ||
113 | if (aResult[0] == True): | |
114 | total = len(aResult[1]) | |
115 | dialog = cConfig().createDialog(SITE_NAME) | |
116 | for aEntry in aResult[1]: | |
117 | cConfig().updateDialog(dialog, total) | |
118 | if dialog.iscanceled(): | |
119 | break | |
120 | ||
121 | #encode/decode pour affichage des accents | |
122 | sTitle = unicode(aEntry[1], 'utf-8') | |
123 | sTitle = unicodedata.normalize('NFD', sTitle).encode('ascii', 'ignore').decode("unicode_escape") | |
124 | sTitle = sTitle.encode("latin-1") | |
125 | ||
126 | sThumb = aEntry[2] | |
127 | sUrl = aEntry[0] | |
128 | ||
129 | oOutputParameterHandler = cOutputParameterHandler() | |
130 | oOutputParameterHandler.addParameter('siteUrl',sUrl) | |
131 | oOutputParameterHandler.addParameter('sMovieTitle',sTitle) | |
132 | oOutputParameterHandler.addParameter('sThumbnail',sThumb) | |
133 | ||
134 | if 'series/' in sUrl: | |
135 | oGui.addTV(SITE_IDENTIFIER,'showSeries',sTitle,'',sThumb,'',oOutputParameterHandler) | |
136 | else: | |
137 | oGui.addMovie(SITE_IDENTIFIER,'showLinks',sTitle,'',sThumb,'',oOutputParameterHandler) | |
138 | ||
139 | cConfig().finishDialog(dialog) | |
140 | sNextPage = __checkForNextPage(sHtmlContent) | |
141 | if (sNextPage != False): | |
142 | oOutputParameterHandler = cOutputParameterHandler() | |
143 | oOutputParameterHandler.addParameter('siteUrl', sNextPage) | |
144 | oGui.addNext(SITE_IDENTIFIER, 'showMovies', '[COLOR teal]Next >>>[/COLOR]', oOutputParameterHandler) | |
145 | ||
146 | if not sSearch: | |
147 | oGui.setEndOfDirectory() | |
148 | ||
149 | def __checkForNextPage(sHtmlContent): | |
150 | sPattern = '<a class="nextpostslink" rel="next" href="(.+?)">' | |
151 | oParser = cParser() | |
152 | aResult = oParser.parse(sHtmlContent, sPattern) | |
153 | ||
154 | if (aResult[0] == True): | |
155 | return aResult[1][0] | |
156 | ||
157 | return False | |
158 | ||
159 | def showSeries(): | |
160 | oGui = cGui() | |
161 | oInputParameterHandler = cInputParameterHandler() | |
162 | sUrl = oInputParameterHandler.getValue('siteUrl') | |
163 | sMovieTitle = oInputParameterHandler.getValue('sMovieTitle') | |
164 | sThumbnail = oInputParameterHandler.getValue('sThumbnail') | |
165 | ||
166 | oRequestHandler = cRequestHandler(sUrl) | |
167 | sHtmlContent = oRequestHandler.request() | |
168 | ||
169 | sPattern = '<span class="title">(.+?)<i>|<div class="numerando">(.+?)<\/div>.+?<a href="(.+?)">' | |
170 | ||
171 | oParser = cParser() | |
172 | aResult = oParser.parse(sHtmlContent, sPattern) | |
173 | ||
174 | if (aResult[0] == True): | |
175 | total = len(aResult[1]) | |
176 | dialog = cConfig().createDialog(SITE_NAME) | |
177 | for aEntry in aResult[1]: | |
178 | cConfig().updateDialog(dialog, total) | |
179 | if dialog.iscanceled(): | |
180 | break | |
181 | ||
182 | if aEntry[0]: | |
183 | sSaison = aEntry[0] | |
184 | oGui.addText(SITE_IDENTIFIER,'[COLOR red]'+sSaison+'[/COLOR]') | |
185 | else: | |
186 | sUrl = aEntry[2] | |
187 | sTitle = aEntry[1].replace(' x ','').replace(' ','')+' '+sMovieTitle | |
188 | ||
189 | oOutputParameterHandler = cOutputParameterHandler() | |
190 | oOutputParameterHandler.addParameter('siteUrl',sUrl) | |
191 | oOutputParameterHandler.addParameter('sMovieTitle',sTitle) | |
192 | oOutputParameterHandler.addParameter('sThumbnail',sThumbnail) | |
193 | oGui.addTV(SITE_IDENTIFIER,'showHosters',sTitle,'',sThumbnail,'',oOutputParameterHandler) | |
194 | ||
195 | cConfig().finishDialog(dialog) | |
196 | ||
197 | oGui.setEndOfDirectory() | |
198 | ||
199 | def showLinks(): | |
200 | oGui = cGui() | |
201 | oInputParameterHandler = cInputParameterHandler() | |
202 | sRefUrl = oInputParameterHandler.getValue('siteUrl') | |
203 | sMovieTitle = oInputParameterHandler.getValue('sMovieTitle') | |
204 | sThumbnail = oInputParameterHandler.getValue('sThumbnail') | |
205 | ||
206 | oParser = cParser() | |
207 | ||
208 | oRequestHandler = cRequestHandler(sRefUrl) | |
209 | sHtmlContent = oRequestHandler.request() | |
210 | ||
211 | try: | |
212 | sCom = '' | |
213 | sPattern = '<p><p>(.+?)<\/p>' | |
214 | aResult = oParser.parse(sHtmlContent, sPattern) | |
215 | if aResult[0]: | |
216 | sCom = aResult[1][0] | |
217 | except: | |
218 | pass | |
219 | ||
220 | sPattern = 'var movie.+?id.+?"(.+?)"' | |
221 | aResult = oParser.parse(sHtmlContent, sPattern) | |
222 | if (aResult[0] == True): | |
223 | MovieUrl = URL_MAIN+'playery/?id='+aResult[1][0] | |
224 | ||
225 | req = urllib2.Request(MovieUrl,None,headers) | |
226 | req.add_header('Referer', sRefUrl) | |
227 | response = urllib2.urlopen(req) | |
228 | head = response.headers | |
229 | sHtmlContent = response.read() | |
230 | response.close() | |
231 | ||
232 | cookies = getcookie(head) | |
233 | ||
234 | sPattern = '<input type="hidden" name="videov" id="videov" value="(.+?)">.+?<\/b>(.+?)<span class="dt_flag">.+?\/flags\/(.+?)\.' | |
235 | aResult = oParser.parse(sHtmlContent, sPattern) | |
236 | if (aResult[0] == True): | |
237 | for aEntry in aResult[1]: | |
238 | ||
239 | sHoster = aEntry[1].lower().replace(' ','') | |
240 | # sQual = aEntry[2].replace(' ','') | |
241 | sLang = aEntry[2].upper() | |
242 | ||
243 | sTitle = ('%s [%s] (%s)') % (sMovieTitle,sLang,sHoster) | |
244 | ||
245 | sUrl = URL_MAIN[:-1]+aEntry[0] | |
246 | ||
247 | oOutputParameterHandler = cOutputParameterHandler() | |
248 | oOutputParameterHandler.addParameter('siteUrl', sUrl) | |
249 | oOutputParameterHandler.addParameter('sMovieTitle', sMovieTitle) | |
250 | oOutputParameterHandler.addParameter('sThumbnail', sThumbnail) | |
251 | oOutputParameterHandler.addParameter('sRefUrl', sRefUrl) | |
252 | oOutputParameterHandler.addParameter('cookies', cookies) | |
253 | oGui.addMovie(SITE_IDENTIFIER,'showHosters',sTitle,'',sThumbnail,sCom,oOutputParameterHandler) | |
254 | ||
255 | oGui.setEndOfDirectory() | |
256 | ||
257 | def showHosters(): | |
258 | oGui = cGui() | |
259 | oInputParameterHandler = cInputParameterHandler() | |
260 | sUrl = oInputParameterHandler.getValue('siteUrl') | |
261 | sMovieTitle = oInputParameterHandler.getValue('sMovieTitle') | |
262 | sThumbnail = oInputParameterHandler.getValue('sThumbnail') | |
263 | sRefUrl = oInputParameterHandler.getValue('sRefUrl') | |
264 | sCookie = oInputParameterHandler.getValue('cookies') | |
265 | ||
266 | #validation | |
267 | req = urllib2.Request(URL_MAIN+'image/logo.png',None,headers) | |
268 | req.add_header('Referer', sRefUrl) | |
269 | req.add_header('Cookie',sCookie) | |
270 | response = urllib2.urlopen(req) | |
271 | response.close() | |
272 | ||
273 | #final | |
274 | req = urllib2.Request(sUrl,None,headers) | |
275 | req.add_header('Referer', sRefUrl) | |
276 | req.add_header('Cookie',sCookie) | |
277 | response = urllib2.urlopen(req) | |
278 | sHtmlContent = response.read() | |
279 | response.close() | |
280 | ||
281 | sPattern = '<script type=\"text\/javascript\">;(.+?)<\/script>' | |
282 | oParser = cParser() | |
283 | aResult = oParser.parse(sHtmlContent, sPattern) | |
284 | if (aResult[0] == False): | |
285 | oGui.setEndOfDirectory() | |
286 | return | |
287 | ||
288 | if (aResult[0] == True): | |
289 | jscode = aResult[1][0] | |
290 | maxretries = 5 | |
291 | while 'url=' not in jscode: | |
292 | sPattern = "join\(\'\'\)\;\}\('(.+?)','(.+?)','(.+?)','(.+?)'\)\)" | |
293 | args = re.findall(sPattern,jscode,re.DOTALL) | |
294 | jscode = decode_js(args[0][0],args[0][1],args[0][2],args[0][3]) | |
295 | maxretries = maxretries -1 | |
296 | ||
297 | sPattern='url=([^"]+)\"' | |
298 | oParser = cParser() | |
299 | aResult = oParser.parse(jscode, sPattern) | |
300 | if (aResult[0] == True): | |
301 | sHosterUrl = aResult[1][0] | |
302 | oHoster = cHosterGui().checkHoster(sHosterUrl) | |
303 | sDisplayTitle = cUtil().DecoTitle(sMovieTitle) | |
304 | if (oHoster != False): | |
305 | oHoster.setDisplayName(sDisplayTitle) | |
306 | oHoster.setFileName(sMovieTitle) | |
307 | cHosterGui().showHoster(oGui, oHoster, sHosterUrl, sThumbnail) | |
308 | ||
309 | oGui.setEndOfDirectory() | |
310 | ||
311 | def getcookie(head): | |
312 | #get cookie | |
313 | cookies = '' | |
314 | if 'Set-Cookie' in head: | |
315 | oParser = cParser() | |
316 | sPattern = '(?:^|,) *([^;,]+?)=([^;,\/]+?);' | |
317 | aResult = oParser.parse(str(head['Set-Cookie']), sPattern) | |
318 | if (aResult[0] == True): | |
319 | for cook in aResult[1]: | |
320 | cookies = cookies + cook[0] + '=' + cook[1]+ ';' | |
321 | return cookies | |
322 | ||
323 | #author @NizarAlaoui | |
324 | def decode_js(k, i, s, e): | |
325 | varinc = 0 | |
326 | incerement2 = 0 | |
327 | finalincr = 0 | |
328 | firsttab = [] | |
329 | secondtab = [] | |
330 | while True : | |
331 | if varinc < 5: | |
332 | secondtab.append(k[varinc]); | |
333 | elif varinc < len(k): | |
334 | firsttab.append(k[varinc]); | |
335 | varinc=varinc+1 | |
336 | if incerement2 < 5: | |
337 | secondtab.append(i[incerement2]); | |
338 | elif incerement2 < len(i): | |
339 | firsttab.append(i[incerement2]); | |
340 | incerement2=incerement2+1 | |
341 | if finalincr < 5: | |
342 | secondtab.append(s[finalincr]); | |
343 | elif finalincr < len(s): | |
344 | firsttab.append(s[finalincr]); | |
345 | finalincr=finalincr+1 | |
346 | if (len(k) + len(i) + len(s) + len(e)) == (len(firsttab) + len(secondtab) + len(e)) : | |
347 | break; | |
348 | ||
349 | firststr = ''.join(firsttab) | |
350 | secondstr = ''.join(secondtab) | |
351 | incerement2 = 0 | |
352 | finaltab = [] | |
353 | for varinc in range(0, len(firsttab), 2): | |
354 | localvar = -1 | |
355 | if ord(secondstr[incerement2]) % 2: | |
356 | localvar = 1 | |
357 | finaltab.append(chr(int(firststr[varinc:varinc+2], base=36) - localvar)) | |
358 | incerement2=incerement2+1 | |
359 | if incerement2 >= len(secondtab): | |
360 | incerement2 = 0 | |
361 | ||
362 | return ''.join(finaltab) |