Fix menu (#93)
This commit is contained in:
parent
f221d0040f
commit
9c44d323e6
@ -17,6 +17,7 @@ disable=
|
|||||||
too-many-statements,
|
too-many-statements,
|
||||||
use-maxsplit-arg,
|
use-maxsplit-arg,
|
||||||
consider-using-from-import,
|
consider-using-from-import,
|
||||||
|
unspecified-encoding,
|
||||||
|
|
||||||
super-with-arguments, # Python 2.7 compatibility
|
super-with-arguments, # Python 2.7 compatibility
|
||||||
raise-missing-from, # Python 2.7 compatibility
|
raise-missing-from, # Python 2.7 compatibility
|
@ -66,7 +66,7 @@ class IPTVManager:
|
|||||||
|
|
||||||
today = datetime.today()
|
today = datetime.today()
|
||||||
|
|
||||||
results = dict()
|
results = {}
|
||||||
for key, channel in CHANNELS.items():
|
for key, channel in CHANNELS.items():
|
||||||
iptv_id = channel.get('iptv_id')
|
iptv_id = channel.get('iptv_id')
|
||||||
|
|
||||||
|
@ -128,14 +128,7 @@ class Menu:
|
|||||||
}
|
}
|
||||||
|
|
||||||
visible = True
|
visible = True
|
||||||
if isinstance(item.episodes, list) and not item.episodes:
|
title = item.title
|
||||||
# We know that we don't have episodes
|
|
||||||
title = '[COLOR gray]' + item.title + '[/COLOR]'
|
|
||||||
visible = kodiutils.get_setting_bool('interface_show_unavailable')
|
|
||||||
|
|
||||||
else:
|
|
||||||
# We have episodes, or we don't know it
|
|
||||||
title = item.title
|
|
||||||
|
|
||||||
context_menu = []
|
context_menu = []
|
||||||
if item.uuid:
|
if item.uuid:
|
||||||
|
@ -454,30 +454,33 @@ class ContentApi:
|
|||||||
|
|
||||||
# Categories regexes
|
# Categories regexes
|
||||||
regex_articles = re.compile(r'<article[^>]+>(.*?)</article>', re.DOTALL)
|
regex_articles = re.compile(r'<article[^>]+>(.*?)</article>', re.DOTALL)
|
||||||
regex_category = re.compile(r'<h1.*?>(.*?)</h1>(?:.*?<div class="visually-hidden">(.*?)</div>)?', re.DOTALL)
|
regex_category = re.compile(r'<h1.*?>(.*?)</h1>(?:.*?<div class=\"visually-hidden\">(.*?)</div>)?', re.DOTALL)
|
||||||
|
|
||||||
categories = []
|
categories = []
|
||||||
for result in regex_articles.finditer(raw_html):
|
for result in regex_articles.finditer(raw_html):
|
||||||
article_html = result.group(1)
|
article_html = result.group(1)
|
||||||
|
|
||||||
match_category = regex_category.search(article_html)
|
match_category = regex_category.search(article_html)
|
||||||
category_title = match_category.group(1).strip()
|
category_title = None
|
||||||
if match_category.group(2):
|
if match_category:
|
||||||
category_title += ' [B]%s[/B]' % match_category.group(2).strip()
|
category_title = match_category.group(1).strip()
|
||||||
|
if match_category.group(2):
|
||||||
|
category_title += ' [B]%s[/B]' % match_category.group(2).strip()
|
||||||
|
|
||||||
# Extract programs and lookup in all_programs so we have more metadata
|
if category_title:
|
||||||
programs = []
|
# Extract programs and lookup in all_programs so we have more metadata
|
||||||
for program in self._extract_programs(article_html):
|
programs = []
|
||||||
try:
|
for program in self._extract_programs(article_html):
|
||||||
rich_program = next(rich_program for rich_program in all_programs if rich_program.path == program.path)
|
try:
|
||||||
programs.append(rich_program)
|
rich_program = next(rich_program for rich_program in all_programs if rich_program.path == program.path)
|
||||||
except StopIteration:
|
programs.append(rich_program)
|
||||||
programs.append(program)
|
except StopIteration:
|
||||||
|
programs.append(program)
|
||||||
|
|
||||||
episodes = self._extract_videos(article_html)
|
episodes = self._extract_videos(article_html)
|
||||||
|
|
||||||
categories.append(
|
categories.append(
|
||||||
Category(uuid=hashlib.md5(category_title.encode('utf-8')).hexdigest(), title=category_title, programs=programs, episodes=episodes))
|
Category(uuid=hashlib.md5(category_title.encode('utf-8')).hexdigest(), title=category_title, programs=programs, episodes=episodes))
|
||||||
|
|
||||||
return categories
|
return categories
|
||||||
|
|
||||||
@ -595,35 +598,35 @@ class ContentApi:
|
|||||||
"""
|
"""
|
||||||
# Create Program info
|
# Create Program info
|
||||||
program = Program(
|
program = Program(
|
||||||
uuid=data['id'],
|
uuid=data.get('id'),
|
||||||
path=data['link'].lstrip('/'),
|
path=data.get('link').lstrip('/'),
|
||||||
channel=data['pageInfo']['brand'],
|
channel=data.get('pageInfo').get('brand'),
|
||||||
title=data['title'],
|
title=data.get('title'),
|
||||||
description=html_to_kodi(data['description']),
|
description=html_to_kodi(data.get('description')),
|
||||||
aired=datetime.fromtimestamp(data.get('pageInfo', {}).get('publishDate')),
|
aired=datetime.fromtimestamp(data.get('pageInfo', {}).get('publishDate', 0.0)),
|
||||||
poster=data['images']['poster'],
|
poster=data.get('images').get('poster'),
|
||||||
thumb=data['images']['teaser'],
|
thumb=data.get('images').get('teaser'),
|
||||||
fanart=data['images']['hero'],
|
fanart=data.get('images').get('teaser'),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Create Season info
|
# Create Season info
|
||||||
program.seasons = {
|
program.seasons = {
|
||||||
key: Season(
|
key: Season(
|
||||||
uuid=playlist['id'],
|
uuid=playlist.get('id'),
|
||||||
path=playlist['link'].lstrip('/'),
|
path=playlist.get('link').lstrip('/'),
|
||||||
channel=playlist['pageInfo']['brand'],
|
channel=playlist.get('pageInfo').get('brand'),
|
||||||
title=playlist['title'],
|
title=playlist.get('title'),
|
||||||
description=html_to_kodi(playlist.get('description')),
|
description=html_to_kodi(playlist.get('description')),
|
||||||
number=playlist['episodes'][0]['seasonNumber'], # You did not see this
|
number=playlist.get('episodes')[0].get('seasonNumber'), # You did not see this
|
||||||
)
|
)
|
||||||
for key, playlist in enumerate(data['playlists']) if playlist['episodes']
|
for key, playlist in enumerate(data.get('playlists', [])) if playlist.get('episodes')
|
||||||
}
|
}
|
||||||
|
|
||||||
# Create Episodes info
|
# Create Episodes info
|
||||||
program.episodes = [
|
program.episodes = [
|
||||||
ContentApi._parse_episode_data(episode, playlist['id'])
|
ContentApi._parse_episode_data(episode, playlist.get('id'))
|
||||||
for playlist in data['playlists']
|
for playlist in data.get('playlists', [])
|
||||||
for episode in playlist['episodes']
|
for episode in playlist.get('episodes')
|
||||||
]
|
]
|
||||||
|
|
||||||
return program
|
return program
|
||||||
|
Loading…
Reference in New Issue
Block a user