Playback Monitor as a service,
Global search fix other minimal fix
This commit is contained in:
@@ -59,8 +59,7 @@ def movies(item):
|
|||||||
def itemlistHook(itemlist):
|
def itemlistHook(itemlist):
|
||||||
args = item.args
|
args = item.args
|
||||||
args[0] += 1
|
args[0] += 1
|
||||||
support.nextPage(itemlist, item, next_page=item.url, "movies")
|
support.nextPage(itemlist, item, 'movies', next_page=item.url, total_pages=15)
|
||||||
# itemlist.append(item.clone(title=support.typo(support.config.getLocalizedString(30992), 'color kod bold'), args=args, thumbnail=support.thumb()))
|
|
||||||
return itemlist
|
return itemlist
|
||||||
return locals()
|
return locals()
|
||||||
|
|
||||||
@@ -73,7 +72,7 @@ def search(item, text):
|
|||||||
item.url += text + '.html'
|
item.url += text + '.html'
|
||||||
try:
|
try:
|
||||||
return movies(item)
|
return movies(item)
|
||||||
# Cattura la eccezione così non interrompe la ricerca globle se il canale si rompe!
|
# Cattura l' eccezione così non interrompe la ricerca globle se il canale si rompe!
|
||||||
except:
|
except:
|
||||||
import sys
|
import sys
|
||||||
for line in sys.exc_info():
|
for line in sys.exc_info():
|
||||||
|
|||||||
+37
-16
@@ -2,12 +2,14 @@
|
|||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
# Canale per Mediaset Play
|
# Canale per Mediaset Play
|
||||||
# ------------------------------------------------------------
|
# ------------------------------------------------------------
|
||||||
|
import functools
|
||||||
|
|
||||||
from platformcode import logger, config
|
from platformcode import logger, config
|
||||||
import uuid, datetime, xbmc
|
import uuid, datetime, xbmc
|
||||||
|
|
||||||
import requests, sys
|
import requests, sys
|
||||||
from core import support
|
from core import jsontools, support, httptools
|
||||||
|
|
||||||
if sys.version_info[0] >= 3:
|
if sys.version_info[0] >= 3:
|
||||||
from urllib.parse import urlencode, quote
|
from urllib.parse import urlencode, quote
|
||||||
else:
|
else:
|
||||||
@@ -23,6 +25,7 @@ loginData = {"client_id": clientid, "platform": "pc", "appName": "web//mediasetp
|
|||||||
sessionUrl = "https://api.one.accedo.tv/session?appKey=59ad346f1de1c4000dfd09c5&uuid={uuid}&gid=default"
|
sessionUrl = "https://api.one.accedo.tv/session?appKey=59ad346f1de1c4000dfd09c5&uuid={uuid}&gid=default"
|
||||||
|
|
||||||
session = requests.Session()
|
session = requests.Session()
|
||||||
|
session.request = functools.partial(session.request, timeout=httptools.HTTPTOOLS_DEFAULT_DOWNLOAD_TIMEOUT)
|
||||||
session.headers.update({'Content-Type': 'application/json', 'User-Agent': support.httptools.get_user_agent(), 'Referer': host})
|
session.headers.update({'Content-Type': 'application/json', 'User-Agent': support.httptools.get_user_agent(), 'Referer': host})
|
||||||
|
|
||||||
entry = 'https://api.one.accedo.tv/content/entry/{id}?locale=it'
|
entry = 'https://api.one.accedo.tv/content/entry/{id}?locale=it'
|
||||||
@@ -75,19 +78,26 @@ def live(item):
|
|||||||
stations = res['stations']
|
stations = res['stations']
|
||||||
|
|
||||||
for it in stations.values():
|
for it in stations.values():
|
||||||
|
logger.debug(jsontools.dump(it))
|
||||||
plot = ''
|
plot = ''
|
||||||
title = it['title']
|
title = it['title']
|
||||||
url = 'https:' + it['mediasetstation$pageUrl']
|
url = 'https:' + it['mediasetstation$pageUrl']
|
||||||
if 'plus' in title.lower() or 'premium' in title.lower(): continue
|
if 'SVOD' in it['mediasetstation$channelsRights']: continue
|
||||||
|
thumb = it.get('thumbnails',{}).get('channel_logo-100x100',{}).get('url','')
|
||||||
if it['callSign'] in allguide:
|
if it['callSign'] in allguide:
|
||||||
|
|
||||||
guide = allguide[it['callSign']]
|
guide = allguide[it['callSign']]
|
||||||
plot = '[B]{}[/B]\n{}\n\nA Seguire:\n[B]{}[/B]\n{}'.format(guide['currentListing']['mediasetlisting$epgTitle'],
|
plot = '[B]{}[/B]\n{}'.format(guide.get('currentListing', {}).get('mediasetlisting$epgTitle', ''),guide.get('currentListing', {}).get('description', ''))
|
||||||
guide['currentListing']['description'],
|
if 'nextListing' in guide.keys():
|
||||||
guide['nextListing']['mediasetlisting$epgTitle'],
|
plot += '\n\nA Seguire:\n[B]{}[/B]\n{}'.format(guide.get('nextListing', {}).get('mediasetlisting$epgTitle', ''),guide.get('nextListing', {}).get('description', ''))
|
||||||
guide['nextListing']['description'],)
|
itemlist.append(item.clone(title=title,
|
||||||
|
fulltitle=title, callSign=it['callSign'],
|
||||||
itemlist.append(item.clone(title=support.typo(title, 'bold'), fulltitle=title, callSign=it['callSign'], urls=guide['tuningInstruction']['urn:theplatform:tv:location:any'], plot=plot, url=url, action='play', forcethumb=True))
|
urls=guide['tuningInstruction']['urn:theplatform:tv:location:any'],
|
||||||
|
plot=plot,
|
||||||
|
url=url,
|
||||||
|
action='findvideos',
|
||||||
|
thumbnail=thumb,
|
||||||
|
forcethumb=True))
|
||||||
|
|
||||||
itemlist.sort(key=lambda it: support.channels_order.get(it.fulltitle, 999))
|
itemlist.sort(key=lambda it: support.channels_order.get(it.fulltitle, 999))
|
||||||
support.thumb(itemlist, mode='live')
|
support.thumb(itemlist, mode='live')
|
||||||
@@ -103,7 +113,7 @@ def search(item, text):
|
|||||||
except:
|
except:
|
||||||
import sys
|
import sys
|
||||||
for line in sys.exc_info():
|
for line in sys.exc_info():
|
||||||
logger.error("%s" % line)
|
support.logger.error("%s" % line)
|
||||||
return []
|
return []
|
||||||
|
|
||||||
|
|
||||||
@@ -131,7 +141,7 @@ def movies(item):
|
|||||||
else:
|
else:
|
||||||
contentType = 'movie'
|
contentType = 'movie'
|
||||||
video_id = it['guid']
|
video_id = it['guid']
|
||||||
action = 'play'
|
action = 'findvideos'
|
||||||
for k, v in it['thumbnails'].items():
|
for k, v in it['thumbnails'].items():
|
||||||
if 'image_vertical' in k and not thumb:
|
if 'image_vertical' in k and not thumb:
|
||||||
thumb = v['url'].replace('.jpg', '@3.jpg')
|
thumb = v['url'].replace('.jpg', '@3.jpg')
|
||||||
@@ -140,7 +150,7 @@ def movies(item):
|
|||||||
if thumb and fanart:
|
if thumb and fanart:
|
||||||
break
|
break
|
||||||
|
|
||||||
itemlist.append(item.clone(title=support.typo(title, 'bold'),
|
itemlist.append(item.clone(title=title,
|
||||||
fulltitle=title,
|
fulltitle=title,
|
||||||
contentTitle=title,
|
contentTitle=title,
|
||||||
contentSerieName=contentSerieName,
|
contentSerieName=contentSerieName,
|
||||||
@@ -172,14 +182,14 @@ def epmenu(item):
|
|||||||
for s in item.seriesid:
|
for s in item.seriesid:
|
||||||
itemlist.append(
|
itemlist.append(
|
||||||
item.clone(seriesid = s['id'],
|
item.clone(seriesid = s['id'],
|
||||||
title=support.typo(s['title'], 'bold')))
|
title=s['title']))
|
||||||
if len(itemlist) == 1: return epmenu(itemlist[0])
|
if len(itemlist) == 1: return epmenu(itemlist[0])
|
||||||
else:
|
else:
|
||||||
res = requests.get(epUrl.format(item.seriesid)).json()['entries']
|
res = requests.get(epUrl.format(item.seriesid)).json()['entries']
|
||||||
for it in res:
|
for it in res:
|
||||||
itemlist.append(
|
itemlist.append(
|
||||||
item.clone(seriesid = '',
|
item.clone(seriesid = '',
|
||||||
title=support.typo(it['description'], 'bold'),
|
title=it['description'],
|
||||||
subbrand=it['mediasetprogram$subBrandId'],
|
subbrand=it['mediasetprogram$subBrandId'],
|
||||||
action='episodes'))
|
action='episodes'))
|
||||||
itemlist = sorted(itemlist, key=lambda it: it.title, reverse=True)
|
itemlist = sorted(itemlist, key=lambda it: it.title, reverse=True)
|
||||||
@@ -195,15 +205,18 @@ def episodes(item):
|
|||||||
except: # per i test, xbmc.getLocalizedString non è supportato
|
except: # per i test, xbmc.getLocalizedString non è supportato
|
||||||
for month in range(21, 33): months.append('dummy')
|
for month in range(21, 33): months.append('dummy')
|
||||||
|
|
||||||
|
# i programmi tv vanno ordinati per data decrescente, gli episodi delle serie per data crescente
|
||||||
|
order = 'desc' if '/programmi-tv/' in item.url else 'asc'
|
||||||
|
|
||||||
itemlist = []
|
itemlist = []
|
||||||
res = requests.get('https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-programs-v2?byCustomValue={subBrandId}{' + item.subbrand +'}&sort=:publishInfo_lastPublished|asc,tvSeasonEpisodeNumber').json()['entries']
|
res = requests.get('https://feed.entertainment.tv.theplatform.eu/f/PR1GhC/mediaset-prod-all-programs-v2?byCustomValue={subBrandId}{' + item.subbrand +'}&sort=:publishInfo_lastPublished|' + order + ',tvSeasonEpisodeNumber').json()['entries']
|
||||||
|
|
||||||
for it in res:
|
for it in res:
|
||||||
thumb = ''
|
thumb = ''
|
||||||
titleDate = ''
|
titleDate = ''
|
||||||
if 'mediasetprogram$publishInfo_lastPublished' in it:
|
if 'mediasetprogram$publishInfo_lastPublished' in it:
|
||||||
date = datetime.date.fromtimestamp(it['mediasetprogram$publishInfo_lastPublished'] / 1000)
|
date = datetime.date.fromtimestamp(it['mediasetprogram$publishInfo_lastPublished'] / 1000)
|
||||||
titleDate =' [{} {}]'.format(date.day, months[date.month])
|
titleDate =' [{} {}]'.format(date.day, months[date.month-1])
|
||||||
title = '[B]{}[/B]{}'.format(it['title'], titleDate)
|
title = '[B]{}[/B]{}'.format(it['title'], titleDate)
|
||||||
for k, v in it['thumbnails'].items():
|
for k, v in it['thumbnails'].items():
|
||||||
if 'image_keyframe' in k and not thumb:
|
if 'image_keyframe' in k and not thumb:
|
||||||
@@ -215,15 +228,21 @@ def episodes(item):
|
|||||||
thumbnail=thumb,
|
thumbnail=thumb,
|
||||||
forcethumb=True,
|
forcethumb=True,
|
||||||
contentType='episode',
|
contentType='episode',
|
||||||
action='play',
|
action='findvideos',
|
||||||
video_id=it['guid']))
|
video_id=it['guid']))
|
||||||
|
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
|
|
||||||
|
def findvideos(item):
|
||||||
|
logger.debug()
|
||||||
|
return support.server(item, itemlist=[item.clone(server='directo', action='play')])
|
||||||
|
|
||||||
|
|
||||||
def play(item):
|
def play(item):
|
||||||
logger.debug()
|
logger.debug()
|
||||||
item.no_return=True
|
item.no_return=True
|
||||||
|
# support.dbg()
|
||||||
mpd = config.getSetting('mpd', item.channel)
|
mpd = config.getSetting('mpd', item.channel)
|
||||||
|
|
||||||
|
|
||||||
@@ -238,6 +257,8 @@ def play(item):
|
|||||||
if Format in it['format']:
|
if Format in it['format']:
|
||||||
item.url = requests.head(it['publicUrls'][0]).headers['Location']
|
item.url = requests.head(it['publicUrls'][0]).headers['Location']
|
||||||
pid = it['releasePids'][0]
|
pid = it['releasePids'][0]
|
||||||
|
if mpd and 'widevine' in it['assetTypes']:
|
||||||
|
break
|
||||||
|
|
||||||
if mpd:
|
if mpd:
|
||||||
item.manifest = 'mpd'
|
item.manifest = 'mpd'
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ def live(item):
|
|||||||
logger.debug()
|
logger.debug()
|
||||||
itemlist=[]
|
itemlist=[]
|
||||||
for key, value in liveDict().items():
|
for key, value in liveDict().items():
|
||||||
itemlist.append(item.clone(title=support.typo(key,'bold'), contentTitle=key, fulltitle=key, show=key, url=value['url'], plot=value['plot'], action='play', forcethumb=True, no_return=True))
|
itemlist.append(item.clone(title=key, contentTitle=key, fulltitle=key, show=key, url=value['url'], plot=value['plot'], action='findvideos', forcethumb=True, no_return=True))
|
||||||
return support.thumb(itemlist, mode='live')
|
return support.thumb(itemlist, mode='live')
|
||||||
|
|
||||||
|
|
||||||
@@ -92,7 +92,7 @@ def movies(item):
|
|||||||
continue
|
continue
|
||||||
if item.text.lower() in title.lower():
|
if item.text.lower() in title.lower():
|
||||||
itemlist.append(
|
itemlist.append(
|
||||||
item.clone(title=support.typo(title,'bold'),
|
item.clone(title=title,
|
||||||
fulltitle = title,
|
fulltitle = title,
|
||||||
show = title,
|
show = title,
|
||||||
contentTitle = title if item.contentType == 'movie' else '',
|
contentTitle = title if item.contentType == 'movie' else '',
|
||||||
@@ -137,10 +137,10 @@ def episodes(item):
|
|||||||
s = support.match(se, patron=r'S\s*(?P<season>\d+)').match
|
s = support.match(se, patron=r'S\s*(?P<season>\d+)').match
|
||||||
e = support.match(se, patron=r'E\s*(?P<episode>\d+)').match
|
e = support.match(se, patron=r'E\s*(?P<episode>\d+)').match
|
||||||
if not e: e = support.match(it['meta']['subHeader'], patron=r'(\d+)').match
|
if not e: e = support.match(it['meta']['subHeader'], patron=r'(\d+)').match
|
||||||
title = support.typo((s + 'x' if s else 'Episodio ') + e.zfill(2) + ' - ' + it['meta']['subHeader'],'bold')
|
title = (s + 'x' if s else 'Episodio ') + e.zfill(2) + ' - ' + it['meta']['subHeader']
|
||||||
else:
|
else:
|
||||||
s = e = '0'
|
s = e = '0'
|
||||||
title = support.typo(it['meta']['header']['title'],'bold')
|
title = it['meta']['header']['title']
|
||||||
itemlist.append(
|
itemlist.append(
|
||||||
item.clone(title=title,
|
item.clone(title=title,
|
||||||
season=int(s) if s else '',
|
season=int(s) if s else '',
|
||||||
@@ -170,9 +170,4 @@ def play(item):
|
|||||||
url = 'https://media.mtvnservices.com/pmt/e1/access/index.html?uri=' + mgid + '&configtype=edge&ref=' + item.url
|
url = 'https://media.mtvnservices.com/pmt/e1/access/index.html?uri=' + mgid + '&configtype=edge&ref=' + item.url
|
||||||
ID, rootUrl = support.match(url, patron=[r'"id":"([^"]+)",',r'brightcove_mediagenRootURL":"([^"]+)"']).matches
|
ID, rootUrl = support.match(url, patron=[r'"id":"([^"]+)",',r'brightcove_mediagenRootURL":"([^"]+)"']).matches
|
||||||
item.url = jsontools.load(support.match(rootUrl.replace('&device={device}','').format(uri = ID)).data)['package']['video']['item'][0]['rendition'][0]['src']
|
item.url = jsontools.load(support.match(rootUrl.replace('&device={device}','').format(uri = ID)).data)['package']['video']['item'][0]['rendition'][0]['src']
|
||||||
|
|
||||||
if item.livefilter:
|
|
||||||
d = liveDict()[item.livefilter]
|
|
||||||
item = item.clone(title=support.typo(item.livefilter, 'bold'), fulltitle=item.livefilter, url=d['url'], plot=d['plot'], action='play', forcethumb=True, no_return=True)
|
|
||||||
support.thumb(item, mode='live')
|
|
||||||
return [item]
|
return [item]
|
||||||
+7
-7
@@ -19,8 +19,8 @@ host = support.config.get_channel_url()
|
|||||||
|
|
||||||
@support.menu
|
@support.menu
|
||||||
def mainlist(item):
|
def mainlist(item):
|
||||||
top = [('Dirette {bold}', ['/dirette', 'live', '/palinsesto/onAir.json']),
|
top = [('Dirette {bullet bold}', ['/dirette', 'live', '/palinsesto/onAir.json']),
|
||||||
('Replay {bold}', ['/guidatv', 'replayMenu', '/guidatv.json'])]
|
('Replay {bullet bold}', ['/guidatv', 'replayMenu', '/guidatv.json'])]
|
||||||
|
|
||||||
menu = [('Film {bullet bold}', ['/film', 'menu', '/tipologia/film/index.json']),
|
menu = [('Film {bullet bold}', ['/film', 'menu', '/tipologia/film/index.json']),
|
||||||
('Serie TV {bullet bold}', ['/serietv', 'menu', '/tipologia/serietv/index.json']),
|
('Serie TV {bullet bold}', ['/serietv', 'menu', '/tipologia/serietv/index.json']),
|
||||||
@@ -58,7 +58,7 @@ def menu(item):
|
|||||||
thumb = item.thumbnail
|
thumb = item.thumbnail
|
||||||
if 'RaiPlay Slider Generi Block' in it['type']:
|
if 'RaiPlay Slider Generi Block' in it['type']:
|
||||||
action = 'menu'
|
action = 'menu'
|
||||||
thumb = support.thumb('genres')
|
thumb = support.thumb('genre')
|
||||||
itemlist.append(item.clone(title=support.typo(it['name'], 'bold'), data=it.get('contents', item.data), thumbnail=thumb, action=action))
|
itemlist.append(item.clone(title=support.typo(it['name'], 'bold'), data=it.get('contents', item.data), thumbnail=thumb, action=action))
|
||||||
|
|
||||||
return itemlist
|
return itemlist
|
||||||
@@ -141,7 +141,7 @@ def live(item):
|
|||||||
current = it['currentItem']
|
current = it['currentItem']
|
||||||
next = it['nextItem']
|
next = it['nextItem']
|
||||||
plot = '[B]{}[/B]\n{}\n\nA Seguire: [B]{}[/B]\n{}'.format(current['name'], current['description'], next['name'], next['description'])
|
plot = '[B]{}[/B]\n{}\n\nA Seguire: [B]{}[/B]\n{}'.format(current['name'], current['description'], next['name'], next['description'])
|
||||||
itemlist.append(item.clone(title=title, fulltitle=title, fanart=fanart, plot=plot, url=url, videoUrl=url + '.json', action='play'))
|
itemlist.append(item.clone(title=title, fulltitle=title, fanart=fanart, plot=plot, url=url, videoUrl=url + '.json', action='findvideos'))
|
||||||
itemlist.sort(key=lambda it: support.channels_order.get(it.fulltitle, 999))
|
itemlist.sort(key=lambda it: support.channels_order.get(it.fulltitle, 999))
|
||||||
support.thumb(itemlist, mode='live')
|
support.thumb(itemlist, mode='live')
|
||||||
return itemlist
|
return itemlist
|
||||||
@@ -207,7 +207,7 @@ def replay(item):
|
|||||||
plot = info['description'],
|
plot = info['description'],
|
||||||
url = getUrl(it['weblink']),
|
url = getUrl(it['weblink']),
|
||||||
videoUrl = getUrl(it['path_id']),
|
videoUrl = getUrl(it['path_id']),
|
||||||
action = 'play',
|
action = 'findvideos',
|
||||||
forcethumb = True)
|
forcethumb = True)
|
||||||
|
|
||||||
|
|
||||||
@@ -225,7 +225,7 @@ def replay(item):
|
|||||||
return [Item(title='Non ci sono Replay per questo Canale')]
|
return [Item(title='Non ci sono Replay per questo Canale')]
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
def play(item):
|
def findvideos(item):
|
||||||
logger.debug()
|
logger.debug()
|
||||||
|
|
||||||
res = requests.get(item.videoUrl).json()
|
res = requests.get(item.videoUrl).json()
|
||||||
@@ -283,7 +283,7 @@ def addinfo(items, item):
|
|||||||
plot=info.get('description', ''))
|
plot=info.get('description', ''))
|
||||||
|
|
||||||
if 'Genere' not in key.get('sub_type', '') and ('layout' not in key or key['layout'] == 'single'):
|
if 'Genere' not in key.get('sub_type', '') and ('layout' not in key or key['layout'] == 'single'):
|
||||||
it.action = 'play'
|
it.action = 'findvideos'
|
||||||
it.contentTitle = it.fulltitle
|
it.contentTitle = it.fulltitle
|
||||||
else:
|
else:
|
||||||
it.action = 'episodes'
|
it.action = 'episodes'
|
||||||
|
|||||||
@@ -283,6 +283,12 @@ class Item(object):
|
|||||||
def __str__(self):
|
def __str__(self):
|
||||||
return '\r\t' + self.tostring('\r\t')
|
return '\r\t' + self.tostring('\r\t')
|
||||||
|
|
||||||
|
def __eq__(self, other):
|
||||||
|
if type(other) == Item:
|
||||||
|
return self.__dict__ == other.__dict__
|
||||||
|
else:
|
||||||
|
return False
|
||||||
|
|
||||||
def set_parent_content(self, parentContent):
|
def set_parent_content(self, parentContent):
|
||||||
"""
|
"""
|
||||||
Fill the contentDetails fields with the information of the item "parent"
|
Fill the contentDetails fields with the information of the item "parent"
|
||||||
|
|||||||
+2
-2
@@ -1882,9 +1882,9 @@ def get_jwplayer_mediaUrl(data, srvName, onlyHttp=False, dataIsBlock=False):
|
|||||||
def itemlistdb(itemlist=None):
|
def itemlistdb(itemlist=None):
|
||||||
from core import db
|
from core import db
|
||||||
if itemlist:
|
if itemlist:
|
||||||
db['itemlist']['itemlist'] = itemlist
|
db['control']['itemlist'] = itemlist
|
||||||
else:
|
else:
|
||||||
itemlist = db['itemlist'].get('itemlist',[])
|
itemlist = db['control'].get('itemlist',[])
|
||||||
db.close()
|
db.close()
|
||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
|
|||||||
+1
-3
@@ -38,8 +38,6 @@ from threading import Thread
|
|||||||
|
|
||||||
__version__ = '1.7.0.dev0'
|
__version__ = '1.7.0.dev0'
|
||||||
|
|
||||||
import xbmc
|
|
||||||
kodi_monitor = xbmc.Monitor()
|
|
||||||
|
|
||||||
major_version = sys.version_info[0]
|
major_version = sys.version_info[0]
|
||||||
if major_version < 3: # py <= 2.x
|
if major_version < 3: # py <= 2.x
|
||||||
@@ -443,7 +441,7 @@ class SqliteMultithread(Thread):
|
|||||||
self._sqlitedict_thread_initialized = True
|
self._sqlitedict_thread_initialized = True
|
||||||
|
|
||||||
res = None
|
res = None
|
||||||
while not kodi_monitor.abortRequested():
|
while True:
|
||||||
req, arg, res, outer_stack = self.reqs.get()
|
req, arg, res, outer_stack = self.reqs.get()
|
||||||
if req == '--close--':
|
if req == '--close--':
|
||||||
assert res, ('--close-- without return queue', res)
|
assert res, ('--close-- without return queue', res)
|
||||||
|
|||||||
@@ -115,7 +115,8 @@ def run(item=None):
|
|||||||
platformtools.itemlistUpdate(Item(channel='setting', action='report_menu'), True)
|
platformtools.itemlistUpdate(Item(channel='setting', action='report_menu'), True)
|
||||||
finally:
|
finally:
|
||||||
# db need to be closed when not used, it will cause freezes
|
# db need to be closed when not used, it will cause freezes
|
||||||
from core import db
|
from core import db, videolibrarydb
|
||||||
|
videolibrarydb.close()
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -533,7 +533,7 @@ def getCurrentView(item=None, parent_item=None):
|
|||||||
or (item.channel in ['videolibrary'] and parent_item.action in ['list_tvshows']):
|
or (item.channel in ['videolibrary'] and parent_item.action in ['list_tvshows']):
|
||||||
return 'tvshow', 'tvshows'
|
return 'tvshow', 'tvshows'
|
||||||
|
|
||||||
elif parent_item.action in ['episode', 'get_episodes'] or item.contentType == 'episode':
|
elif parent_item.action in ['episodes', 'get_episodes'] or item.contentType == 'episode':
|
||||||
return 'episode', 'tvshows'
|
return 'episode', 'tvshows'
|
||||||
|
|
||||||
elif parent_item.action in ['get_seasons']:
|
elif parent_item.action in ['get_seasons']:
|
||||||
@@ -546,11 +546,11 @@ def getCurrentView(item=None, parent_item=None):
|
|||||||
elif parent_item.action in ['filterchannels']:
|
elif parent_item.action in ['filterchannels']:
|
||||||
return 'channels', addons
|
return 'channels', addons
|
||||||
|
|
||||||
elif item.action:
|
else:
|
||||||
return 'menu', addons
|
return 'menu', addons
|
||||||
|
|
||||||
else:
|
# else:
|
||||||
return None, None
|
# return None, None
|
||||||
|
|
||||||
|
|
||||||
def setViewMode(item, parent_item):
|
def setViewMode(item, parent_item):
|
||||||
@@ -1387,12 +1387,14 @@ def setPlayer(item, xlistitem, mediaUrl, view, strm):
|
|||||||
item.options = {'strm':False}
|
item.options = {'strm':False}
|
||||||
# logger.debug("item:\n" + item.tostring('\n'))
|
# logger.debug("item:\n" + item.tostring('\n'))
|
||||||
|
|
||||||
# Moved del conector "torrent" here
|
# Get Media Url for play Torrent
|
||||||
if item.server == "torrent":
|
if item.server == "torrent":
|
||||||
playTorrent(item, xlistitem, mediaUrl)
|
mediaUrl = playTorrent(item, mediaUrl)
|
||||||
return
|
if not mediaUrl:
|
||||||
|
return
|
||||||
|
|
||||||
# If it is a strm file, play is not necessary
|
# If it is a strm file, play is not necessary
|
||||||
elif strm:
|
if strm:
|
||||||
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xlistitem)
|
xbmcplugin.setResolvedUrl(int(sys.argv[1]), True, xlistitem)
|
||||||
if item.subtitle:
|
if item.subtitle:
|
||||||
xbmc.sleep(2000)
|
xbmc.sleep(2000)
|
||||||
@@ -1408,13 +1410,11 @@ def setPlayer(item, xlistitem, mediaUrl, view, strm):
|
|||||||
logger.info("mediaUrl=" + mediaUrl)
|
logger.info("mediaUrl=" + mediaUrl)
|
||||||
|
|
||||||
if player_mode in [0,1]:
|
if player_mode in [0,1]:
|
||||||
# preventBusy(item)
|
if player_mode in [1] and item.server != "torrent":
|
||||||
if player_mode in [1]:
|
|
||||||
# logger.dbg()
|
|
||||||
item.played_time = resumePlayback(getPlayedTime(item))
|
item.played_time = resumePlayback(getPlayedTime(item))
|
||||||
|
|
||||||
from core import db
|
from core import db
|
||||||
db['playitem']['item'] = item
|
db['control']['playItem'] = item
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
logger.info('Player Mode:',['Direct', 'Bookmark'][player_mode])
|
logger.info('Player Mode:',['Direct', 'Bookmark'][player_mode])
|
||||||
@@ -1484,8 +1484,9 @@ def torrentClientInstalled(showTuple=False):
|
|||||||
return torrentOptions
|
return torrentOptions
|
||||||
|
|
||||||
|
|
||||||
def playTorrent(item, xlistitem, mediaUrl):
|
def playTorrent(item, mediaUrl):
|
||||||
logger.debug()
|
logger.debug()
|
||||||
|
# logger.dbg()
|
||||||
import time
|
import time
|
||||||
from servers import torrent
|
from servers import torrent
|
||||||
|
|
||||||
@@ -1493,14 +1494,14 @@ def playTorrent(item, xlistitem, mediaUrl):
|
|||||||
if len(torrentOptions) == 0:
|
if len(torrentOptions) == 0:
|
||||||
from platformcode import elementum_download
|
from platformcode import elementum_download
|
||||||
elementum_download.download()
|
elementum_download.download()
|
||||||
return playTorrent(item, xlistitem, mediaUrl)
|
return playTorrent(item, mediaUrl)
|
||||||
elif len(torrentOptions) > 1:
|
elif len(torrentOptions) > 1:
|
||||||
selection = dialogSelect(config.getLocalizedString(70193), [opcion[0] for opcion in torrentOptions])
|
selection = dialogSelect(config.getLocalizedString(70193), [opcion[0] for opcion in torrentOptions])
|
||||||
else:
|
else:
|
||||||
selection = 0
|
selection = 0
|
||||||
|
|
||||||
if selection >= 0:
|
if selection >= 0:
|
||||||
preventBusy()
|
# preventBusy()
|
||||||
|
|
||||||
mediaUrl = urllib.quote_plus(item.url)
|
mediaUrl = urllib.quote_plus(item.url)
|
||||||
torr_client = torrentOptions[selection][0]
|
torr_client = torrentOptions[selection][0]
|
||||||
@@ -1514,14 +1515,14 @@ def playTorrent(item, xlistitem, mediaUrl):
|
|||||||
if torr_client in ['elementum'] and item.downloadFilename:
|
if torr_client in ['elementum'] and item.downloadFilename:
|
||||||
torrent.elementum_download(item)
|
torrent.elementum_download(item)
|
||||||
else:
|
else:
|
||||||
time.sleep(3)
|
import xbmcaddon
|
||||||
xbmc.executebuiltin("PlayMedia(" + torrentOptions[selection][1] % mediaUrl + ")")
|
addon = xbmcaddon.Addon(id='plugin.video.elementum')
|
||||||
|
if addon.getSetting('download_storage') == '0':
|
||||||
torrent.mark_auto_as_watched(item)
|
addon.setSetting('download_storage', '1')
|
||||||
|
xbmc.sleep(3000)
|
||||||
if not item.globalsearch:
|
mediaUrl = torrentOptions[selection][1] % mediaUrl
|
||||||
while isPlaying() and not xbmc.Monitor().abortRequested():
|
return mediaUrl
|
||||||
time.sleep(3)
|
return ''
|
||||||
|
|
||||||
|
|
||||||
def resumePlayback(played_time):
|
def resumePlayback(played_time):
|
||||||
@@ -1557,7 +1558,7 @@ def resumePlayback(played_time):
|
|||||||
self.set_values(False)
|
self.set_values(False)
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
if played_time and played_time > 30:
|
if played_time:
|
||||||
Dialog = ResumePlayback('ResumePlayback.xml', config.getRuntimePath(), played_time=played_time)
|
Dialog = ResumePlayback('ResumePlayback.xml', config.getRuntimePath(), played_time=played_time)
|
||||||
Dialog.show()
|
Dialog.show()
|
||||||
t = 0
|
t = 0
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ if PY3:
|
|||||||
else:
|
else:
|
||||||
import urllib2 # Usamos el nativo de PY2 que es más rápido
|
import urllib2 # Usamos el nativo de PY2 que es más rápido
|
||||||
|
|
||||||
from core import filetools, jsontools, videolibrarydb
|
from core import filetools, jsontools, support, videolibrarydb
|
||||||
from platformcode import config, logger, platformtools
|
from platformcode import config, logger, platformtools
|
||||||
from core import scrapertools
|
from core import scrapertools
|
||||||
from xml.dom import minidom
|
from xml.dom import minidom
|
||||||
@@ -118,13 +118,10 @@ def mark_auto_as_watched():
|
|||||||
# If it is configured to mark as seen
|
# If it is configured to mark as seen
|
||||||
if config.getSetting("mark_as_watched", "videolibrary"):
|
if config.getSetting("mark_as_watched", "videolibrary"):
|
||||||
from core import db
|
from core import db
|
||||||
item = db['playitem'].get('item')
|
item = db['control'].get('playItem')
|
||||||
db.close()
|
db.close()
|
||||||
imdb_id = xbmc.Player().getVideoInfoTag().getIMDBNumber()
|
threading.Thread(target=mark_as_watched_subThread, args=[item]).start()
|
||||||
if item.infoLabels['imdb_id'] == imdb_id:
|
logger.debug('EXIT MONITOR')
|
||||||
# mark_as_watched_subThread(item)
|
|
||||||
threading.Thread(target=mark_as_watched_subThread, args=[item]).start()
|
|
||||||
logger.debug('EXIT MONITOR')
|
|
||||||
|
|
||||||
|
|
||||||
def sync_trakt_addon(path_folder):
|
def sync_trakt_addon(path_folder):
|
||||||
|
|||||||
+6
-4
@@ -19,11 +19,10 @@ except:
|
|||||||
librerias = xbmc.translatePath(os.path.join(config.getRuntimePath(), 'lib'))
|
librerias = xbmc.translatePath(os.path.join(config.getRuntimePath(), 'lib'))
|
||||||
sys.path.insert(0, librerias)
|
sys.path.insert(0, librerias)
|
||||||
|
|
||||||
from core import filetools, httptools, jsontools, scrapertools, db, support
|
from core import filetools, httptools, scrapertools, db, videolibrarydb
|
||||||
from lib import schedule
|
from lib import schedule
|
||||||
from platformcode import logger, platformtools, updater, xbmc_videolibrary
|
from platformcode import logger, platformtools, updater, xbmc_videolibrary
|
||||||
from specials import videolibrary
|
from specials import videolibrary
|
||||||
from servers import torrent
|
|
||||||
|
|
||||||
# if this service need to be reloaded because an update changed it
|
# if this service need to be reloaded because an update changed it
|
||||||
needsReload = False
|
needsReload = False
|
||||||
@@ -243,8 +242,10 @@ if __name__ == "__main__":
|
|||||||
logger.error(traceback.format_exc())
|
logger.error(traceback.format_exc())
|
||||||
|
|
||||||
if needsReload:
|
if needsReload:
|
||||||
join_threads()
|
|
||||||
db.close()
|
db.close()
|
||||||
|
videolibrarydb.close()
|
||||||
|
join_threads()
|
||||||
|
|
||||||
logger.info('Relaunching service.py')
|
logger.info('Relaunching service.py')
|
||||||
xbmc.executeJSONRPC(
|
xbmc.executeJSONRPC(
|
||||||
'{"jsonrpc": "2.0", "id":1, "method": "Addons.SetAddonEnabled", "params": { "addonid": "plugin.video.kod", "enabled": false }}')
|
'{"jsonrpc": "2.0", "id":1, "method": "Addons.SetAddonEnabled", "params": { "addonid": "plugin.video.kod", "enabled": false }}')
|
||||||
@@ -254,7 +255,8 @@ if __name__ == "__main__":
|
|||||||
break
|
break
|
||||||
|
|
||||||
if monitor.waitForAbort(1): # every second
|
if monitor.waitForAbort(1): # every second
|
||||||
join_threads()
|
|
||||||
# db need to be closed when not used, it will cause freezes
|
# db need to be closed when not used, it will cause freezes
|
||||||
db.close()
|
db.close()
|
||||||
|
videolibrarydb.close()
|
||||||
|
join_threads()
|
||||||
break
|
break
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ from core import channeltools, scrapertools, support
|
|||||||
from platformcode import platformtools, config, logger
|
from platformcode import platformtools, config, logger
|
||||||
from threading import Thread
|
from threading import Thread
|
||||||
from collections import OrderedDict
|
from collections import OrderedDict
|
||||||
|
from specials.search import save_search
|
||||||
|
|
||||||
if sys.version_info[0] >= 3:
|
if sys.version_info[0] >= 3:
|
||||||
PY3 = True
|
PY3 = True
|
||||||
@@ -69,7 +70,7 @@ PREV = 507
|
|||||||
|
|
||||||
|
|
||||||
class SearchWindow(xbmcgui.WindowXML):
|
class SearchWindow(xbmcgui.WindowXML):
|
||||||
def start(self, item, moduleDict={}, searchActions=[], thActions=None):
|
def start(self, item, thActions=None):
|
||||||
logger.debug()
|
logger.debug()
|
||||||
|
|
||||||
self.exit = False
|
self.exit = False
|
||||||
@@ -119,8 +120,12 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
if not self.item.text: self.item.text = platformtools.dialogInput(default=last_search, heading='')
|
if not self.item.text: self.item.text = platformtools.dialogInput(default=last_search, heading='')
|
||||||
if self.item.text:
|
if self.item.text:
|
||||||
channeltools.setChannelSetting('Last_searched', self.item.text, 'search')
|
channeltools.setChannelSetting('Last_searched', self.item.text, 'search')
|
||||||
from specials.search import save_search
|
if self.item.mode == 'all':
|
||||||
save_search(self.item.text)
|
save_search(self.item.text)
|
||||||
|
else:
|
||||||
|
if self.item.context:
|
||||||
|
del self.item.context # needed for preventing same content twice in saved search
|
||||||
|
if not self.item.saved: save_search(self.item.clone(channel='search', action='new_search').__dict__)
|
||||||
|
|
||||||
def getActionsThread(self):
|
def getActionsThread(self):
|
||||||
logger.debug()
|
logger.debug()
|
||||||
@@ -147,7 +152,7 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
# wait and return as getActionsThread load
|
# wait and return as getActionsThread load
|
||||||
lastLen = len(self.searchActions)
|
lastLen = len(self.searchActions)
|
||||||
if self.thActions:
|
if self.thActions:
|
||||||
while self.thActions.is_alive():
|
while self.thActions.is_alive() or lastLen < len(self.searchActions):
|
||||||
while len(self.searchActions) == lastLen:
|
while len(self.searchActions) == lastLen:
|
||||||
if not self.thActions.is_alive():
|
if not self.thActions.is_alive():
|
||||||
return
|
return
|
||||||
@@ -322,7 +327,7 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
self.PROGRESS.setPercent(percent)
|
self.PROGRESS.setPercent(percent)
|
||||||
self.MAINTITLE.setText('{} | {}/{} [{}"]'.format(self.mainTitle,self.count, len(self.searchActions), int(time.time() - self.time)))
|
self.MAINTITLE.setText('{} | {}/{} [{}"]'.format(self.mainTitle,self.count, len(self.searchActions), int(time.time() - self.time)))
|
||||||
|
|
||||||
if percent == 100:
|
if percent == 100 and not self.thActions.is_alive():
|
||||||
if len(self.channels['valid']) or len(self.channels) == 2:
|
if len(self.channels['valid']) or len(self.channels) == 2:
|
||||||
self.setFocusId(RESULTS)
|
self.setFocusId(RESULTS)
|
||||||
elif not len(self.channels['valid']) and not len(self.channels):
|
elif not len(self.channels['valid']) and not len(self.channels):
|
||||||
@@ -608,7 +613,7 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
self.actors()
|
self.actors()
|
||||||
elif search == 'persons':
|
elif search == 'persons':
|
||||||
item = self.item.clone(mode='person_', discovery=self.persons[pos])
|
item = self.item.clone(mode='person_', discovery=self.persons[pos])
|
||||||
new_search(item, self.moduleDict, self.searchActions)
|
new_search(item)
|
||||||
if close_action:
|
if close_action:
|
||||||
self.close()
|
self.close()
|
||||||
else:
|
else:
|
||||||
@@ -616,7 +621,7 @@ class SearchWindow(xbmcgui.WindowXML):
|
|||||||
if self.mode == 'movie': item.contentTitle = self.RESULTS.getSelectedItem().getLabel()
|
if self.mode == 'movie': item.contentTitle = self.RESULTS.getSelectedItem().getLabel()
|
||||||
else: item.contentSerieName = self.RESULTS.getSelectedItem().getLabel()
|
else: item.contentSerieName = self.RESULTS.getSelectedItem().getLabel()
|
||||||
|
|
||||||
new_search(item, self.moduleDict, self.searchActions)
|
new_search(item)
|
||||||
if close_action:
|
if close_action:
|
||||||
self.close()
|
self.close()
|
||||||
|
|
||||||
|
|||||||
+6
-3
@@ -191,6 +191,7 @@ def saved_search(item):
|
|||||||
return itemlist
|
return itemlist
|
||||||
|
|
||||||
def get_saved_searches():
|
def get_saved_searches():
|
||||||
|
# logger.dbg()
|
||||||
current_saved_searches_list = config.getSetting("saved_searches_list", "search")
|
current_saved_searches_list = config.getSetting("saved_searches_list", "search")
|
||||||
if not current_saved_searches_list:
|
if not current_saved_searches_list:
|
||||||
current_saved_searches_list = []
|
current_saved_searches_list = []
|
||||||
@@ -209,9 +210,11 @@ def get_saved_searches():
|
|||||||
thumbnail=thumb('search')))
|
thumbnail=thumb('search')))
|
||||||
else:
|
else:
|
||||||
item = Item().fromjson(json.dumps(saved_search_item))
|
item = Item().fromjson(json.dumps(saved_search_item))
|
||||||
if item.action == 'Search':
|
item.saved = True
|
||||||
item.action = 'new_search'
|
item.channel = 'globalsearch' if config.getSetting('new_search') else 'classicsearch'
|
||||||
if item.type: item.mode = 'search/'+item.type
|
item.folder = False if config.getSetting('new_search') else True
|
||||||
|
if item.type: item.mode = 'search/' + item.type
|
||||||
|
if item.action == 'Search': item.action = 'new_search'
|
||||||
saved_searches_list.append(item)
|
saved_searches_list.append(item)
|
||||||
|
|
||||||
return saved_searches_list
|
return saved_searches_list
|
||||||
|
|||||||
Reference in New Issue
Block a user