def add_show(self, title, alt_title, episodes, build_url):
"""Adds a show to the local db, generates & persists the strm files
Note: Can also used to store complete seasons or single episodes,
it all depends on what is present in the episodes dictionary
Parameters
----------
title : :obj:`str`
Title of the show
alt_title : :obj:`str`
Alternative title given by the user
episodes : :obj:`dict` of :obj:`dict`
Episodes that need to be added
build_url : :obj:`fn`
Function to generate the stream url
"""
title = re.sub(r'[?|$|!|:|#]', r'', title)
show_meta = '%s' % (title)
folder = re.sub(r'[?|$|!|:|#]', r'', alt_title.encode('utf-8'))
show_dir = self.kodi_helper.check_folder_path(
path=os.path.join(self.tvshow_path, folder))
progress = xbmcgui.DialogProgress()
progress.create(self.kodi_helper.get_local_string(650), show_meta)
count = 1
if not xbmcvfs.exists(show_dir):
xbmcvfs.mkdirs(show_dir)
if self.show_exists(title) is False:
self.db[self.series_label][show_meta] = {
'seasons': [],
'episodes': [],
'alt_title': alt_title}
episode_count_total = len(episodes)
step = round(100.0 / episode_count_total, 1)
percent = step
for episode in episodes:
desc = self.kodi_helper.get_local_string(20373) + ': '
desc += str(episode.get('season'))
long_desc = self.kodi_helper.get_local_string(20359) + ': '
long_desc += str(episode.get('episode'))
progress.update(
percent=int(percent),
line1=show_meta,
line2=desc,
line3=long_desc)
self._add_episode(
show_dir=show_dir,
title=title,
season=episode.get('season'),
episode=episode.get('episode'),
video_id=episode.get('id'),
build_url=build_url)
percent += step
time.sleep(0.05)
self._update_local_db(filename=self.db_filepath, db=self.db)
time.sleep(1)
progress.close()
return show_dir
评论列表
文章目录