[ff9f0d]: plugin.video.pelisalacarta / channels / discoverymx.py  Maximize  Restore  History

Download this file

410 lines (333 with data), 16.3 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
# -*- coding: iso-8859-1 -*-
#------------------------------------------------------------
# pelisalacarta - XBMC Plugin
# Canal para discoverymx
# http://blog.tvalacarta.info/plugin-xbmc/pelisalacarta/
#------------------------------------------------------------
import urlparse,urllib2,urllib,re
import os
import sys
import xbmc
import xbmcgui
import xbmcplugin
import scrapertools
import megavideo
import servertools
import binascii
import xbmctools
import youtube
import config
import logger
CHANNELNAME = "discoverymx"
# Esto permite su ejecución en modo emulado
try:
pluginhandle = int( sys.argv[ 1 ] )
except:
pluginhandle = ""
# Traza el inicio del canal
logger.info("[discoverymx.py] init")
DEBUG = True
def mainlist(params,url,category):
logger.info("[discoverymx.py] mainlist")
# Ańade al listado de XBMC
xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , "Documentales - Novedades" ,"http://discoverymx.wordpress.com/","","")
xbmctools.addnewfolder( CHANNELNAME , "DocuCat" , category , "Documentales - Lista por categorías" ,"http://discoverymx.wordpress.com/","","")
xbmctools.addnewfolder( CHANNELNAME , "DocuSeries" , category , "Documentales - Series Disponibles" ,"http://discoverymx.wordpress.com/","","")
xbmctools.addnewfolder( CHANNELNAME , "DocuTag" , category , "Documentales - Tag" ,"http://discoverymx.wordpress.com/","","")
xbmctools.addnewfolder( CHANNELNAME , "DocuARCHIVO", category , "Documentales - Archivo" ,"http://discoverymx.wordpress.com/","","")
xbmctools.addnewfolder( CHANNELNAME , "search" , category , "Buscar" ,"","","")
# Propiedades
xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def search(params,url,category):
logger.info("[discoverymx.py] search")
keyboard = xbmc.Keyboard('')
keyboard.doModal()
if (keyboard.isConfirmed()):
tecleado = keyboard.getText()
if len(tecleado)>0:
#convert to HTML
tecleado = tecleado.replace(" ", "+")
searchUrl = "http://discoverymx.wordpress.com/index.php?s="+tecleado
SearchResult(params,searchUrl,category)
def SearchResult(params,url,category):
logger.info("[discoverymx.py] SearchResult")
# Descarga la página
data = scrapertools.cachePage(url)
# Extrae las entradas (carpetas)
patronvideos = '<p class="entry-title"><[^>]+>[^<]+</span><a href="([^"]+)"[^>]+>([^<]+)</a></p>'
matches = re.compile(patronvideos,re.DOTALL).findall(data)
scrapertools.printMatches(matches)
for match in matches:
# Atributos
scrapedurl = match[0]
scrapedtitle =match[1]
scrapedtitle = scrapedtitle.replace("&#8211;","-")
scrapedtitle = scrapedtitle.replace("&nbsp;"," ")
scrapedthumbnail = ""
scrapedplot = ""
if (DEBUG): logger.info("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")
# Ańade al listado de XBMC
xbmctools.addnewfolder( CHANNELNAME , "detail" , category , scrapedtitle , scrapedurl , scrapedthumbnail, scrapedplot )
# Propiedades
xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def performsearch(texto):
logger.info("[discoverymx.py] performsearch")
url = "http://discoverymx.wordpress.com/index.php?s="+texto
# Descarga la página
data = scrapertools.cachePage(url)
# Extrae las entradas (carpetas)
patronvideos = '<p class="entry-title"><[^>]+>[^<]+</span><a href="([^"]+)"[^>]+>([^<]+)</a></p>'
matches = re.compile(patronvideos,re.DOTALL).findall(data)
scrapertools.printMatches(matches)
resultados = []
for match in matches:
scrapedtitle = match[1]
scrapedtitle = scrapedtitle.replace("&#8211;","-")
scrapedtitle = scrapedtitle.replace("&nbsp;"," ")
scrapedurl = match[0]
scrapedthumbnail = ""
scrapedplot = ""
if (DEBUG): logger.info("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")
# Ańade al listado de XBMC
resultados.append( [CHANNELNAME , "detail" , "buscador" , scrapedtitle , scrapedurl , scrapedthumbnail, scrapedplot ] )
return resultados
def DocuSeries(params,url,category):
logger.info("[discoverymx.py] DocuSeries")
# Descarga la página
data = scrapertools.cachePage(url)
# Extrae las entradas (carpetas)
patronvideos = '<a href="([^"]+)" target="_blank"><img src="([^"]+)"></a><br>'
matches = re.compile(patronvideos,re.DOTALL).findall(data)
scrapertools.printMatches(matches)
for match in matches:
# Atributos
scrapedurl = match[0]
mobj = re.search(r"http://discoverymx.wordpress.com/tag/([^/]+)/", scrapedurl)
scrapedtitle = mobj.group(1)
scrapedtitle = scrapedtitle.replace("-"," ")
scrapedthumbnail = match[1]
scrapedplot = ""
if (DEBUG): logger.info("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")
# Ańade al listado de XBMC
xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , scrapedtitle , scrapedurl , scrapedthumbnail, scrapedplot )
# Propiedades
xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def DocuTag(params,url,category):
logger.info("[discoverymx.py] DocuSeries")
# Descarga la página
data = scrapertools.cachePage(url)
# Extrae las entradas (carpetas)
patronvideos = "<a href='([^']+)' class='tag-link-[^']+' title='[^']+' style='[^']+'>([^<]+)</a>"
matches = re.compile(patronvideos,re.DOTALL).findall(data)
scrapertools.printMatches(matches)
for match in matches:
# Atributos
scrapedurl = match[0]
scrapedtitle = match[1]
scrapedthumbnail = ""
scrapedplot = ""
if (DEBUG): logger.info("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")
# Ańade al listado de XBMC
xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , scrapedtitle , scrapedurl , scrapedthumbnail, scrapedplot )
# Propiedades
xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def DocuARCHIVO(params,url,category):
logger.info("[discoverymx.py] DocuSeries")
# Descarga la página
data = scrapertools.cachePage(url)
# Extrae las entradas (carpetas)
patronvideos = "<li><a href='([^']+)' title='[^']+'>([^<]+)</a></li>"
matches = re.compile(patronvideos,re.DOTALL).findall(data)
scrapertools.printMatches(matches)
for match in matches:
# Atributos
scrapedurl = match[0]
scrapedtitle = match[1]
scrapedthumbnail = ""
scrapedplot = ""
if (DEBUG): logger.info("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")
# Ańade al listado de XBMC
xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , scrapedtitle , scrapedurl , scrapedthumbnail, scrapedplot )
# Propiedades
xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def DocuCat(params,url,category):
logger.info("[discoverymx.py] peliscat")
# Descarga la página
data = scrapertools.cachePage(url)
# Extrae las entradas (carpetas)
patronvideos = '<li class="cat-item cat-item[^"]+"><a href="([^"]+)" title="[^"]+">([^<]+)</a>'
matches = re.compile(patronvideos,re.DOTALL).findall(data)
scrapertools.printMatches(matches)
for match in matches:
# Atributos
scrapedtitle = match[1]
scrapedurl = match[0]
scrapedthumbnail = ""
scrapedplot = ""
if (DEBUG): logger.info("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")
# Ańade al listado de XBMC
xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , scrapedtitle , scrapedurl , scrapedthumbnail, scrapedplot )
# Propiedades
xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def listvideos(params,url,category):
logger.info("[discoverymx.py] listvideos")
scrapedthumbnail = ""
scrapedplot = ""
# Descarga la página
data = scrapertools.cachePage(url)
#logger.info(data)
# Extrae las entradas (carpetas)
patronvideos = '<h3 class="entry-title"><a href="([^"]+)"[^>]+>([^<]+)</a></h3>.*?'
patronvideos += '<div class="entry-content">(.*?)</div> <!-- #post-ID -->'
matches = re.compile(patronvideos,re.DOTALL).findall(data)
scrapertools.printMatches(matches)
for match in matches:
scrapedtitle = match[1]
scrapedtitle = re.sub("<[^>]+>"," ",scrapedtitle)
scrapedtitle = scrapedtitle.replace("&#8211;","-")
scrapedtitle = scrapedtitle.replace("&nbsp;"," ")
scrapedtitle = scrapedtitle.replace("&amp;;","&")
scrapedurl = match[0]
regexp = re.compile(r'src="([^"]+)"')
matchthumb = regexp.search(match[2])
if matchthumb is not None:
scrapedthumbnail = matchthumb.group(1)
scrapedplot = match[2]
scrapedplot = re.sub("<[^>]+>"," ",scrapedplot)
scrapedplot = scrapedplot.replace("&#215;","*")
scrapedplot = scrapedplot.replace("&amp;","&")
scrapedplot = scrapedplot.replace("&#8211;","-")
scrapedplot = scrapedplot.replace("\n","")
scrapedplot = scrapedplot.replace("\t","")
scrapedplot = scrapedplot.replace("\:\:","")
scrapedplot = scrapedplot.replace("…","")
scrapedplot = scrapedplot.replace("Uploading","")
scrapedplot = scrapedplot.replace("DepositFiles","")
scrapedplot = scrapedplot.replace("HotFile","")
#scrapedplot = scrapedplot.replace("…","")
if (DEBUG): logger.info("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")
# Ańade al listado de XBMC
xbmctools.addnewfolder( CHANNELNAME , "detail" , category , scrapedtitle , scrapedurl , scrapedthumbnail, scrapedplot )
# Extrae la marca de siguiente página
patronvideos = '<div class="left"><a href="([^"]+)" ><span>&laquo;</span> Entradas Anteriores</a></div>'
matches = re.compile(patronvideos,re.DOTALL).findall(data)
scrapertools.printMatches(matches)
if len(matches)>0:
scrapedtitle = "Página siguiente"
scrapedurl = urlparse.urljoin(url,matches[0])
scrapedthumbnail = ""
scrapedplot = ""
xbmctools.addnewfolder( CHANNELNAME , "listvideos" , category , scrapedtitle , scrapedurl , scrapedthumbnail, scrapedplot )
# Propiedades
xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def detail(params,url,category):
logger.info("[discoverymx.py] detail")
title = urllib.unquote_plus( params.get("title") )
thumbnail = urllib.unquote_plus( params.get("thumbnail") )
plot = urllib.unquote_plus( params.get("plot") )
# Descarga la página
data = scrapertools.cachePage(url)
#logger.info(data)
# ------------------------------------------------------------------------------------
# Busca los enlaces a videos no megavideo (youtube)
# ------------------------------------------------------------------------------------
patronyoutube = '<a href="http\:\/\/www.youtube.com/watch\?v=[^=]+=PlayList\&amp\;p=(.+?)&[^"]+"'
matchyoutube = re.compile(patronyoutube,re.DOTALL).findall(data)
if len(matchyoutube)>0:
for match in matchyoutube:
listyoutubeurl = 'http://www.youtube.com/view_play_list?p='+match
data1 = scrapertools.cachePage(listyoutubeurl)
newpatronyoutube = '<a href="(.*?)".*?<img src="(.*?)".*?alt="([^"]+)"'
matchnewyoutube = re.compile(newpatronyoutube,re.DOTALL).findall(data1)
if len(matchnewyoutube)>0:
for match2 in matchnewyoutube:
scrapedthumbnail = match2[1]
scrapedtitle = match2[2]
scrapedurl = match2[0]
if (DEBUG): logger.info("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")
xbmctools.addnewvideo( CHANNELNAME , "youtubeplay" , category , "Directo" , scrapedtitle +" - "+"(youtube) ", scrapedurl , scrapedthumbnail , plot )
logger.info(" lista de links encontrados U "+str(len(matchnewyoutube)))
#-------------------------------------------------------------------------------
#<a href="http://www.youtube.com/watch?v=je-692ngMY0" target="_blank">parte 1</a>
patronyoutube = '<a href="(http://www.youtube.com/watch\?v\=[^"]+)".*?>(.*?)</a>'
matchyoutube = re.compile(patronyoutube,re.DOTALL).findall(data)
if len(matchyoutube)>0:
for match in matchyoutube:
if "PlayList" not in match[0]:
scrapedtitle = match[1]
scrapedtitle = re.sub("<[^>]+>"," ",scrapedtitle)
scrapedurl = match[0]
if (DEBUG): logger.info("title=["+scrapedtitle+"], url=["+scrapedurl+"], thumbnail=["+scrapedthumbnail+"]")
xbmctools.addnewvideo( CHANNELNAME , "youtubeplay" , category , "Directo" , scrapedtitle +" - "+"(youtube) ", scrapedurl , thumbnail , plot )
else:
patronyoutube = "<param name='movie' value='(http://www.youtube.com/v/[^']+)'"
matchyoutube = re.compile(patronyoutube,re.DOTALL).findall(data)
parte = 0
for match in matchyoutube:
parte = parte + 1
scrapedurl = match
scrapedtitle = title
scrapedthumbnail = thumbnail
re.compile(patronyoutube,re.DOTALL).findall(data)
xbmctools.addnewvideo( CHANNELNAME , "youtubeplay" , category , "Directo" , scrapedtitle +" - "+str(parte)+" (youtube) ", scrapedurl , scrapedthumbnail , plot )
# ------------------------------------------------------------------------------------
# Busca los enlaces a los videos
# ------------------------------------------------------------------------------------
listavideos = servertools.findvideos(data)
for video in listavideos:
videotitle = video[0]
url = video[1]
server = video[2]
xbmctools.addnewvideo( CHANNELNAME , "play" , category , server , title.strip() + " - " + videotitle , url , thumbnail , plot )
# ------------------------------------------------------------------------------------
'''
patronvideos = '(http://www.zshare.net/download/[^"]+)"'
matches = re.compile(patronvideos,re.DOTALL).findall(data)
for match in matches:
import zshare
scrapedurl = zshare.geturl(match).replace(" ","%20")
scrapedtitle = title
re.compile(patronyoutube,re.DOTALL).findall(data)
xbmctools.addnewvideo( CHANNELNAME , "play" , category , "Directo" , scrapedtitle +" - "+"(Zshare) ", scrapedurl , thumbnail , plot )
'''
# Label (top-right)...
xbmcplugin.setPluginCategory( handle=pluginhandle, category=category )
# Disable sorting...
xbmcplugin.addSortMethod( handle=pluginhandle, sortMethod=xbmcplugin.SORT_METHOD_NONE )
# End of directory...
xbmcplugin.endOfDirectory( handle=pluginhandle, succeeded=True )
def play(params,url,category):
logger.info("[discoverymx.py] play")
title = unicode( xbmc.getInfoLabel( "ListItem.Title" ), "utf-8" )
thumbnail = urllib.unquote_plus( params.get("thumbnail") )
plot = unicode( xbmc.getInfoLabel( "ListItem.Plot" ), "utf-8" )
server = params["server"]
xbmctools.playvideo(CHANNELNAME,server,url,category,title,thumbnail,plot)
def youtubeplay(params,url,category):
logger.info("[dospuntocerovision.py] youtubeplay")
if "www.youtube" not in url:
url = 'http://www.youtube.com'+url
title = urllib.unquote_plus( params.get("title") )
thumbnail = urllib.unquote_plus( params.get("thumbnail") )
plot = "Ver Video"
server = "Directo"
id = youtube.Extract_id(url)
videourl = youtube.geturl(id)
if len(videourl)>0:
logger.info("link directo de youtube : "+videourl)
xbmctools.playvideo("Trailer",server,videourl,category,title,thumbnail,plot)
return

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks