/
itafilmtv.py
278 lines (198 loc) · 10.6 KB
/
itafilmtv.py
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
# -*- coding: utf-8 -*-
#------------------------------------------------------------
# pelisalacarta - XBMC Plugin
# Canal para itafilmtv
# http://blog.tvalacarta.info/plugin-xbmc/pelisalacarta/
#------------------------------------------------------------
import urlparse,urllib2,urllib,re
import os, sys
from core import scrapertools
from core import logger
from core import config
from core.item import Item
from servers import servertools
__channel__ = "itafilmtv"
__category__ = "F,S"
__type__ = "generic"
__title__ = "ITA Film TV"
__language__ = "IT"
host = "http://www.itafilm.tv"
headers = [
['Host','www.itafilm.tv'],
['User-Agent','Mozilla/5.0 (Windows NT 6.1; WOW64; rv:39.0) Gecko/20100101 Firefox/39.0'],
['Accept-Encoding','gzip, deflate'],
['Cookie','_ddn_intercept_2_=b33473ad0b70b320a9f7546e213a396a']
]
def isGeneric():
return True
def mainlist( item ):
logger.info( "[itafilmtv.py] mainlist" )
itemlist = []
itemlist.append( Item( channel=__channel__, action="fichas", title="[COLOR azure]Novità[/COLOR]", url=host, thumbnail="http://orig03.deviantart.net/6889/f/2014/079/7/b/movies_and_popcorn_folder_icon_by_matheusgrilo-d7ay4tw.png" ) )
itemlist.append( Item( channel=__channel__, action="genere", title="[COLOR azure]Film Per Genere[/COLOR]", url=host, thumbnail="http://xbmc-repo-ackbarr.googlecode.com/svn/trunk/dev/skin.cirrus%20extended%20v2/extras/moviegenres/All%20Movies%20by%20Genre.png" ) )
itemlist.append( Item( channel=__channel__, action="nazione", title="[COLOR azure]Film Per Nazione[/COLOR]", url=host, thumbnail="http://i.imgur.com/RCkZdTz.png" ) )
itemlist.append( Item( channel=__channel__, action="anno", title="[COLOR azure]Film Per Anno[/COLOR]", url=host, thumbnail="http://xbmc-repo-ackbarr.googlecode.com/svn/trunk/dev/skin.cirrus%20extended%20v2/extras/moviegenres/Movie%20Year.png" ) )
itemlist.append( Item( channel=__channel__, action="fichas", title="[COLOR azure]Contenuti Erotici[/COLOR]", url="http://www.itafilm.tv/film-erotici-streaming/", thumbnail="http://orig08.deviantart.net/8008/f/2013/080/9/4/movies_by_musicopath-d5ysmxe.png" ) )
itemlist.append( Item(channel=__channel__, action="search", title="[COLOR yellow]Cerca Film...[/COLOR]", url=host, thumbnail="http://dc467.4shared.com/img/fEbJqOum/s7/13feaf0c8c0/Search"))
itemlist.append( Item( channel=__channel__, action="serietv", title="[COLOR azure]Serie TV[/COLOR]", url=host + "/telefilm-serie-tv-streaming/", thumbnail="http://xbmc-repo-ackbarr.googlecode.com/svn/trunk/dev/skin.cirrus%20extended%20v2/extras/moviegenres/New%20TV%20Shows.png") )
itemlist.append( Item(channel=__channel__, action="search", title="[COLOR orange]Cerca Serie...[/COLOR]", url=host, extra="serie", thumbnail="http://dc467.4shared.com/img/fEbJqOum/s7/13feaf0c8c0/Search"))
return itemlist
## Al llamarse "search" la función, el launcher pide un texto a buscar y lo añade como parámetro
def search( item, texto ):
logger.info( "[itafilmtv.py] " + item.url + " search " + texto )
item.url+= "/?do=search&subaction=search&story=" + texto
try:
if item.extra == "serie":
item.url+= "/?do=search&subaction=search&story=" + texto
return serietv(item)
else:
return fichas( item )
## Se captura la excepción, para no interrumpir al buscador global si un canal falla
except:
import sys
for line in sys.exc_info():
logger.error( "%s" % line )
return []
def fichas( item ):
logger.info( "[itafilmtv.py] fichas" )
itemlist = []
## Descarga la página
data = scrapertools.cache_page( item.url, headers=headers )
action = "findvideos"
## Extrae las datos
patron = '<div class="main-news">.*?'
patron+= '<div class="main-news-image"[^<]+'
patron += '<a href="([^"]+)">'
patron += '<img src="([^"]+)" '
patron += 'alt="([^"]+)"'
matches = re.compile( patron, re.DOTALL ).findall( data )
for scrapedurl, scrapedthumbnail, scrapedtitle in matches:
scrapedtitle = scrapertools.decodeHtmlentities( scrapedtitle )
itemlist.append( Item( channel=__channel__, action=action, title=scrapedtitle, url=scrapedurl, thumbnail=urlparse.urljoin( host, scrapedthumbnail ), fulltitle=scrapedtitle, show=scrapedtitle ) )
## Paginación
next_page = scrapertools.find_single_match( data, '<span>\d+</span> <a href="([^"]+)">' )
if next_page != "":
itemlist.append( Item( channel=__channel__, action="fichas" , title="[COLOR orange]Successivo >>[/COLOR]" , url=next_page, thumbnail="http://2.bp.blogspot.com/-fE9tzwmjaeQ/UcM2apxDtjI/AAAAAAAAeeg/WKSGM2TADLM/s1600/pager+old.png") )
return itemlist
def serietv( item ):
logger.info( "[itafilmtv.py] fichas" )
itemlist = []
## Descarga la página
data = scrapertools.cache_page( item.url, headers=headers )
action = "episodios"
## Extrae las datos
patron = '<div class="main-news">.*?'
patron+= '<div class="main-news-image"[^<]+'
patron += '<a href="([^"]+)">'
patron += '<img src="([^"]+)" '
patron += 'alt="([^"]+)"'
matches = re.compile( patron, re.DOTALL ).findall( data )
for scrapedurl, scrapedthumbnail, scrapedtitle in matches:
scrapedtitle = scrapertools.decodeHtmlentities( scrapedtitle )
itemlist.append( Item( channel=__channel__, action=action, title=scrapedtitle, url=scrapedurl, thumbnail=urlparse.urljoin( host, scrapedthumbnail ), fulltitle=scrapedtitle, show=scrapedtitle ) )
## Paginación
next_page = scrapertools.find_single_match( data, '<span>\d+</span> <a href="([^"]+)">' )
if next_page != "":
itemlist.append( Item( channel=__channel__, action="serietv" , title="[COLOR orange]Successivo >>[/COLOR]" , url=next_page ) )
return itemlist
def genere(item):
logger.info("[itafilmtv.py] genere")
itemlist = []
data = scrapertools.cachePage(item.url, headers=headers )
logger.info("data="+data)
data = scrapertools.find_single_match(data,'<div class="menu2">(.*?)<div class="left-wrap">')
logger.info("data="+data)
patron = '<a href="(.*?)">(.*?)</a>'
matches = re.compile(patron,re.DOTALL).findall(data)
scrapertools.printMatches(matches)
for scrapedurl,scrapedtitle in matches:
itemlist.append( Item(channel=__channel__, action="fichas", title="[COLOR azure]"+scrapedtitle+"[/COLOR]", url=host+scrapedurl, folder=True))
return itemlist
def nazione(item):
logger.info("[itafilmtv.py] genere")
itemlist = []
data = scrapertools.cachePage(item.url, headers=headers )
logger.info("data="+data)
data = scrapertools.find_single_match(data,'<div class="menu-block-content">(.*?)<div style="clear: both;"></div>')
logger.info("data="+data)
patron = '<a href="(.*?)">(.*?)</a>'
matches = re.compile(patron,re.DOTALL).findall(data)
scrapertools.printMatches(matches)
for scrapedurl,scrapedtitle in matches:
itemlist.append( Item(channel=__channel__, action="fichas", title="[COLOR azure]"+scrapedtitle+"[/COLOR]", url=host+scrapedurl, folder=True))
return itemlist
def anno(item):
logger.info("[itafilmtv.py] genere")
itemlist = []
data = scrapertools.cachePage(item.url, headers=headers )
logger.info("data="+data)
data = scrapertools.find_single_match(data,'<div class="menu-col fixcol2">(.*?)<div style="clear: both;"></div>')
logger.info("data="+data)
patron = '<a href="(.*?)">(.*?)</a>'
matches = re.compile(patron,re.DOTALL).findall(data)
scrapertools.printMatches(matches)
for scrapedurl,scrapedtitle in matches:
itemlist.append( Item(channel=__channel__, action="fichas", title="[COLOR azure]"+scrapedtitle+"[/COLOR]", url=host+scrapedurl, folder=True))
return itemlist
def episodios( item ):
logger.info( "[itafilmtv.py] episodios" )
itemlist = []
## Descarga la página
data = scrapertools.cache_page( item.url, headers=headers )
plot = scrapertools.htmlclean(
scrapertools.get_match( data, '<div class="main-news-text main-news-text2">(.*?)</div>' )
).strip()
## Extrae las datos - Episodios
patron = '<br />(\d+x\d+).*?href="//ads.ad-center.com/[^<]+</a>(.*?)<a href="//ads.ad-center.com/[^<]+</a>'
matches = re.compile( patron, re.DOTALL ).findall( data )
if len( matches ) == 0:
patron = ' />(\d+x\d+)(.*?)<br'
matches = re.compile( patron, re.DOTALL ).findall( data )
## Extrae las datos - sub ITA/ITA
patron = '<b>.*?STAGIONE.*?(sub|ITA).*?</b>'
lang = re.compile( patron, re.IGNORECASE ).findall( data )
lang_index = 0
for scrapedepisode, scrapedurls in matches:
if int( scrapertools.get_match( scrapedepisode, '\d+x(\d+)' ) ) == 1:
lang_title = lang[lang_index]
if lang_title.lower() == "sub": lang_title+= " ITA"
lang_index+= 1
title = scrapedepisode + " - " + item.show + " (" + lang_title + ")"
scrapedurls = scrapedurls.replace( "playreplay", "moevideo" )
matches_urls = re.compile( 'href="([^"]+)"', re.DOTALL ).findall( scrapedurls )
urls = ""
for url in matches_urls:
urls+= url + "|"
if urls != "":
itemlist.append( Item( channel=__channel__, action="findvideos", title=title, url=urls[:-1], thumbnail=item.thumbnail, plot=plot, fulltitle=item.fulltitle, show=item.show ) )
return itemlist
def findvideos( item ):
logger.info( "[itafilmtv.py] findvideos" )
itemlist = []
## Extrae las datos
if "|" not in item.url:
## Descarga la página
data = scrapertools.cache_page( item.url, headers=headers )
sources = scrapertools.get_match( data, '(<noindex> <div class="video-player-plugin">.*?</noindex>)')
patron = 'src="([^"]+)"'
matches = re.compile( patron, re.DOTALL ).findall( sources )
else:
matches = item.url.split( '|' )
for scrapedurl in matches:
server = scrapedurl.split( '/' )[2].split( '.' )
if len(server) == 3: server = server[1]
else: server = server[0]
title = "[" + server + "] " + item.fulltitle
itemlist.append( Item( channel=__channel__, action="play" , title=title, url=scrapedurl, thumbnail=item.thumbnail, fulltitle=item.fulltitle, show=item.show, folder=False ) )
return itemlist
def play( item ):
logger.info( "[itafilmtv.py] play" )
## Sólo es necesario la url
data = item.url
itemlist = servertools.find_video_items( data=data )
for videoitem in itemlist:
videoitem.title = item.show
videoitem.fulltitle = item.fulltitle
videoitem.thumbnail = item.thumbnail
videoitem.channel = __channel__
return itemlist