если исключения - возвращаем False
parent
4ec38a5c13
commit
f8ac0c159d
166
addon.py
166
addon.py
|
@ -34,16 +34,19 @@ def root(plugin, content_type='video'):
|
||||||
))
|
))
|
||||||
@Route.register
|
@Route.register
|
||||||
def search_history(plugin):
|
def search_history(plugin):
|
||||||
@Route.register_delayed
|
try:
|
||||||
def set_view():
|
@Route.register_delayed
|
||||||
xbmc.executebuiltin('Container.SetViewMode("51")')
|
def set_view():
|
||||||
h_list = PersistentList('search_history')
|
xbmc.executebuiltin('Container.SetViewMode("51")')
|
||||||
for i in h_list:
|
h_list = PersistentList('search_history')
|
||||||
item = Listitem.from_dict(search, i, params={'search_query': i})
|
for i in h_list:
|
||||||
item.art.local_thumb('search.png')
|
item = Listitem.from_dict(search, i, params={'search_query': i})
|
||||||
yield item
|
item.art.local_thumb('search.png')
|
||||||
else:
|
yield item
|
||||||
yield None
|
else:
|
||||||
|
yield None
|
||||||
|
except:
|
||||||
|
yield False
|
||||||
@Route.register
|
@Route.register
|
||||||
def new_search(plugin):
|
def new_search(plugin):
|
||||||
q = utils.keyboard('Поиск')
|
q = utils.keyboard('Поиск')
|
||||||
|
@ -52,78 +55,87 @@ def new_search(plugin):
|
||||||
return search(plugin, q)
|
return search(plugin, q)
|
||||||
@Route.register
|
@Route.register
|
||||||
def search(plugin, search_query, thumb=None):
|
def search(plugin, search_query, thumb=None):
|
||||||
@Route.register_delayed
|
try:
|
||||||
def set_view():
|
|
||||||
xbmc.executebuiltin('Container.SetViewMode("51")')
|
|
||||||
with PersistentList('search_history') as h_list:
|
|
||||||
if search_query in h_list:
|
|
||||||
del h_list[h_list.index(search_query)]
|
|
||||||
h_list.insert(0, search_query)
|
|
||||||
progress = xbmcgui.DialogProgress()
|
|
||||||
found_items = []
|
|
||||||
progress.create(localize(33054))
|
|
||||||
for p, se in zip(range(0, 100, 100 / len(search_engines)), search_engines):
|
|
||||||
progress.update(p, line1=se.name)
|
|
||||||
found_items.extend(se().search(search_query))
|
|
||||||
res_items = []
|
|
||||||
for i in sorted(found_items, key=lambda x: x.seeders, reverse=True):
|
|
||||||
if '2160p' in i.title: hd = '[2160p/{}] '.format(i.size)
|
|
||||||
elif '1080p' in i.title: hd = '[1080p/{}] '.format(i.size)
|
|
||||||
elif '720p' in i.title: hd = '[720p/{}] '.format(i.size)
|
|
||||||
else: hd = ''
|
|
||||||
item = Listitem.from_dict(
|
|
||||||
open_torrent,
|
|
||||||
'{}{} {} ({}/{})'.format(hd, i.title, i.size, i.seeders, i.leachers),
|
|
||||||
params={'url': i.url, 'cookies': i.cookies, 'referer': i.referer}
|
|
||||||
)
|
|
||||||
if thumb:
|
|
||||||
item.art['thumb'] = thumb
|
|
||||||
else:
|
|
||||||
item.art.local_thumb(i.icon)
|
|
||||||
res_items.append(item)
|
|
||||||
progress.close()
|
|
||||||
return res_items
|
|
||||||
@Route.register
|
|
||||||
def open_torrent(plugin, url='--back--', cookies={}, referer='', path=''):
|
|
||||||
if url == '--back--':
|
|
||||||
xbmc.executebuiltin('ActivateWindow("home")')
|
|
||||||
yield False
|
|
||||||
else:
|
|
||||||
@Route.register_delayed
|
@Route.register_delayed
|
||||||
def set_view():
|
def set_view():
|
||||||
xbmc.executebuiltin('Container.SetViewMode("51")')
|
xbmc.executebuiltin('Container.SetViewMode("51")')
|
||||||
tf = torrent_file_fetch(url, referer, cookies)
|
with PersistentList('search_history') as h_list:
|
||||||
if not tf: yield False
|
if search_query in h_list:
|
||||||
t_full_path = store_torrent_file(tf)
|
del h_list[h_list.index(search_query)]
|
||||||
e = get_engine(t_full_path)
|
h_list.insert(0, search_query)
|
||||||
files = sorted(list(filter(lambda x: x.name.decode('utf-8').startswith(path) and x.name.decode('utf-8').lower().endswith(video_extensions), e.list_from_info(media_types=['video']))),
|
progress = xbmcgui.DialogProgress()
|
||||||
key=lambda x: x.name)
|
found_items = []
|
||||||
dirs = list(set(list(map( lambda x: x.name.decode('utf-8')[len(path):].lstrip('/').split('/')[0], filter( lambda x: len(x.name.decode('utf-8')[len(path):].lstrip('/').split('/')) > 1, files ) ))))
|
progress.create(localize(33054))
|
||||||
for d in sorted(dirs):
|
for p, se in zip(range(0, 100, 100 / len(search_engines)), search_engines):
|
||||||
item = Listitem.from_dict(open_torrent,
|
progress.update(p, line1=se.name)
|
||||||
d,
|
found_items.extend(se().search(search_query))
|
||||||
params={'url': url, 'cookies': cookies, 'referer': referer, 'path': '{}/{}'.format(
|
res_items = []
|
||||||
path, d
|
for i in sorted(found_items, key=lambda x: x.seeders, reverse=True):
|
||||||
) if path != '' else d}
|
if '2160p' in i.title: hd = '[2160p/{}] '.format(i.size)
|
||||||
)
|
elif '1080p' in i.title: hd = '[1080p/{}] '.format(i.size)
|
||||||
item.art.local_thumb('folder.png')
|
elif '720p' in i.title: hd = '[720p/{}] '.format(i.size)
|
||||||
yield item
|
else: hd = ''
|
||||||
for i in range(len(files)):
|
item = Listitem.from_dict(
|
||||||
f = files[i]
|
open_torrent,
|
||||||
p = f.name.decode('utf-8')[len(path):].lstrip('/').split('/')
|
'{}{} {} ({}/{})'.format(hd, i.title, i.size, i.seeders, i.leachers),
|
||||||
if len(p) == 1:
|
params={'url': i.url, 'cookies': i.cookies, 'referer': i.referer}
|
||||||
item = Listitem.from_dict(play_file,
|
)
|
||||||
'{} ({:.3f} GB)'.format(p[0], f.size / 1024.0 / 1024.0 /1024.0),
|
if thumb:
|
||||||
params={'t_full_path': t_full_path, 'f_index': i}
|
item.art['thumb'] = thumb
|
||||||
)
|
else:
|
||||||
item.art.local_thumb('video.png')
|
item.art.local_thumb(i.icon)
|
||||||
yield item
|
res_items.append(item)
|
||||||
|
progress.close()
|
||||||
|
return res_items
|
||||||
|
except:
|
||||||
|
return False
|
||||||
|
@Route.register
|
||||||
|
def open_torrent(plugin, url='--back--', cookies={}, referer='', path=''):
|
||||||
|
try:
|
||||||
|
if url == '--back--':
|
||||||
|
xbmc.executebuiltin('ActivateWindow("home")')
|
||||||
|
yield False
|
||||||
else:
|
else:
|
||||||
yield None
|
@Route.register_delayed
|
||||||
|
def set_view():
|
||||||
|
xbmc.executebuiltin('Container.SetViewMode("51")')
|
||||||
|
tf = torrent_file_fetch(url, referer, cookies)
|
||||||
|
if not tf: yield False
|
||||||
|
t_full_path = store_torrent_file(tf)
|
||||||
|
e = get_engine(t_full_path)
|
||||||
|
files = sorted(list(filter(lambda x: x.name.decode('utf-8').startswith(path) and x.name.decode('utf-8').lower().endswith(video_extensions), e.list_from_info(media_types=['video']))),
|
||||||
|
key=lambda x: x.name)
|
||||||
|
dirs = list(set(list(map( lambda x: x.name.decode('utf-8')[len(path):].lstrip('/').split('/')[0], filter( lambda x: len(x.name.decode('utf-8')[len(path):].lstrip('/').split('/')) > 1, files ) ))))
|
||||||
|
for d in sorted(dirs):
|
||||||
|
item = Listitem.from_dict(open_torrent,
|
||||||
|
d,
|
||||||
|
params={'url': url, 'cookies': cookies, 'referer': referer, 'path': '{}/{}'.format(
|
||||||
|
path, d
|
||||||
|
) if path != '' else d}
|
||||||
|
)
|
||||||
|
item.art.local_thumb('folder.png')
|
||||||
|
yield item
|
||||||
|
for i in range(len(files)):
|
||||||
|
f = files[i]
|
||||||
|
p = f.name.decode('utf-8')[len(path):].lstrip('/').split('/')
|
||||||
|
if len(p) == 1:
|
||||||
|
item = Listitem.from_dict(play_file,
|
||||||
|
'{} ({:.3f} GB)'.format(p[0], f.size / 1024.0 / 1024.0 /1024.0),
|
||||||
|
params={'t_full_path': t_full_path, 'f_index': i}
|
||||||
|
)
|
||||||
|
item.art.local_thumb('video.png')
|
||||||
|
yield item
|
||||||
|
else:
|
||||||
|
yield None
|
||||||
|
except:
|
||||||
|
yield False
|
||||||
@Route.register
|
@Route.register
|
||||||
def play_file(plugin, t_full_path, f_index):
|
def play_file(plugin, t_full_path, f_index):
|
||||||
vl = VideoLoop(t_full_path)
|
try:
|
||||||
vl.start(f_index)
|
vl = VideoLoop(t_full_path)
|
||||||
return False
|
vl.start(f_index)
|
||||||
|
return False
|
||||||
|
except:
|
||||||
|
return False
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
run()
|
run()
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<addon id="plugin.video.torrenter3" name="Torrenter3" provider-name="inpos" version="3.0.3">
|
<addon id="plugin.video.torrenter3" name="Torrenter3" provider-name="inpos" version="3.0.4">
|
||||||
<requires>
|
<requires>
|
||||||
<import addon="xbmc.python" version="2.25.0"/>
|
<import addon="xbmc.python" version="2.25.0"/>
|
||||||
<import addon="script.module.pyrrent2http"/>
|
<import addon="script.module.pyrrent2http"/>
|
||||||
|
|
Loading…
Reference in New Issue