- Fix Render Items

- Fix Autorenumber
 - Fix Conversione Videoteca
This commit is contained in:
Alhaziel01
2021-06-08 18:07:40 +02:00
parent dbc2ecd57e
commit 5f16ff4121
7 changed files with 87 additions and 72 deletions

View File

@@ -139,10 +139,10 @@ def peliculas(item):
if not item.contentLanguage:
if 'dub=1' in item.url or item.l == 'dub':
item.contentLanguage = 'ITA'
item.title += support.typo(item.contentLanguage,'_ [] color kod')
# item.title += support.typo(item.contentLanguage,'_ [] color kod')
else:
item.contentLanguage = 'Sub-ITA'
item.title += support.typo(item.contentLanguage,'_ [] color kod')
# item.title += support.typo(item.contentLanguage,'_ [] color kod')
return item
return locals()

View File

@@ -377,7 +377,7 @@ def scrapeBlock(item, args, block, patron, headers, action, pagination, debug, t
args = item.args,
contentSerieName = title if 'movie' not in [contentType] and function != 'episodios' else item.contentSerieName,
contentTitle = title if 'movie' in [contentType] and function == 'peliculas' else item.contentTitle,
contentLanguage = lang1 if lang1 else item.contentLanguage if item.contentLanguage else 'ITA',
contentLanguage = lang1 if lang1 else item.contentLanguage,
contentSeason = infolabels.get('season', ''),
contentEpisodeNumber=infolabels.get('episode', ''),
news = item.news if item.news else '',
@@ -1106,18 +1106,18 @@ def videolibrary(itemlist, item, typography='', function_level=1, function=''):
if config.get_videolibrary_support() and len(itemlist) > 0:
itemlist.append(
item.clone(channel=item.channel,
title=title,
fulltitle=item.fulltitle,
show=item.fulltitle,
contentType=contentType,
contentTitle=contentTitle,
contentSerieName=contentSerieName,
url=item.url,
action=action,
from_action=item.action,
extra=extra,
path=item.path,
thumbnail=thumb('add_to_videolibrary')
title=title,
fulltitle=item.fulltitle,
show=item.fulltitle,
contentType=contentType,
contentTitle=contentTitle,
contentSerieName=contentSerieName,
url=item.url,
action=action,
from_action=item.action,
extra=extra,
path=item.path,
thumbnail=thumb('add_to_videolibrary')
))
return itemlist

View File

@@ -389,9 +389,6 @@ def check_renumber_options(item):
json[item.fulltitle] = item.renumber
write(item, json)
# head_nfo, tvshow_item = read_nfo(filetools.join(item.context[0]['nfo']))
# if tvshow_item['channel_prefs'][item.fullti]
def save_tvshow(item, episodelist, silent=False):
"""
@@ -420,8 +417,9 @@ def save_tvshow(item, episodelist, silent=False):
logger.debug("NOT FOUND contentSerieName or code")
return 0, 0, -1, path # Salimos sin guardar
contentTypeBackup = item.contentType # Fix errors in some channels
item.contentType = contentTypeBackup # Fix errors in some channels
# contentTypeBackup = item.contentType # Fix errors in some channels
# item.contentType = contentTypeBackup # Fix errors in some channels
# item.contentType = 'tvshow'
# At this point we can have:
# scraper_return = True: An item with infoLabels with the updated information of the series
@@ -469,7 +467,7 @@ def save_tvshow(item, episodelist, silent=False):
if not item.head_nfo:
head_nfo = scraper.get_nfo(item)
if not head_nfo: return 0, 0, -1, ''
# support.dbg()
extra_info = get_fanart_tv(item)
if not item.infoLabels.get('posters'):item.infoLabels['posters'] = []
item.infoLabels['posters'] += extra_info['poster'].get('all',[])
@@ -487,14 +485,14 @@ def save_tvshow(item, episodelist, silent=False):
item.infoLabels['mediatype'] = 'tvshow'
item.contentType = 'tvshow'
item.infoLabels['title'] = item.contentSerieName
if item.contentSerieName: item.infoLabels['title'] = item.contentSerieName
tvshow_item.infoLabels = item.infoLabels
if not tvshow_item.infoLabels.get('playcount'): tvshow_item.infoLabels['playcount'] = 0
tvshow_item.channel = 'videolibrary'
tvshow_item.action = 'get_seasons'
tvshow_item.nfo_path = nfo_path
if not tvshow_item.head_nfo: tvshow_item.head_nfo = head_nfo
if not tvshow_item.title: tvshow_item.title = item.contentSerieName
if not tvshow_item.title: tvshow_item.title = item.infoLabels['title']
if not tvshow_item.videolibrary_id: tvshow_item.videolibrary_id = _id
if not tvshow_item.thumbnail: tvshow_item.thumbnail = item.infoLabels['thumbnail']
if not tvshow_item.fanart: tvshow_item.fanart = item.infoLabels['fanart']
@@ -636,14 +634,14 @@ def save_episodes(item, episodelist, extra_info, host, local_files, silent=False
failed += 1
# add strm_file if episode is not present in db or inside videolibrary path
if not filetools.exists(filetools.join(TVSHOWS_PATH, strm_path)):
logger.debug("Creating .strm: " + strm_path)
item_strm = Item(channel='videolibrary', action='play_from_library', strm_path=strm_path, contentType='episode', videolibrary_id=episode_item.videolibrary_id, contentSeason = episode_item.contentSeason, contentEpisodeNumber = episode_item.contentEpisodeNumber,)
filetools.write(filetools.join(TVSHOWS_PATH, strm_path), '{}?{}'.format(addon_name, item_strm.tourl()))
# if not filetools.exists(filetools.join(TVSHOWS_PATH, strm_path)):
logger.debug("Creating .strm: " + strm_path)
item_strm = Item(channel='videolibrary', action='play_from_library', strm_path=strm_path, contentType='episode', videolibrary_id=episode_item.videolibrary_id, contentSeason = episode_item.contentSeason, contentEpisodeNumber = episode_item.contentEpisodeNumber,)
filetools.write(filetools.join(TVSHOWS_PATH, strm_path), '{}?{}'.format(addon_name, item_strm.tourl()))
# update db if episode added
if failed == 0 and config.get_setting('kod_scraper'):
add_video(episode_item)
# update db if episode added
if failed == 0 and config.get_setting('kod_scraper'):
add_video(episode_item)
return item, episode, season_episode, e.contentLanguage, inserted, overwritten, failed
@@ -883,9 +881,9 @@ def add_tvshow(item, channel=None):
from platformcode.autorenumber import start, check
if not check(item):
action = item.action
item.renumber = True
item.setrenumber = True
start(item)
item.renumber = False
item.setrenumber = False
item.action = action
if not item.exit:
return add_tvshow(item, channel)
@@ -1023,3 +1021,5 @@ def get_local_files(path, item):
break
return local_files

View File

@@ -108,17 +108,14 @@ class autorenumber():
self.manual = False
self.auto = False
if self.item:
from core.videolibrarytools import check_renumber_options
check_renumber_options(self.item)
self.renumberdict = load(item)
self.auto = config.get_setting('autorenumber', item.channel)
self.title = self.item.fulltitle.strip()
if item.contentSeason:
item.exit = True
return
elif (self.item.channel in self.item.channel_prefs and RENUMBER in self.item.channel_prefs[item.channel] and self.title not in self.renumberdict) or self.item.renumber:
from core.videolibrarytools import check_renumber_options
# from specials.videolibrary import update_videolibrary
check_renumber_options(self.item)
# update_videolibrary(self.item)
self.series = self.renumberdict.get(self.title,{})
self.id = self.series.get(ID, 0)

View File

@@ -363,24 +363,25 @@ def render_items(itemlist, parent_item):
title = item.title
episode = ''
if type(item.contentSeason) == int and type(item.contentEpisodeNumber) == int and not parent_item.onlyep:
episode = '{}x{:02d}'.format(item.contentSeason, item.contentEpisodeNumber)
elif type(item.contentEpisodeNumber) == int:
episode = '{:02d}'.format(item.contentEpisodeNumber)
if episode and item.episode2:
if len(item.episode2) < 4: episode = '{}-{}'.format(episode, '-'.join('{:02d}'.format(e) for e in item.episode2))
else: episode = '{} -> {:02d}'.format(episode, item.episode2[-1])
if episode: title = '{}. {}'.format(episode, title)
if item.title2: title = '{} - {}'.format(title, item.title2)
if parent_item.channel not in ['videolibrary']:
if type(item.contentSeason) == int and type(item.contentEpisodeNumber) == int and not parent_item.onlyep:
episode = '{}x{:02d}'.format(item.contentSeason, item.contentEpisodeNumber)
elif type(item.contentEpisodeNumber) == int:
episode = '{:02d}'.format(item.contentEpisodeNumber)
if episode and item.episode2:
if len(item.episode2) < 4: episode = '{}-{}'.format(episode, '-'.join('{:02d}'.format(e) for e in item.episode2))
else: episode = '{} -> {:02d}'.format(episode, item.episode2[-1])
if episode: title = '{}. {}'.format(episode, title)
if item.title2: title = '{} - {}'.format(title, item.title2)
if not config.get_setting('format_title') and title[:1] not in ['[', '']:
server = typo(item.server, '_ []') if item.server else ''
quality = typo(item.quality, '_ [] color kod') if item.quality else ''
lang = typo(item.contentLanguage, '_ [] color kod') if item.contentLanguage else ''
extra = typo(item.extraInfo, '_ [] color kod') if item.extraInfo else ''
if not config.get_setting('format_title') and title[:1] not in ['[', '']:
server = typo(item.server, '_ []') if item.server else ''
quality = typo(item.quality, '_ [] color kod') if item.quality else ''
lang = typo(item.contentLanguage, '_ [] color kod') if item.contentLanguage else ''
extra = typo(item.extraInfo, '_ [] color kod') if item.extraInfo else ''
title = '[B]{}{}[/B]{}{}{}'.format(title, server, quality, lang, extra)
title = '[B]{}{}[/B]{}{}{}'.format(title, server, quality, lang, extra)
listitem = xbmcgui.ListItem(title)
art = {'icon': icon_image, 'thumb': item.thumbnail, 'poster': item.thumbnail, 'fanart': item.fanart if item.fanart else default_fanart}
@@ -1614,7 +1615,7 @@ def serverwindow(item, itemlist):
self.close()
reopen = False
if len(itemlist) > 0:
if itemlist:
reopen = False
while not xbmc.Monitor().abortRequested():
played = True

View File

@@ -19,7 +19,7 @@ except:
librerias = xbmc.translatePath(os.path.join(config.get_runtime_path(), 'lib'))
sys.path.insert(0, librerias)
from core import filetools, httptools, scrapertools, db
from core import filetools, httptools, jsontools, scrapertools, db, support
from lib import schedule
from platformcode import logger, platformtools, updater, xbmc_videolibrary
from specials import videolibrary
@@ -191,7 +191,7 @@ if __name__ == "__main__":
config.verify_directories_created()
import glob, xbmc
from core import videolibrarytools
from core import videolibrarytools, tmdb
from core.item import Item
dialog = None
path_to_delete = []
@@ -201,18 +201,29 @@ if __name__ == "__main__":
path_to_delete.append(filetools.dirname(film))
it = Item().fromjson(filetools.read(film))
videolibrarytools.save_movie(it)
for tvshow in glob.glob(xbmc.translatePath(filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_tvshows'), '*/1x01*.json'))):
for tvshow in glob.glob(xbmc.translatePath(filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_tvshows'), '*/tvshow.nfo'))):
if not dialog:
dialog = platformtools.dialog_progress(config.get_localized_string(20000), 'Conversione videoteca in corso')
path_to_delete.append(filetools.dirname(tvshow))
it = Item().fromjson(filetools.read(tvshow))
try:
channel = __import__('channels.%s' % it.channel, fromlist=['channels.%s' % it.channel])
except:
channel = __import__('specials.%s' % it.channel, fromlist=['specials.%s' % it.channel])
episodes = getattr(channel, it.action)(it)
js = jsontools.load('\n'.join(filetools.read(tvshow).splitlines()[1:]))
channels_dict = js.get('library_urls')
if channels_dict:
for ch, url in channels_dict.items():
path = xbmc.translatePath(filetools.join(config.get_setting('videolibrarypath'), config.get_setting('folder_tvshows'), js['path'], '1x01 [{}].json'.format(ch)))
videolibrarytools.save_tvshow(it, episodes, True)
if filetools.exists(path):
path_to_delete.append(filetools.dirname(tvshow))
it = Item().fromjson(filetools.read(path))
it.infoLabels = {'code': it.infoLabels['code'], 'tmdb_id': it.infoLabels['tmdb_id'], 'mediatype':'tvshow'}
it.contentType = 'tvshow'
tmdb.find_and_set_infoLabels(it)
it.url = channels_dict[it.channel]
try:
channel = __import__('channels.%s' % it.channel, fromlist=['channels.%s' % it.channel])
except:
channel = __import__('specials.%s' % it.channel, fromlist=['specials.%s' % it.channel])
episodes = getattr(channel, 'episodios')(it)
videolibrarytools.save_tvshow(it, episodes, True)
for path in path_to_delete:
filetools.rmdirtree(path, True)
if dialog:

View File

@@ -199,7 +199,9 @@ def list_tvshows(item):
if config.get_setting('no_pile_on_seasons', 'videolibrary') == 2 or config.get_setting('no_pile_on_seasons', 'videolibrary') == 1 and len(seasons) == 1:
it.action = 'get_episodes'
it.all = True
if not it.active: it.title = '{} {}'.format(it.title, support.typo('','bullet bold'))
if not it.active:
it.title += ' [B]•[/B]'
it.contentTitle += ' [B]•[/B]'
return it
@@ -211,9 +213,9 @@ def list_tvshows(item):
if itemlist:
itemlist = sorted(itemlist, key=lambda it: it.title.lower())
add_context(itemlist)
itemlist += [Item(channel=item.channel, action='update_videolibrary', thumbnail=item.thumbnail,
fanart=item.thumbnail, landscape=item.thumbnail,
thumbnail = thumb('videolibrary_tvshow')
itemlist += [Item(channel=item.channel, action='update_videolibrary', thumbnail=thumbnail,
fanart=thumbnail, landscape=thumbnail,
title=typo(config.get_localized_string(70269), 'bold color kod'), folder=False)]
videolibrarydb.close()
return itemlist
@@ -308,6 +310,9 @@ def findvideos(item):
videolibrarytools.check_renumber_options(item)
itemlist = []
if item.window:
p_dialog = platformtools.dialog_progress_bg(config.get_localized_string(50003))
p_dialog.update(0)
if not item.strm_path:
@@ -331,6 +336,8 @@ def findvideos(item):
item.infoLabels = videolibrarydb['episode'][item.videolibrary_id][ep]['item'].infoLabels
videolibrarydb.close()
if item.window:
p_dialog.update(40)
if videolibrary_items.get('local'):
try:
@@ -366,6 +373,8 @@ def findvideos(item):
pl = [s for s in itemlist if s.contentLanguage in [prefered_lang, '']]
if pl: itemlist = pl
if item.window:
p_dialog.update(80)
if len(itlist) > 1:
@@ -382,6 +391,7 @@ def findvideos(item):
itemlist = servertools.check_list_links(itemlist, config.get_setting('checklinks_number'))
if item.window:
p_dialog.update(100)
platformtools.serverwindow(item, itemlist)
else:
@@ -1309,7 +1319,3 @@ def get_results(nfo_path, root, Type, local=False):
# platformtools.itemlist_refresh()