Fix menu (#93)

This commit is contained in:
mediaminister 2021-09-15 16:18:53 +02:00 committed by GitHub
parent f221d0040f
commit 9c44d323e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 40 additions and 43 deletions

View File

@ -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

View File

@ -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')

View File

@ -128,13 +128,6 @@ class Menu:
} }
visible = True visible = True
if isinstance(item.episodes, list) and not item.episodes:
# 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 title = item.title
context_menu = [] context_menu = []

View File

@ -454,17 +454,20 @@ 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 = None
if match_category:
category_title = match_category.group(1).strip() category_title = match_category.group(1).strip()
if match_category.group(2): if match_category.group(2):
category_title += ' [B]%s[/B]' % match_category.group(2).strip() category_title += ' [B]%s[/B]' % match_category.group(2).strip()
if category_title:
# Extract programs and lookup in all_programs so we have more metadata # Extract programs and lookup in all_programs so we have more metadata
programs = [] programs = []
for program in self._extract_programs(article_html): for program in self._extract_programs(article_html):
@ -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